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

ID 767251
Date 6/24/2024
Public

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

Document Table of Contents

GETSTATUSFPQQ

Portability Subroutine: Returns the floating-point processor status word. This routine is only available for Windows.

Module

USE IFPORT

CALL GETSTATUSFPQQ (status)

status

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

The floating-point status word shows whether various floating-point exception conditions have occurred. The compiler initially clears (sets to 0) all status flags, but after an exception occurs it does not reset the flags before performing additional floating-point operations. A status flag with a value of one thus shows there has been at least one occurrence of the corresponding exception. The following table lists the status flags and their values:

Parameter name

Hex value

Description

FPSW$MSW_EM

Z'003F'

Status Mask (set all flags to 1)

FPSW$INVALID

Z'0001'

An invalid result occurred

FPSW$DENORMAL

Z'0002'

A subnormal (very small number) occurred

FPSW$SUBNORMAL

Z'0002'

A subnormal (very small number) occurred

FPSW$ZERODIVIDE

Z'0004'

A divide by zero occurred

FPSW$OVERFLOW

Z'0008'

An overflow occurred

FPSW$UNDERFLOW

Z'0010'

An underflow occurred

FPSW$INEXACT

Z'0020'

Inexact precision occurred

You can use a logical comparison on the status word returned by GETSTATUSFPQQ to determine which of the six floating-point exceptions listed in the table has occurred.

An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0. By default, all exception traps are disabled. Exceptions can be enabled and disabled by clearing and setting the flags with SETCONTROLFPQQ. You can use GETCONTROLFPQQ to determine which exceptions are currently enabled and disabled.

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 flags 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.

Example

!  Program to demonstrate GETSTATUSFPQQ
 USE IFPORT
 INTEGER(2) status
 CALL GETSTATUSFPQQ(status)
!  check for divide by zero
 IF (IAND(status, FPSW$ZERODIVIDE) .NE. 0) THEN
   WRITE (*,*) 'Divide by zero occurred. Look    &
   for NaN or signed infinity in resultant data.'
 END IF
END