Xref: utzoo comp.lang.c:39377 comp.lang.fortran:5420 comp.unix.questions:31479 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!samsung!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c,comp.lang.fortran,comp.unix.questions Subject: Re: Calling C from FORTRAN under Unix Message-ID: <5826@goanna.cs.rmit.oz.au> Date: 20 May 91 05:23:14 GMT References: <5343@dftsrv.gsfc.nasa.gov> <1991May17.023941.18053@zoo.toronto.edu> <5348@dftsrv.gsfc.nasa.gov> Followup-To: comp.lang.fortran Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 18 In article <5348@dftsrv.gsfc.nasa.gov>, packer@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.