Example of declaration for C calling Fortran

The following example shows a partial C routine that calls a Fortran function. The calling C routine contains the #pragma linkage directive for the Fortran function FORTFCN, the function prototype for the Fortran function, and a static call to the Fortran function.

C function Fortran function
#pragma linkage (fortfcn, FORTRAN)
⋮
double fortfcn(int, double [100]);
⋮
int index;
double list[100];
double value;
⋮
value=fortfcn(index, list);
 
FUNCTION FORTFCN (INDEX, LIST) RESULT (VALUE)
INTEGER*4 INDEX
REAL*8 LIST(0:99)
REAL*8 VALUE
⋮
VALUE=LIST(INDEX)
END