Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

SETCONTROLFPQQ

Portability Subroutine: Sets the value of the floating-point processor control word.

Module

USE IFPORT

CALL SETCONTROLFPQQ (controlword)

controlword

(Input) INTEGER(2). Floating-point processor control word.

The floating-point control word specifies how various exception conditions are handled by the floating-point math processor, sets the floating-point precision, and specifies the floating-point rounding mechanism used.

The control word can be any of the following constants (defined in IFPORT.F90):

Parameter name

Hex value

Description

FPCW$MCW_IC

Z'1000'

Infinity control mask

FPCW$AFFINE

Z'1000'

Affine infinity

FPCW$PROJECTIVE

Z'0000'

Projective infinity

FPCW$MCW_PC

Z'0300'

Precision control mask

FPCW$64

Z'0300'

64-bit precision

FPCW$53

Z'0200'

53-bit precision

FPCW$24

Z'0000'

24-bit precision

FPCW$MCW_RC

Z'0C00'

Rounding control mask

FPCW$CHOP

Z'0C00'

Truncate

FPCW$UP

Z'0800'

Round up

FPCW$DOWN

Z'0400'

Round down

FPCW$NEAR

Z'0000'

Round to nearest

FPCW$MCW_EM

Z'003F'

Exception mask

FPCW$INVALID

Z'0001'

Allow invalid numbers

FPCW$DENORMAL

Z'0002'

Allow subnormals (very small numbers)

FPCW$SUBNORMAL

Z'0002'

Allow subnormals (very small numbers)

FPCW$ZERODIVIDE

Z'0004'

Allow divide by zero

FPCW$OVERFLOW

Z'0008'

Allow overflow

FPCW$UNDERFLOW

Z'0010'

Allow underflow

FPCW$INEXACT

Z'0020'

Allow inexact precision

An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.

Setting the floating-point precision and rounding mechanism can be useful if you are reusing old code that is sensitive to the floating-point precision standard used and you want to get the same results as on the old machine.

You can use GETCONTROLFPQQ to retrieve the current control word and SETCONTROLFPQQ to change the control word. Most users do not need to change the default settings. If you need to change the control word, always use SETCONTROLFPQQ to make sure that special routines handling floating-point stack exceptions and abnormal propagation work correctly.

NOTE:

The Intel® Fortran exception handler allows for software masking of invalid operations, but does not allow the math chip to mask them. If you choose to use the software masking, be aware that this can affect program performance if you compile code written for Intel Fortran with another compiler.

Example

 USE IFPORT
 INTEGER(2) status, control, controlo
 CALL GETCONTROLFPQQ(control)
 WRITE (*, 9000) 'Control word: ', control
 !     Save old control word
 controlo = control
 !     Clear all flags
 control = control .AND. Z'0000'
 !     Set new control to round up
 control = control .OR. FPCW$UP
 CALL SETCONTROLFPQQ(control)
 CALL GETCONTROLFPQQ(control)
 WRITE (*, 9000) 'Control word: ', control
 9000 FORMAT (1X, A, Z4)
 END