home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20025 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  1.4 KB

  1. Xref: sparky comp.lang.c:20025 comp.lang.fortran:5112
  2. Path: sparky!uunet!paladin.american.edu!gatech!emory!emory!not-for-mail
  3. From: swhite@mathcs.emory.edu (Scott White)
  4. Newsgroups: comp.lang.c,comp.lang.fortran
  5. Subject: calling a Fortran subroutine from a C program
  6. Date: 21 Jan 1993 13:35:22 -0500
  7. Organization: Emory University, Dept of Math and CS
  8. Lines: 36
  9. Distribution: world
  10. Message-ID: <1jmqdaINN11g@mudhoney.mathcs.emory.edu>
  11. NNTP-Posting-Host: mudhoney.mathcs.emory.edu
  12.  
  13. Can someone please tell me how to call a Fortran subroutine from a C program?
  14. The environment is sun4, OS 4.1.2.
  15.  
  16. Also, the called Fortran routine takes variables which are arrays as 
  17. parameters.  And, I looked and saw that the subscripts start at 1, whereas in
  18. C they start at zero.  That's no problem is it (an address is an address):
  19.  
  20. /* .c file */
  21.     int num[100];
  22.     double zeta[100];
  23.  
  24.     foo(num, zeta);
  25.  
  26.  
  27. /* .f file */
  28.     subroutine foo(number, gamma)
  29.     integer*4 number(100)
  30.     real*8    gamma(100)
  31.  
  32.     /* program proceeds to manipulate values in the arrays, with subscripts
  33.         1 through 100, not 0 through 99 */
  34.  
  35.  
  36. Finally, if the Fortran subroutine changes the values in gamma, the changes
  37. show up when we return to the C program, right?
  38.  
  39. Your gracious help is deeply appreciated.
  40.  
  41. Scott White
  42. Emory University Math Dept.
  43.  
  44. -- 
  45. Scott White
  46. Department of Mathematics and Computer Science
  47. Emory University, Atlanta, GA 
  48. Internet: swhite@mathcs.emory.edu   UUCP: {rutgers,ogicse,gatech}!emory!swhite    
  49.