【发布时间】:2015-09-14 00:39:05
【问题描述】:
我开始使用运行 Redhat 6.6 的 HPC。 作为另一个程序的教程步骤,我被要求编译一些旧的 F77 代码。
我正在运行gfortran 3bar.f
我收到错误消息:
/tmp/ccgUvoGd.o: In function `MAIN__': 3bar.f:(.text+0x43): undefined reference to `mygetarg_' 3bar.f:(.text+0x61): undefined reference to `mygetarg_' 3bar.f:(.text+0x8a): undefined reference to `mygetarg_' collect2: ld returned 1 exit status
我相信这与代码中 sqrt 内在函数的使用有关。我已经对这个错误和gfortran 进行了一些搜索,但是对于这个和那个的特定版本的 Fortran,我有一些争论。
如果有人能建议我如何让这段代码工作,我将不胜感激,因为这真的不是我正在做的事情的重点。
代码是:
program Three_bar
implicit none
real*8 a1,a2, g1,g2, weight, sum,
1 l0,d0,sqrt
intrinsic sqrt
character*80 inp_fname, out_fname
character*4 card1
integer i, ir,iw, numb_args, iargc, numb_iter
numb_args = iargc()
if ( numb_args .ge. 2 ) then
call MYGETARG(1,inp_fname)
call MYGETARG(2,out_fname)
else if ( numb_args .eq. 1 ) then
call MYGETARG(1,inp_fname)
out_fname = 'rdcs_output'
else
inp_fname = 'rdcs_input'
out_fname = 'rdcs_output'
endif
ir = 7
open (ir, file=inp_fname,status='UNKNOWN',access='SEQUENTIAL')
iw = 8
open (iw, file=out_fname,status='UNKNOWN',access='SEQUENTIAL')
l0 = 1.0
d0 = 1.0
c loop to spend some cpu - to test recall feature
sum = 1.0
numb_iter = 20000
do 1005 i=1,numb_iter
sum = (sum*1.00001)**1.001
if ( sum .gt. 1.0e6 ) sum = 1.0
1005 continue
c read the data from param file
weight = (2.d0*sqrt(2.d0)*a1 + a2)*l0*d0
g1=(2.d0*a1+sqrt(2.d0)*a2)/(2.d0*a1*(a1+sqrt(2.d0)*a2))-1.0d0
g2 = 1.0d0/(a1 + sqrt(2.d0)*a2) -1.0d0
write (iw,601) g1,g2,weight
close (unit=ir,status='KEEP')
close (unit=iw,status='KEEP')
501 format(a4,1x,f30.0)
601 format("g1 = ",e25.16," ",/,"g2 = ",e25.16," ",/,
1 "weight = ",e25.16," ")
stop
end
【问题讨论】:
-
是什么让你认为这与 sqrt 有关系?该错误表示链接器找不到您的代码调用的 MYGETARG 子例程。该子程序在哪里定义?
-
我已经在您的代码中缩进了更多用于固定格式源代码的列,因为这不太可能是问题所在,如上面的评论中所述。不过,请检查它是否正确。
-
抱歉,感谢您对缩进的帮助。缩进在本地看起来是正确的,如果网站以不同的方式解释它,我不知道如何发布它。
-
Casey,一些早期的编译器错误返回的网络搜索结果似乎与内在相关。