HP-UX Floating-Point Guide
158 Chapter 6
Floating-Point Trap Handling
Handling Traps
The ON statement allows you to specify a particular action to be taken
when a particular exception arises. The action may be any of the
following:
• ABORT (the default action). Specifying ABORT allows you to get the
address where the error occurred, which may be useful in debugging.
• IGNORE (usually not a good idea).
• CALL sub (call a subroutine). If you call a subroutine to handle an
IEEE exception, you must pass it one argument, which is of the same
type as the type associated with the exception. If the subroutine
returns, the program uses the assigned value of the argument as the
result value of the operation that caused the handler to be invoked.
NOTE A subroutine that handles an IEEE exception takes a different number
of arguments from a subroutine that handles a math library error (as
described in “Math Library Error Handling for Fortran” on page 106).
See the HP FORTRAN/9000 Programmer’s Guide for details. HP
discourages the use of the ON statement to handle library errors in HP
Fortran 90, but using it to handle arithmetic errors poses no problems.
You can use the ON statement to handle any of the following exceptions:
DIV 0
OVERFLOW
UNDERFLOW
INEXACT
ILLEGAL
For example, the following program calls the subroutine HANDLE_OFL to
handle a DOUBLE PRECISION overflow. The subroutine prints a message
describing the error, prints the biased value passed to the subroutine,
then the correct value, and exits.