The Fortran 2003 standard provides a set of intrinsic modules that define features to support IEEE arithmetic and interoperability with the C language.
The Fortran 2003 standard intrinsic modules IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES to support new features in the proposed language standard to support IEEE arithmetic and IEEE exception handling.
The draft standard defines a set of inquiry functions, elemental functions, kind functions, elemental subroutines, and nonelemental subroutines. These are listed in the tables that follow.
To access these functions and subroutines, the calling routine must include
USE, INTRINSIC :: IEEE_ARITHMETIC, IEEE_EXCEPTIONS
See the Fortran standard (http://www.j3-fortran.org) for details.
The module IEEE_EXCEPTIONS contains the following inquiry functions.
Function |
Descripton |
IEEE_SUPPORT_FLAG(FLAG[,X]) |
Inquire whether the processor supports an exception. |
IEEE_SUPPORT_HALTING(FLAG) |
Inquire whether the processor supports control of halting after an exception. |
The module IEEE_ARITHMETIC contains the following inquiry functions.
Function |
Description |
IEEE_SUPPORT_DATATYPE([X]) |
Inquire whether the processor supports IEEE arithmetic. |
IEEE_SUPPORT_DENORMAL([X]) |
Inquire whether the processor supports denormalized numbers. |
IEEE_SUPPORT_DIVIDE([X]) |
Inquire whether the processor supports divide with the accuracy specified by the IEEE standard. |
IEEE_SUPPORT_INF([X]) |
Inquire whether the processor supports the IEEE infinity. |
IEEE_SUPPORT_IO([X]) |
Inquire whether the processor supports IEEE base conversion rounding during formatted input/output. |
IEEE_SUPPORT_NAN([X]) |
Inquire whether the processor supports the IEEE Not-a-Number. |
IEEE_SUPPORT_ROUNDING(VAL[,X]) |
Inquire whether the processor supports a particular rounding mode. |
IEEE_SUPPORT_SQRT([X]) |
Inquire whether the processor supports the IEEE square root. |
IEEE_SUPPORT_STANDARD([X]) |
Inquire whether the processor supports all IEEE facilities. |
The module IEEE_ARITHMETIC contains the following elemental functions for real X and Y for which IEEE_SUPPORT_DATATYPE(X) and IEEE_SUPPORT_DATATYPE(Y) are true.
Function |
Description |
IEEE_CLASS(X) |
IEEE class. |
IEEE_COPY_SIGN(X,Y) |
IEEE copysign function. |
IEEE_IS_FINITE(X) |
Determine if value is finite. |
IEEE_IS_NAN(X) |
Determine if value is IEEE Not-a-Number |
IEEE_IS_NORMAL(X) |
Determine if a value is normal. |
IEEE_IS_NEGATIVE(X) |
Determine if value is negative. |
IEEE_LOGB(X) |
Unbiased exponent in the IEEE floating point format. |
IEEE_NEXT_AFTER(X,Y) |
Returns the next representable neighbor of X in the direction toward Y. |
IEEE_REM(X,Y) |
The IEEE REM remainder function, X - Y*N where N is the integer nearest to the exact value of X/Y. |
IEEE_RINT(X) |
Round to an integer value according to the current rounding mode. |
IEEE_SCALB(X,I) |
Returns X*2**I |
IEEE_UNORDERED(X,Y) |
IEEE unordered function. True if X or Y is a NaN and false otherwise. |
IEEE_VALUE(X,CLASS) |
Generate an IEEE value. |
The module IEEE_ARITHMETIC contains the following transformational function:
Function |
Description |
IEEE_SELECTED_REAL_KIND([P,][R]) |
Kind type parameter value fo an IEEE real with given precision and range. |
The module IEEE_EXCEPTIONS contains the following elemental subroutines.
Subroutine |
Description |
IEEE_GET_FLAG(FLAG,FLAG_VALUE) |
Get an exception flag. |
IEEE_GET_HALTING_MODE(FLAG,HALTING) |
GEt halting mode for an exception. |
The module IEEE_EXCEPTIONS contains the following nonelemental subroutines.
Subroutine |
Description |
IEEE_GET_STATUS(STATUS_VALUE) |
Get the current state of the floating point environment. |
IEEE_SET_FLAG(FLAG,FLAG_VALUE) |
Set an exception flag. |
IEEE_SET_HALTING_MODE(FLAG,HALTING) |
Controls continuation or halting on exceptions. |
IEEE_SET_STATUS(STATUS_VALUE) |
Restore the state of the floating point environment. |
The module IEEE_ARITHMETIC contains the following nonelemental subroutines.
Subroutine |
Description |
IEEE_GET_ROUNDING_MODE(ROUND_VAL) |
Get the current IEEE rounding mode. |
IEEE_SET_ROUNDING_MODE(ROUND_VAL) |
Set the current IEEE rounding mode. |
The Fortran 2003 standard provides a means of referencing C language procedures. The ISO_C_BINDING module defines three support procedures as intrinsic module functions. Accessing these functions requires
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_LOC, C_PTR, C_ASSOCIATED
in the calling routine. The procedures defined in the module are
Function |
Description |
---|---|
C_LOC(X) |
Returns the C address of the argument |
C_ASSOCIATED(C_PTR_1 [, C_PTR_2]) |
Indicates the association status of C_PTR_1 or indicates whether C_PTR_1 and C_PTR_2 are associated with the same entity. |
C_F_POINTER(CPTR, FPTR [, SHAPE]) |
Associates a pointer with the target of a C pointer and specifies its shape. |
For details on the ISO_C_BINDING intrinsic module, see Chapter 15 of the Fortran 2003 standard at http://www.j3-fortran.org/.