Fortran Programming Guide

Establishing an Exception Handler Function

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

The routine that calls ieee_handler() should also declare:

#include 'f77_floatingpoint.h'

For f90 programs, declare:

#include 'f90/floatingpoint.h'

The special arguments SIGFPE_DEFAULT, SIGFPE_IGNORE,and SIGFPE_ABORT are defined in f77_floatingpoint.h 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.