calling a fortran subroutine from a C main routine

calling a fortran subroutine from a C main routine

On Sun UNIX, I used to be able to call a fortran routine from C main routine. In detail,

----- C routine: test2_f_land_2.c

void main(){

int f_land_2_();

printf(%c", f_land_2_(&lat, &lon) );

---- Fortrain subroutine

integer function f_land_2(lat,long)

But when I ported the codes to Tru64 Unix, and compile it as

test2 : test2.o f_land_2.o

$(CC) test2.o f_land_2.o $(LIBS) -o test2

I get an error:

cc -I./ -I~sk/tp/prog/libraries/headers -g -c test2_f_land_2.c

f77 test2_f_land_2.o f_land_2.o -lm -o test2_f_land_2


/usr/lib/cmplrs/fort90/for_main.o: main: multiply defined



f77: Severe: Failed while trying to link.

*** Exit 1


Can anyone suggest how I can properly link? I tried f90 & f95 - no luck

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Try adding -noformain to the f77 command when you link.


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today