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

Charlie Geyer charlie at mica.stat.washington.edu
Sat Apr 29 04:56:14 AEST 1989


In article <307 at cbnewsh.ATT.COM> georg at cbnewsh.ATT.COM (georg.k.karawas) writes:

> The book 'Numerical Recipes in C' should contain a routine
> for matrix inversion. As it was already pointed in other
> articles, it is a hassle to work with pointers.
> A better solution might be to take a 'canned' FORTRAN routine
> from a standard package, like LINPACK, and call it from C.
> Be careful though that C stores arrays row-by-row.
> UNIX f77 compilers can produce object code which can be linked
> with a C calling program.

Yes this is the right answer and it applies even more so to algorithms more
complicated than matrix inversion for which reinventing the wheel would be
crazy.  I worry about portability though.  I hate to tell sombody I'm giving
software to "This is portable except the calls of FORTRAN from C and C from
FORTRAN; they work on our machines; you'll have to figure out how to make them
work on yours.  Here is a copy of message <14081 at mimsy.UUCP> in comp.lang.c
by Chris Torek that tells how to do it on a VAX running BSD 4.x.  Have fun."

Is there anything in pANS C, Fortran 8x, and POSIX that will alleviate this
situation?  It's very annoying, especially these days when all of the really
high quality numerical stuff is still in FORTRAN and all of the good user
interface stuff is in C.



More information about the Comp.lang.c mailing list