This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch,Fortran] Update gfortran.texi for mixed-language programming

Tobias Burnus wrote:

I hope I have not missed anything.

You didn't, but I did. A couple more corrections (the first few of which I overlooked in your original submission):

-Although GNU Fortran focuses on implementing the Fortran 95
-standard for the time being, a few Fortran 2003 features are currently
+GNU Fortran supports the several Fortran 2003 features; an incomplete
+list can be found below.

Strike 'the'.

@item @@ -1529,8 +1548,8 @@ It consists of a set of compiler directi
and environment variables that influence run-time behavior.

This line got chopped somewhere. It should be 'directives'.

+This chapter is about mixed-language interoperability, but also applies
+if one links Fortran code compiled by different compilers. In most cases
+using the C Binding features of the Fortran 2003 standard is sufficient
+and its use is highly recommended.

I think the last sentence should be,
In most cases, use of the C Binding features of the Fortran 2003 standard is sufficient, and their use is highly recommended.

I like 'use of' better than 'using', although that's personal preference and either are appropriate, there needs to be a comma before 'and' because what follows is an independent clause, and the pronoun needs to be plural to agree with 'features'.

+Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a
+standardized way to generate procedure and derived-type
+declarations and global variables which are interoperable with C
+(ISO/IEC 9899:1999). The @code{bind(C)} attribute has been added
+to inform the compiler that a symbol shall be interoperable with C;
+also, some constrains are added. Note, however, that not
+all C features have a Fortran equivalent or vice versa. For instance,
+neither C's unsigned integers nor C's functions with variable number
+of arguments have an equivalent in Fortran.


+For compatibility of derived types with @code{struct}, one needs to use
+the @code{BIND(C)} attribute in the type declaration. For instance the
+following type declaration

Add a comma after 'For instance'.

+Variables can be made accessible from C using the C binding attribute,
+optionally together with specifying a binding name. Those variables
+have to be declared in the declaration part of a @code{MODULE},
+be of interoperable type, and and have neither the @code{pointer} nor
+the @code{allocatable} attribute.

Duplicated 'and' here.

+Subroutines and functions have to have the @code{BIND(C)} attribute to
+be compatible with C. The dummy argument declaration is relatively


However, one needs to be careful because C uses
+call-by-value by default while Fortran uses call-by-reference. Furthermore,
+strings and pointers are handled differently. Note that only explicit
+size and assumed-size arrays are supported but not assumed-shape or
+allocatable arrays.
+To pass a variable by value, use the @code{VALUE} attribute.
+Thus the following C prototype
+@code{int func(int i, int *j)}
+@end smallexample
+matches the Fortran declaration
+  integer(c_int) func(i,j)
+    integer, VALUE :: i
+    integer :: j
+@end smallexample
+Note that frequently also the pointer argument needs the
+@code{VALUE} attribute.

I don't think the last sentence reads quite right. What do you mean by "the pointer argument"?

Does the following reworking make sense?
Also, note that pointer arguments frequently need the @code{VALUE} attribute.

Note that pointer arguments also frequently need the @code{VALUE} attribute.

+Assumed-shape and allocatable arrays are passed using an array descriptor
+(dope vector). The internal structure of the array descriptor used
+by GNU Fortran is not yet documented and will change. There will also be
+a Technical Report (TR 29113) which standardizes an interoperable
+array descriptor. Until then, you can use the Chasm Language
+Interoperability Tools, @url{},
+which provides an interface to GNU Fortran's array descriptor.

s/provides/provide/ (to agree with 'Tools')

+The technical report 29113 will presumably also include support for
+C-interoperable @code{OPTIONAL} and for assumed-rank, and assumed-type
+dummy arguments. However, the TR has neither been approved nor implemented
+in GNU Fortran; therefore, these features are not yet available.

Drop the comma between assumed-rank and assumed-type.

 The @code{ISO_C_BINDING} module provides the following named constants of the
-type integer, which can be used as KIND type parameter. Note that GNU
-Fortran currently does not support the @code{C_INT_FAST...} KIND type
-parameters (marked by an asterisk (@code{*}) in the list below).
-The @code{C_INT_FAST...} parameters have therefore the value @math{-2}
-and cannot be used as KIND type parameter of the @code{INTEGER} type.
+type integer, which can be used as KIND type parameter.

I would strike the 'the' before 'type integer'. Should that be @code, or should it be 'default integer' instead of 'integer'?

Also, s/parameter/&s/ to agree with 'constants'.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]