Technical data

44
Chapter 3: Fortran Program Interfaces
To illustrate the use of extcentry, the C le foo.c is shown below. It contains the
function foo, which is to be made Fortran callable.
typedef unsigned short grunt [4];
struct {
long 1,11;
char *str;
} bar;
main ()
{
int kappa =7;
foo (kappa,bar.str);
}
/* CENTRY */
foo (integer, cstring)
int integer;
char *cstring;
{
if (integer==1) printf(%s,cstring);
} /* ENDCENTRY */
The special comments /* CENTRY */ and /* ENDCENTRY */ surround the
section that is to be made Fortran callable. To generate the assembly
language wrapper foowrp.s from the above le foo.c, use the following set
of commands:
% extcentry foo.c foowrp.fc
% mkf2c foowrp.fc foowrp.s
The programs mkf2c and extcentry are found in the directory /usr/bin on your
workstation.