Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Fortran 90 Compiler for HP-UX: Fortran 90 Programmer's Guide > Chapter 5 Using the ON statement

Exceptions handled by the ON statement

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

Like the +fp_exception option, the ON statement enables traps for floating-point exceptions (by default, traps for floating-point exceptions are disabled on HP 9000 computers). When traps are enabled, an executing program that takes any of the following exceptions will abort, unless an ON statement specifies a different action:

  • Division by zero

  • Overflow

  • Underflow

  • Inexact result

  • Invalid (or illegal) operation

These exceptions are defined by the IEEE standard for floating-point operations. The ON statement enables traps for these exceptions, regardless of whether the exception is taken by user code or by a call to a library routine. In addition, the ON statement also enables traps for integer division by zero, integer overflow, and +Ctrl-C interrupts. The +Ctrl-C interrupt occurs when the user presses +Ctrl-C during program execution.

The table below lists the exceptions handled by the ON statement and gives the keywords that must be specified in the ON statement to indicate the exception being handled. The first column indicates the type of exception. The second column gives the keywords that must appear in the ON statement, immediately following the word ON. The third column gives alternate keywords you can specify instead of those in the second column.

For example, the following ON statement will trap attempts to divide by zero with 8-byte floating-point operands:

ON REAL(8) DIV 0 CALL div_zero_trap

The next example ON statement does the same as the first but uses the alternate keywords from the third column of the table:

ON DOUBLE PRECISION DIV 0 CALL div_zero_trap

Table 5-1  Exceptions handled by the ON statement

Exceptions

Exception keywords

Alternate keywords

Division by zero

REAL(4) DIV 0

REAL DIV 0

REAL(8) DIV 0

DOUBLE PRECISION DIV 0

REAL(16) DIV 0

(none)

INTEGER(2) DIV 0

INTEGER*2 DIV 0

 

INTEGER(4) DIV 0

INTEGER DIV 0

Overflow

REAL(4) OVERFLOW

REAL OVERFLOW

REAL(8) OVERFLOW

DOUBLE PRECISION OVERFLOW

REAL(16) OVERFLOW

(none)

INTEGER(2) OVERFLOW

INTEGER*2 OVERFLOW

INTEGER(4) OVERFLOW

INTEGER OVERFLOW

Underflow

REAL(4) UNDERFLOW

REAL UNDERFLOW

REAL(8) UNDERFLOW

DOUBLE PRECISION UNDERFLOW

 

REAL(16) UNDERFLOW

(none)

Inexact result

REAL(4) INEXACT

REAL INEXACT

REAL(8) INEXACT

DOUBLE PRECISION INEXACT

REAL(16) INEXACT

(none)

Invalid (illegal) operation

REAL(4) ILLEGAL

REAL ILLEGAL

REAL(8) ILLEGAL

DOUBLE PRECISION ILLEGAL

REAL(16) ILLEGAL

(none)

+Ctrl-C interrupt

CONTROLC

(none)

 

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.