Sun Studio 12: Fortran Programming Guide

6.2.4 Trapping a Floating-Point Exception

f95 differs significantly from the earlier f77 compiler in the way it handles floating-point exceptions.

The default with f95 is to automatically trap on division by zero, overflow, and invalid operation. With f77, the default was not to automatically generate a signal to interrupt the running program for a floating-point exception. The assumption was that trapping would degrade performance while most exceptions were insignificant as long as expected values are returned.

The f95 command-line option -ftrap can be used to change the default. The default for f95 is -ftrap=common. To follow the earlier f77 default, compile the main program with -ftrap=%none.