home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / math / numanal / 3376 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.9 KB

  1. Path: sparky!uunet!spool.mu.edu!agate!darkstar.UCSC.EDU!gross
  2. From: gross@maxwell.ucsc.edu (Mike Gross)
  3. Newsgroups: sci.math.num-analysis
  4. Subject: Re: calling Fortran libraries with C
  5. Date: 23 Nov 1992 04:25:54 GMT
  6. Organization: University of California, Santa Cruz
  7. Lines: 48
  8. Distribution: ba
  9. Message-ID: <1epmgiINN6tb@darkstar.UCSC.EDU>
  10. References: <1ep9qjINNsni@agate.berkeley.edu>
  11. NNTP-Posting-Host: maxwell.ucsc.edu
  12. Keywords: Fortran, C
  13.  
  14. In <1ep9qjINNsni@agate.berkeley.edu> actize@garnet.berkeley.edu () writes:
  15.  
  16. >I program in C, and most of our mathematical libraries are in Fortran 77.
  17. >Our online documentation describes a few things, such as 
  18. >1.    Fortran calls by address
  19. >2.    The order of array storage is different.
  20.  
  21. >Does anybody have experience with this, and advice ?
  22.  
  23. >David
  24. >actize@garnet.berkeley.edu
  25.  
  26. If you're programming on a Sun, the SunOS fortran manual has a whole chapter
  27. on this. IBM's RS-6000 has a similar document, though it isn't as detailed.
  28.  
  29. A few more differences (assuming you're on a Unix system):
  30.  
  31. All fortran routines are converted to lowercase and have an underscore appended
  32. to the end of the function name.
  33.  
  34. Strings are passed in an odd manner--there is an extra argument at the *end*
  35. of the argument list for each string passed. This is a long (*not* a long *)
  36. and it holds the length of the string in bytes.
  37.  
  38. Subroutines return int *'s. Functions return the corresponding type in C (passed
  39. by reference, of course).
  40.  
  41. You must link in libF77.a (or libV77.a if you need VMS compatibility).
  42.  
  43. int * <--> INTEGER or INTEGER*4
  44. long * <--> INTEGER*8
  45. char * <--> CHARACTER or INTEGER*1 or CHARACTER*n or LOGICAL
  46. double * <--> DOUBLE PRECISION or REAL*8
  47. float * <--> REAL or REAL*4
  48.  
  49. Complex numbers correspond to a structure of two of the appropriate floating
  50. point type.
  51.  
  52. If you're programming a VMS system, all this is BS.
  53.  
  54. Good luck.
  55.  
  56. Mike Gross
  57. Physics Board
  58. Univ of California                 GO SLUGS!!!!!
  59. Santa Cruz, CA 95064
  60.  
  61.  
  62.