Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Underflow problems

Don_D_
New Contributor I
190 Views

My code deals with numbers whose value can be almost anything.  If a very small number gets raised to the 18th power, it triggers an underflow error.  I have the Properties Page set so underflow gives 0.0 (in Visual Studio), and that seems to work -- but I can sometimes get this:

First-chance exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC0000090: Floating-point invalid operation.
Unhandled exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
First-chance exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC0000090: Floating-point invalid operation.
Unhandled exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
First-chance exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC0000090: Floating-point invalid operation.
Unhandled exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
First-chance exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC0000090: Floating-point invalid operation.
Unhandled exception at 0x013b23bd in SYNOPSYS200v15.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
The program '[7568] SYNOPSYS200v15.exe: Native' has exited with code 0 (0x0).


Then the program crashes.  What should I do?

0 Kudos
2 Replies
mecej4
Black Belt
190 Views

Setting FTZ (flush to zero) using a VS property (or by specifying /Qftz- as a compiler option) may not protect you from unwanted floating point behavior in library functions.

Have you located the point where the exception occurs? If it occurs in a library that you cannot recompile with the proper FPU control flags set, you may have to do one of

  1. Check a function argument before calling a library function. For example, instead of "y = x ** 18", you can say "if ( abs(x) < 1d-17) then y = 0 else y = x ** 18".
  2. Capture and process the underflow exception.
  3. Use the facilities provided in the IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES modules.
Brooks_Van_Horn
New Contributor I
190 Views

An alternate and easier solution is to

USE INTRINSIC :: IEEE_EXCEPTIONS

Call IEEE_SET_HALTING_MODE(IEEE_UNDERFLOW, .FALSE.)

that will take care of your problem.

 

Brooks

Reply