Xref: utzoo comp.lang.c:18314 comp.lang.fortran:2001 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: Calling FORTRAN from C (Was: Need matrix inversion C routine). Message-ID: <1544@auspex.auspex.com> Date: 3 May 89 07:36:24 GMT References: <2846@tank.uchicago.edu> <5785@cbnews.ATT.COM> <10087@smoke.BRL.MIL> <1523@auspex.auspex.com> <1274@l.cc.purdue.edu> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 40 >There are two problems. Each implementation of a language will have its >calling sequence. This problem is unavoidable, and can be a major headache. ... >The bigger problem is names. No, there are at least three problems. The third problem is the representation of the language's data types, unless you consider that a subclass of the first problem. Passing a C character string to a routine expecting a FORTRAN character string may not work, nor will passing an integer value by reference, FORTRAN-style, to a routine expecting it to be passed by value, C-style. >It should be considered essential that any user be able to access any >object program compiled by any processor by proper use of the calling >sequence and return, and this means knowing the system name of the program >and being able to instruct the compiler that a program with that name is >to be called. Well: 1) that's not something within the purview of either the C or FORTRAN standard, since it requires particular implementation choices to be made for both languages; it falls between two chairs, and touches on an area that standards committees often try to avoid constraining, namely implementations. It's not within the purview of POSIX, either. 2) given the "third problem", you may have to write a "jacket" routine to translate data types, which means that it may not necessarily be useful merely to patch up the name-space problem, since you can't just call, say, the UNIX "open" routine from FORTRAN in the same way you can call it from C. I don't have Stu Feldman's paper on F77 handy, so I don't know if he put in the prepended underscore, in part, to allow you to have a jacket for the C routine "foobar" written in C and called "foobar_" from within C and thus "foobar" from within FORTRAN, that does any requisite data type translations.