Fortran Programming Guide

Trapping a Floating-Point Exception

f77 and f90 differ significantly in the way they handle floating-point exceptions.

With f77, the default on SPARC and x86 systems is not to automatically generate a signal to interrupt the running program for a floating-point exception. The assumptions are that signals could degrade performance and that most exceptions are not significant as long as expected values are returned.

The default with f90 is to automatically trap on division by zero, overflow, and invalid operation.

The f77 and f90 command-line option -ftrap can be used to change the default. In terms of -ftrap, the default for f77 is -ftrap=%none. The default for f90 is -ftrap=common.

To enable exception trapping, compile the main program with one of the -ftrap options--for example: -ftrap=common.