- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I capture runtime exceptions such as overflows, etc.? I am presently using "Produce Nan, signed infinities, and denormal results" (/fpe:3) and when an exception occurs the program just hangs. I would like it to generate an error message.
I have tried /fpe:0 and 1 but the program results are incorrect and different from the ones with /fpe:3.
Any suggestions?
R
Link Copied
16 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The program "hanging" is not normal for an arithmetic exception. Note that the default is to allow underflows to produce denormals and your program might be trying to "converge" and not doing so. If /fpe:0 gives you different results, then you are very likely doing computations with denormalized values and this loses precision. Since you don't get exceptions, you're not seeing overflows so there's nothing to capture.
The standard way to do what you want is through the IEEE_EXCEPTIONS and IEEE_ARITHMETIC intrinsic modules. You can set the behavior to give an error on an underflow.
The standard way to do what you want is through the IEEE_EXCEPTIONS and IEEE_ARITHMETIC intrinsic modules. You can set the behavior to give an error on an underflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
When I said that the program was "hanging", I wanted to say that the program reported NaNs and became exceedingly slow. I just want it to bang and stop when an overflow occurs. Beside the IEEE modules, is there n equivalent option to /fpe:0 that would abort the program without reducing underflows to 0.0?
Cheers,
R//G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could simply test a strategic value (outside any performance-critical loop) by ieee_isnan() so as to take a kill action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
USE, INTRINSIC :: IEEE_EXCEPTIONS
...
CALL IEEE_SET_HALTING_MODE(IEEE_OVERFLOW,.TRUE.)
I will comment, though, that if you're getting NaNs, you aren't seeing overflows.
...
CALL IEEE_SET_HALTING_MODE(IEEE_OVERFLOW,.TRUE.)
I will comment, though, that if you're getting NaNs, you aren't seeing overflows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand well, you are indicating that if my program was generating overflows, it would halt even when using /fpe:3?
Are NaNs generated by Division by 0?
Are NaNs generated by Division by 0?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that's what should happen.
That's one way to generate NaNs, but not the only way.
That's one way to generate NaNs, but not the only way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
Is there a compiler option that would forcethe program halt when a NaN occurs in the same way of the Overflows and withouth assinging 0. to the underflows?
R//G
Is there a compiler option that would forcethe program halt when a NaN occurs in the same way of the Overflows and withouth assinging 0. to the underflows?
R//G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, but you can call IEEE_SET_HALTING_MODE(IEEE_INVALID,.TRUE.) in the main program to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excellent. I will try that.
Thanks again.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Are NaNs generated by Division by 0?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, division by zero is one way to generate a NaN.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only for the case 0./0,, or possibly cases involving subnormal, as well as (x/0.)*0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure. I created the following code:
call ieee_get_flag (ieee_usual, flag_values)
if (any(flag_values)) then
write(*,*) ' Error code: ', flag_values
stop
endif
That outputs: T F T when it captures an error.
I guess that reflects an ieee_invalid, but I am not sure.
R//G
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For whatever weird way posting on this forum is broken with IE9.
Anyways TimP posted the same (division by zero generates +-infinity, not NaN).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting strohhaecker
For whatever weird way posting on this forum is broken with IE9.
Anyways TimP posted the same (division by zero generates +-infinity, not NaN).
If you want to post to this forum with IE9 you need toswitch on the browsercompatibility mode (the iconshowing abrokenpage at the end of the address bar).
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not seeing any problems posting with IE9 (using it to post this) and there is no compatibility mode icon in my browser bar.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page