User Errors
The errors discussed in this section are exclusively those issued by the IMSL Mathematics and Statistics libraries. These are distinct from errors issued by PV-WAVE and do not affect the PV-WAVE system variables !ERR, !ERROR, and !ERR_STR. Errors originating from the IMSL libraries are stored in their own PV_WAVE system variables:
!CMAST_ERR - the code for the last error issued by the IMSL libraries.
!CMAST_ERR_STRING - A string containing the last error message issued by the IMSL libraries.
!CMAST_ERR_TYPE - The severity of the last error issued by the IMSL libraries.( "Note", "Alert", "Warning", "Fatal error" or "Terminal error")
PV‑WAVE Advantage mathematical functions attempt to detect user errors and handle them in a way that provides as much information to the user as possible. To do this, five levels of Informational Error severity, in addition to the basic PV‑WAVE Advantage error-handling facility, are recognized. Following a call to a PV‑WAVE Advantage mathematical or statistical function, the system variables !Error and !Cmast_Err contain information concerning the current error state. The system variable !Error contains the error number of the last error. System variable !Cmast_Err is set to either zero, which indicates that an Informational Error did not occur, or to the error code of the last Informational Error that did occur.
Errors and Default Actions
When your application returns from a PV‑WAVE Advantage mathematical function, the system variable !Cmast_Err is set either to zero, which indicates that an informational error did not occur, or to the error code for the last Informational Error that did occur. Internally, there are five levels of Informational Error severity: note, alert, warning, fatal, and terminal. Although PV‑WAVE Advantage does not allow users to directly manipulate how these errors are interpreted internally, some control over the output of error messages is allowed. All informational error messages are printed by default. The CMAST_ERR_PRINT function sets options for error printing in PV-WAVE IMSL Mathematics and Statistics libraries.
The system variable !Error remains active during all PV‑WAVE Advantage error states. But when an Informational Error occurs within a mathematical function, the system variable !Cmast_Err is used.
What Determines Error Severity
Although your input(s) may be mathematically correct, limitations of the computer’s arithmetic and the algorithm itself can make it impossible to accurately compute an answer. In this case, the assessed degree of accuracy determines the severity of the error. In instances where the function computes several output quantities and some are not computable, an error condition exists. Its severity depends on an assessment of the overall impact of the error.
Functions for Error Handling
With respect to Informational Errors, you can interact with the PV‑WAVE Advantage error-handling system in two ways: (1) change the default printing actions and (2) determine the code of an Informational Error in order to take corrective action. To change the default printing action, use the CMAST_ERR_PRINT function. Use CMAST_ERR_TRANS to retrieve the integer code for an informational error.
Use of CMAST_ERR_TRANS to Determine Program Action
In the program segment below, the Cholesky factorization of a matrix is to be performed. If it is determined that the matrix is not nonnegative definite (and often this is not immediately obvious), the program takes a different branch:
; Call CHNNDFAC with a matrix that may not be nonnegative
; definite.
x = CHNNDFAC, a, fac
 
; Check system variable !Cmast_Err to see if it contains the
; error code for the error NOT_NONNNEG_DEFINITE. 
IF (CMAST_ERROR_TRANS($
'MATH_NOT_NONNNEG_DEFINITE') eq !Cmast_Err)) THEN ...