Installing an exception handler
When a program that uses the Open XL Fortran for AIX® exception-detection facilities encounters an exception condition, it receives a signal from the operating system.
This causes a branch to whatever handler is specified by the program.
xlf95 -qflttrap=ov:und:en pi.f # Dump core on an exception
xlf95 -qflttrap=ov:und:en -qsigtrap pi.f # Uses the xl__trce handler
xlf95 -qflttrap=ov:und:en -qsigtrap=return_22_over_7 pi.f # Uses any other handler
/usr/include/fexcp.h):
INCLUDE 'fexcp.h'
CALL SIGNAL(SIGTRAP,handler_name)
CALL SIGNAL(SIGFPE,handler_name)
- xl__ieee
- Produces a traceback and an explanation of the signal and continues execution by supplying the default IEEE result for the failed computation. This handler allows the program to produce the same results as if exception detection was not turned on.
- xl__trce
- Produces a traceback and stops the program.
- xl__trcedump
- Produces a traceback and a core file and stops the program.
- xl__sigdump
- Provides a traceback that starts from the point at which it is called and provides information about the signal. You can only call it from inside a user-written signal handler. It does not stop the program. To successfully continue, the signal handler must perform some cleanup after calling this subprogram.
- xl__trbk
- Provides a traceback that starts from the point at which it is called. You call it as a subroutine from your code, rather than specifying it with the -qsigtrap option. It requires no parameters. It does not stop the program.
All of these handler names contain double underscores to avoid duplicating names that you declared in your program. All of these routines work for both SIGTRAP and SIGFPE signals.
You can use the -g compiler option to
get line numbers in the traceback listings. The file /usr/include/fsignal.h defines
a Fortran derived type similar to the ucontext_t structure
in /usr/include/sys/ucontext.h. You can write a Fortran signal
handler that accesses this derived type.
Sample programs for exception handling lists some sample programs that illustrate how to use these signal handlers or write your own. Also see the SIGNAL procedure in the IBM® Open XL Fortran Language Reference for more information.