delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/07/16/23:22:54

From: 0994cicc AT s1 DOT cise DOT it (Massimo CICCOTELLI)
Subject: Re: Calling Fortran Routines from C
16 Jul 1998 23:22:54 -0700 :
Message-ID: <9807161311.AA23535.cygnus.gnu-win32@dns.cise.it>
To: gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019