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

IEEE Intrinsic Modules and Procedures

Fortran includes IEEE intrinsic modules that support IEEE arithmetic and exception handling. The modules contain derived data types that include named constants for controlling the level of support, and intrinsic module procedures.

To include an IEEE module in your program, specify the intrinsic module name in a USE statement; for example:

USE,INTRINSIC :: IEEE_ARITHMETIC

You must include the INTRINSIC attribute or the processor will look for a non-intrinsic module. Once you include a module, all related intrinsic procedures are defined.

Determining Availability of IEEE Features

Before using a particular IEEE feature, you can determine whether your processor supports it by using the IEEE inquiry functions (listed in below section Restrictions for IEEE Intrinsic Procedures).

For example:

  • To determine whether IEEE arithmetic is available for a particular kind of real, use intrinsic module function IEEE_SUPPORT_DATATYPE.

  • To determine whether you can change a rounding mode, use intrinsic module function IEEE_SUPPORT_ROUNDING.

  • To determine whether a divide operation will be supported with the accuracy specified by the IEEE standard, use intrinsic module function IEEE_SUPPORT_DIVIDE.

  • To determine whether you can control halting after an exception has occurred, use intrinsic module function IEEE_SUPPORT_HALTING.

  • To determine which exceptions are supported in a scoping unit, use intrinsic module function IEEE_SUPPORT_FLAG.

  • To determine whether all IEEE features are supported, use intrinsic module function IEEE_SUPPORT_STANDARD.

The compiler establishes the initial IEEE floating-point environment. The user can affect this initial environment with several different command-line options. For the IEEE intrinsic module procedures to work as defined by the Fortran Standard, the following command lines options must be set as follows:

  • Option /fpe:3 (Windows*) or -fpe3 (Linux*) must be set to disable all floating-point exceptions.

  • Option /Qftz- (Windows*) or -no-ftz (Linux*) must be set to disable flushing subnormal results to zero (notice that all optimization levels, except O0, set ftz so the user has to explicitly set "no ftz").

  • Option /fp:precise (Windows*) or option -fp-model=precise (Linux*) must be set to disable floating-point exception semantics.

Restrictions for IEEE Intrinsic Procedures

The following intrinsic procedures can only be invoked if IEEE_SUPPORT_DATATYPE is true for their arguments of type REAL:

IEEE_CLASS

IEEE_REM

IEEE_COPY_SIGN

IEEE_RINT

IEEE_FMA

IEEE_SCALB

IEEE_IS_FINITE

IEEE_SET_ROUNDING_MODE 3

IEEE_NEGATIVE

IEEE_SIGNALING_EQ

For example, the IEEE_IS_NORMAL(X) function can only be invoked if IEEE_SUPPORT_DATATYPE(X) has the value true. Consider the following:

USE, INTRINSIC :: IEEE_ARITHMETIC
...
  IF IEEE_SUPPORT_DATATYPE(X) THEN
    IF IEEE_IS_NORMAL(X) THEN
      PRINT *, ' X is a "normal" '
    ELSE
      PRINT *, ' X is not "normal" '
    ENDIF
  ELSE
    PRINT *, ' X is not a supported IEEE type '
  ENDIF
...

Certain other IEEE intrinsic module procedures have similar restrictions:

  • IEEE_IS_NAN(X) can only be invoked if IEEE_SUPPORT_NAN(X) has the value true.

  • IEEE_SET_HALTING_MODE(FLAG, HALTING) can only be invoked if IEEE_SUPPORT_HALTING(FLAG) has the value true.

  • IEEE_GET_UNDERFLOW_MODE(GRADUAL) can only be invoked if IEEE_SUPPORT_UNDERFLOW_CONTROL(X) is true for some X.

For intrinsic module function IEEE_CLASS(X), some of the possible return values also have restrictions. These restrictions are also true for argument CLASS in intrinsic module function IEEE_VALUE(X, CLASS):

  • IEEE_POSITIVE_INF and IEEE_NEGATIVE_INF can only be returned if IEEE_SUPPORT_INF(X) has the value true.

  • IEEE_POSITIVE_DENORMAL, IEEE_POSITIVE_SUBNORMAL, IEEE_NEGATIVE_SUBNORMAL, and IEEE_NEGATIVE_DENORMAL can only be returned if IEEE_SUPPORT_DENORMAL(X) and IEEE_SUPPORT_SUBNORMAL(X) have the value true.

  • IEEE_SIGNALING_NAN and IEEE_QUIET_NAN can only be returned if IEEE_SUPPORT_NAN(X) has the value true.