next up previous contents
Next: C/FORTRAN Binding Up: 6.2.2 Language Binding Previous: 6.2.2 Language Binding

FORTRAN/C Binding

The language binding between FORTRAN and C is quite simple. For each FORTRAN type a corresponding base C type exists. To remain fully system independent the VBS data types (see Section A.7) are used. The corresponding type conversions for all supported types are shown in Table 6.6.

  table3097
Tabelle 6.6: Type conversion FORTRAN to C

Since types cannot be defined in standard F77, language binding to C is straight forward. Extensions for type and structure definitions introduced by F90 are currently not supported by TAC. String parameters in FORTRAN have a length parameter and are not zero terminated like C strings. For input parameters, a C string is given as parameter and the length of the string is either stored in the string descriptor structure or passed as hidden parameter. Arrays of strings are not supported. Only arrays of INTEGER and DOUBLEPRECISION can be used. All parameters declared as indices using the key index in the parameter documentation are automatically converted from FORTRAN to C because FORTRAN indices start at one and C at zero. LOGICAL values are converted to the vBoolean type in both directions. If a FORTRAN parameter is declared as input only it is passed by value to the wrapping C function whereas FORTRAN always passes parameters by pointer. Figure 6.6 shows an example binding used by the MINIMOS simulator[Sel80, Fis94]. The parameter documentation key c-name is required because TAC has no default method to convert a FORTRAN SUBROUTINE name to a C function.

  figure3148
Abbildung 6.6: TAC documented FORTRAN function for binding

FORTRAN has a useful IMPLICIT parameter type definition so no additional comments have to be written. The only additional comment is used to defined the parameters NX, NXY, and N as an input only parameters to allow `pass by value' from C. The corresponding C function is shown in Figure 6.7.

  figure3163
Abbildung 6.7: C function created by TAC

All parameters are assumed to be pointers to single values which is compatible to an array too. Only the last three parameters nx, nxy, and n are passed by value because they were declared as input parameters. The generated C function has always a void return type since it represents a FORTRAN SUBROUTINE. This kind of language binding is mainly used to write a C main program using a FORTRAN calculation kernel.


next up previous contents
Next: C/FORTRAN Binding Up: 6.2.2 Language Binding Previous: 6.2.2 Language Binding

IUE WWW server
Fri Jan 3 17:00:13 MET 1997