Subject: Re: Calling Fortran Routines from C
From: [email-masked] (Massimo CICCOTELLI)

16 Jul 1998 23:22:54 -0700
Message-ID: <[email-masked]>
To: [email-masked]

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
"[email-masked]" with one line of text: "help".