Program: f2cvv
Purpose: This program generates C code for the F2C/C2F interface
routines.
Category: SYSTEM
File: f2cvv.c
Author: K.G. Begeman
Description: This program creates c source code for the intermediate
routines necessary to call C routines from Fortran and
Fortran routines from C. The name of the Fortran
callable routine is as stated in the document, the C
callable routine has the same name with postfix '_c'.
All arguments are passed by reference, except fortran
character arguments. For Fortran character types a
special C type has been defined, fchar, which is a
struct which holds the address of the Fortran character
string and its length. For the Fortran types integer,
integer(kind=8), logical and complex C types fint, fint8,
bool and complex are defined. The correspondence of fortran
types with C types is as follows:
FORTRAN C
integer <-> * fint
integer*8 <-> * fint8
logical <-> * bool
real <-> * float
double precision <-> * double
complex <-> * complex
character <-> fchar
Except for fortran character functions, the number and
type of arguments correspond as stated above. Fortran
character functions correspond with C procedures of type
void with an extra fchar as first argument, which corresponds
with the character returned by the fortran function.
A fchar struct contains a character pointer 'a' to the
Fortran character string and a fint 'l' which holds the
length of the character string.
A complex struct contains a float 'r' which holds the
real part and a float 'i' which holds the imaginary part.
For the interpretation of fortran logicals, two macros are
defined, tobool(l) and toflog(l); tobool converts a Fortran
logical to a C true or false value, toflog converts a C true
or false value to a Fortran logical. To set a bool to a
Fortran .TRUE. or .FALSE., the macros TRUE and
FALSE can be used. These four macros are defined in the
definition file generated by f2cvv.
Operation: The program reads the routine definition from the source
file. The routine definition is placed in the comment area
of the source code and should be preceded by '@' in the
first or second column on each new line. The syntax of the
routine definition is as follows:
procedure_name ( [type [, type [, type [ ... ] ] ] ] )
where:
procedure_name = { subroutine }, { type function }
type = { character }, { integer }, {integer*8}, { logical },
{ real }, { double precision }, { complex }
Note that integer(kind=8) is specified here as integer*8.
Use: F2CVV