If a Fortran program expects a function to return data of type character, the Fortran compiler adds two additional arguments to the beginning of the called procedure's argument list:
The first argument is a pointer to the location where the called procedure should store the result.
The second is the maximum number of characters that must be returned, padded with white spaces if necessary.
The called routine must copy its result through the address specified in the first argument. Example that follows shows the Fortran code for a return character function called makechars and corresponding C routine.
Fortran code |
Corresponding C Routine |
In the above example, the following restrictions and behaviors apply:
The function's length and result do not appear in the call statement; they are added by the compiler.
The called routine must copy the result string into the location specified by result; it must not copy more than length characters.
If fewer than length characters are returned, the return location should be padded on the right with blanks; Fortran does not use zeros to terminate strings.
The called procedure is type void.
You must use lowercase names for C routines or Microsoft* attributes and INTERFACE blocks to make the calls using uppercase.