Technical data

34
Chapter 3: Fortran Program Interfaces
3. Specify the length of each normal character parameter in the order it
appeared in the argument list. The length must be specied as a
constant value or INTEGER variable (that is, not an address).
The examples on the following pages illustrate these rules.
Example 1
This example shows how a C routine species the destination address of a
Fortran function (which is only implied in a Fortran program).
Fortran
C Fortran call to SAM, a routine written
C in Fortran
EXTERNAL F
CHARACTER*7 S
INTEGER B(3)
CALL SAM (F, B(2), S)
C
/* C call to SAM, a routine written in Fortran */
/* We pass in the function pointer for the */
/* Fortran SUBROUTINE F */
char s[7];
int b[3];
extern void sam_(void (*)(), int *, char*);
/* Fortran subroutine SAM */
extern void f_(); /* Fortran subroutine F */
sam_(F, &B[1], S); /* We pass in pointer to Fortran F */
/* for Fortran call-by-reference */
Example 2
This example shows how a C routine must specify the length of a character
string (which is only implied in a Fortran call).