
#include <string.h> #ifdef _CRAY # include <fortran.h> # define nameage NAMEAGE #else # ifndef _AIX # define nameage nameage_ # endif # define _fcd char * # define _cptofcd(a,b) (a) # define _fcdlen(a) strlen(a) #endif void nameage(_fcd name, int *nlen, int *age, float *temp); int main() { char *name = "Knut"; _fcd fp; int nlen,age = 4; float temp = 98.6; nlen = strlen(name); fp = _cptofcd(name, nlen); /* convert to Fortran string */ nameage(fp, &nlen, &age, &temp); return 0; }
SUBROUTINE NAMEAGE(NAME, NLEN, AGE, TEMP) CHARACTER*(*) NAME INTEGER NLEN,AGE REAL TEMP C WRITE(6,1000) NAME(1:NLEN),AGE,TEMP 1000 FORMAT(1X,'Hello ',A,', who is ',I2, . ' years old, has a temperature of ', f4.1) RETURN END
To discover which libraries are necessary for Fortran modules, compile a short Fortran test program and add the-Voption (or equivalent) to get a verbose execution listing.
- Cray - PVPs - UNICOS
cf77 -c c2ffn.fcc -c c2f.ccf77 c2f.o c2ffn.o- (or substitute f90 for cf77)
- IBM - SP2 - AIX
xlf -c c2ffn.fcc c2f.c c2ffn.o -lxlf90 -lxlf -lm- SGI - IRIX
f77 -c c2ffn.fgcc c2f.c c2ffn.o -lF77 -lm -lU77 -lI77 -lisam -lmpc -lc- SUN - SunOS
f77 -c c2ffn.fgcc c2f.c c2ffn.o -L/usr/lang/SC0.0 -lF77 -lm -lc- PC - Linux
g77 -c c2ffn.fgcc -c c2f.cg77 c2f.o c2ffn.o
