Technical data
Fortran/C Interface
33
• When passing the address of a variable, the data representations of the
variable in the calling and called routines must correspond, as shown in
Table 3-3.
• Note that in Fortran, INTEGER and LOGICAL variables occupy 32 bits
of memory by default, but this can be changed by using the –i2 option.
• The Fortran compiler may add items not explicitly specified in the
source code to the argument list. The compiler adds the following items
under the conditions specified:
– destination address for character functions, when called
– length of a character variable, when an argument is the address of a
character variable
When a C function calls a Fortran routine, the C function must explicitly
specify these items in its argument list in the following order:
1. If the Fortran routine is a function that returns a character variable of
length greater than 1, specify the address and length of the resultant
character variable.
2. Specify normal arguments (addresses of arguments or functions).
a. The array length must also be passed, as discussed in the next section.
Table 3-3 Equivalent Fortran and C Data Types
Fortran C
integer*2 x short int x;
integer x long int x; or just int x;
logical x long int x; or just int x;
real x float x;
double precision x double x;
complex x struct{float real, imag;) x;
double complex x struct{double dreal,dimag;} x;
character*6 x char x[6]
a










