MATHERRQQ (ia32 only)

Run-Time Subroutine: Handles run-time math errors. This routine is only available on ia32 processors.

Module: USE DFLIB

Syntax

CALL MATHERRQQ (name, nlen, info, retcode)

name
(Output) Character*(*). Name of the function causing the error. The parameter name is a typeless version of the function called. For example, if an error occurs in a SIN function, the name will be returned as sin for real arguments and csin for complex arguments even though the function may have actually been called with an alternate name such as DSIN or CDSIN, or with SIN and complex arguments.


nlen
(Output) INTEGER(2). Length of name.


info
(Output) Structure. Record containing data about the error. The MTH$E_INFO structure is defined in DFLIB.F90 (in the \DF98\INCLUDE subdirectory) as follows:
 STRUCTURE /MTH$E_INFO/
   INTEGER*4 ERRCODE      ! One of the MTH$ values below
   INTEGER*4 FTYPE        ! One of the TY$ values below
   UNION
   MAP
     REAL*4 R4ARG1        ! INPUT: First argument
     CHARACTER*12 R4FILL1
     REAL*4 R4ARG2        ! INPUT: Second argument (if any)
     CHARACTER*12 R4FILL2
     REAL*4 R4RES         ! OUTPUT : Desired result
     CHARACTER*12 R4FILL3
   END MAP
   MAP
     REAL*8 R8ARG1        ! INPUT : First argument
     CHARACTER*8 R8FILL1
     REAL*8 R8ARG2        ! INPUT : Second argument (if any)
     CHARACTER*8 R8FILL2
     REAL*8 R8RES         ! OUTPUT : Desired result
     CHARACTER*8 R8FILL3
   END MAP
   MAP
     COMPLEX*8 C8ARG1     ! INPUT : First argument
     CHARACTER*8 C8FILL1
     COMPLEX*8 C8ARG2     ! INPUT : Second argument (if any)
     CHARACTER*8 C8FILL2
     COMPLEX*8 C8RES      ! OUTPUT : Desired result
     CHARACTER*8 C8FILL1
   END MAP
   MAP
     COMPLEX*16 C16ARG1    ! INPUT : First argument
     COMPLEX*16 C16ARG2    ! INPUT : Second argument (if any)
     COMPLEX*16 C16RES     ! OUTPUT : Desired result
   END MAP
   END UNION
 END STRUCTURE
retcode
(Output) INTEGER(2). Return code passed back to the run-time library. The value of retcode should be set by the user's MATHERRQQ routine to indicate whether the error was resolved. Set this value to 0 to indicate that the error was not resolved and that the program should fail with a run-time error. Set it to any nonzero value to indicate that the error was resolved and the program should continue.

If you are not compiling with full optimization (using the /Ox compiler option), errors in math functions generate a call to the MATHERRQQ subroutine. You can write a MATHERRQQ function that resolves the error or takes other appropriate action based on arguments passed to the function. If you do not provide your own MATHERRQQ function, a default MATHERRQQ provided with the library terminates the process.

Under the ANSI definition of Fortran, there is no handling of math errors. The programmer is responsible for making sure that arguments to math intrinsics are valid. If they are not valid, the result is undefined. Handling of math errors in math debug mode is a language extension. This mode provides more safety, but the performance of math functions is significantly slower.

The ERRCODE element in the MTH$E_INFO structure specifies the type of math error that occurred, and can have one of the following values:

Value Meaning
MTH$E_DOMAIN Argument domain error
MTH$E_OVERFLOW Overflow range error
MTH$E_PLOSS Partial loss of significance
MTH$E_SINGULARITY Argument singularity
MTH$E_TLOSS Total loss of significance
MTH$E_UNDERFLOW Underflow range error

The FTYPE element of the info structure identifies the data type of the math function as TY$REAL4, TY$REAL8, TY$CMPLX4, or TY$CMPLX8. Internally, REAL(4) and COMPLEX(4) arguments are converted to REAL(8) and COMPLEX(8). This means that the corresponding mapped sections of the structure are never used.

In general, a MATHERRQQ function should test the FTYPE value and take separate action for TY$REAL8 or TY$CMPLX8 using the appropriate mapped values. If you want to resolve the error, set the R8RES or C8RES field to an appropriate value such as 0.0. You can do calculations within the MATHERRQQ function using the approprate ARG1 and ARG2 fields, but avoid doing any calculations that would cause an error resulting in another call to MATHERRQQ.


Note: You cannot use MATHERRQQ in DLLs or in a program that links with a DLL.

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS LIB

Example

See the example MATHERRQQ in Handling Run-Time Math Exceptions in the Programmer's Guide.