Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!deimos.cis.ksu.edu!uxc!uxc.cso.uiuc.edu!gistdev!flint From: flint@gistdev.UUCP Newsgroups: comp.lang.c Subject: Re: Calling FORTRAN from C (Was: Ne Message-ID: <7800008@gistdev> Date: 10 May 89 23:14:00 GMT References: <176@csun1.UUCP> Lines: 29 Nf-ID: #R:csun1.UUCP:176:gistdev:7800008:000:1675 Nf-From: gistdev.UUCP!flint May 10 18:14:00 1989 Dealing with blank-filled vs null terminated strings, calling conventions, variable sizes, routine names, etc. are all a pain. The biggest pain is when the system libraries are improperly constructed though. An example: The main() routine is in C which calls Fortran routines which in turn call C routines. Unfortunately, the Fortran parts use some string functions that don't exist in the C library, so if you want it to work, you have to link in the Fortran library. Can you just add a -lF77? Wrong, that gives you a "duplicate function main()" error. Ok, so you ar the routines you need out of the Fortran library and link them in explicitly, and you can make it link and work. Now you want to put some debug output into the Fortran codes and guess what: the routines needed aren't available, and if you try to ar only the .o files out of libF77.a you need, you eventually end up needing something that is in the same .o file as the main() routine of libF77. The end result is that if I want to do any output at all from the Fortran code, I have to call a C routine to do it. All this pain could be avoided if the genius who created the libF77.a had put the main() routine in it's own .o all by itself, so that I could just copy the library and remove main.o and link it. But if you toss several routines into the same .o together, then you can't take the extra main() out without taking out something else that you have to have to do Fortran style I/O. Flint Pellett, Global Information Systems Technology, Inc. 1800 Woodfield Drive, Savoy, IL 61874 (217) 352-1165 INTERNET: flint%gistdev@uxc.cso.uiuc.edu UUCP: {uunet,pur-ee,convex}!uiucuxc!gistdev!flint