Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mkc2f(1) — GL2 W2.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

extcentry(1)

cc(1)

MKF2C(1)  —  Silicon Graphics

NAME

mkf2c, mkc2f − generate C-FORTRAN interface routines

SYNOPSIS

mkf2c [ cprog.fc [ cprog.s ] ]
mkc2f [ dummyfortran.cf [ dummyfortran.s ] ]

DESCRIPTION

mkf2c and mkc2f are used to generate assembly-language routines to interface C functions to FORTRAN routines.  mkc2f generates an interface for C functions to call FORTRAN routines.  mkf2c generates an interface for FORTRAN routines to call C functions. 

Both programs accept as input a set of C functions, and produce an assembly-language interface routine in the output file.  If the input and output files are not specified, mkf2c (or mkc2f) reads from stdin and writes to stdout.  In the case of mkc2f, the input may be a copy of the actual C file being interfaced, perhaps filtered by the program extcentry(1). In the case of mkf2c, the FORTRAN routines must have their parameter lists coded in C for input to the program.  (This must be done manually.  Refer to “C/FORTRAN Interface” in the UNIX Programmer’s Manual, Volume IIB.)  In all cases, mkf2c and mkc2f generate a .s file that must be assembled with as(1), and loaded with the FORTRAN and C routines that are to be interfaced. 

mkc2f and mkf2c use the parameter declarations in the C function headers to transform each parameter of the calling language to that of the receiving language.  The standard basic C types attached to the parameters are used to determine the object each parameter represents − i.e., whether it is a value or pointer, its size, whether it is unsigned, etc.  (Character strings are handled specially − the reader is referred to the Appendix on the programs.)  Only the opening and closing brace of the function body must be present.  Information in the body of the function is ignored.  The programs cannot understand C constructs other than functions and comments (e.g., external declarations, typedefs, C preprocessor constructs, etc.).  Such unrecognized constructs must be eliminated from the input (this is the purpose of extcentry). 

EXAMPLE

A sample C function given to the programs as input might be

test(i,s,c,ptr1,ptr2,ar1,f,d,d1,str1,str2,str3,u)
short s;
unsigned char c;
int *ptr1;
char *ptr2[];
short ar1[];
float f;
long float d,*d1;
char *str1;
char str2[],str3[30];
sometype u;
{
/*
The C function body may go here.  Nothing except
the opening and closing braces are necessary.
*/
}

A complaint will be given about not understanding the type of parameter u.  It will be assumed to be a simple pointer. 

SEE ALSO

UNIX Programmer’s Guide, Volume II , “C/FORTRAN Interface”, “IRIS Floating Point”
extcentry(1), cc(1)

DIAGNOSTICS

mkf2c and mkc2f are very simple-minded about diagnosing syntax errors.  They can detect such things as a formal parameter having its type declared when it is not in the formal parameter list.  A few such cases give intelligable error messages.  The programs will complain about types they do not understand.  The default type assigned in such cases is simple pointer.  mkf2c and mkc2f will also delete characters from FORTRAN entry names which are illegal (e.g., underscores).  The user will be warned in such instances.  Most errors that the programs detect are indicated only by the source line number. 

If mkf2c or mkc2f encounter an error which they cannot remedy, they will abort, giving the line number on which the error occurred.  The resultant .s file will be removed, and an error exit will be taken. 

Because of their limited error diagnostic ability, it is advisable to use cc (1) to determine whether the input syntax is correct before passing it to mkc2f or mkf2c. 

Version 2.4  —  May 08, 1986

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026