Intel® Fortran Compiler XE 13.1 User and Reference Guides

Returning Character Data Types

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 called routine must copy its result through the address specified in the first argument. The following example shows the Fortran code for a return character function called MAKECHARS and a corresponding C routine.

Example of Returning Character Types from C to Fortran

Fortran code

interface
   function makechars(x,y)
   !DEC$ATTRIBUTES decorate, alias:'makechars'::makechars
   character*10 makechars
   double precision x,y
   end function
end interface

character *10 chars
double precision x,y
chars=makechars(x,y) 

Corresponding C Routine

void makechars (char *result, size_t length, double *x, double *y)
{
...program text, producing returnvalue...
for (i = 0; i < length; i++ ) {
result[i] = returnvalue[i];
}
}

In the above example, the following restrictions and behaviors apply:


Submit feedback on this help topic