Technical data
42
Chapter 3: Fortran Program Interfaces
• S, C, and D would be passed as values of length 16 bits, 64 bits, and 8
bits, respectively. F would be converted to a 64-bit DOUBLE before
being passed, unless the –f option had been specified. If the –f option
had been specified, F would be passed as a 32-bit value. Because the
type of I is not specified, it would be assumed to be INT and would
also be passed as a 32-bit value. Storing values in any of these
parameters would not have any effect on the original Fortran data.
Fortran Character Array Lengths
When the wrapper generator is used, a character variable that is specified as
char* in the C parameter list is copied and null terminated. C may thus
determine the length of the string by the use of the standard C function
strlen.
If a character variable is specified as a character array in the C parameter list,
the address of the character variable is passed, making it impossible for C to
determine its length, as it is not null terminated. When the call occurs, the
wrapper code receives this length from Fortran. For those C functions
needing this information, the wrapper passes it by extending the C
parameter list.
For example, if the C function header is specified as follows
func1 (carr1,i,str,j,carr2)
char carr1[],*str,carr2[];
int i, j;
{}
mkf2c will pass a total of seven parameters to C. The sixth parameter will be
the length of the Fortran character variable corresponding to carr1, and the
seventh will be the length of carr2. The C function func1() must use the
varargs macros to retrieve these hidden parameters. mkf2c will ignore the










