The FPU (floating-point unit) on systems based on the IA-32 architecture contains eight floating-point registers the system uses for numeric calculations, status and control words, and error pointers. You normally need to consider only the status and control words, and then only when customizing your floating-point environment.
The FPU status and control words correspond to 16-bit registers whose bits hold the value of a state of the FPU or control its operation. Intel Fortran defines a set of symbolic constants to set and reset the proper bits in the status and control words.
The symbolic constants and the library routines used to read and write the control and status registers only affect the x87 control and status registers. They do not affect the MXCSR register (the control and status register for the Intel(R) SSE and Intel(R) SSE2 instructions).
They do not affect the MXCSR (the control and status register for the Intel(R) SSE and Intel(R) SSE2 instructions). For example:
USE IFPORT
INTEGER(2) status, control, controlo, mask_all_traps
CALL GETCONTROLFPQQ(control)
WRITE (*, 9000) 'Control word: ', control
! Save old control word
controlo = control
! Clear the rounding control flags
control = IAND(control,NOT(FPCW$MCW_RC))
! Set new control to round up
control = IOR(control,FPCW$UP)
CALL SETCONTROLFPQQ(control)
CALL GETCONTROLFPQQ(control)
WRITE (*, 9000) 'Control word: ', control
! Demonstrate setting and clearing exception mask flags
mask_all_traps = FPCW$INVALID + FPCW$DENORMAL + &
FPCW$ZERODIVIDE + FPCW$OVERFLOW + &
FPCW$UNDERFLOW + FPCW$INEXACT
! Clear the exception mask flags
control = IAND(control,NOT(FPCW$MCW_EM))
! Set new exception mask to disallow overflow
! (i.e., enable overflow traps)
! but allow (i.e., mask) all other exception conditions.
control = IOR(control,IEOR(mask_all_traps,FPCW$OVERFLOW))
CALL SETCONTROLFPQQ(control)
CALL GETCONTROLFPQQ(control)
WRITE (*, 9000) 'Control word: ', control
9000 FORMAT (1X, A, Z4)
END
The status and control symbolic constants (such as FPCW$OVERFLOW and FPCW$CHOP in the preceding example) are defined as INTEGER(2) parameters in the module IFORT.F90 in the ...\INCLUDE folder. The status and control words are logical combinations (such as with .AND.) of different parameters for different FPU options.
The name of a symbolic constant takes the general form name$option. The prefix name is one of the following:
name |
Meaning |
---|---|
FPSW |
Floating-point status word |
FPCW |
Floating-point control word |
SIG |
Signal |
FPE |
Floating-point exception |
MTH |
Math function |
The suffix option is one of the options available for that name. The parameter name$option corresponds either to a status or control option (for example, FPSW$ZERODIVIDE, a status word parameter that shows whether a zero-divide exception has occurred or not) or name$option corresponds to a mask, which sets all symbolic constants to 1 for all the options of name. You can use the masks in logical functions (such as IAND, IOR, and NOT) to set or to clear all options for the specified name. The following sections define the options and illustrate their use with examples.
You can control the floating-point processor options (on systems based on the IA-32 architecture) and find out its status with the run-time library routines GETSTATUSFPQQ (IA-32 architecture only), GETCONTROLFPQQ (IA-32 architecture only), and SETCONTROLFPQQ (IA-32 architecture only). Examples of using these routines also appear in the following sections.