To establish a function as an exception handler, pass the name of the function to ieee_handler(), together with the name of the exception to watch for and the action to take. Once you establish a handler, a SIGFPE signal is generated whenever the particular floating-point exception occurs, and the specified function is called.
The form for invoking ieee_handler() is shown in the following table:
Table 6–4 Arguments for ieee_handler( action , exception , handler)
Argument |
Type |
Possible Values |
---|---|---|
action |
character |
get, set, or clear |
exception |
character |
invalid, division, overflow, underflow, or inexact |
handler |
Function name |
The name of the user handler function or SIGFPE_DEFAULT, SIGFPE_IGNORE, or SIGFPE_ABORT |
Return value |
integer |
0 =OK |
A Fortran 95 routine compiled with f95 that calls ieee_handler() should also declare:
#include ’floatingpoint.h’
The special arguments SIGFPE_DEFAULT, SIGFPE_IGNORE, and SIGFPE_ABORT are defined in these include files and can be used to change the behavior of the program for a specific exception:
SIGFPE_DEFAULT or SIGFPE_IGNORE |
No action taken when the specified exception occurs. |
SIGFPE_ABORT |
Program aborts, possibly with dump file, on exception. |