This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Calling Fortran Routines from C


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]