Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

floating exception reporting

justanotherengineer
558 Views
Hello,
I would like to optimize my code while catching the exception sqrt of negative numbers. I thought setting -fpe0 would ensure this but optimizations seem to override this. Playing with compilation options fo the test progam below, I found that:
ifort -O0 -fpe0 test.f produces forrtl error of sqrt(-1.9)
ifort -O1 -fpe0 test.f does not produce forrtl error (result prints as NaN)
ifort -O2 -fpe0 test.f does not produce forrtl error
ifort -O{n} test.f does not produce forrtl error
So, -fpe0 only works with -O0? Any suggestions on how to catch this error at higher optimization levels?
Thanks for any help.
Jonathan
ia64, Linux RH Enterprise 3, ifort 8.1.021 or ifort 9.0.031
Simple test progam follows:
=====================
program TEST
implicit none
real dx,dy
dy = -1.952034
dx = sqrt(dx)
write(0,*) dx,dy
stop
end
0 Kudos
1 Reply
justanotherengineer
558 Views

Just adding some more info:

  1. ifort -mp -fpe0 test.f produces a forrtl erorr (but a different statement than -O1 -fpe0 does -- getRegFromUnwindContext: Can't get Gro from UnwindContext)
  2. ifort -mp -O0test.t does not producean error!

The User's Guide isn't clear what is happening with -mp other than the line "compile-time floating-pointarithmetic is not performed to ensure that floating-point exceptions are also maintained"...but example #2 seems like this is incorrect?

0 Kudos
Reply