Software Archive
Read-only legacy content
17061 Discussions

calling a fortran subroutine from a C main routine

Intel_C_Intel
Employee
341 Views
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

ld:

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

Unresolved:

MAIN__

f77: Severe: Failed while trying to link.

*** Exit 1

Stop.

Can anyone suggest how I can properly link? I tried f90 & f95 - no luck
Thanks
0 Kudos
1 Reply
Steven_L_Intel1
Employee
341 Views
Try adding -noformain to the f77 command when you link.

Steve
0 Kudos
Reply