https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Sat, Jan 16, 2021 at 12:51:38AM +0000, Bahram.shahrooz at uc dot edu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98701 > > --- Comment #6 from Bahram.shahrooz at uc dot edu --- > I get wrong answers doing this: > > gfortran FiberAnalysis.f -o FiberAnalysis > > I get correct answers doing this: > > gfortran FiberAnalysis.f -fcheck=all -ffpe-trap=zero,invalid -o FiberAnalysis > Your code is broken. I added -freal-init=nan to initialize all variables to an NaN. The compiled program dies, and the debugger shows % gdb ./z z.core Program terminated with signal SIGFPE, Arithmetic exception. #0 0x08049476 in fsteel1 (es=nan(0x8000000000000), fs=nan(0x8000000000000), ibuckle=0) at FiberAnalysis.f:387 387 if(es.ge.0.0) go to 10 (gdb) p es $1 = nan(0x8000000000000) If I reduce the loop 'do 3000 na=1,500' by 1, i.e., I use 'do 3000 na=1,499', then the computation dies at (gdb) bt #0 0x0804e323 in fiberanalysis () at FiberAnalysis.f:313 #1 0x0804ed63 in main (argc=1, argv=0xffbfe864) at FiberAnalysis.f:361 #2 0x08048a37 in _start1 () #3 0x08048b90 in _start () Line 313 is if(xp(k).ne.0.and.xp(k).ge.xpmin) then and (gdb) p xp(500) $4 = nan(0x8000000000000) (gdb) p xp(499) $5 = 2425.0013590651233 If I reduce the loop to 498, it then dies at Program terminated with signal SIGFPE, Arithmetic exception. #0 0x0804e08b in fiberanalysis () at FiberAnalysis.f:302 302 if(xp(k).lt.xpmin) then (gdb) p xp(498) $1 = 2424.590579331998 (gdb) p xp(499) $2 = nan(0x8000000000000) You're using undefined variables.