fortran - Compiling .f file, "undefined reference to 'MAIN_' issue -
i trying compile .f file using g77. tried compile .cmd batch file (as per 1 of ways described in g77 documentation) following content (in .cmd file):
g77 -o gtemp.exe gtemp.f pause
but when run upper .cmd file, following error message: "undefined reference 'main_'
why happening? gtemp.f file in same folder g77.exe file. thank you.
here code gtemp.f file:
subroutine gtemp(dif,tmin,tmax,tav,tg) gtemp 2 dimension amon(12),tg(12) gtemp 3 data amon / 15.,46.,74.,95.,135.,166.,196.,227.,258.,288., gtemp 4 1 319.,349. / gtemp 5 data p,pi,po / 8760.,3.14159265,0.6 / gtemp 6 c gtemp 7 beta = sqrt(pi/(dif*p))*10. gtemp 8 x = exp(-beta) gtemp 9 x2 = x*x gtemp 10 c = cos(beta) gtemp 11 s = sin(beta) gtemp 12 y = x2 - 2.*x*c + 1. gtemp 13 y = y / (2.*beta*beta) gtemp 14 gm = sqrt(y) gtemp 15 z = (1.-x*(c+s)) / (1.-x*(c-s)) gtemp 16 phi = atan(z) gtemp 17 bo = (tmax-tmin)*0.5 gtemp 18 40 i=1,12 gtemp 19 theta = amon(i)*24. gtemp 20 40 tg(i) = tav - bo*cos(2.*(pi/p)*theta-po-phi)*gm + 460. gtemp 21 return gtemp 22 end gtemp 23
this problem happens when compiler cannot find main program.
create main program follows
program test implicit none real :: dif, tmin, tmax, tav, tg(12) call gtemp(dif,tmin,tmax,tav,tg) contains subroutine gtemp(dif,tmin,tmax,tav,tg) ..... end subroutine gtemp end program test
Comments
Post a Comment