Error Handling
KML_LAPACK checks input parameters. When an error such as a null pointer or an invalid value occurs, KML_LAPACK calls the LAPACK error handling function xerbla_ to rectify the error. By default, the built-in xerbla_ of Netlib LAPACK is used for the error handling. The implementation is to print the following error information and exit the process with the error code 0:
** On entry to FUNC parameter number N had an illegal value
In the preceding information, FUNC indicates the name of the LAPACK function where the error occurs, and N indicates the parameter sequence number.
You can customize the xerbla_() function to avoid exiting the entire program when the error occurs. The following is an example:
void xerbla_(const char *func, const int *param, int funcLen)
{
printf("XERBLA: function %.*s, info %i.\n", funcLen, func, *param);
}
When the preceding example function is used, a line of error information is printed when the parameter is incorrect, but the process does not exit. In this case, the result is returned to the function caller and the info parameter is set to the corresponding error parameter value.
Please note that:
- When multiple parameter errors exist, info may be set to the sequence number of any of the problematic parameters (negation).
- When the input matrix dimension is too large to be calculated properly, info is set to the sequence number (negation) of the related dimension parameter.
- A user program must link the file that contains the customized xerbla_ implementation before linking the liblapack_adapt.a file. Otherwise, repeated symbol definition errors may occur or the xerbla_ implementation of Netlib LAPACK is still used.
- If a customized xerbla_ is provided for the implementation, the handling of all errors (including those related functions not optimized by KML_LAPACK) uses this implementation.