This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Calling Fortran Routines from C
- To: gnu-win32 at cygnus dot com
- Subject: Re: Calling Fortran Routines from C
- From: "Massimo CICCOTELLI" <0994cicc at s1 dot cise dot it>
- Date: Thu, 16 Jul 1998 15:15:28 +0100
- Organization: ENEL-SRI
Hi!
In the following example you can see how to call FORTRAN stuff
from a C main. Obviously you can do also the opposite.
Hope this helps.
Bye, Massimo
------------------------------- beginning ---------------------------------
------------------------------- main.c ------------------------------------
#include <stdio.h>
int main() {
int i=2;
printf("Calling fsub() with argument: i=%d\n",i);
fsub_(&i);
printf(" after fsub(): i=%d\n",i);
printf("Calling intfsub() with argument: i=%d\n",i);
printf("intfun() returns %d \n",intfun_(&i));
}
------------------------------- ffun.f ------------------------------------
integer function intfun(i)
intfun=3*i
return
end
subroutine fsub(i)
i=i*2
return
end
------------------------------- makefile -----------------------------------
O = o
F = f
C = c
X = exe
FOR = g77
CL = gcc
OBJS = main.$(O) ffun.$(O)
CO = -c
LO =
LIBS =
a.$(X) : $(OBJS) $(LIBS)
$(FOR) $(LO) $(OBJS) $(LIBS) -o a.$(X)
main.$(O) : main.$(C)
$(CL) $(CO) main.$(C)
ffun.$(O) : ffun.$(F)
$(FOR) $(CO) ffun.$(F)
------------------------------- end -----------------------------------
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".