Run-Time Subroutine: Handles run-time math errors. This routine is only available on ia32 processors.
Module: USE DFLIB
Syntax
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
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.
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS LIB
Example
See the example MATHERRQQ
in Handling Run-Time
Math Exceptions in the Programmer's Guide.