HP Fortran Programmer's Guide (September 2007)
Debugging
Handling runtime exceptions
Chapter 4120
• A procedure traceback is displayed on standard error. A procedure traceback lists routine
names and their offsets that are helpful in locating the code that triggered the exception.
• The program aborts.
The following sections discuss each of exceptions listed in Table 4-1. For more information
about signals, refer to the signal(2) and signal(5) man pages.
NOTE Standard Fortran 90 provides the IOSTAT= and ERR= specifiers for handling I/O
runtime errors. For information about these specifiers, refer to the descriptions
of the I/O statements (for example, OPEN and READ) in the HP Fortran
Programmer’s Reference. For a descriptive list of the error messages that can be
returned by IOSTAT=, refer to the HP Fortran Programmer’s Reference.
Bus error exception
A bus error exception occurs when a program references an inaccessible memory location,
typically because the reference is to an unaligned or nonexistent address, or because of a
hardware failure.
The most likely cause of a bus error is unaligned data reference. A program that passes an
array of (KIND=1) elements to a routine that attempts to access them as (KIND=4) elements
may take a bus error exception. Or if an array of (KIND=1) elements is declared in a common
block and the third element is passed to a routine that attempts to access it as a (KIND=4)
variable, the program will take a bus error exception. For information about the alignment of
HP Fortran data types, refer to the HP Fortran Programmer’s Reference.
Bus errors can occur (as can other exceptions) in any program that generates bad address
references. Although less likely to happen with programs that use the standard Fortran 90
pointer, bad address references can happen when the Cray-style pointer extension is misused
or when Fortran program unit passes a parameter by value to a C routine that attempts to
use it as a pointer.
Floating-point exceptions
In accordance with the IEEE Posix Standard, floating-point exceptions are disabled on
HP 9000 computers. Thus, if a program attempts the following operation:
x = 1.0/0.0
it will not trap it as an exception and will not abort. Instead, the value of a positive infinity
(displayed as +INF) will be assigned to x.