Technical data

Fortran/C Interface
35
Fortran
C Fortran call to F, a function written
C in Fortran
EXTERNAL F
CHARACTER*10 F, G
G = F()
C
/* C call to SAM, a routine written in Fortran */
/* which returns a string. */
CHAR S[10];
. . .
f_(S, 10);
The function F, written in Fortran
C function F, written in Fortran
CHARACTER*10 FUNCTION F()
F = 0123456789
RETURN
END
Array Handling
Fortran stores arrays in column-major order with the leftmost subscript
varying the fastest. C, however, stores arrays in the opposite arrangement
(row-major order), with the rightmost subscripts varying the fastest.
Here is how the layout of the Fortran array looks:
integer t (2,3)
t(1,1), t(2,1), t(1,2), t(2,2), t(1,3), t(2,3)
Here is how the layout of the C array looks:
int t [2] [3]
t[0][0], t[0][1], t[0][2], t[1][0], t[1][0], t[1][1],t[1][2]
Note that the default for the lower bound of an array in Fortran is 1, where
the default in C is 0.