HP Fortran Programmer's Guide (September 2007)
Using the ON statement
Chapter 5126
As described in “Handling runtime exceptions” on page 119, the +fp_exception and +FP
options provide control over how a program behaves when a runtime error occurs. The ON
statement provides an additional level of control by enabling your program to handle
floating-point and integer exceptions and +Ctrl-C interrupts. Before an exception can be
handled, the flow of control must pass through an ON statement that specifies:
• The type of the exception
• One of the following actions:
❏ Execute a trap procedure
❏ Ignore the interrupt
❏ Abort the program
The action specified by the ON statement can only be changed by another ON statement that
specifies the same exception.
This chapter describes how to use the ON statement. The syntax of the ON statement is
described in the HP Fortran Programmer’s Reference. For detailed information about
trapping math errors, see the HP-UX Floating-Point Guide.
NOTE If you include the ON statement in a program that you optimize at level 2 or
higher and the program takes an exception, the results may vary from those
you would get from an unoptimized program or from a program that didn’t have
the ON statement.