HP Fortran Programmer's Guide (B3908-90031; September 2011)

Using the ON statement
Actions specified by ON
Chapter 5 137
i = i + 1
PRINT *, i
END PROGRAM main
SUBROUTINE trap_oflow(n)
INTEGER :: n
! write error message to standard error
WRITE (7, *) 'integer overflow occurred, assigning 0 to result'
n = 0
END SUBROUTINE trap_oflow
Here is the command line, followed by the output from a sample run:
$ f90 call_itrap.f90
$ a.out
integer overflow occurred, assigning 0 to result
0
If you were to comment out the ON statement but keep the directive, the program would abort with a
procedure traceback and a core dump. Compiling with the +check=all option would have the same effect.