Calling C from FORTRAN under Unix
Richard A. O'Keefe
ok at goanna.cs.rmit.oz.au
Mon May 20 15:23:14 AEST 1991
In article <5348 at dftsrv.gsfc.nasa.gov>, packer at amarna.gsfc.nasa.gov (Charles Packer) writes:
> In fact, everybody said that =their= systems' C compiler put an
> underscore =following= the routine name, and therefore I should
> write the calling Fortran code to CALL subr_.
That is back to front. On many UNIX systems, it is the *Fortran*
compiler which adds '_' as a suffix (and either _both_ C and Fortran
add '_' at the beginning (usually BSD) or _neither_ do (usually Sys V)).
So when a C function calls a Fortran 'SUBR' C uses the name 'subr_',
and a C function can be called *from* Fortran only if the C function
name has no capital letters and ends with '_'. So C would call the
function 'subr_()' and Fortran would 'CALL SUBR'.
However, there are lots of different UNIX Fortran compilers out there,
so it isn't enough to say which hardware and operating system; you have
to say whose Fortran compiler as well.
--
There is no such thing as a balanced ecology; ecosystems are chaotic.
More information about the Comp.unix.questions
mailing list