home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!darkstar.UCSC.EDU!gross
- From: gross@maxwell.ucsc.edu (Mike Gross)
- Newsgroups: sci.math.num-analysis
- Subject: Re: calling Fortran libraries with C
- Date: 23 Nov 1992 04:25:54 GMT
- Organization: University of California, Santa Cruz
- Lines: 48
- Distribution: ba
- Message-ID: <1epmgiINN6tb@darkstar.UCSC.EDU>
- References: <1ep9qjINNsni@agate.berkeley.edu>
- NNTP-Posting-Host: maxwell.ucsc.edu
- Keywords: Fortran, C
-
- In <1ep9qjINNsni@agate.berkeley.edu> actize@garnet.berkeley.edu () writes:
-
- >I program in C, and most of our mathematical libraries are in Fortran 77.
- >Our online documentation describes a few things, such as
- >1. Fortran calls by address
- >2. The order of array storage is different.
-
- >Does anybody have experience with this, and advice ?
-
- >David
- >actize@garnet.berkeley.edu
-
- If you're programming on a Sun, the SunOS fortran manual has a whole chapter
- on this. IBM's RS-6000 has a similar document, though it isn't as detailed.
-
- A few more differences (assuming you're on a Unix system):
-
- All fortran routines are converted to lowercase and have an underscore appended
- to the end of the function name.
-
- Strings are passed in an odd manner--there is an extra argument at the *end*
- of the argument list for each string passed. This is a long (*not* a long *)
- and it holds the length of the string in bytes.
-
- Subroutines return int *'s. Functions return the corresponding type in C (passed
- by reference, of course).
-
- You must link in libF77.a (or libV77.a if you need VMS compatibility).
-
- int * <--> INTEGER or INTEGER*4
- long * <--> INTEGER*8
- char * <--> CHARACTER or INTEGER*1 or CHARACTER*n or LOGICAL
- double * <--> DOUBLE PRECISION or REAL*8
- float * <--> REAL or REAL*4
-
- Complex numbers correspond to a structure of two of the appropriate floating
- point type.
-
- If you're programming a VMS system, all this is BS.
-
- Good luck.
-
- Mike Gross
- Physics Board
- Univ of California GO SLUGS!!!!!
- Santa Cruz, CA 95064
-
-
-