Calling FORTRAN from C (Was: Need matrix inversion C routine).

Herman Rubin cik at l.cc.purdue.edu
Sun May 7 01:17:38 AEST 1989


In article <17333 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> In article <1415 at uw-entropy.ms.washington.edu>
> charlie at 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 at l.cc.purdue.edu (Internet, bitnet, UUCP)



More information about the Comp.lang.c mailing list