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

ID 767251
Date 7/13/2023
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

Intel® 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* and macOS) must be set to disable all floating-point exceptions.

  • Option /Qftz- (Windows*) or -no-ftz (Linux* and macOS) 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* and macOS) 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

IEEE_INT

IEEE_SIGNALING_GE

IEEE_IS_NORMAL

IEEE_SIGNALING_GT

IEEE_LOGB

IEEE_SIGNALING_LE

IEEE_MAX_NUM

IEEE_SIGNALING_LT

IEEE_MAX_NUM_MAG

IEEE_SIGNALING_NE

IEEE_MIN_NUM

IEEE_SIGNBIT

IEEE_MIN_NUM_MAG

IEEE_SUPPORT_DENORMAL

IEEE_NEXT_AFTER

IEEE_SUPPORT_DIVIDE

IEEE_NEXT_DOWN 1

IEEE_SUPPORT_INF

IEEE_NEXT_UP 1

IEEE_SUPPORT_IO

IEEE_QUIET_EQ

IEEE_SUPPORT_NAN

IEEE_QUIET_GE

IEEE_SUPPORT_ROUNDING

IEEE_QUIET_GT

IEEE_SUPPORT_SQRT

IEEE_QUIET_LE

IEEE_SUPPORT_SUBNORMAL

IEEE_QUIET_LT

IEEE_SUPPORT_UNORDERED

IEEE_QUIET_NE

IEEE_SUPPORT_VALUE

IEEE_REAL 2

IEEE_VALUE

1 IEEE_SUPPORT_INF() must be true if IEEE_NEXT_DOWN is called with the argument -HUGE (X) or if IEEE_NEXT_UP is called with the argument HUGE (X).

2 IEEE_SUPPORT_DATATYPE (IEEE_REAL (A, KIND)) must also be true.

3 IEEE_SUPPORT_ROUNDING(ROUND_VALUE, X) must also be true.

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.