Oracle® Solaris Studio 12.4: Numerical Computation Guide

Exit Print View

Updated: January 2015
 
 

3.4.4 ieee_retrospective(3m)

The libsunmath function ieee_retrospective prints information about unrequited exceptions and nonstandard IEEE modes. It reports:

  • Outstanding exceptions.

  • Enabled traps.

  • If rounding direction or precision is set to other than the default.

  • If nonstandard arithmetic is in effect.

The necessary information is obtained from the hardware floating-point status register.

ieee_retrospective prints information about exception flags that are raised, and exceptions for which a trap is enabled. These two distinct, if related, pieces of information should not be confused. If an exception flag is raised, then that exception occurred at some point during program execution. If a trap is enabled for an exception, then the exception might not have actually occurred, but if it had, a SIGFPE signal would have been delivered. The ieee_retrospective message is meant to alert you about exceptions that might need to be investigated, if the exception flag is raised, or to remind you that exceptions might have been handled by a signal handler, if the exception's trap is enabled. Chapter 4, Exceptions and Exception Handling discusses exceptions, signals, and traps, and shows how to investigate the cause of a raised exception.

A program can explicitly call ieee_retrospective at any time. Fortran programs compiled with f95 in –f77 compatibility mode automatically call ieee_retrospective before they exit. C/C++ programs and Fortran programs compiled with f95 in the default mode do not automatically call ieee_retrospective.

Note, though, that the f95 compiler enables trapping on common exceptions by default, so unless a program either explicitly disables trapping or installs a SIGFPE handler, it will immediately abort when such an exception occurs. In –f77 compatibility mode, the compiler does not enable trapping, so when floating-point exceptions occur, the program continues execution and reports those exceptions via the ieee_retrospective output on exit.

The syntax for calling this function is as follows:

  • C, C++ - ieee_retrospective(fp);

  • Fortran - call ieee_retrospective()

For the C function, the argument fp specifies the file to which the output will be written. The Fortran function always prints output on stderr.

The following example shows four of the six ieee_retrospective warning messages:

Note: IEEE floating-point exception flags raised:
   Inexact; Underflow; 
Rounding direction toward zero 
IEEE floating-point exception traps enabled: 
   overflow; 
See the Numerical Computation Guide, ieee_flags(3M), 
ieee_handler(3M), ieee_sun(3m)

A warning message appears only if trapping is enabled or an exception was raised.

You can suppress ieee_retrospective messages from Fortran programs by one of three methods. One approach is to clear all outstanding exceptions, disable traps, and restore round-to-nearest, extended precision, and standard modes before the program exits. To do this, call ieee_flags, ieee_handler, and standard_arithmetic as follows:

character*8 out 
i = ieee_flags('clearall', '', '', out) 
call ieee_handler('clear', 'all', 0)
call standard_arithmetic()

Note -  Clearing outstanding exceptions without investigating their cause is not recommended.

Another way to avoid seeing ieee_retrospective messages is to redirect stderr to a file. Of course, this method should not be used if the program sends output other than ieee_retrospective messages to stderr.

The third approach is to include a dummy ieee_retrospective function in the program, for example:

subroutine ieee_retrospective
return
end