请教一下,在c中调用fortran的subroutine,但是编译c文件的时候不能通过
fortran文件如下:
randomnum.f90
--------------------------------------------------------------------
subroutine randomnum(iseed,fn_val)
real fn_val, rm
integer ia, ic, ir, iseed, ix, iy, j, m
parameter (m=714025, ia=1366, ic=150889, rm=1./m)
common /rndm/ ir(97), ix, iy
if(iseed .lt. 0) then
ix = mod(ic-iseed, m)
do j=1,97
ix = mod(ia*ix+ic, m)
ir(j) = ix
end do
ix = mod(ia*ix+ic, m)
iy = ix
end if
j = 1 + (97*iy)/m
if(j.gt.97 .or. j.lt.1) stop
iy = ir(j)
ix = mod(ia*ix+ic, m)
ir(j) = ix
fn_val = iy*rm
end subroutine randomnum
--------------------------------------------------------------------
编译命令如下:
/opt/intel/fc/10.1.013//bin/ifort -o randomnum.o -c randomnum.f90
c文件如下:
ccf.c
--------------------------------------------------------------------
#include <stdio.h>
extern void randomnum_(int * a,float * b);
int main(){
float b;
int a=1;
int i = 0;
for(; i <10 ; i++){
randomnum_(&a,&b);
printf("b = %f\n",b);
}
}
--------------------------------------------------------------------
编译命令如下:
gcc -o ccf ccf.c randomnum.o
出错信息如下:
[william@localhost workspace]$ gcc -o ccf ccf.c randomnum.o
randomnum.o: In function `randomnum_':
randomnum.f90:(.text+0x10e): undefined reference to `for_stop_core'
collect2: ld returned 1 exit status
[william@localhost workspace]$
请问这是什么问题,应该如何解决,谢谢!