Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

GETCONTROLFPQQ

Portability Subroutine: Returns the floating-point processor control word.

Module

USE IFPORT

CALL GETCONTROLFPQQ (controlword)

controlword

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

The floating-point control word is a bit flag that controls various modes of the floating-point processor.

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

An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0. Exceptions can be disabled by setting the control bits to 1 with SETCONTROLFPQQ.

If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes generate an appropriate special value (NaN or signed infinity), but the program continues.

You can find out which exceptions (if any) occurred by calling GETSTATUSFPQQ. If errors on floating-point exceptions are enabled (by clearing the control bits to 0 with SETCONTROLFPQQ), the operating system generates an interrupt when the exception occurs. By default, these interrupts cause runtime errors, but you can capture the interrupts with SIGNALQQ and branch to your own error-handling routines.

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.

Example

USE IFPORT INTEGER(2) control CALL GETCONTROLFPQQ (control) ! if not rounding down IF (IAND(control, FPCW$DOWN) .NE. FPCW$DOWN) THEN control = IAND(control, NOT(FPCW$MCW_RC)) ! clear all ! rounding control = IOR(control, FPCW$DOWN) ! set to ! round down CALL SETCONTROLFPQQ(control) END IF END