Xref: utzoo comp.lang.c:18445 comp.lang.fortran:2017 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!mentor.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: Calling FORTRAN from C (Was: Need matrix inversion C routine). Message-ID: <1288@l.cc.purdue.edu> Date: 6 May 89 15:17:38 GMT References: <2846@tank.uchicago.edu> <5785@cbnews.ATT.COM> <10087@smoke.BRL.MIL> <17333@mimsy.UUCP> Followup-To: comp.lang.c,comp.lang.fortran Organization: Purdue University Statistics Department Lines: 49 In article <17333@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > In article <1415@uw-entropy.ms.washington.edu> > charlie@mica.stat.washington.edu (Charlie Geyer) writes: > >I just want an answer to a much simpler problem. How to write an > >intellegent C program (no strings or structures in arguments, no call > >by value, etc.) that calls a Fortran subroutine or is called by one. > >I know there is no portable answer to this now. But shouldn't there > >be? > > Perhaps there should. But note that a Fortran compiler might use an > entirely different run-time environment (e.g., perhaps no stack at all) > than a C compiler, even on the same machine. > > It is clear that no one language standard can constrain any *other* > language, and that therefore no one standard (for Fortran, C, PL/I, > APL, Lisp, DDL, rog-o-matic, or whatever) can require inter-language > calls. It requires an inter-language standard to do this. > > Good luck on getting together an inter-language standard ... you will > certainly need it. Even with the same language, different compilers can have different calling sequences. This problem can be handled by the process of having each compiler have access to the calling sequences of the others. The harder problem is names. Suppose I am writing a buffer refill program. I could write this in Fortran or C (I would prefer C, but it would make little difference). On vector machines, I could vectorize it (maybe). It is easy to call. How do I name it? If I give it a name in one language, how will it appear to the system? Can I call it at all? I know how to produce a .s file as an intermediate and edit that file to change the name. But what do you do if source is not provided? An object file editor should be available to do the job, but I believe is not. And the problem is greater if it is in a package. There are statistics packages with many formats. What if it is necessary for someone like Charlie to use several packages to do what he wants? This is an important question, and one which has been ignored by the computing and language people. The answer is not to make a universal calling sequence, as that prevents development. But there is no reason why names should be altered by processors, as is now the case. And the calling sequences for the processors should be public knowledge. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (Internet, bitnet, UUCP)