You copied the Doc URL to your clipboard.

Character

Fortran functions that return a character require the calling C/C++ function to have two arguments to describe the result:

  1. The first argument provides the address of the returned character.

  2. The second argument provides the length of the returned character.

For example, the Fortran function:

CHARACTER*(*) FUNCTION CHF( C1, I)
     CHARACTER*(*) C1
     INTEGER I
END

when called in C/C++, has an extra declaration:

extern void chf_();
     char tmp[10];
     char c1[9];
     int i;
     chf_(tmp, 10, c1, &i, 9);

The argument, tmp, provides the address, and the length is defined with the second argument, 10.

Note

  • Fortran functions declared with a character return length, for example CHARACTER*4 FUNCTION CHF(), still require the second parameter to be supplied to the calling C/C++ code.

  • The value of the character function is not automatically NULL-terminated.

Was this page helpful? Yes No