I am currently working to debug a subroutine of some software that my boss has written back in the 90s. There seems to be a floating-point exception that occurs in a do loop of a particular subroutine:
16 irad=1,incmax
rr1=rr2
rr2=rr2+rdiv
if(rr1.gt.rlimit) goto 16
if(pts(irad).gt.0.0) then
discrm=(rmsden(mt,irad)/pts(irad))
1 -((average(mt,irad)**2)/(pts(irad)**2))
else
discrm=0.0
endif
if(discrm.ge.0.0) then
rmsden(mt,irad)=sqrt(discrm)
else
rmsden(mt,irad)=0.0
endif
average(mt,irad)=average(mt,irad)/pts(irad)
average(mt,irad)=(average(mt,irad)*100.0)/bigmost(mt)
rmsden(mt,irad)=(rmsden(mt,irad)*100.0)/bigmost(mt)
denbot(mt,irad)=(denbot(mt,irad)*100.0)/bigmost(mt)
dentop(mt,irad)=(dentop(mt,irad)*100.0)/bigmost(mt)
iradmax(mt)=irad
17 if(iverbose0.ge.1) then
ipts=pts(irad)
iptszero=ptszero(irad)
if(ipts.eq.0) then
average(mt,irad)=0.0
rmsden(mt,irad)=0.0
denbot(mt,irad)=0.0
dentop(mt,irad)=0.0
endif
write(6,99) rr1,rr2,ipts,iptszero,average(mt,irad),
1 rmsden(mt,irad),denbot(mt,irad),dentop(mt,irad)
99 format(1x,2f9.2,2i8,2f8.1,2f8.1)
endif
16 continue
stop 'PIPPA'
If I put the stop 'PIPPA' statement before "16 continue", the there are no errors. However, if the stop statement goes after the "16 continue", I get:
Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG
STOP PIPPA
This didn't happen before upgrading the GCC compilers/libraries. I admit that I have found a lot of resources through Googling, but I am still unable to debug this. I have also tried the --fpe-trap
flags upon compilation, however they do not output anything.
Why does gfortran now complain?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…