home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / math / numanal / 3382 < prev    next >
Encoding:
Text File  |  1992-11-23  |  2.1 KB  |  66 lines

  1. Newsgroups: sci.math.num-analysis
  2. Path: sparky!uunet!van-bc!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!acs.ucalgary.ca!lessard
  3. From: lessard@acs.ucalgary.ca (Rodney Lessard)
  4. Subject: Re: calling Fortran libraries with C
  5. Sender: news@acs.ucalgary.ca (USENET News System)
  6. Message-ID: <92Nov23.201317.12471@acs.ucalgary.ca>
  7. Date: Mon, 23 Nov 92 20:13:17 GMT
  8. Distribution: ba
  9. References: <1ep9qjINNsni@agate.berkeley.edu>
  10. Nntp-Posting-Host: acs5.acs.ucalgary.ca
  11. Organization: The University of Calgary, Alberta
  12. Keywords: Fortran, C
  13. Lines: 51
  14.  
  15. In article <1ep9qjINNsni@agate.berkeley.edu> actize@garnet.berkeley.edu () writes:
  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. I have had some experience with this phenomena by calling NCAR
  27. graphics and IMSL fortran routines from my C code. It is actually
  28. not that difficult. Here some examples.
  29.  
  30. 1. Fortran programs must be declared extern.
  31.     extern int srface();
  32. 2. Like you mentioned arguments must be passed by address.
  33.     call srface(x,y,10) looks like
  34.  
  35.     static int c_10 = 10;
  36.     float x[100],y[100];
  37.     srface(x,y,&c_10);
  38. 3. String arguments must be passed their length at the end of the
  39. argument list.
  40.     call srface(x,y,'Title') looks like
  41.  
  42.     srface(x,y,"Title",5L);
  43. 4. Ordering of multi-dimensional arrays is different. For example
  44.     x(10)(20) would look like
  45.     x[200] where x(1)(1..20) fills x[0..19] and so on.
  46.  
  47. This part is a little tricky and may need some test programs if
  48. your not sure. After all is said and done maybe you should try
  49. the f2c program available from netlib to get some idea of how it
  50. is done. Note: you will have to do some tricks to get common
  51. block declarations going. Basically you declare a structure.
  52. E-mail me if you need more help.
  53.  
  54. Cheers
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. -- 
  62. | Rod Lessard                    lessard@acs.ucalgary.ca      |
  63. | Cosmic Ray Group                2500 University Drive         |
  64. | Dept. of Physics and Astronomy        Calgary, AB, Canada         |
  65. | University of Calgary                (403) 220 - 3640         |
  66.