提问人:Surya Sarvajith 提问时间:7/30/2022 最后编辑:Surya Sarvajith 更新时间:7/30/2022 访问量:85
由于内存访问问题导致的分段故障
Segmentation fault due to memory access issue
问:
当我运行 f77 代码时,由于内存访问问题,我遇到了分段错误。
这是我的终端输出的消息:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000f523b7 in bcvnmtn (xb=<error reading variable: Cannot access memory at address 0xc44a8000c3818>,
yb=<error reading variable: Cannot access memory at address 0xc5dc8000c5138>, nstp=0, npoints=0, tx=..., ty=..., anx=..., any=...) at ./bcvnmtn.F:14
14 tx(1) = xb(1+nstp) - xb(1)
下面是遇到此分段错误的子例程
subroutine bcvnmtn(xb,yb,nstp,npoints,tx,ty,anx,any)
c-----compute the vertex valued tangential and normal vector fields
c----- (tx,ty)(n) and (anx,any)(n) to the curve (xb,yb)((n-1)*nstp+1)
c----- for n=1 to npoints
cdir$ nolist
include 'paramcom.h'
cdir$ list
dimension xb(1),yb(1),tx(1),ty(1),anx(1),any(1)
c-----get tangent vector field
tx(1) = xb(1+nstp) - xb(1)
ty(1) = yb(1+nstp) - yb(1)
in = 1
do 100 n=2,npoints-1
inp = in + 2*nstp
tx(n) = (xb(inp) - xb(in))*0.5
ty(n) = (yb(inp) - yb(in))*0.5
in = in + nstp
100 continue
nlast = npoints
ilast = 1 + (npoints-1)*nstp
tx(nlast) = xb(ilast) - xb(ilast-nstp)
ty(nlast) = yb(ilast) - yb(ilast-nstp)
c-----normalize to unit length and rotate to get normal vector
do 200 n=1,npoints
tl = sqrt( tx(n)**2 + ty(n)**2 )
tx(n) = tx(n) / ( tl + tiny )
ty(n) = ty(n) / ( tl + tiny )
any(n) = tx(n)
anx(n) = -ty(n)
200 continue
return
end
上面的子例程由以下子例程调用:
subroutine bcsymgd(xi,yi)
c-----compute ghost point locations along a symmetry boundary
cdir$ nolist
include 'common.h'
include 'inputcom.h'
include 'pointer.h'
cdir$ list
common /bcpoint/ idimfrm,jdimfrm,isttfrm,jsttfrm,nstpfrm,nofffrm,
% idimtoo,jdimtoo,istttoo,jstttoo,nstptoo,nofftoo,
% npoints
dimension xi(0:idimfrm,0:jdimfrm),yi(0:idimfrm,0:jdimfrm)
call bcvnmtn(xi(isttfrm,jsttfrm),yi(isttfrm,jsttfrm),
% nstpfrm,npoints,tangx,tangy,anormx,anormy)
call bcdifvf(dispx(isttfrm,jsttfrm),dispy(isttfrm,jsttfrm),
% nofffrm,nstpfrm,
% xi(isttfrm,jsttfrm),yi(isttfrm,jsttfrm),
% (- nofftoo),nstpfrm,
% xi(isttfrm,jsttfrm),yi(isttfrm,jsttfrm),
% nofffrm,nstpfrm,npoints)
call bctrflc(dispx(isttfrm,jsttfrm),dispy(isttfrm,jsttfrm),
% dispx(isttfrm,jsttfrm),dispy(isttfrm,jsttfrm),
% nstpfrm,npoints,tangx,tangy,anormx,anormy)
call bcaddvf(xi(istttoo,jstttoo),yi(istttoo,jstttoo),
% nofftoo,nstptoo,
% dispx(isttfrm,jsttfrm),dispy(isttfrm,jsttfrm),
% nofffrm,nstpfrm,
% xi(isttfrm,jsttfrm),yi(isttfrm,jsttfrm),
% nofffrm,nstpfrm,npoints)
return
end
习 和 yi (在 bcymgd.F) 是几何图形的坐标。但正如你所看到的,它似乎是从 bcymgd 的 2 维开始的。F 到 bcvnmtn 中的 1 维 (xb,yb)。F
这是一个非常大和旧的代码。我目前没有太多的灵活性来编辑源代码。我正在使用 pgi/2020.4 编译器。
如果有人能帮我解决这个问题,那就太好了。如果我能提供更多信息,请告诉我。
答: 暂无答案
评论
-g
-g