Sun Studio 12: Fortran Programming Guide

6.2.2 Floating-Point Exceptions

f95 programs do not automatically report on exceptions. An explicit call to ieee_retrospective(3M) is required to display a list of accrued floating-point exceptions on program termination. In general, a message results if any one of the invalid, division-by-zero, or overflow exceptions have occurred. Inexact exceptions do not generate messages because they occur so frequently in real programs.

6.2.2.1 Retrospective Summary

The ieee_retrospective function queries the floating-point status registers to find out which exceptions have accrued and a message is printed to standard error to inform you which exceptions were raised but not cleared. The message typically looks like this; the format may vary with each compiler release:


Note: IEEE floating-point exception flags raised:
    Division by Zero;
IEEE floating-point exception traps enabled:
    inexact;  underflow;  overflow;  invalid operation;
See the Numerical Computation Guide, ieee_flags(3M),
    ieee_handler(3M)

A Fortran 95 program would need to call ieee_retrospective explicitly and compile with -xlang=f77 to link with the f77 compatibility library.

Compiling with the -f77 compatibility flag will enable the Fortran 77 convention of automatically calling ieee_retrospective at program termination.

You can turn off any or all of these messages with ieee_flags() by clearing exception status flags before the call to ieee_retrospective.