Technical data
Fortran/C Wrapper Interface
39
Here is another example:
simplefunc (a)
int a;
{}
In this example, the function simplefunc has one argument, a. The argument
is of type int. For this function, mkf2c produces three items: a Fortran entry,
simple, and two pieces of code. The first piece of code dereferences the
address of a, which was passed by Fortran. The second passes the resulting
int to C. It then calls the C routine simplefunc().
Using Fortran Character Variables as Parameters
You can specify the length of a character variable passed as a parameter to
Fortran either at compilation or at run time. The length is determined by the
declaration of the parameter in the Fortran routine. If the declaration
contains a length, the passed length must match the declaration. For
example, in the following declaration, the length of the string is declared to
be 10 characters:
character*10 string
The passed length must be 10 in order to match the declaration.
When this next declaration is used, the passed length is taken for operations
performed on the variable inside the routine:
character*(*) string
The length can be retrieved by use of the Fortran intrinsic function LEN.
Substring operations may cause Fortran run-time errors if they do not check
this passed length.
Arrays of character variables are treated by Fortran as simple byte arrays,
with no alignment of elements. The length of the individual elements is
determined by the length passed at run time. For instance, the array sarray()
can be declared in this manner:
character*(*) sarray()










