home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20025 comp.lang.fortran:5112
- Path: sparky!uunet!paladin.american.edu!gatech!emory!emory!not-for-mail
- From: swhite@mathcs.emory.edu (Scott White)
- Newsgroups: comp.lang.c,comp.lang.fortran
- Subject: calling a Fortran subroutine from a C program
- Date: 21 Jan 1993 13:35:22 -0500
- Organization: Emory University, Dept of Math and CS
- Lines: 36
- Distribution: world
- Message-ID: <1jmqdaINN11g@mudhoney.mathcs.emory.edu>
- NNTP-Posting-Host: mudhoney.mathcs.emory.edu
-
- Can someone please tell me how to call a Fortran subroutine from a C program?
- The environment is sun4, OS 4.1.2.
-
- Also, the called Fortran routine takes variables which are arrays as
- parameters. And, I looked and saw that the subscripts start at 1, whereas in
- C they start at zero. That's no problem is it (an address is an address):
-
- /* .c file */
- int num[100];
- double zeta[100];
-
- foo(num, zeta);
-
-
- /* .f file */
- subroutine foo(number, gamma)
- integer*4 number(100)
- real*8 gamma(100)
-
- /* program proceeds to manipulate values in the arrays, with subscripts
- 1 through 100, not 0 through 99 */
-
-
- Finally, if the Fortran subroutine changes the values in gamma, the changes
- show up when we return to the C program, right?
-
- Your gracious help is deeply appreciated.
-
- Scott White
- Emory University Math Dept.
-
- --
- Scott White
- Department of Mathematics and Computer Science
- Emory University, Atlanta, GA
- Internet: swhite@mathcs.emory.edu UUCP: {rutgers,ogicse,gatech}!emory!swhite
-