Technical data
38
Chapter 3: Fortran Program Interfaces
Fortran/C Wrapper Interface
This section describes the process of generating wrappers for C routines
called by Fortran. If you want to call existing C routines (which use value
parameters rather than reference parameters) from Fortran, these wrappers
convert the parameters during the call.
The program mkf2c provides an alternate interface for C routines called by
Fortran.
Fortran routines called by C must use the method described in “Fortran/C
Wrapper Interface” on page 38.
The Wrapper Generator mkf2c
The mkf2c program uses C data-type declarations for parameters to generate
the correct assembly language interface. In generating a Fortran-callable
entry point for an existing C-callable function, the C function is passed
through mkf2c, and mkf2c adds additional entry points. Native language
entry points are not altered.
Use these rules with mkf2c:
• Each function given to mkf2c must have the standard C function syntax.
• The function body must exist but can be empty. Function names are
transformed as necessary in the output.
A simple case of using a function as input to mkf2c is
func()
{}
Here, the function func has no parameters. If mkf2c is used to produce a
Fortran-to-C wrapper, the Fortran entry is func_. The wrapper func_ simply
calls the C routine func().
–










