Reputation: 47
I am trying to debug a Fortran program. To catch floating point errors, I'm using the following compiler options for gfortran 4.9.0:
FFLAGS1 = -std=f2003 -ffree-form -fdefault-real-8 -fdefault-double-8 \
-Ofast -fall-intrinsics -fcheck=all -m64 \
-fno-trapping-math -c \
-ffpe-trap=invalid,zero,overflow,underflow,precision,denormal -Wall
With these options, the program fails at this line:
read(ctrlUnit,*) slope_fasst, aspect
when trying to read these inputs: 10.0 70.0
If I remove
-ffpe-trap=invalid,zero,overflow,underflow,precision,denormal
from the compiler options, it reads the following line just fine. Both variables are declared as real(8)
. In the input file, I've tried spaces, commas, etc. but see no changes. Does anyone have a suggestion?
Upvotes: 0
Views: 6174
Reputation: 6999
It seems the gfortran -ffpe-trap,precision
flag results in errors for perfectly normal / routine read/write operations.
For example, this program throws a "Floating exception" error:
write(*,*)1.0
end
(gfortran 4.1.2, redhat linux)
Solution, do not use that flag.
Note this makes sense since the conversion from machine number to/from ascii results in a loss of precision ( I'm not sure if thats the intent of the flag to catch such though )
Upvotes: 1