floating point exception
Janne Blomqvist
blomqvist.janne@gmail.com
Fri Apr 3 15:26:00 GMT 2015
On Fri, Apr 3, 2015 at 6:03 PM, Frankenstein, Susan ERDC-RDE-CRREL-NH
<Susan.Frankenstein@erdc.dren.mil> wrote:
> Hello All:
>
> I have a fortran program for which I get different behavior depending on
> which compiler options I see. The code that is causing the problem is:
>
> read(ctrlUnit,'(a)') snwFile
> !snow processes output data
> snwFile = snwFile(1:len_trim(snwFile(1:index(snwFile,'!')-1)))
>
> write(*,*)'"',trim(snwFile),'" ',ctrlUnit
> read(ctrlUnit,*) slope_fasst,aspect
> !degrees from horizontal, degrees from N
> write(*,*)slope_fasst,aspect
>
>
> If I use the following compiler options:
>
> 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
>
> The program stops executing after the first write statement. If I use
> instead:
>
> FFLAGS1 = -std=f2003 -ffree-form -fdefault-real-8 -fdefault-double-8
> -Ofast -fall-intrinsics -fcheck=all -m64 -fno-trapping-math c
>
> The program runs just fine. The input file lines are:
>
> snow_info.out !output of snow information
> 10.0 70.0 !surface slope (degrees from horizontal), surface
> aspect angle (degrees from N, + = clockwise)
>
>
> I have compiled and run this code using Intel fortran with the fpe0
> option and receive no errors.
>
> I¹m at a loss as to what to do. Suggestions?
Please read the manual section about the -ffpe-trap option:
https://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html
Let me quote one sentence from there in particular:
"Many, if not most, floating point operations incur loss of precision
due to rounding, and hence the ffpe-trap=inexact is likely to be
uninteresting in practice."
(-ffpe-trap=precision that you have used is an alias for "inexact"
which is there for backwards compatibility).
I'm too lazy to look up the Intel Fortran documentation at the moment,
but I suspect that the "fpe0" option does not enable the inexact
exception trap.
--
Janne Blomqvist
More information about the Fortran
mailing list