| United States-English |
|
|
|
![]() |
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Appendix D Using the ON statementOverview of how to handle arithmetic errors |
|
Error conditions detected by various HP Fortran 90 library routines result in basic arithmetic errors. For example, attempting to take the log (DLOG) of a negative number results in an error condition. When an error occurs, the action taken depends on the following:
The following sections describe how to use the ON statement to specify the action you want to take in the event of an error. Use the ABORT form of the CALL statement to terminate the program when an error occurs. In the following example, the log is taken of a negative number. The ABORT clause causes the program immediately after the error is detected:
You can use the ON statement to ignore the error condition, as in the following:
Note that, when you run this program, LOG still returns a NaN. You can use the ON statement to call your own trap-handler procedure, as in the following:
When you run this program, it produces the following output:
Upon exit from a trap procedure, control returns to the instruction following the one that activated the trap, regardless of whether erring instruction appears in user code or in a library routine. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||