If OPERATION is not computationally associative, REDUCE without ORDERED=.TRUE. with the same
argument values might not always produce the same result, as the processor can apply the associative law
to the evaluation.
16.9.162 REPEAT (STRING, NCOPIES)
2 Class. Transformational function.
⃝c ISO/IEC 2017 – All rights reserved 4193 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
STRING shall be a character scalar.4 Result Characteristics. Character scalar of length NCOPIES times that of STRING, with the same kind typeNCOPIES shall be an integer scalar. Its value shall not be negative.
parameter as STRING.5 Result Value. The value of the result is the concatenation of NCOPIES copies of STRING.
6 Examples. REPEAT (’H’, 2) has the value HH. REPEAT (’XYZ’, 0) has the value of a zero-length string.
16.9.163 RESHAPE (SOURCE, SHAPE [, PAD, ORDER])1 Description. Arbitrary shape array construction.
2 Class. Transformational function.
3 Arguments.
SOURCE shall be an array of any type. If PAD is absent or of size zero, the size of SOURCE shall be greater4 Result Characteristics. The result is an array of shape SHAPE (that is, SHAPE (RESHAPE (SOURCE,than or equal to PRODUCT (SHAPE). The size of the result is the product of the values of the
elements of SHAPE.
SHAPE shall be a rank-one integer array. SIZE (x), where x is the actual argument corresponding to
SHAPE, shall be a constant expression whose value is positive and less than 16. It shall not have
an element whose value is negative.
PAD (optional) shall be an array of the same type and type parameters as SOURCE.
ORDER (optional) shall be of type integer, shall have the same shape as SHAPE, and its value shall be a
permutation of (1, 2, . . . , n), where n is the size of SHAPE. If absent, it is as if it were present with
value (1, 2, . . . , n).
SHAPE, PAD, ORDER)) is equal to SHAPE) with the same type and type parameters as SOURCE.5 Result Value. The elements of the result, taken in permuted subscript order ORDER (1), . . . , ORDER (n), are
those of SOURCE in normal array element order followed if necessary by those of PAD in array element order,followed if necessary by additional copies of PAD in array element order.
1 3 5
1 Description. Reciprocal of relative spacing of model numbers.
6 Examples. RESHAPE ([1, 2, 3, 4, 5, 6], [2, 3]) has the value 2 4 61 2 3 4
16.9.164 RRSPACING (X)
RESHAPE ([1, 2, 3, 4, 5, 6], [2, 4], [0, 0], [2, 1]) has the value 5 6 0 0
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Result Characteristics. Same as X.
5 Result Value. The result has the value |Y × b−e | × bp = ABS (FRACTION (Y)) * RADIX (X) / EPSILON (X),
where b, e, and p are as defined in 16.4 for Y, the value nearest to X in the model for real values whose kind type6 Example. RRSPACING (−3.0) has the value 0.75 × 224 for reals whose model is as in NOTE 16.4.parameter is that of X; if there are two such values, the value of greater absolute value is taken. If X is an IEEE
infinity, the result is an IEEE NaN. If X is an IEEE NaN, the result is that NaN.
420 ⃝c ISO/IEC 2017 – All rights reserved1 Description. Dynamic type equality test.
ISO/IEC DIS 1539-1:2017 (E)
16.9.165 SAME_TYPE_AS (A, B)
2 Class. Inquiry function.
3 Arguments.
A shall be an object of extensible declared type or unlimited polymorphic. If it is a polymorphic4 Result Characteristics. Default logical scalar.pointer, it shall not have an undefined association status.
B shall be an object of extensible declared type or unlimited polymorphic. If it is a polymorphic
pointer, it shall not have an undefined association status.
5 Result Value. If the dynamic type of A or B is extensible, the result is true if and only if the dynamic type of
A is the same as the dynamic type of B. If neither A nor B has extensible dynamic type, the result is processor6 Example. Given the declarations and assignmentsdependent.
NOTE 16.28
The dynamic type of a disassociated pointer or unallocated allocatable variable is its declared type. An
unlimited polymorphic entity has no declared type.
NOTE 16.29
The test performed by SAME_TYPE_AS is not the same as the test performed by the type guard TYPE
IS. The test performed by SAME_TYPE_AS does not consider kind type parameters.
TYPE T1
REAL C
END TYPE
TYPE, EXTENDS(T1) :: T2
END TYPE
CLASS(T1), POINTER :: P, Q, R
ALLOCATE(P, Q)
ALLOCATE(T2 :: R)
the value of SAME_TYPE_AS (P, Q) will be true, and the value of SAME_TYPE_AS (P, R) will be false.
16.9.166 SCALE (X, I)
1 Description. Real number scaled by radix power.
2 Class. Elemental function.
3 Arguments.
X shall be of type real.4 Result Characteristics. Same as X.I shall be of type integer.
5 Result Value. The result has the value X × bI , where b is defined in 16.4 for model numbers representing values
of X, provided this result is representable; if not, the result is processor dependent.6 Example. SCALE (3.0, 2) has the value 12.0 for reals whose model is as in NOTE 16.4.
⃝c ISO/IEC 2017 – All rights reserved 4211 Description. Character set membership search.
ISO/IEC DIS 1539-1:2017 (E)
16.9.167 SCAN (STRING, SET [, BACK, KIND])
2 Class. Elemental function.
3 Arguments.
STRING shall be of type character.4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value ofSET shall be of type character with the same kind type parameter as STRING.
BACK (optional) shall be of type logical.
KIND (optional) shall be a scalar integer constant expression.
KIND; otherwise the kind type parameter is that of default integer type.5 Result Value.
Case (i): If BACK is absent or is present with the value false and if STRING contains at least one character6 Examples.that is in SET, the value of the result is the position of the leftmost character of STRING that is
in SET.
Case (ii): If BACK is present with the value true and if STRING contains at least one character that is in
SET, the value of the result is the position of the rightmost character of STRING that is in SET.
Case (iii): The value of the result is zero if no character of STRING is in SET or if the length of STRING or
SET is zero.
Case (i): SCAN (’FORTRAN’, ’TR’) has the value 3.1 Description. Character kind selection.Case (ii): SCAN (’FORTRAN’, ’TR’, BACK = .TRUE.) has the value 5.
Case (iii): SCAN (’FORTRAN’, ’BCD’) has the value 0.
16.9.168 SELECTED_CHAR_KIND (NAME)
2 Class. Transformational function.
3 Argument. NAME shall be default character scalar.
4 Result Characteristics. Default integer scalar.
5 Result Value. If NAME has the value DEFAULT, then the result has a value equal to that of the kind type
parameter of default character. If NAME has the value ASCII, then the result has a value equal to that of the6 Examples. SELECTED_CHAR_KIND (’ASCII’) has the value 1 on a processor that uses 1 as the kind typekind type parameter of ASCII character if the processor supports such a kind; otherwise the result has the value
−1. If NAME has the value ISO_10646, then the result has a value equal to that of the kind type parameter of
the ISO 10646 character kind (corresponding to UCS-4 as specified in ISO/IEC 10646) if the processor supports
such a kind; otherwise the result has the value −1. If NAME is a processor-defined name of some other character
kind supported by the processor, then the result has a value equal to that kind type parameter value. If NAME is
not the name of a supported character type, then the result has the value −1. The NAME is interpreted without
respect to case or trailing blanks.
parameter for the ASCII character set. The following subroutine produces a Japanese date stamp.SUBROUTINE create_date_string(string)
INTRINSIC date_and_time,selected_char_kind
INTEGER,PARAMETER :: ucs4 = selected_char_kind("ISO_10646")
422 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
CHARACTER(1,UCS4),PARAMETER :: nen=CHAR(INT(Z’5e74’),UCS4), & !year
gatsu=CHAR(INT(Z’6708’),UCS4), & !month
nichi=CHAR(INT(Z’65e5’),UCS4) !day
CHARACTER(len= *, kind= ucs4) string
INTEGER values(8)
CALL date_and_time(values=values)
WRITE(string,1) values(1),nen,values(2),gatsu,values(3),nichi
1 FORMAT(I0,A,I0,A,I0,A)
END SUBROUTINE
16.9.169 SELECTED_INT_KIND (R)
1 Description. Integer kind selection.
2 Class. Transformational function.
3 Argument.  Default integer scalar.
5 Result Value. The result has a value equal to the value of the kind type parameter of an integer type that
represents all values n in the range −10R < n < 10R , or if no such kind type parameter is available on the6 Example. Assume a processor supports two integer kinds, 32 with representation method r = 2 and q = 31,processor, the result is −1. If more than one kind type parameter meets the criterion, the value returned is the
one with the smallest decimal exponent range, unless there are several such values, in which case the smallest of
these kind values is returned.
and 64 with representation method r = 2 and q = 63. On this processor SELECTED_INT_KIND (9) has the1 Description. Real kind selection.value 32 and SELECTED_INT_KIND (10) has the value 64.
16.9.170 SELECTED_REAL_KIND ([P, R, RADIX])
2 Class. Transformational function.
3 Arguments. At least one argument shall be present.
P (optional) shall be an integer scalar.4 Result Characteristics. Default integer scalar.R (optional) shall be an integer scalar.
RADIX (optional) shall be an integer scalar.
5 Result Value. If P or R is absent, the result value is the same as if it were present with the value zero. If
RADIX is absent, there is no requirement on the radix of the selected kind.6 The result has a value equal to a value of the kind type parameter of a real type with decimal precision, as
returned by the function PRECISION, of at least P digits, a decimal exponent range, as returned by the function7 Otherwise, the result is −1 if the processor supports a real type with radix RADIX and exponent range of at leastRANGE, of at least R, and a radix, as returned by the function RADIX, of RADIX, if such a kind type parameter
is available on the processor.
R but not with precision of at least P, −2 if the processor supports a real type with radix RADIX and precision of8 If more than one kind type parameter value meets the criteria, the value returned is the one with the smallestat least P but not with exponent range of at least R, −3 if the processor supports a real type with radix RADIX
but with neither precision of at least P nor exponent range of at least R, −4 if the processor supports a real type
⃝c ISO/IEC 2017 – All rights reserved 423
ISO/IEC DIS 1539-1:2017 (E)
with radix RADIX and either precision of at least P or exponent range of at least R but not both together, and
−5 if the processor supports no real type with radix RADIX.
decimal precision, unless there are several such values, in which case the smallest of these kind values is returned.9 Example. SELECTED_REAL_KIND (6, 70) has the value KIND (0.0) on a machine that supports a default
real approximation method with b = 16, p = 6, emin = −64, and emax = 63 and does not have a less precise1 Description. Real value with specified exponent.approximation method.
16.9.171 SET_EXPONENT (X, I)
2 Class. Elemental function.
3 Arguments.
X shall be of type real.4 Result Characteristics. Same as X.I shall be of type integer.
5 Result Value. If X has the value zero, the result has the same value as X. If X is an IEEE infinity, the result is
an IEEE NaN. If X is an IEEE NaN, the result is the same NaN. Otherwise, the result has the value X × bI−e ,6 Example. SET_EXPONENT (3.0, 1) has the value 1.5 for reals whose model is as in NOTE 16.4.where b and e are as defined in 16.4 for the representation for the value of X in the extended real model for the
kind of X.
16.9.172 SHAPE (SOURCE [, KIND])1 Description. Shape of an array or a scalar.
2 Class. Inquiry function.
3 Arguments.
SOURCE shall be a scalar or array of any type. It shall not be an unallocated allocatable variable or a pointer4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the valuethat is not associated. It shall not be an assumed-size array.
KIND (optional) shall be a scalar integer constant expression.
of KIND; otherwise the kind type parameter is that of default integer type. The result is an array of rank one5 Result Value. The result has a value whose ith element is equal to the extent of dimension i of SOURCE,whose size is equal to the rank of SOURCE.
except that if SOURCE is assumed-rank, and associated with an assumed-size array, the last element is equal to6 Examples. The value of SHAPE (A (2:5, −1:1) ) is [4, 3]. The value of SHAPE (3) is the rank-one array of size−1.
zero.1 Description. Right shift with fill.16.9.173 SHIFTA (I, SHIFT)
2 Class. Elemental function.
424 ⃝c ISO/IEC 2017 – All rights reserved3 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
I shall be of type integer.4 Result Characteristics. Same as I.SHIFT shall be of type integer. It shall be nonnegative and less than or equal to BIT_SIZE (I).
5 Result Value. The result has the value obtained by shifting the bits of I to the right SHIFT bits and replicating
the leftmost bit of I in the left SHIFT bits.6 If SHIFT is zero the result is I. Bits shifted out from the right are lost. The model for the interpretation of an
integer value as a sequence of bits is in 16.3.7 Example. SHIFTA (IBSET (0, BIT_SIZE (0) − 1), 2) is equal to SHIFTL (7, BIT_SIZE (0) − 3).
16.9.174 SHIFTL (I, SHIFT)1 Description. Left shift.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer.4 Result Characteristics. Same as I.SHIFT shall be of type integer. It shall be nonnegative and less than or equal to BIT_SIZE (I).
5 Result Value. The value of the result is ISHFT (I, SHIFT).
6 Examples. SHIFTL (3, 1) has the value 6.
16.9.175 SHIFTR (I, SHIFT)1 Description. Right shift.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer.4 Result Characteristics. Same as I.SHIFT shall be of type integer. It shall be nonnegative and less than or equal to BIT_SIZE (I).
5 Result Value. The value of the result is ISHFT (I, −SHIFT).
6 Examples. SHIFTR (3, 1) has the value 1.
16.9.176 SIGN (A, B)1 Description. Magnitude of A with the sign of B.
2 Class. Elemental function.
3 Arguments.
A shall be of type integer or real.4 Result Characteristics. Same as A.B shall be of the same type as A.
⃝c ISO/IEC 2017 – All rights reserved 4255 Result Value.
ISO/IEC DIS 1539-1:2017 (E)
Case (i): If B > 0, the value of the result is |A|.6 Example. SIGN (−3.0, 2.0) has the value 3.0.Case (ii): If B < 0, the value of the result is -|A|.
Case (iii): If B is of type integer and B=0, the value of the result is |A|.
Case (iv): If B is of type real and is zero, then:
• if the processor does not distinguish between positive and negative real zero, or if B is positive
real zero, the value of the result is |A|;
• if the processor distinguishes between positive and negative real zero, and B is negative real
zero, the value of the result is -|A|.
16.9.177 SIN (X)1 Description. Sine function.
2 Class. Elemental function.
3 Argument. X shall be of type real or complex.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to sin(X). If X is of type
real, it is regarded as a value in radians. If X is of type complex, its real part is regarded as a value in radians.6 Example. SIN (1.0) has the value 0.84147098 (approximately).
16.9.178 SINH (X)1 Description. Hyperbolic sine function.
2 Class. Elemental function.
3 Argument. X shall be of type real or complex.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to sinh(X). If X is of type
complex its imaginary part is regarded as a value in radians.6 Example. SINH (1.0) has the value 1.1752012 (approximately).
16.9.179 SIZE (ARRAY [, DIM, KIND])1 Description. Size of an array or one extent.
2 Class. Inquiry function.
3 Arguments.
ARRAY shall be assumed-rank or an array. It shall not be an unallocated allocatable variable or a pointer4 Result Characteristics. Integer scalar. If KIND is present, the kind type parameter is that specified by thethat is not associated. If ARRAY is an assumed-size array, DIM shall be present with a value less
than the rank of ARRAY.
DIM (optional) shall be an integer scalar with a value in the range 1 ≤ DIM ≤ n, where n is the rank of ARRAY.
KIND (optional) shall be a scalar integer constant expression.
value of KIND; otherwise the kind type parameter is that of default integer type.5 Result Value. If DIM is present, the result has a value equal to the extent of dimension DIM of ARRAY, except426 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
that if ARRAY is assumed-rank and associated with an assumed-size array and DIM is present with a value equal6 If DIM is absent and ARRAY is assumed-rank, the result has a value equal to PRODUCT(SHAPE(ARRAY,to the rank of ARRAY, the value is −1.
KIND)). Otherwise, the result has a value equal to the total number of elements of ARRAY.7 Examples. The value of SIZE (A (2:5, −1:1), DIM=2) is 3. The value of SIZE (A (2:5, −1:1)) is 12.
NOTE 16.3016.9.180 SPACING (X)If ARRAY is assumed-rank and has rank zero, DIM cannot be present since it cannot satisfy the requirement
1 ≤ DIM ≤ 0.
1 Description. Spacing of model numbers.
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Result Characteristics. Same as X.
5 Result Value. If X does not have the value zero and is not an IEEE infinity or NaN, the result has the value
be−p , where b, e, and p are as defined in 16.4 for the value nearest to X in the model for real values whose kind6 Example. SPACING (3.0) has the value 2−22 for reals whose model is as in NOTE 16.4.type parameter is that of X, provided this result is representable; otherwise, the result is the same as that of
TINY (X). If there are two extended model values equally near to X, the value of greater absolute value is taken.
If X has the value zero, the result is the same as that of TINY (X). If X is an IEEE infinity, the result is an IEEE
NaN. If X is an IEEE NaN, the result is that NaN.
16.9.181 SPREAD (SOURCE, DIM, NCOPIES)1 Description. Value replicated in a new dimension.
2 Class. Transformational function.
3 Arguments.
SOURCE shall be a scalar or array of any type. The rank of SOURCE shall be less than 15.4 Result Characteristics. The result is an array of the same type and type parameters as SOURCE and of rankDIM shall be an integer scalar with value in the range 1 ≤ DIM ≤ n + 1, where n is the rank of SOURCE.
NCOPIES shall be an integer scalar.
n + 1, where n is the rank of SOURCE.5 Result Value.Case (i): If SOURCE is scalar, the shape of the result is (MAX (NCOPIES, 0)).
Case (ii): If SOURCE is an array with shape [d1 , d2 , . . . , dn ], the shape of the result is [d1 , d2 , . . . , dDIM−1 ,
MAX (NCOPIES, 0), dDIM , . . . , dn ].
Case (i): If SOURCE is scalar, each element of the result has a value equal to SOURCE.6 Examples. If A is the array [2, 3, 4], SPREAD (A, DIM=1, NCOPIES=NC) is the array 2 3 4 if NCCase (ii): If SOURCE is an array, the element of the result with subscripts (r1 , r2 , . . . , rn+1 ) has the value
SOURCE (r1 , r2 , . . . , rDIM−1 , rDIM+1 , . . . , rn+1 ).
2 3 4
2 3 4
has the value 3 and is a zero-sized array if NC has the value 0.
⃝c ISO/IEC 2017 – All rights reserved 427
ISO/IEC DIS 1539-1:2017 (E)16.9.182 SQRT (X)
1 Description. Square root.
2 Class. Elemental function.
3 Argument. X shall be of type real or complex. If X is real, its value shall be greater than or equal to zero.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to the square root of X. A
result of type complex is the principal value with the real part greater than or equal to zero. When the real part6 Example. SQRT (4.0) has the value 2.0 (approximately).of the result is zero, the imaginary part has the same sign as the imaginary part of X.
16.9.183 STOPPED_IMAGES ([TEAM, KIND])1 Description. Indices of stopped images.
2 Class. Transformational function.
3 Arguments.
TEAM (optional) shall be a scalar of type TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV,4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the valuewhose value identifies the current or an ancestor team. If TEAM is absent the team specified is the
current team.
KIND (optional) shall be a scalar integer constant expression.
of KIND; otherwise, the kind type parameter is that of default integer type. The result is an array of rank one5 Result Value. The elements of the result are the values of the indices of the images that are known to havewhose size is equal to the number of images in the specified team that have initiated normal termination.
initiated normal termination in the specified team, in numerically increasing order. If the executing image has6 Examples. If image 3 is the only image in the current team that is known to have initiated normal termination,previously executed an image control statement whose STAT= specifier assigned the value STAT_STOPPED_-
IMAGE from the intrinsic module ISO_FORTRAN_ENV or invoked a collective subroutine whose STAT argu-
ment was assigned STAT_STOPPED_IMAGE, at least one of the images participating in that image control
statement or collective invocation shall be known to have initiated normal termination.
STOPPED_IMAGES() will have the value [3]. If there are no images in the current team that have initiated1 Description. Storage size in bits.normal termination, the value of STOPPED_IMAGES() will be a zero-sized array.
16.9.184 STORAGE_SIZE (A [, KIND])
2 Class. Inquiry function.
3 Arguments.
A shall be a data object of any type. If it is polymorphic it shall not be an undefined pointer. If4 Result Characteristics. Integer scalar. If KIND is present, the kind type parameter is that specified by theit is unlimited polymorphic or has any deferred type parameters, it shall not be an unallocated
allocatable variable or a disassociated or undefined pointer.
KIND (optional) shall be a scalar integer constant expression.
value of KIND; otherwise, the kind type parameter is that of default integer type.5 Result Value. The result value is the size expressed in bits for an element of an array that has the dynamic428 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
type and type parameters of A. If the type and type parameters are such that storage association (19.5.3) applies,6 Example. STORAGE_SIZE (1.0) has the same value as the named constant NUMERIC_STORAGE_SIZE inthe result is consistent with the named constants defined in the intrinsic module ISO_FORTRAN_ENV.
NOTE 16.31
An array element might take more bits to store than an isolated scalar, since any hardware-imposed align-
ment requirements for array elements might not apply to a simple scalar variable.
NOTE 16.32
This is intended to be the size in memory that an object takes when it is stored; this might differ from the
size it takes during expression handling (which might be the native register size) or when stored in a file.
If an object is never stored in memory but only in a register, this function nonetheless returns the size it
would take if it were stored in memory.
the intrinsic module ISO_FORTRAN_ENV.1 Description. Array reduced by addition.16.9.185 SUM (ARRAY, DIM [, MASK]) or SUM (ARRAY [, MASK])
2 Class. Transformational function.
3 Arguments.
ARRAY shall be an array of numeric type.4 Result Characteristics. The result is of the same type and kind type parameter as ARRAY. It is scalar ifDIM shall be an integer scalar with a value in the range 1 ≤ DIM ≤ n, where n is the rank of ARRAY.
MASK (optional) shall be of type logical and shall be conformable with ARRAY.
DIM does not appear; otherwise, the result has rank n − 1 and shape [d1 , d2 , . . . , dDIM−1 , dDIM+1 , . . . , dn ] where5 Result Value.[d1 , d2 , . . . , dn ] is the shape of ARRAY.
Case (i): The result of SUM (ARRAY) has a value equal to a processor-dependent approximation to the sum6 Examples.of all the elements of ARRAY or has the value zero if ARRAY has size zero.
Case (ii): The result of SUM (ARRAY, MASK = MASK) has a value equal to a processor-dependent approx-
imation to the sum of the elements of ARRAY corresponding to the true elements of MASK or has
the value zero if there are no true elements.
Case (iii): If ARRAY has rank one, SUM (ARRAY, DIM = DIM [, MASK = MASK]) has a value equal to that
of SUM (ARRAY [,MASK = MASK ]). Otherwise, the value of element (s1 , s2 , . . . , sDIM−1 , sDIM+1 ,
. . . , sn ) of SUM (ARRAY, DIM = DIM [ , MASK = MASK]) is equal to
SUM (ARRAY (s1 , s2 , . . . , sDIM−1 , :, sDIM+1 , . . . , sn ) [, MASK= MASK (s1 , s2 , . . . , sDIM−1 ,
:, sDIM+1 , . . . , sn ) ] ).
Case (i): The value of SUM ([1, 2, 3]) is 6.1 Description. Query system clock.Case (ii): SUM (C, MASK= C > 0.0) forms the sum of the positive elements of C.
1 3 5
Case (iii): If B is the array , SUM (B, DIM = 1) is [3, 7, 11] and SUM (B, DIM = 2) is [9, 12].
2 4 6
⃝c ISO/IEC 2017 – All rights reserved 429
ISO/IEC DIS 1539-1:2017 (E)
16.9.186 SYSTEM_CLOCK ([COUNT, COUNT_RATE, COUNT_MAX])
2 Class. Subroutine.
3 Arguments.
COUNT (optional) shall be an integer scalar. It is an INTENT (OUT) argument. It is assigned a processor-4 Whether an image has no clock, has a single clock of its own, or shares a clock with another image, is processordependent value based on the value of a processor clock, or −HUGE (COUNT) if there is no clock
for the invoking image. The processor-dependent value is incremented by one for each clock count
until the value COUNT_MAX is reached and is reset to zero at the next count. It lies in the range
0 to COUNT_MAX if there is a clock.
COUNT_RATE (optional) shall be an integer or real scalar. It is an INTENT (OUT) argument. It is assigned
a processor-dependent approximation to the number of processor clock counts per second, or zero
if there is no clock for the invoking image.
COUNT_MAX (optional) shall be an integer scalar. It is an INTENT (OUT) argument. It is assigned the
maximum value that COUNT can have, or zero if there is no clock for the invoking image.
dependent.5 Example. If the processor clock is a 24-hour clock that registers time at approximately 18.20648193 ticks per
second, at 11:30 A.M. the reference1 Description. Tangent function.CALL SYSTEM_CLOCK (COUNT = C, COUNT_RATE = R, COUNT_MAX = M)
defines C = (11×3600+30×60)×18.20648193 = 753748, R = 18.20648193, and M = 24×3600×18.20648193−1 =
1573039.
16.9.187 TAN (X)
2 Class. Elemental function.
3 Argument. X shall be of type real or complex.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to tan(X). If X is of type
real, it is regarded as a value in radians. If X is of type complex, its real part is regarded as a value in radians.6 Example. TAN (1.0) has the value 1.5574077 (approximately).
16.9.188 TANH (X)1 Description. Hyperbolic tangent function.
2 Class. Elemental function.
3 Argument. X shall be of type real or complex.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to tanh(X). If X is of type
complex its imaginary part is regarded as a value in radians.6 Example. TANH (1.0) has the value 0.76159416 (approximately).
430 ⃝c ISO/IEC 2017 – All rights reserved1 Description. Team number.
ISO/IEC DIS 1539-1:2017 (E)
16.9.189 TEAM_NUMBER ([TEAM])
2 Class. Transformational function.
3 Argument. TEAM (optional) shall be a scalar of type TEAM_TYPE from the intrinsic module ISO_FOR-
TRAN_ENV, whose value identifies the current or an ancestor team. If TEAM is absent, the team specified is4 Result Characteristics. Default integer scalar.the current team.
5 Result Value. The result has the value −1 if the specified team is the initial team; otherwise, the result value
is equal to the positive integer that identifies the specified team within its parent team.6 Example. The team number can be used to control which statements get executed, for example:
TYPE(TEAM_TYPE) :: ODD_EVEN...
FORM TEAM (2-MOD(ME,2), ODD_EVEN)
...
CHANGE TEAM (ODD_EVEN)
SELECT CASE (TEAM_NUMBER())
CASE (1)
! Case for images with odd image indices in the parent team.
CASE (2)
! Case for images with even image indices in the parent team.
END SELECT
END TEAM
16.9.190 THIS_IMAGE ([TEAM]) or THIS_IMAGE (COARRAY [, TEAM]) or
THIS_IMAGE (COARRAY, DIM [, TEAM])1 Description. Cosubscript(s) for this image.
2 Class. Transformational function.
3 Arguments.
COARRAY shall be a coarray of any type. If it is allocatable it shall be allocated. If its designator has more4 Result Characteristics. Default integer. It is scalar if COARRAY does not appear or DIM appears; otherwise,than one part-ref , the rightmost part-ref shall have nonzero corank. If it is of type TEAM_TYPE
from the intrinsic module ISO_FORTRAN_ENV, the TEAM argument shall appear.
DIM shall be an integer scalar. Its value shall be in the range 1 ≤ DIM ≤ n, where n is the corank of
COARRAY.
TEAM (optional) shall be a scalar of type TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV,
whose value identifies the current or an ancestor team. If COARRAY appears, it shall be established
in that team.
the result has rank one and its size is equal to the corank of COARRAY.5 Result Value.
Case (i): The result of THIS_IMAGE ([TEAM]) is a scalar with a value equal to the index of the invoking6 Examples. If A is declared by the statementimage in the team specified by TEAM, if present, or in the current team if absent.
⃝c ISO/IEC 2017 – All rights reserved 431
ISO/IEC DIS 1539-1:2017 (E)
Case (ii): The result of THIS_IMAGE (COARRAY [, TEAM = TEAM]) is the sequence of cosubscript values
for COARRAY that would specify the invoking image in the team specified by TEAM, if present,
or in the current team if absent.
Case (iii): The result of THIS_IMAGE (COARRAY, DIM [, TEAM = TEAM]) is the value of cosubscript
DIM in the sequence of cosubscript values for COARRAY that would specify the invoking image in
the team specified by TEAM, if present, or in the current team if absent.
REAL A (10, 20) [10, 0:9, 0:*]then on image 5, THIS_IMAGE ( ) has the value 5 and THIS_IMAGE (A) has the value [5, 0, 0]. For the same
coarray on image 213, THIS_IMAGE (A) has the value [3, 1, 2].
7 The following code uses image 1 to read data. The other images then copy the data.
 Smallest positive model number.
2 Class. Inquiry function.
3 Argument. X shall be a real scalar or array.
4 Result Characteristics. Scalar with the same type and kind type parameter as X.
5 Result Value. The result has the value bemin −1 where b and emin are as defined in 16.4 for the model representing
numbers of the same type and kind type parameter as X.6 Example. TINY (X) has the value 2−127 for real X whose model is as in NOTE 16.4.
16.9.192 TRAILZ (I)1 Description. Number of trailing zero bits.
2 Class. Elemental function.
3 Argument. I shall be of type integer.
4 Result Characteristics. Default integer.
5 Result Value. If all of the bits of I are zero, the result value is BIT_SIZE (I). Otherwise, the result value is the
position of the rightmost 1 bit in I. The model for the interpretation of an integer value as a sequence of bits is6 Examples. TRAILZ (8) has the value 3.in 16.3.
16.9.193 TRANSFER (SOURCE, MOLD [, SIZE])1 Description. Transfer physical representation.
2 Class. Transformational function.
3 Arguments.
SOURCE shall be a scalar or array of any type.4 Result Characteristics. The result is of the same type and type parameters as MOLD.432 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
MOLD shall be a scalar or array of any type. If it is a variable, it need not be defined. If the storage size of
SOURCE is greater than zero and MOLD is an array, a scalar with the type and type parameters
of MOLD shall not have a storage size equal to zero.
SIZE (optional) shall be an integer scalar. The corresponding actual argument shall not be an optional dummy
argument.
Case (i): If MOLD is a scalar and SIZE is absent, the result is a scalar.5 Result Value. If the physical representation of the result has the same length as that of SOURCE, the physicalCase (ii): If MOLD is an array and SIZE is absent, the result is an array and of rank one. Its size is as small
as possible such that its physical representation is not shorter than that of SOURCE.
Case (iii): If SIZE is present, the result is an array of rank one and size SIZE.
representation of the result is that of SOURCE. If the physical representation of the result is longer than that6 Examples.of SOURCE, the physical representation of the leading part is that of SOURCE and the remainder is processor
dependent. If the physical representation of the result is shorter than that of SOURCE, the physical representation
of the result is the leading part of SOURCE. If D and E are scalar variables such that the physical representation
of D is as long as or longer than that of E, the value of TRANSFER (TRANSFER (E, D), E) shall be the value
of E. IF D is an array and E is an array of rank one, the value of TRANSFER (TRANSFER (E, D), E, SIZE (E))
shall be the value of E.
Case (i): TRANSFER<PHONE_NUMBER>, 0.0) has the value 4.0 on a processor that represents the values 4.0 and1 Description. Transpose of an array of rank two.1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000.
Case (ii): TRANSFER ([1.1, 2.2, 3.3], [(0.0, 0.0)])) is a complex rank-one array of length two whose first
element has the value (1.1, 2.2) and whose second element has a real part with the value 3.3. The
imaginary part of the second element is processor dependent.
Case (iii): TRANSFER ([1.1, 2.2, 3.3], [(0.0, 0.0)], 1) is a complex rank-one array of length one whose only
element has the value (1.1, 2.2).
16.9.194 TRANSPOSE (MATRIX)
2 Class. Transformational function.
3 Argument. MATRIX shall be a rank-two array of any type.
4 Result Characteristics. The result is an array of the same type and type parameters as MATRIX and with
rank two and shape [n, m] where [m, n] is the shape of MATRIX.5 Result Value. Element (i, j) of the result has the value MATRIX (j + LBOUND (MATRIX, 1) − 1, i +
LBOUND (MATRIX, 2) − 1).
1 2 3 1 4 7
6 Example. If A is the array 4 5 6 , then TRANSPOSE (A) has the value 2 5 8 .
7 8 9 3 6 9 16.9.195 TRIM (STRING) 1 Description. String without trailing blanks. 2 Class. Transformational function. 3 Argument. STRING shall be a character scalar. ⃝c ISO/IEC 2017 – All rights reserved 4334 Result Characteristics. Character with the same kind type parameter value as STRING and with a length
ISO/IEC DIS 1539-1:2017 (E)
that is the length of STRING less the number of trailing blanks in STRING. If STRING contains no nonblank5 Result Value. The value of the result is the same as STRING except any trailing blanks are removed.characters, the result has zero length.
6 Example. TRIM (’ A B ’) has the value ’ A B’. 16.9.196 UBOUND (ARRAY [, DIM, KIND])1 Description. Upper bound(s).
2 Class. Inquiry function. 3 Arguments. ARRAY shall be assumed-rank or an array. It shall not be an unallocated allocatable array or a pointer that4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value ofis not associated. If ARRAY is an assumed-size array, DIM shall be present with a value less than
the rank of ARRAY.
DIM (optional) shall be an integer scalar with a value in the range 1 ≤ DIM ≤ n, where n is the rank of ARRAY.
The corresponding actual argument shall not be an optional dummy argument, a disassociated
pointer, or an unallocated allocatable.
KIND (optional) shall be a scalar integer constant expression.
KIND; otherwise the kind type parameter is that of default integer type. The result is scalar if DIM is present;5 Result Value.otherwise, the result is an array of rank one and size n, where n is the rank of ARRAY.
Case (i): If DIM is present, ARRAY is a whole array, and dimension DIM of ARRAY has nonzero extent,6 Examples. If A is declared by the statementthe result has a value equal to the upper bound for subscript DIM of ARRAY. Otherwise, if DIM
is present and ARRAY is assumed-rank, the value of the result is as if ARRAY were a whole array,
with the extent of the final dimension of ARRAY when ARRAY is associated with an assumed-size
array being considered to be −1. Otherwise, if DIM is present, the result has a value equal to the
number of elements in dimension DIM of ARRAY.
Case (ii): If ARRAY has rank zero, UBOUND (ARRAY) has a value that is a zero-sized array. Otherwise,
UBOUND (ARRAY) has a value whose ith element is equal to UBOUND (ARRAY, i), for i = 1, 2,
. . . , n, where n is the rank of ARRAY. UBOUND (ARRAY, KIND=KIND) has a value whose ith
element is equal to UBOUND (ARRAY, i, KIND=KIND), for i = 1, 2, . . . , n, where n is the
rank of ARRAY.
REAL A (2:3, 7:10)then UBOUND (A) is [3, 10] and UBOUND (A, DIM = 2) is 10.
NOTE 16.3316.9.197 UCOBOUND (COARRAY [, DIM, KIND])If ARRAY is assumed-rank and has rank zero, DIM cannot be present since it cannot satisfy the requirement
1 ≤ DIM ≤ 0.
1 Description. Upper cobound(s) of a coarray. 2 Class. Inquiry function. 434 ⃝3 Arguments.c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
COARRAY shall be a coarray of any type. It may be a scalar or an array. If it is allocatable it shall be allocated.4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value ofIf its designator has more than one part-ref , the rightmost part-ref shall have nonzero corank.
DIM (optional) shall be an integer scalar with a value in the range 1 ≤ DIM ≤ n, where n is the corank
of COARRAY. The corresponding actual argument shall not be an optional dummy argument, a
disassociated pointer, or an unallocated allocatable.
KIND (optional) shall be a scalar integer constant expression.
KIND; otherwise, the kind type parameter is that of default integer type. The result is scalar if DIM is present;5 Result Value. The final upper cobound is the final cosubscript in the cosubscript list for the coarray that selectsotherwise, the result is an array of rank one and size n, where n is the corank of COARRAY.
the image whose index is equal to the number of images in the team current when COARRAY was established.6 Examples. If NUM_IMAGES( ) has the value 30 and A is allocated by the statementCase (i): If DIM is present, the result has a value equal to the upper cobound for codimension DIM of
COARRAY.
Case (ii): If DIM is absent, the result has a value whose ith element is equal to the upper cobound for
codimension i of COARRAY, for i = 1, 2,. . . , n, where n is the corank of COARRAY.
ALLOCATE (A [2:3, 0:7, *])then UCOBOUND (A) is [3, 7, 2] and UCOBOUND (A, DIM=2) is 7. Note that the cosubscripts [3, 7, 2] do
not correspond to an actual image.
16.9.198 UNPACK (VECTOR, MASK, FIELD)
1 Description. Vector unpacked into an array. 2 Class. Transformational function. 3 Arguments. VECTOR shall be a rank-one array of any type. Its size shall be at least t where t is the number of true4 Result Characteristics. The result is an array of the same type and type parameters as VECTOR and theelements in MASK.
MASK shall be a logical array.
FIELD shall be of the same type and type parameters as VECTOR and shall be conformable with MASK.
same shape as MASK.5 Result Value. The element of the result that corresponds to the ith true element of MASK, in array element
order, has the value VECTOR (i) for i = 1, 2, . . . , t, where t is the number of true values in MASK. Each other6 Examples.element has a value equal to FIELD if FIELD is scalar or to the corresponding element of FIELD if it is an array.
Particular values can be “scattered” to particular positionsin an array by
using UNPACK. If M is the
1 0 0 . T .
array 0 1 0 , V is the array [1, 2, 3], and Q is the logical mask T . . , where “T” represents true
0 0 1 . . T 1 2 0
and “.” represents false, then the result of UNPACK (V, MASK = Q, FIELD = M) has the value 1 1 0
0 0 0 2 0
and the result of UNPACK (V, MASK = Q, FIELD = 0) has the value 1 0 0 . 0 0 3
⃝c ISO/IEC 2017 – All rights reserved 435
ISO/IEC DIS 1539-1:2017 (E)16.9.199 VERIFY (STRING, SET [, BACK, KIND])
1 Description. Character set non-membership search.
2 Class. Elemental function.
3 Arguments.
STRING shall be of type character.4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value ofSET shall be of type character with the same kind type parameter as STRING.
BACK (optional) shall be of type logical.
KIND (optional) shall be a scalar integer constant expression.
KIND; otherwise the kind type parameter is that of default integer type.5 Result Value.
Case (i): If BACK is absent or has the value false and if STRING contains at least one character that is not6 Examples.in SET, the value of the result is the position of the leftmost character of STRING that is not in
SET.
Case (ii): If BACK is present with the value true and if STRING contains at least one character that is not
in SET, the value of the result is the position of the rightmost character of STRING that is not in
SET.
Case (iii): The value of the result is zero if each character in STRING is in SET or if STRING has zero length.
Case (i): VERIFY (’ABBA’, ’A’) has the value 2.1 This document defines five standard intrinsic modules: a Fortran environment module, a set of three modulesCase (ii): VERIFY (’ABBA’, ’A’, BACK = .TRUE.) has the value 3.
Case (iii): VERIFY (’ABBA’, ’AB’) has the value 0.
16.10 Standard intrinsic modules
16.10.1 General
to support floating-point exceptions and IEEE arithmetic, and a module to support interoperability with the C2 The intrinsic modules IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES are described inprogramming language.
Clause 17. The intrinsic module ISO_C_BINDING is described in Clause 18. The module procedures described3 A processor may extend the standard intrinsic modules to provide public entities in them in addition to thosein 16.10.2 are pure.
NOTE 16.34
The types and procedures defined in standard intrinsic modules are not themselves intrinsic.
specified in this document.1 The intrinsic module ISO_FORTRAN_ENV provides public entities relating to the Fortran environment.16.10.2 The ISO_FORTRAN_ENV intrinsic module
<IP_ADDRESS> General
436 ⃝2 The processor shall provide the named constants, derived types, and procedures described in subclause 16.10.2.c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
In the detailed descriptions below, procedure names are generic and not specific.1 The value of the default integer scalar constant ATOMIC_INT_KIND is the kind type parameter value of type<IP_ADDRESS> ATOMIC_INT_KIND
integer variables for which the processor supports atomic operations specified by atomic subroutines.1 The value of the default integer scalar constant ATOMIC_LOGICAL_KIND is the kind type parameter value<IP_ADDRESS> ATOMIC_LOGICAL_KIND
of type logical variables for which the processor supports atomic operations specified by atomic subroutines.1 The values of the elements of the default integer array constant CHARACTER_KINDS are the kind values<IP_ADDRESS> CHARACTER_KINDS
supported by the processor for variables of type character. The order of the values is processor dependent. The1 The value of the default integer scalar constant CHARACTER_STORAGE_SIZE is the size expressed in bitsrank of the array is one, its lower bound is one, and its size is the number of character kinds supported.
<IP_ADDRESS> CHARACTER_STORAGE_SIZE
of the character storage unit (<IP_ADDRESS>).1 Description. Processor-dependent string describing the options that controlled the program translation phase.<IP_ADDRESS> COMPILER_OPTIONS ( )
2 Class. Transformational function.
3 Argument. None.
4 Result Characteristics. Default character scalar with processor-dependent length.
5 Result Value. A processor-dependent value which describes the options that controlled the translation phase of
program execution. This value should include relevant information that could be useful for diagnosing problems6 Example. COMPILER_OPTIONS ( ) might have the value ’/OPTIMIZE /FLOAT=IEEE’.at a later date.
<IP_ADDRESS> COMPILER_VERSION ( )1 Description. Processor-dependent string identifying the program translation phase.
2 Class. Transformational function.
3 Argument. None.
4 Result Characteristics. Default character scalar with processor-dependent length.
5 Result Value. A processor-dependent value that identifies the name and version of the program translation
phase of the processor. This value should include relevant information that could be useful for diagnosing problems6 Example. COMPILER_VERSION ( ) might have the value ’Fast KL-10 Compiler Version 7’.at a later date.
⃝c ISO/IEC 2017 – All rights reserved 4371 The value of the default integer scalar constant CURRENT_TEAM identifies the current team when it is used
ISO/IEC DIS 1539-1:2017 (E)
NOTE 16.35
Relevant information that could be useful for diagnosing problems at a later date might include compiler
release and patch level, default compiler arguments, environment variable values, and run time library
requirements. A processor might include this information in an object file automatically, without the user
needing to save the result of this function in a variable.
<IP_ADDRESS> CURRENT_TEAM
as the LEVEL argument to GET_TEAM.1 The value of the default integer scalar constant ERROR_UNIT identifies the processor-dependent preconnected<IP_ADDRESS> ERROR_UNIT
external unit used for the purpose of error reporting (12.5). This unit may be the same as OUTPUT_UNIT.1 EVENT_TYPE is a derived type with private components. It is an extensible type with no type parameters.The value shall not be −1.
<IP_ADDRESS> EVENT_TYPE
Each nonallocatable component is fully default-initialized.2 A scalar variable of type EVENT_TYPE is an event variable. The value of an event variable includes its event
count, which is updated by execution of a sequence of EVENT POST or EVENT WAIT statements. The effect1 The value of the default integer scalar constant FILE_STORAGE_SIZE is the size expressed in bits of the fileof each change is as if the intrinsic subroutine ATOMIC_ADD were executed with a variable that stores the
event count as its ATOM argument. A coarray that is of type EVENT_TYPE may be referenced or defined
during execution of a segment that is unordered relative to the execution of another segment in which that
coarray is defined. The event count is of type integer with kind ATOMIC_INT_KIND from the intrinsic module
ISO_FORTRAN_ENV. The initial value of the event count of an event variable is zero.
C1603 A named entity with declared type EVENT_TYPE, or which has a noncoarray potential subobject
component with declared type EVENT_TYPE, shall be a variable. A component that is of such a type
shall be a data component.
C1604 A named variable with declared type EVENT_TYPE shall be a coarray. A named variable with a
noncoarray potential subobject component of type EVENT_TYPE shall be a coarray.
C1605 An event variable shall not appear in a variable definition context except as the event-variable in an
EVENT POST or EVENT WAIT statement, as an allocate-object, or as an actual argument in a reference
to a procedure with an explicit interface if the corresponding dummy argument has INTENT (INOUT).
C1606 A variable with a nonpointer subobject of type EVENT_TYPE shall not appear in a variable definition
context except as an allocate-object in an ALLOCATE statement without a SOURCE= specifier, as an
allocate-object in a DEALLOCATE statement, or as an actual argument in a reference to a procedure
with an explicit interface if the corresponding dummy argument has INTENT (INOUT).
NOTE 16.36
The restrictions against changing an event variable except via EVENT POST and EVENT WAIT state-
ments ensure the integrity of its value and facilitate efficient implementation, particularly when special
synchronization is needed for correct event handling.
NOTE 16.37
Updates to variables via atomic subroutines are coherent but not necessarily consistent, so a processor
might have to use extra synchronization to obtain the consistency required for the segments ordered by
EVENT POST and EVENT WAIT statements.
438 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> FILE_STORAGE_SIZE
storage unit (12.3.5).1 The value of the default integer scalar constant INITIAL_TEAM identifies the initial team when it is used as<IP_ADDRESS> INITIAL_TEAM
the LEVEL argument to GET_TEAM.1 The value of the default integer scalar constant INPUT_UNIT identifies the same processor-dependent external<IP_ADDRESS> INPUT_UNIT
unit preconnected for sequential formatted input as the one identified by an asterisk in a READ statement; this1 The values of these default integer scalar constants shall be those of the kind type parameters that specify anunit is the one used for a READ statement that does not contain an input/output control list (<IP_ADDRESS>). The
value shall not be −1.
<IP_ADDRESS> INT8, INT16, INT32, and INT64
INTEGER type whose storage size expressed in bits is 8, 16, 32, and 64 respectively. If, for any of these constants,1 The values of the elements of the default integer array constant INTEGER_KINDS are the kind values supportedthe processor supports more than one kind of that size, it is processor dependent which kind value is provided. If
the processor supports no kind of a particular size, that constant shall be equal to −2 if the processor supports
a kind with larger size and −1 otherwise.
<IP_ADDRESS> INTEGER_KINDS
by the processor for variables of type integer. The order of the values is processor dependent. The rank of the1 The value of the default integer scalar constant IOSTAT_END is assigned to the variable specified in an IOSTAT=array is one, its lower bound is one, and its size is the number of integer kinds supported.
<IP_ADDRESS> IOSTAT_END
specifier (12.11.5) if an end-of-file condition occurs during execution of an input statement and no error condition1 The value of the default integer scalar constant IOSTAT_EOR is assigned to the variable specified in an IOSTAT=occurs. This value shall be negative.
<IP_ADDRESS> IOSTAT_EOR
specifier (12.11.5) if an end-of-record condition occurs during execution of an input statement and no end-of-file1 The value of the default integer scalar constant IOSTAT_INQUIRE_INTERNAL_UNIT is assigned to theor error condition occurs. This value shall be negative and different from the value of IOSTAT_END.
<IP_ADDRESS> IOSTAT_INQUIRE_INTERNAL_UNIT
variable specified in an IOSTAT= specifier in an INQUIRE statement (12.10) if a file-unit-number identifies an1 LOCK_TYPE is a derived type with private components; no component is allocatable or a pointer. It is aninternal unit in that statement.
NOTE 16.38
This can only occur when a defined input/output procedure is called by the processor as the result of
executing a parent data transfer statement (<IP_ADDRESS>.3) for an internal unit.
⃝c ISO/IEC 2017 – All rights reserved 439
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> LOCK_TYPE
extensible type with no type parameters. All components have default initialization.2 A scalar variable of type LOCK_TYPE is a lock variable. A lock variable can have one of two states: locked and
unlocked. The unlocked state is represented by the one value that is the default value of a LOCK_TYPE variable;1 The values of the elements of the default integer array constant LOGICAL_KINDS are the kind values supportedthis is the value specified by the structure constructor LOCK_TYPE ( ). The locked state is represented by all
other values. The value of a lock variable can be changed with the LOCK and UNLOCK statements (11.6.10).
C1607 A named entity with declared type LOCK_TYPE, or which has a noncoarray potential subobject com-
ponent with declared type LOCK_TYPE, shall be a variable. A component that is of such a type shall
be a data component.
C1608 A named variable with declared type LOCK_TYPE shall be a coarray. A named variable with a
noncoarray potential subobject component of type LOCK_TYPE shall be a coarray.
C1609 A lock variable shall not appear in a variable definition context except as the lock-variable in a LOCK or
UNLOCK statement, as an allocate-object, or as an actual argument in a reference to a procedure with
an explicit interface where the corresponding dummy argument has INTENT (INOUT).
C1610 A variable with a subobject of type LOCK_TYPE shall not appear in a variable definition context except
as an allocate-object or as an actual argument in a reference to a procedure with an explicit interface
where the corresponding dummy argument has INTENT (INOUT).
NOTE 16.39
The restrictions against changing a lock variable except via the LOCK and UNLOCK statements ensure
the integrity of its value and facilitate efficient implementation, particularly when special synchronization
is needed for correct lock operation.
<IP_ADDRESS> LOGICAL_KINDS
by the processor for variables of type logical. The order of the values is processor dependent. The rank of the1 The value of the default integer scalar constant NUMERIC_STORAGE_SIZE is the size expressed in bits of thearray is one, its lower bound is one, and its size is the number of logical kinds supported.
<IP_ADDRESS> NUMERIC_STORAGE_SIZE
numeric storage unit (<IP_ADDRESS>).1 The value of the default integer scalar constant OUTPUT_UNIT identifies the same processor-dependent external<IP_ADDRESS> OUTPUT_UNIT
unit preconnected for sequential formatted output as the one identified by an asterisk in a WRITE statement1 The value of the default integer scalar constant PARENT_TEAM identifies the parent team when it is used as(<IP_ADDRESS>). The value shall not be −1.
<IP_ADDRESS> PARENT_TEAM
the LEVEL argument to GET_TEAM.1 The values of the elements of the default integer array constant REAL_KINDS are the kind values supported by<IP_ADDRESS> REAL_KINDS
the processor for variables of type real. The order of the values is processor dependent. The rank of the array is1 The values of these default integer scalar named constants shall be those of the kind type parameters that specifyone, its lower bound is one, and its size is the number of real kinds supported.
440 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> REAL32, REAL64, and REAL128
a REAL type whose storage size expressed in bits is 32, 64, and 128 respectively. If, for any of these constants,1 If the processor has the ability to detect that an image has failed, the value of the default integer scalar constantthe processor supports more than one kind of that size, it is processor dependent which kind value is provided. If
the processor supports no kind of a particular size, that constant shall be equal to −2 if the processor supports
kinds of a larger size and −1 otherwise.
<IP_ADDRESS> STAT_FAILED_IMAGE
STAT_FAILED_IMAGE is positive; otherwise, the value of STAT_FAILED_IMAGE is negative. If an image1 The value of the default integer scalar constant STAT_LOCKED is assigned to the variable specified in a STAT=involved in execution of an image control statement, a reference to a coindexed object, or execution of a collective
or atomic subroutine has failed, and no other error condition occurs, the value of STAT_FAILED_IMAGE is
assigned to the variable specified in a STAT= specifier in the execution of an image control statement or reference
to a coindexed object, or to the STAT argument in an invocation of a collective or atomic subroutine.
<IP_ADDRESS> STAT_LOCKED
specifier (11.6.11) of a LOCK statement if the lock variable is locked by the executing image.1 The value of the default integer scalar constant STAT_LOCKED_OTHER_IMAGE is assigned to the variable<IP_ADDRESS> STAT_LOCKED_OTHER_IMAGE
specified in a STAT= specifier (11.6.11) of an UNLOCK statement if the lock variable is locked by another image.1 The value of the default integer scalar constant STAT_STOPPED_IMAGE is assigned to the variable specified<IP_ADDRESS> STAT_STOPPED_IMAGE
in a STAT= specifier (9.7.4, 11.6.11), if execution of the statement with that specifier requires synchronization1 The value of the default integer scalar constant STAT_UNLOCKED is assigned to the variable specified in awith an image that has initiated normal termination. It is assigned to a STAT argument in a reference to a
collective subroutine if any image of the current team has initiated normal termination. This value shall be
positive.
<IP_ADDRESS> STAT_UNLOCKED
STAT= specifier (11.6.11) of an UNLOCK statement if the lock variable is unlocked.1 The value of the default integer scalar constant STAT_UNLOCKED_FAILED_IMAGE is assigned to the vari-<IP_ADDRESS> STAT_UNLOCKED_FAILED_IMAGE
able specified in a STAT= specifier (11.6.11) of a LOCK statement if the lock variable is unlocked because of the1 TEAM_TYPE is a derived type with private components. It is an extensible type with no type parameters.failure of the image that locked it.
<IP_ADDRESS> TEAM_TYPE
Each nonallocatable component is fully default-initialized.2 A scalar variable of type TEAM_TYPE is a team variable, and can identify a team. The default initial value of
a team variable does not identify any team.1 The values of these named constants shall be distinct:⃝c ISO/IEC 2017 – All rights reserved 441
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> Uniqueness of named constant values
IOSTAT_INQUIRE_INTERNAL_UNIT STAT_STOPPED_IMAGE
STAT_FAILED_IMAGE STAT_UNLOCKED
STAT_LOCKED STAT_UNLOCKED_FAILED_IMAGE
STAT_LOCKED_OTHER_IMAGE
442 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)17 Exceptions and IEEE arithmetic
17.1 Overview of IEEE arithmetic support 1 The intrinsic modules IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES provide support
for the facilities defined by ISO/IEC/IEEE 60559:2011∗ . Whether the modules are provided is processor depend-2 If IEEE_EXCEPTIONS or IEEE_ARITHMETIC is accessible in a scoping unit, the exceptions IEEE_OVER-ent. If the module IEEE_FEATURES is provided, which of the named constants defined in this document are
included is processor dependent. The module IEEE_ARITHMETIC behaves as if it contained a USE statement
for IEEE_EXCEPTIONS; everything that is public in IEEE_EXCEPTIONS is public in IEEE_ARITHMETIC.
NOTE 17.1
The types and procedures defined in these modules are not themselves intrinsic.
FLOW and IEEE_DIVIDE_BY_ZERO are supported in the scoping unit for all kinds of real and complex3 If a scoping unit does not access IEEE_FEATURES, IEEE_EXCEPTIONS, or IEEE_ARITHMETIC, the levelIEEE floating-point data. Which other exceptions are supported can be determined by the inquiry function
IEEE_SUPPORT_FLAG (17.11.51); whether control of halting is supported can be determined by the inquiry
function IEEE_SUPPORT_HALTING. The extent of support of the other exceptions may be influenced by
the accessibility of the named constants IEEE_INEXACT_FLAG, IEEE_INVALID_FLAG, and IEEE_UN-
DERFLOW_FLAG of the module IEEE_FEATURES. If a scoping unit has access to IEEE_UNDERFLOW_-
FLAG of IEEE_FEATURES, within the scoping unit the processor shall support underflow and return true from
IEEE_SUPPORT_FLAG (IEEE_UNDERFLOW, X) for at least one kind of real. Similarly, if IEEE_INEX-
ACT_FLAG or IEEE_INVALID_FLAG is accessible, within the scoping unit the processor shall support the
exception and return true from the corresponding inquiry function for at least one kind of real. If IEEE_HALT-
ING is accessible, within the scoping unit the processor shall support control of halting and return true from
IEEE_SUPPORT_HALTING (FLAG) for the flag.
NOTE 17.2
IEEE_INVALID is not required to be supported whenever IEEE_EXCEPTIONS is accessed. This is to
allow a processor whose arithmetic does not conform to ISO/IEC/IEEE 60559:2011 to provide support for
overflow and divide_by_zero. On a processor which does support ISO/IEC/IEEE 60559:2011, invalid is
an equally serious condition.
of support is processor dependent, and need not include support for any exceptions. If a flag is signaling on entry4 Additional ISO/IEC/IEEE 60559:2011 facilities are available from the module IEEE_ARITHMETIC. The extentto such a scoping unit, the processor ensures that it is signaling on exit. If a flag is quiet on entry to such a
scoping unit, whether it is signaling on exit is processor dependent.
of support may be influenced by the accessibility of the named constants of the module IEEE_FEATURES. If a5 Execution might be slowed on some processors by the support of some features. If IEEE_EXCEPTIONS orscoping unit has access to IEEE_DATATYPE of IEEE_FEATURES, within the scoping unit the processor shall
support IEEE arithmetic and return true from IEEE_SUPPORT_DATATYPE (X) (17.11.48) for at least one
kind of real. Similarly, if IEEE_DENORMAL, IEEE_DIVIDE, IEEE_INF, IEEE_NAN, IEEE_ROUNDING,
IEEE_SQRT, or IEEE_SUBNORMAL is accessible, within the scoping unit the processor shall support the
feature and return true from the corresponding inquiry function for at least one kind of real. In the case of
IEEE_ROUNDING, it shall return true for the rounding modes IEEE_NEAREST, IEEE_TO_ZERO, IEEE_-
UP, and IEEE_DOWN; support for IEEE_AWAY is also required if there is at least one kind of real X for
∗ Because ISO/IEC/IEEE 60559:2011 was originally an IEEE standard, its facilities are widely known as “IEEE arithmetic”,
and this terminology is used by this document.
⃝c ISO/IEC 2017 – All rights reserved 443
ISO/IEC DIS 1539-1:2017 (E)
which IEEE_SUPPORT_DATATYPE (X) is true and RADIX (X) is equal to ten. Note that the effect of
IEEE_DENORMAL is the same as that of IEEE_SUBNORMAL.
IEEE_ARITHMETIC is accessed but IEEE_FEATURES is not accessed, the supported subset of features is1 The modules IEEE_EXCEPTIONS, IEEE_ARITHMETIC, and IEEE_FEATURES define five derived types,processor dependent. The processor’s fullest support is provided when all of IEEE_FEATURES is accessed as in
USE, INTRINSIC :: IEEE_ARITHMETIC; USE, INTRINSIC :: IEEE_FEATURES
but execution might then be slowed by the presence of a feature that is not needed. In all cases, the extent of
support can be determined by the inquiry functions.
17.2 Derived types, constants, and operators defined in the modules
whose components are all private. No direct component of any of these types is allocatable or a pointer.2 The module IEEE_EXCEPTIONS defines the following types.
• IEEE_FLAG_TYPE is for identifying a particular exception flag. Its only possible values are those of3 The module IEEE_ARITHMETIC defines the following types, constants, and operators.named constants defined in the module: IEEE_INVALID, IEEE_OVERFLOW, IEEE_DIVIDE_BY_-
ZERO, IEEE_UNDERFLOW, and IEEE_INEXACT. The module also defines the array named constants
IEEE_USUAL = [ IEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO, IEEE_INVALID ] and IEEE_-
ALL = [ IEEE_USUAL, IEEE_UNDERFLOW, IEEE_INEXACT ].
• IEEE_MODES_TYPE is for representing the floating-point modes.
• IEEE_STATUS_TYPE is for representing the floating-point status.
• The type IEEE_CLASS_TYPE, for identifying a class of floating-point values. Its only possible4 The module IEEE_FEATURES defines the type IEEE_FEATURES_TYPE, for expressing the need for particu-values are those of named constants defined in the module: IEEE_SIGNALING_NAN, IEEE_QUI-
ET_NAN, IEEE_NEGATIVE_INF, IEEE_NEGATIVE_NORMAL, IEEE_NEGATIVE_DENORMAL,
IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO, IEEE_POSITIVE_SUBNORMAL, IEEE_POS-
ITIVE_NORMAL, IEEE_POSITIVE_INF, and IEEE_OTHER_VALUE. The named constants IEEE_-
NEGATIVE_DENORMAL and IEEE_POSITIVE_DENORMAL are defined with the same value as
IEEE_NEGATIVE_SUBNORMAL and IEEE_POSITIVE_SUBNORMAL respectively.
• The type IEEE_ROUND_TYPE, for identifying a particular rounding mode. Its only possible values
are those of named constants defined in the module: IEEE_NEAREST, IEEE_TO_ZERO, IEEE_UP,
IEEE_DOWN, IEEE_AWAY and IEEE_OTHER for the rounding modes specified in this document.
• The pure elemental operator == for two values of one of these types to return true if the values are the
same and false otherwise.
• The pure elemental operator /= for two values of one of these types to return true if the values differ and
false otherwise.
lar ISO/IEC/IEEE 60559:2011 features. Its only possible values are those of named constants defined in the mod-1 The exceptions are the following.ule: IEEE_DATATYPE, IEEE_DENORMAL, IEEE_DIVIDE, IEEE_HALTING, IEEE_INEXACT_FLAG,
IEEE_INF, IEEE_INVALID_FLAG, IEEE_NAN, IEEE_ROUNDING, IEEE_SQRT, IEEE_SUBNORMAL,
and IEEE_UNDERFLOW_FLAG.
17.3 The exceptions
444 ⃝2 Each exception has a flag whose value is either quiet or signaling. The value can be determined by the subroutinec ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
• IEEE_OVERFLOW occurs in an intrinsic real addition, subtraction, multiplication, division, or conversion
by the intrinsic function REAL, as specified by ISO/IEC/IEEE 60559:2011 if IEEE_SUPPORT_DATA-
TYPE is true for the operands of the operation or conversion, and as determined by the processor otherwise.
It occurs in an intrinsic real exponentiation as determined by the processor. It occurs in a complex op-
eration, or conversion by the intrinsic function CMPLX, if it is caused by the calculation of the real or
imaginary part of the result.
• IEEE_DIVIDE_BY_ZERO occurs in a real division as specified by ISO/IEC/IEEE 60559:2011 if IEEE_-
SUPPORT_DATATYPE is true for the operands of the division, and as determined by the processor
otherwise. It is processor-dependent whether it occurs in a real exponentiation with a negative exponent.
It occurs in a complex division if it is caused by the calculation of the real or imaginary part of the result.
• IEEE_INVALID occurs when a real or complex operation or assignment is invalid; possible examples are
SQRT (X) when X is real and has a nonzero negative value, and conversion to an integer (by assignment,
an intrinsic procedure, or a procedure defined in an intrinsic module) when the result is too large to be
representable. IEEE_INVALID occurs for numeric relational intrinsic operations as specified below.
• IEEE_UNDERFLOW occurs when the result for an intrinsic real operation or assignment has an absolute
value less than a processor-dependent limit, or the real or imaginary part of the result for an intrinsic
complex operation or assignment has an absolute value less than a processor-dependent limit.
• IEEE_INEXACT occurs when the result of a real or complex operation or assignment is not exact.
IEEE_GET_FLAG. Its initial value is quiet. It is set to signaling when the associated exception occurs, except3 If a flag is signaling on entry to a procedure other than IEEE_GET_FLAG or IEEE_GET_STATUS, thethat the flag for IEEE_UNDERFLOW is not set if the result of the operation that caused the exception was exact
and default ISO/IEC/IEEE 60559:2011 exception handling is in effect for IEEE_UNDERFLOW. Its status can
also be changed by the subroutine IEEE_SET_FLAG or the subroutine IEEE_SET_STATUS. Once signaling
within a procedure, it remains signaling unless set quiet by an invocation of the subroutine IEEE_SET_FLAG
or the subroutine IEEE_SET_STATUS.
processor will set it to quiet on entry and restore it to signaling on return. If a flag signals during execution of a4 Evaluation of a specification expression might cause an exception to signal.procedure, the processor shall not set it to quiet on return.
5 In a scoping unit that has access to IEEE_EXCEPTIONS or IEEE_ARITHMETIC, if an intrinsic procedure
or a procedure defined in an intrinsic module executes normally, the values of the flags IEEE_OVERFLOW,6 In a scoping unit that has access to IEEE_EXCEPTIONS or IEEE_ARITHMETIC, if x1 and x2 are numericIEEE_DIVIDE_BY_ZERO, and IEEE_INVALID shall be as on entry to the procedure, even if one or more of
them signals during the calculation. If a real or complex result is too large for the procedure to handle, IEEE_-
OVERFLOW may signal. If a real or complex result is a NaN because of an invalid operation (for example,
LOG (−1.0)), IEEE_INVALID may signal. Similar rules apply to format processing and to intrinsic operations:
no signaling flag shall be set quiet and no quiet flag shall be set signaling because of an intermediate calculation
that does not affect the result.
entities, the type of x1 + x2 is real, and IEEE_SUPPORT_NAN (x1 + x2 ) is true, the relational intrinsic7 In a scoping unit that has access to IEEE_EXCEPTIONS or IEEE_ARITHMETIC, if x1 or x2 are numericoperation x1 rel-op x2 shall signal IEEE_INVALID as specified for the conditional predicate of ISO/IEC/IEEE
60559:2011 corresponding to rel-op indicated by Table 17.1. If the types or kind type parameters of x1 or x2 differ,
the conversions (<IP_ADDRESS>.1) might signal exceptions instead of or in addition to an IEEE_INVALID exception
signaled by the comparison.
NOTE 17.3
Each comparison predicate defined by ISO/IEC/IEEE 60559:2011 is either unordered signaling or unordered
quiet. An unordered signaling predicate signals an invalid operation exception if and only if one of the values
being compared is a NaN. An unordered quiet predicate signals an invalid operation exception if and only
if one of the values being compared is a signaling NaN. The comparison predicates do not signal any other
exceptions.
⃝c ISO/IEC 2017 – All rights reserved 445
ISO/IEC DIS 1539-1:2017 (E)
Table 17.1: IEEE relational operator correspondence
Operator ISO/IEC/IEEE 60559:2011 comparison predicate
.LT. or < compareSignalingLess
.LE. or <= compareSignalingLessEqual
.GT. or > compareSignalingGreater
.GE. or >= compareSignalingGreaterEqual
.EQ. or == compareQuietEqual
.NE. or /= compareQuietNotEqual
entities, the type of x1 + x2 is complex, and IEEE_SUPPORT_NAN (REAL (x1 + x2 )) is true, the intrinsic8 In a sequence of statements that has no invocations of IEEE_GET_FLAG, IEEE_SET_FLAG, IEEE_GET_-equality or inequality operation between x1 and x2 may signal IEEE_INVALID if the value of the real or
imaginary part of either operand is a signaling NaN. If any conversions are done before the values are compared,
those conversions might signal exceptions instead of or in addition to an IEEE_INVALID exception signaled by
the comparison.
STATUS, IEEE_SET_HALTING_MODE, or IEEE_SET_STATUS, if the execution of an operation would9 An exception shall not signal if this could arise only during execution of an operation beyond those required orcause an exception to signal but after execution of the sequence no value of a variable depends on the operation,
whether the exception is signaling is processor dependent. For example, when Y has the value zero, whether the
code
X = 1.0/Y
X = 3.0
signals IEEE_DIVIDE_BY_ZERO is processor dependent. Another example is the following:
REAL, PARAMETER :: X=0.0, Y=6.0
IF (1.0/X == Y) PRINT *,’Hello world’
where the processor is permitted to discard the IF statement because the logical expression can never be true
and no value of a variable depends on it.
permitted by the standard. For example, the statement10 The processor need not support IEEE_INVALID, IEEE_UNDERFLOW, and IEEE_INEXACT. If an exceptionIF (F (X) > 0.0) Y = 1.0/Z
shall not signal IEEE_DIVIDE_BY_ZERO when both F (X) and Z are zero and the statement
WHERE (A > 0.0) A = 1.0/A
shall not signal IEEE_DIVIDE_BY_ZERO. On the other hand, when X has the value 1.0 and Y has the value
0.0, the expression
X>0.00001 .OR. X/Y>0.00001
is permitted to cause the signaling of IEEE_DIVIDE_BY_ZERO.
is not supported, its flag is always quiet. The inquiry function IEEE_SUPPORT_FLAG can be used to inquirewhether a particular flag is supported.
446 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
17.4 The rounding modes 1 This document specifies a binary rounding mode that affects floating-point arithmetic with radix two, and a
decimal rounding mode that affects floating-point arithmetic with radix ten. Unqualified references to the round-2 ISO/IEC/IEEE 60559:2011 specifies five possible rounding-direction attributes: roundTiesToEven, roundTo-ing mode with respect to a particular arithmetic operation or operands refers to the mode for the radix of the
operation or operands, and other unqualified references to the rounding mode refers to both binary and decimal
rounding modes.
wardZero, roundTowardPositive, roundTowardNegative, and roundTiesToAway. These correspond to the round-3 The subroutine IEEE_GET_ROUNDING_MODE can be used to get the rounding modes. The initial roundinging modes IEEE_NEAREST, IEEE_TO_ZERO, IEEE_UP, IEEE_DOWN, and IEEE_AWAY respectively.
The rounding mode IEEE_OTHER does not correspond to any ISO/IEC/IEEE 60559:2011 rounding-direction
attribute; if supported, the effect of this rounding mode is processor dependent.
modes are processor dependent.4 If the processor supports the alteration of the rounding modes during execution, the subroutine IEEE_SET_-
ROUNDING_MODE can be used to alter them. The inquiry function IEEE_SUPPORT_ROUNDING can be5 In a procedure other than IEEE_SET_ROUNDING_MODE or IEEE_SET_STATUS, the processor shall notused to inquire whether this facility is available for a particular mode. The inquiry function IEEE_SUPPORT_-
IO can be used to inquire whether rounding for base conversion in formatted input/output (<IP_ADDRESS>, <IP_ADDRESS>,
<IP_ADDRESS>.8) is as specified in ISO/IEC/IEEE 60559:2011.
change the rounding modes on entry, and on return shall ensure that the rounding modes are the same as they1 Some processors allow control during program execution of whether underflow produces a subnormal number inwere on entry.
NOTE 17.4
ISO/IEC/IEEE 60559:2011 requires support for roundTiesToAway only for decimal floating-point.
NOTE 17.5
ISO/IEC/IEEE 60559:2011 requires that there is a language-defined means to specify a constant value
for the rounding-direction attribute for all standard operations in a block. The means provided by this
document are a CALL to IEEE_GET_ROUNDING_MODE at the beginning of the block followed by
a CALL to IEEE_SET_ROUNDING_MODE with constant arguments, together with another CALL to
IEEE_SET_ROUNDING_MODE at the end of the block to restore the rounding mode.
NOTE 17.6
Within a program, all literal constants that have the same form have the same value (7.1.4). Therefore, the
value of a literal constant is not affected by the rounding modes.
17.5 Underflow mode
conformance with ISO/IEC/IEEE 60559:2011 (gradual underflow) or produces zero instead (abrupt underflow).2 Control over the underflow mode is exercised by invocation of IEEE_SET_UNDERFLOW_MODE. The sub-On some processors, floating-point performance is typically better in abrupt underflow mode than in gradual
underflow mode.
routine IEEE_GET_UNDERFLOW_MODE can be used to get the underflow mode. The inquiry function3 The underflow mode affects only floating-point calculations whose type is that of an X for which IEEE_SUP-IEEE_SUPPORT_UNDERFLOW_CONTROL can be used to inquire whether this facility is available. The
initial underflow mode is processor dependent. In a procedure other than IEEE_SET_UNDERFLOW_MODE
or IEEE_SET_STATUS, the processor shall not change the underflow mode on entry, and on return shall ensure
that the underflow mode is the same as it was on entry.
⃝c ISO/IEC 2017 – All rights reserved 447
ISO/IEC DIS 1539-1:2017 (E)
PORT_UNDERFLOW_CONTROL returns true.1 Some processors allow control during program execution of whether to abort or continue execution after an17.6 Halting
exception. Such control is exercised by invocation of the subroutine IEEE_SET_HALTING_MODE. Halting1 The values of the rounding modes, underflow mode, and halting mode are collectively called the floating-pointis not precise and may occur any time after the exception has occurred. The inquiry function IEEE_SUP-
PORT_HALTING can be used to inquire whether this facility is available. The initial halting mode is processor
dependent. In a procedure other than IEEE_SET_HALTING_MODE or IEEE_SET_STATUS, the processor
shall not change the halting mode on entry, and on return shall ensure that the halting mode is the same as it
was on entry.
17.7 The floating-point modes and status
modes. The values of all the supported flags for exceptions and the floating-point modes are collectively called the1 ISO/IEC/IEEE 60559:2011 specifies the following exceptional floating-point values.floating-point status. The floating-point modes can be stored in a scalar variable of type IEEE_MODES_TYPE
with the subroutine IEEE_GET_MODES and restored with the subroutine IEEE_SET_MODES. The floating-
point status can be stored in a scalar variable of type IEEE_STATUS_TYPE with the subroutine IEEE_GET_-
STATUS and restored with the subroutine IEEE_SET_STATUS. There are no facilities for finding the values of
particular flags represented by such a variable.
NOTE 17.7
Each image has its own floating-point status (5.3.4).
NOTE 17.8
Some processors hold all these flags and modes in one or two status registers that can be obtained and
set as a whole faster than all individual flags and modes can be obtained and set. These procedures are
provided to exploit this feature.
NOTE 17.9
The processor is required to ensure that a call to a Fortran procedure does not change the floating-point
status other than by setting exception flags to signaling.
17.8 Exceptional values
• Subnormal values have very small absolute values and reduced precision.2 A value that does not fall into the above classes is called a normal number.• Infinite values (+infinity and −infinity) are created by overflow or division by zero.
• Not-a-Number ( NaN) values are undefined values or values created by an invalid operation.
3 The functions IEEE_IS_FINITE, IEEE_IS_NAN, IEEE_IS_NEGATIVE, and IEEE_IS_NORMAL are
provided to test whether a value is finite, NaN, negative, or normal. The function IEEE_VALUE is provided to1 The inquiry function IEEE_SUPPORT_DATATYPE can be used to inquire whether IEEE arithmetic is sup-generate an IEEE number of any class, including an infinity or a NaN. The inquiry functions IEEE_SUPPORT_-
SUBNORMAL, IEEE_SUPPORT_INF, and IEEE_SUPPORT_NAN are provided to determine whether these
facilities are available for a particular kind of real.
448 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
17.9 IEEE arithmetic
ported for a particular kind of real. Complete conformance with ISO/IEC/IEEE 60559:2011 is not required,2 The inquiry function IEEE_SUPPORT_NAN is provided to inquire whether the processor supports IEEE NaNs.but
• the normal numbers shall be exactly those of an ISO/IEC/IEEE 60559:2011 floating-point format,
• for at least one rounding mode, the intrinsic operations of addition, subtraction and multiplication shall
conform whenever the operands and result specified by ISO/IEC/IEEE 60559:2011 are normal numbers,
• the IEEE function abs shall be provided by the intrinsic function ABS,
• the IEEE operation remainder shall be provided by the function IEEE_REM, and
• the IEEE functions copySign, logB, and compareQuietUnordered shall be provided by the functions IEEE_-
COPY_SIGN, IEEE_LOGB, and IEEE_UNORDERED, respectively,
for that kind of real.
Where these are supported, the result of the intrinsic operations +, −, and *, and the functions IEEE_REM3 The inquiry function IEEE_SUPPORT_INF is provided to inquire whether the processor supports IEEE infinit-and IEEE_RINT from the intrinsic module IEEE_ARITHMETIC, shall conform to ISO/IEC/IEEE 60559:2011
when the result is an IEEE NaN.
ies. Where these are supported, the result of the intrinsic operations +, −, and *, and the functions IEEE_REM4 The inquiry function IEEE_SUPPORT_SUBNORMAL is provided to inquire whether the processor supportsand IEEE_RINT from the intrinsic module IEEE_ARITHMETIC, shall conform to ISO/IEC/IEEE 60559:2011
when exactly one operand or the result specified by ISO/IEC/IEEE 60559:2011 is an IEEE infinity.
subnormal numbers. Where these are supported, the result of the intrinsic operations +, −, and *, and the5 The inquiry function IEEE_SUPPORT_DIVIDE is provided to inquire whether, on kinds of real for whichfunctions IEEE_REM and IEEE_RINT from the intrinsic module IEEE_ARITHMETIC, shall conform to
ISO/IEC/IEEE 60559:2011 when the result specified by ISO/IEC/IEEE 60559:2011 is subnormal, or any op-
erand is subnormal and either the result is not an IEEE infinity or IEEE_SUPPORT_INF is true.
IEEE_SUPPORT_DATATYPE returns true, the intrinsic division operation conforms to ISO/IEC/IEEE6 ISO/IEC/IEEE 60559:2011 specifies a square root function that returns negative real zero for the square root of60559:2011 when both operands and the result specified by ISO/IEC/IEEE 60559:2011 are normal numbers.
If IEEE_SUPPORT_NAN is also true for a particular kind of real, the intrinsic division operation on that kind
conforms to ISO/IEC/IEEE 60559:2011 when the result specified by ISO/IEC/IEEE 60559:2011 is a NaN. If
IEEE_SUPPORT_INF is also true for a particular kind of real, the intrinsic division operation on that kind
conforms to ISO/IEC/IEEE 60559:2011 when one operand or the result specified by ISO/IEC/IEEE 60559:2011 is
an IEEE infinity. If IEEE_SUPPORT_SUBNORMAL is also true for a particular kind of real, the intrinsic divi-
sion operation on that kind conforms to ISO/IEC/IEEE 60559:2011 when the result specified by ISO/IEC/IEEE
60559:2011 is subnormal, or when any operand is subnormal and either the result specified by ISO/IEC/IEEE
60559:2011 is not an infinity or IEEE_SUPPORT_INF is true.
negative real zero and has certain accuracy requirements. The inquiry function IEEE_SUPPORT_SQRT can7 The inquiry function IEEE_SUPPORT_STANDARD is provided to inquire whether the processor supports allbe used to inquire whether the intrinsic function SQRT conforms to ISO/IEC/IEEE 60559:2011 for a particular
kind of real. If IEEE_SUPPORT_NAN is also true for a particular kind of real, the intrinsic function SQRT
on that kind conforms to ISO/IEC/IEEE 60559:2011 when the result specified by ISO/IEC/IEEE 60559:2011
is a NaN. If IEEE_SUPPORT_INF is also true for a particular kind of real, the intrinsic function SQRT on
that kind conforms to ISO/IEC/IEEE 60559:2011 when the result specified by ISO/IEC/IEEE 60559:2011 is an
IEEE infinity. If IEEE_SUPPORT_SUBNORMAL is also true for a particular kind of real, the intrinsic function
SQRT on that kind conforms to ISO/IEC/IEEE 60559:2011 when the argument is subnormal.
the ISO/IEC/IEEE 60559:2011 facilities defined in this document for a particular kind of real.1 For all of the procedures defined in the modules, the arguments shown are the names that shall be used for⃝c ISO/IEC 2017 – All rights reserved 449
ISO/IEC DIS 1539-1:2017 (E)
17.10 Summary of the procedures
argument keywords if the keyword form is used for the actual arguments.2 A procedure classified in 17.10 as an inquiry function depends on the properties of one or more of its arguments
instead of their values; in fact, these argument values may be undefined. Unless the description of one of these3 In the Class column of Tables 17.2 and 17.3,inquiry functions states otherwise, these arguments are permitted to be unallocated allocatable variables or
pointers that are undefined or disassociated. A procedure that is classified as a transformational function is
neither an inquiry function nor elemental.
E indicates that the procedure is an elemental function,
ES indicates that the procedure is an elemental subroutine, I indicates that the procedure is an inquiry function,
PS indicates that the procedure is a pure subroutine, S indicates that the procedure is an impure subroutine, and
T indicates that the procedure in a transformational function. Table 17.2: IEEE_ARITHMETIC module procedure summary
Procedure Arguments Class Description IEEE_CLASS (X) E Classify number. IEEE_COPY_SIGN (X, Y) E Copy sign. IEEE_FMA (A, B, C) E Fused multiply-add operation. IEEE_GET_ROUNDING_MODE (ROUND_VALUE S Get rounding mode. [, RADIX])
IEEE_GET_UNDERFLOW_- (GRADUAL) S Get underflow mode. MODE
IEEE_INT (A, ROUND [, KIND]) E Conversion to integer type. IEEE_IS_FINITE (X) E Whether a value is finite. IEEE_IS_NAN (X) E Whether a value is an IEEE NaN. IEEE_IS_NEGATIVE (X) E Whether a value is negative. IEEE_IS_NORMAL (X) E Whether a value is a normal number. IEEE_LOGB (X) E Exponent. IEEE_MAX_NUM (X, Y) E Maximum numeric value. IEEE_MAX_NUM_MAG (X, Y) E Maximum magnitude numeric value. IEEE_MIN_NUM (X, Y) E Minimum numeric value. IEEE_MIN_NUM_MAG (X, Y) E Minimum magnitude numeric value. IEEE_NEXT_AFTER (X, Y) E Adjacent machine number. IEEE_NEXT_DOWN (X) E Adjacent lower machine number. IEEE_NEXT_UP (X) E Adjacent higher machine number. IEEE_QUIET_EQ (A, B) E Quiet compares equal. IEEE_QUIET_GE (A, B) E Quiet compares greater than or equal. IEEE_QUIET_GT (A, B) E Quiet compares greater than. IEEE_QUIET_LE (A, B) E Quiet compares less than or equal. IEEE_QUIET_LT (A, B) E Quiet compares less than. IEEE_QUIET_NE (A, B) E Quiet compares not equal. IEEE_REAL (A [, KIND]) E Conversion to real type. IEEE_REM (X, Y) E Exact remainder. IEEE_RINT (X) E Round to integer. IEEE_SCALB (X, I) E X × 2I . IEEE_SELECTED_REAL_KIND ([P, R, RADIX]) T IEEE kind type parameter value. IEEE_SET_ROUNDING_MODE (ROUND_VALUE S Set rounding mode. [, RADIX])
450 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
Table 17.2: IEEE_ARITHMETIC module procedure summary (cont.) Procedure Arguments Class Description
IEEE_SET_UNDERFLOW_- (GRADUAL) S Set underflow mode. MODE
IEEE_SIGNALING_EQ (A, B) E Signaling compares equal. IEEE_SIGNALING_GE (A, B) E Signaling compares greater than or equal.
IEEE_SIGNALING_GT (A, B) E Signaling compares greater than. IEEE_SIGNALING_LE (A, B) E Signaling compares less than or equal. IEEE_SIGNALING_LT (A, B) E Signaling compares less than. IEEE_SIGNALING_NE (A, B) E Signaling compares not equal. IEEE_SIGNBIT (X) E Test sign bit. IEEE_SUPPORT_DATATYPE ([X]) I Query IEEE arithmetic support. IEEE_SUPPORT_DENORMAL ([X]) I Query subnormal number support. IEEE_SUPPORT_DIVIDE ([X]) I Query IEEE division support. IEEE_SUPPORT_INF ([X]) I Query IEEE infinity support. IEEE_SUPPORT_IO ([X]) I Query IEEE formatting support. IEEE_SUPPORT_NAN ([X]) I Query IEEE NaN support. IEEE_SUPPORT_ROUNDING (ROUND_VALUE T Query IEEE rounding support. [, X])
IEEE_SUPPORT_SQRT ([X]) I Query IEEE square root support. IEEE_SUPPORT_SUBNORMAL ([X]) I Query subnormal number support. IEEE_SUPPORT_STANDARD ([X]) I Query IEEE standard support. IEEE_SUPPORT_UNDER- ([X]) I Query underflow control support. FLOW_CONTROL
IEEE_UNORDERED (X, Y) E Whether two values are unordered. IEEE_VALUE (X, CLASS) E Return number in a class. Table 17.3: IEEE_EXCEPTIONS module procedure summary
Procedure Arguments Class Description IEEE_GET_FLAG (FLAG, FLAG_VALUE) ES Get an exception flag. IEEE_GET_HALTING_MODE (FLAG, HALTING) ES Get a halting mode. IEEE_GET_MODES (MODES) S Get floating-point modes. IEEE_GET_STATUS (STATUS_VALUE) S Get floating-point status. IEEE_SET_FLAG (FLAG, FLAG_VALUE) PS Set an exception flag. IEEE_SET_HALTING_MODE (FLAG, HALTING) PS Set a halting mode. IEEE_SET_MODES (MODES) S Set floating-point modes. IEEE_SET_STATUS (STATUS_VALUE) S Restore floating-point status. IEEE_SUPPORT_FLAG (FLAG [, X]) T Query exception support. IEEE_SUPPORT_HALTING (FLAG) T Query halting mode support. 4 In the intrinsic module IEEE_ARITHMETIC, the elemental functions listed are provided for all reals X and Y.
17.11 Specifications of the procedures1 In the detailed descriptions in 17.11, procedure names are generic and are not specific. All the functions are pure17.11.1 General
and all the subroutines are impure unless otherwise stated. All dummy arguments have INTENT (IN) if the2 For the elemental functions of IEEE_ARITHMETIC that return a floating-point result, if X or Y has a valueintent is not stated explicitly. In the examples, it is assumed that the processor supports IEEE arithmetic for
default real.
⃝c ISO/IEC 2017 – All rights reserved 451
ISO/IEC DIS 1539-1:2017 (E)
that is an infinity or a NaN, the result shall be consistent with the general rules in 6.1 and 6.2 of ISO/IEC/IEEE3 A program may contain statements that, if executed, would violate the requirements listed in a Restriction60559:2011. For example, the result for an infinity shall be constructed as the limiting case of the result with a
value of arbitrarily large magnitude, if such a limit exists.
paragraph.NOTE 17.10
A program can avoid violating those requirements by using IF constructs to check whether particular
features are supported. For example,
IF (IEEE_SUPPORT_DATATYPE (X)) THEN
C = IEEE_CLASS (X)
ELSE
...
END IF
avoids invoking IEEE_CLASS except on a processor which supports that facility.
17.11.2 IEEE_CLASS (X) 1 Description. Classify number.
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_CLASS (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false.
5 Result Characteristics. IEEE_CLASS_TYPE.
6 Result Value. The result value shall be IEEE_SIGNALING_NAN or IEEE_QUIET_NAN if IEEE_SUP-
PORT_NAN (X) has the value true and the value of X is a signaling or quiet NaN, respectively. The result7 Example. IEEE_CLASS (−1.0) has the value IEEE_NEGATIVE_NORMAL.value shall be IEEE_NEGATIVE_INF or IEEE_POSITIVE_INF if IEEE_SUPPORT_INF (X) has the value
true and the value of X is negative or positive infinity, respectively. The result value shall be IEEE_NEG-
ATIVE_SUBNORMAL or IEEE_POSITIVE_SUBNORMAL if IEEE_SUPPORT_SUBNORMAL (X) has the
value true and the value of X is a negative or positive subnormal value, respectively. The result value shall
be IEEE_NEGATIVE_NORMAL, IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO, or IEEE_POSIT-
IVE_NORMAL if the value of X is negative normal, negative zero, positive zero, or positive normal, respectively.
Otherwise, the result value shall be IEEE_OTHER_VALUE.
NOTE 17.11The result value IEEE_OTHER_VALUE is useful on systems that are almost IEEE-compatible, but do
not implement all of it. For example, if a subnormal value is encountered on a system that does not support
them.
17.11.3 IEEE_COPY_SIGN (X, Y) 1 Description. Copy sign.
2 Class. Elemental function.
3 Arguments. The arguments shall be of type real.
452 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
4 Restriction. IEEE_COPY_SIGN (X, Y) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) or IEEE_SUPPORT_DATATYPE (Y) has the value false.5 Result Characteristics. Same as X.
6 Result Value. The result has the absolute value of X with the sign of Y. This is true even for IEEE special values, such as a NaN or an infinity (on processors supporting such values).7 Example. The value of IEEE_COPY_SIGN (X, 1.0) is ABS (X) even when X is a NaN.
17.11.4 IEEE_FMA (A, B, C)1 Description. Fused multiply-add operation.
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_FMA (A, B, C) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has the valueB shall be of the same type and kind type parameter as A.
C shall be of the same type and kind type parameter as A.
false.5 Result Characteristics. Same as A.
6 Result Value. The result has the value specified by ISO/IEC/IEEE 60559:2011 for the fusedMultiplyAdd operation; that is, when the result is in range, its value is equal to the mathematical value of (A × B) + C roundedto the representation method of A according to the rounding mode. IEEE_OVERFLOW, IEEE_UNDERFLOW,
and IEEE_INEXACT shall be signaled according to the final step in the calculation and not by any intermediate
calculation.
7 Example. The value of IEEE_FMA (TINY (0.0), TINY (0.0), 1.0), when the rounding mode is IEEE_- NEAREST, is equal to 1.0; only the IEEE_INEXACT exception is signaled.1 Description. Get an exception flag.17.11.5 IEEE_GET_FLAG (FLAG, FLAG_VALUE)
2 Class. Elemental subroutine.
3 Arguments.
FLAG shall be of type IEEE_FLAG_TYPE. It specifies the exception flag to be obtained.4 Example. Following CALL IEEE_GET_FLAG (IEEE_OVERFLOW, FLAG_VALUE), FLAG_VALUE isFLAG_VALUE shall be of type logical. It is an INTENT (OUT) argument. If the value of FLAG is IEEE_-
INVALID, IEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO, IEEE_UNDERFLOW, or IEEE_-
INEXACT, FLAG_VALUE is assigned the value true if the corresponding exception flag is signaling
and is assigned the value false otherwise.
true if the IEEE_OVERFLOW flag is signaling and is false if it is quiet.1 Description. Get a halting mode.17.11.6 IEEE_GET_HALTING_MODE (FLAG, HALTING)
2 Class. Elemental subroutine.
⃝c ISO/IEC 2017 – All rights reserved 4533 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
FLAG shall be of type IEEE_FLAG_TYPE. It specifies the exception flag. It shall have one of the val-4 Example. To store the halting mode for IEEE_OVERFLOW, do a calculation without halting, and restore theues IEEE_INVALID, IEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO, IEEE_UNDERFLOW,
or IEEE_INEXACT.
HALTING shall be of type logical. It is an INTENT (OUT) argument. It is assigned the value true if the
exception specified by FLAG will cause halting. Otherwise, it is assigned the value false.
halting mode later:USE, INTRINSIC :: IEEE_ARITHMETIC
LOGICAL HALTING
...
CALL IEEE_GET_HALTING_MODE (IEEE_OVERFLOW, HALTING) ! Store halting mode
CALL IEEE_SET_HALTING_MODE (IEEE_OVERFLOW, .FALSE.) ! No halting
... ! calculation without halting
CALL IEEE_SET_HALTING_MODE (IEEE_OVERFLOW, HALTING) ! Restore halting mode
17.11.7 IEEE_GET_MODES (MODES) 1 Description. Get floating-point modes.
2 Class. Subroutine.
3 Argument. MODES shall be a scalar of type IEEE_MODES_TYPE. It is an INTENT (OUT) argument that
is assigned the value of the floating-point modes.4 Example. To save the floating-point modes, do a calculation with specific rounding and underflow modes, and
restore them later:1 Description. Get rounding mode.USE, INTRINSIC :: IEEE_ARITHMETIC
TYPE (IEEE_MODES_TYPE) SAVE_MODES
...
CALL IEEE_GET_MODES (SAVE_MODES) ! Save all modes.
CALL IEEE_SET_ROUNDING_MODE (IEEE_TO_ZERO))
CALL IEEE_SET_UNDERFLOW_MODE (GRADUAL=.FALSE.)
... ! calculation with abrupt round-to-zero.
CALL IEEE_SET_MODES (SAVE_MODES) ! Restore all modes.
17.11.8 IEEE_GET_ROUNDING_MODE (ROUND_VALUE [, RADIX])
2 Class. Subroutine.
3 Arguments.
ROUND_VALUE shall be a scalar of type IEEE_ROUND_TYPE. It is an INTENT (OUT) argument. It is4 Example. To save the binary rounding mode, do a calculation with round to nearest, and restore the roundingassigned the value IEEE_NEAREST, IEEE_TO_ZERO, IEEE_UP, IEEE_DOWN, or IEEE_-
AWAY if the corresponding rounding mode is in operation and IEEE_OTHER otherwise.
RADIX (optional) shall be an integer scalar with the value two or ten. If RADIX is present with the value ten,
the rounding mode queried is the decimal rounding mode, otherwise it is the binary rounding mode.
mode later:1 Description. Get floating-point status.454 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
USE, INTRINSIC :: IEEE_ARITHMETIC
TYPE (IEEE_ROUND_TYPE) ROUND_VALUE
...
CALL IEEE_GET_ROUNDING_MODE (ROUND_VALUE) ! Store the rounding mode
CALL IEEE_SET_ROUNDING_MODE (IEEE_NEAREST)
... ! calculation with round to nearest
CALL IEEE_SET_ROUNDING_MODE (ROUND_VALUE) ! Restore the rounding mode
17.11.9 IEEE_GET_STATUS (STATUS_VALUE)
2 Class. Subroutine.
3 Argument. STATUS_VALUE shall be a scalar of type IEEE_STATUS_TYPE. It is an INTENT (OUT)
argument. It is assigned the value of the floating-point status.4 Example. To store all the exception flags, do a calculation involving exception handling, and restore them later:
USE, INTRINSIC :: IEEE_ARITHMETIC17.11.10 IEEE_GET_UNDERFLOW_MODE (GRADUAL)TYPE (IEEE_STATUS_TYPE) STATUS_VALUE
...
CALL IEEE_GET_STATUS (STATUS_VALUE) !  Set the flags quiet.
... ! calculation involving exception handling
CALL IEEE_SET_STATUS (STATUS_VALUE) ! Restore the flags
1 Description. Get underflow mode.
2 Class. Subroutine.
3 Argument. GRADUAL shall be a logical scalar. It is an INTENT (OUT) argument. It is assigned the value
true if the underflow mode is gradual underflow, and false if the underflow mode is abrupt underflow.4 Restriction. IEEE_GET_UNDERFLOW_MODE shall not be invoked unless IEEE_SUPPORT_UNDER-
FLOW_CONTROL (X) is true for some X.5 Example. After CALL IEEE_SET_UNDERFLOW_MODE (.FALSE.), a subsequent CALL IEEE_GET_-
UNDERFLOW_MODE (GRADUAL) will set GRADUAL to false.1 Description. Conversion to integer type.17.11.11 IEEE_INT (A, ROUND [, KIND])
2 Class. Elemental function.
3 Arguments.
A shall be of type real.4 Restriction. IEEE_INT (A, ROUND, KIND) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasROUND shall be of type IEEE_ROUND_TYPE.
KIND (optional) shall be a scalar integer constant expression.
the value false.5 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value of⃝c ISO/IEC 2017 – All rights reserved 455
ISO/IEC DIS 1539-1:2017 (E)
KIND; otherwise, the kind type parameter is that of default integer.6 Result Value. The result has the value specified by ISO/IEC/IEEE 60559:2011 for the convertToInteger{round}
or the convertToIntegerExact{round} operation; the processor shall consistently choose which operation it7 Example. The value of IEEE_INT (12.5, IEEE_UP) is 13; IEEE_INEXACT will be signaled if the processorprovides. That is, the value of A is converted to an integer according to the rounding mode specified by ROUND;
if this value is representable in the representation method of the result, the result has this value, otherwise IEEE_-
INVALID is signaled and the result is processor dependent. If the processor provides the convertToIntegerExact
operation, IEEE_INVALID did not signal, and the value of the result differs from that of A, IEEE_INEXACT
will be signaled.
provides the convertToIntegerExact operation.1 Description. Whether a value is finite.17.11.12 IEEE_IS_FINITE (X)
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_IS_FINITE (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value
false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value true if the value of X is finite, that is, IEEE_CLASS (X) has one
of the values IEEE_NEGATIVE_NORMAL, IEEE_NEGATIVE_SUBNORMAL, IEEE_NEGATIVE_ZERO,7 Example. IEEE_IS_FINITE (1.0) has the value true.IEEE_POSITIVE_ZERO, IEEE_POSITIVE_SUBNORMAL, or IEEE_POSITIVE_NORMAL; otherwise, the
result has the value false.
17.11.13 IEEE_IS_NAN (X)1 Description. Whether a value is an IEEE NaN.
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_IS_NAN (X) shall not be invoked if IEEE_SUPPORT_NAN (X) has the value false.
5 Result Characteristics. Default logical.
6 Result Value. The result has the value true if the value of X is an IEEE NaN; otherwise, it has the value false.
7 Example. IEEE_IS_NAN (SQRT (−1.0)) has the value true if IEEE_SUPPORT_SQRT (1.0) has the value
true.1 Description. Whether a value is negative.17.11.14 IEEE_IS_NEGATIVE (X)
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_IS_NEGATIVE (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the
value false.5 Result Characteristics. Default logical.456 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
6 Result Value. The result has the value true if IEEE_CLASS (X) has one of the values IEEE_NEGATIVE_-
NORMAL, IEEE_NEGATIVE_SUBNORMAL, IEEE_NEGATIVE_ZERO or IEEE_NEGATIVE_INF; oth-7 Example. IEEE_IS_NEGATIVE (0.0) has the value false.erwise, the result has the value false.
17.11.15 IEEE_IS_NORMAL (X)1 Description. Whether a value is a normal number.
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_IS_NORMAL (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value true if IEEE_CLASS (X) has one of the values IEEE_NEGATIVE_-
NORMAL, IEEE_NEGATIVE_ZERO, IEEE_POSITIVE_ZERO or IEEE_POSITIVE_NORMAL; otherwise,7 Example. IEEE_IS_NORMAL (SQRT (−1.0) has the value false if IEEE_SUPPORT_SQRT (1.0) has thethe result has the value false.
value true.1 Description. Exponent.17.11.16 IEEE_LOGB (X)
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Restriction. IEEE_LOGB (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false.
5 Result Characteristics. Same as X.
6 Result Value.
Case (i): If the value of X is neither zero, infinity, nor NaN, the result has the value of the unbiased exponent7 Example. IEEE_LOGB (−1.1) has the value 0.0.of X. Note: this value is equal to EXPONENT (X)− 1.
Case (ii): If X==0, the result is −infinity if IEEE_SUPPORT_INF (X) is true and −HUGE (X) otherwise;
IEEE_DIVIDE_BY_ZERO signals.
Case (iii): If IEEE_SUPPORT_INF (X) is true and X is infinite, the result is +infinity.
Case (iv): If IEEE_SUPPORT_NAN (X) is true and X is a NaN, the result is a NaN.
17.11.17 IEEE_MAX_NUM (X, Y)1 Description. Maximum numeric value.
2 Class. Elemental function.
3 Arguments.
X shall be of type real.4 Restriction. IEEE_MAX_NUM shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the valueY shall be of the same type and kind type parameter as X.
⃝c ISO/IEC 2017 – All rights reserved 457
ISO/IEC DIS 1539-1:2017 (E)
false.5 Result Characteristics. Same as X.
6 Result Value. The result has the value specified for the maxNum operation in ISO/IEC/IEEE 60559:2011; that is,7 Except when X or Y is a signaling NaN, no exception is signaled.• if X < Y the result has the value of Y;
• if Y < X the result has the value of X;
• if exactly one of X and Y is a quiet NaN the result has the value of the other argument;
• if one or both of X and Y are signaling NaNs, IEEE_INVALID signals and the result is a NaN;
• otherwise, the result is either X or Y (processor dependent).
8 Example. The value of IEEE_MAX_NUM (1.5, IEEE_VALUE (IEEE_QUIET_NAN)) is 1.5. 17.11.18 IEEE_MAX_NUM_MAG (X, Y)1 Description. Maximum magnitude numeric value.
2 Class. Elemental function. 3 Arguments. X shall be of type real.4 Restriction. IEEE_MAX_NUM_MAG shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has theY shall be of the same type and kind type parameter as X.
value false.5 Result Characteristics. Same as X.
6 Result Value. The result has the value specified for the maxNumMag operation in ISO/IEC/IEEE 60559:2011; that is,7 Except when X or Y is a signaling NaN, no exception is signaled.• if ABS (X) < ABS (Y) the result has the value of Y;
• if ABS (Y) < ABS (X) the result has the value of X;
• otherwise, the result has the value of IEEE_MAX_NUM (X, Y).
8 Example. The value of IEEE_MAX_NUM_MAG (1.5, −2.5) is −2.5. 17.11.19 IEEE_MIN_NUM (X, Y)1 Description. Minimum numeric value.
2 Class. Elemental function. 3 Arguments. X shall be of type real.4 Restriction. IEEE_MIN_NUM shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false.Y shall be of the same type and kind type parameter as X.
5 Result Characteristics. Same as X. 458 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
6 Result Value. The result has the value specified for the minNum operation in ISO/IEC/IEEE 60559:2011; that is,7 Except when X or Y is a signaling NaN, no exception is signaled.• if X < Y the result has the value of X;
• if Y < X the result has the value of Y;
• if exactly one of X and Y is a quiet NaN the result has the value of the other argument;
• if one or both of X and Y are signaling NaNs, IEEE_INVALID signals and the result is a NaN;
• otherwise, the result is either X or Y (processor dependent).
8 Example. The value of IEEE_MIN_NUM (1.5, IEEE_VALUE (IEEE_QUIET_NAN)) is 1.5. 17.11.20 IEEE_MIN_NUM_MAG (X, Y)1 Description. Minimum magnitude numeric value.
2 Class. Elemental function. 3 Arguments. X shall be of type real.4 Restriction. IEEE_MIN_NUM_MAG shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has theY shall be of the same type and kind type parameter as X.
value false.5 Result Characteristics. Same as X.
6 Result Value. The result has the value specified for the minNumMag operation in ISO/IEC/IEEE 60559:2011; that is,7 Except when X or Y is a signaling NaN, no exception is signaled.• if ABS (X) < ABS (Y) the result has the value of X;
• if ABS (Y) < ABS (X) the result has the value of Y;
• otherwise, the result has the value of IEEE_MIN_NUM (X, Y).
8 Example. The value of IEEE_MIN_NUM_MAG (1.5, −2.5) is 1.5. 17.11.21 IEEE_NEXT_AFTER (X, Y)1 Description. Adjacent machine number.
2 Class. Elemental function. 3 Arguments. The arguments shall be of type real. 4 Restriction. IEEE_NEXT_AFTER (X, Y) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) or IEEE_SUPPORT_DATATYPE (Y) has the value false.5 Result Characteristics. Same as X.
6 Result Value. Case (i): If X == Y, the result is X and no exception is signaled.7 Example. The value of IEEE_NEXT_AFTER (1.0, 2.0) is 1.0 + EPSILON (X).Case (ii): If X ̸= Y, the result has the value of the next representable neighbor of X in the direction of Y.
The neighbors of zero (of either sign) are both nonzero. IEEE_OVERFLOW is signaled when
X is finite but IEEE_NEXT_AFTER (X, Y) is infinite; IEEE_UNDERFLOW is signaled when
IEEE_NEXT_AFTER (X, Y) is subnormal; in both cases, IEEE_INEXACT signals.
⃝c ISO/IEC 2017 – All rights reserved 459
ISO/IEC DIS 1539-1:2017 (E)
17.11.22 IEEE_NEXT_DOWN (X)1 Description. Adjacent lower machine number.
2 Class. Elemental function. 3 Argument. X shall be of type real. 4 Restriction. IEEE_NEXT_DOWN (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false. IEEE_NEXT_DOWN (−HUGE (X)) shall not be invoked if IEEE_SUPPORT_INF (X) has the5 Result Characteristics. Same as X.value false.
6 Result Value. The result has the value specified for the nextDown operation in ISO/IEC/IEEE 60559:2011; that is, it is the greatest value in the representation method of X that compares less than X, except when X is7 Example. If IEEE_SUPPORT_SUBNORMAL (0.0) is true, the value of IEEE_NEXT_DOWN (+0.0) is theequal to −∞ the result has the value −∞, and when X is a NaN the result is a NaN. If X is a signaling NaN,
IEEE_INVALID signals; otherwise, no exception is signaled.
negative subnormal number with least magnitude.1 Description. Adjacent higher machine number.17.11.23 IEEE_NEXT_UP (X)
2 Class. Elemental function. 3 Argument. X shall be of type real. 4 Restriction. IEEE_NEXT_UP (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false. IEEE_NEXT_UP (HUGE (X)) shall not be invoked if IEEE_SUPPORT_INF (X) has the value false.5 Result Characteristics. Same as X.
6 Result Value. The result has the value specified for the nextUp operation in ISO/IEC/IEEE 60559:2011; that is, it is the least value in the representation method of X that compares greater than X, except when X is7 Example. If IEEE_SUPPORT_INF (X) is true, the value of IEEE_NEXT_UP (HUGE (X)) is +∞.equal to +∞ the result has the value +∞, and when X is a NaN the result is a NaN. If X is a signaling NaN,
IEEE_INVALID_signals; otherwise, no exception is signaled.
17.11.24 IEEE_QUIET_EQ (A, B)1 Description. Quiet compares equal.
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_QUIET_EQ (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
460 ⃝6 Result Value. The result has the value specified for the compareQuietEqual operation in ISO/IEC/IEEEc ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
60559:2011; that is, it is true if and only if A compares equal to B. If A or B is a NaN, the result will be false. If7 Example. IEEE_QUIET_EQ (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and no exceptionA or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Quiet compares greater than or equal.17.11.25 IEEE_QUIET_GE (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_QUIET_GE (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareQuietGreaterEqual operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares greater than or equal to B. If A or B is a NaN, the result7 Example. IEEE_QUIET_GE (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and no exceptionwill be false. If A or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Quiet compares greater than.17.11.26 IEEE_QUIET_GT (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_QUIET_GT (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareQuietGreater operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares greater than B. If A or B is a NaN, the result will be7 Example. IEEE_QUIET_GT (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and no exceptionfalse. If A or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Quiet compares less than or equal.17.11.27 IEEE_QUIET_LE (A, B)
2 Class. Elemental function. ⃝c ISO/IEC 2017 – All rights reserved 4613 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
A shall be of type real.4 Restriction. IEEE_QUIET_LE (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareQuietLessEqual operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares less than or equal to B. If A or B is a NaN, the result will7 Example. IEEE_QUIET_LE (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and no exceptionbe false. If A or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Quiet compares less than.17.11.28 IEEE_QUIET_LT (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_QUIET_LT (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareQuietLess operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares less than B. If A or B is a NaN, the result will be7 Example. IEEE_QUIET_LT (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and no exceptionfalse. If A or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Quiet compares not equal.17.11.29 IEEE_QUIET_NE (A, B)
2 Class. Elemental function.
3 Arguments.
A shall be of type real.4 Restriction. IEEE_QUIET_NE (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) has theB shall have the same type and kind type parameter as A.
value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareQuietNotEqual operation in ISO/IEC/IEEE
60559:2011; that is, it is true if and only if A compares not equal to B. If A or B is a NaN, the result will be true.7 Example. IEEE_QUIET_NE (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value true and no exceptionIf A or B is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
is signaled.1 Description. Conversion to real type.462 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
17.11.30 IEEE_REAL (A [, KIND])
2 Class. Elemental function.
3 Arguments.
A shall be of type integer or real.4 Restriction. IEEE_REAL shall not be invoked if A is of type real and IEEE_SUPPORT_DATATYPE (A)KIND (optional) shall be a scalar integer constant expression.
has the value false, or if IEEE_SUPPORT_DATATYPE (IEEE_REAL (A, KIND)) has the value false.5 Result Characteristics. Real. If KIND is present, the kind type parameter is that specified by the value of
KIND; otherwise, the kind type parameter is that of default real.6 Result Value. The result has the same value as A if that value is representable in the representation method
of the result, and is rounded according to the rounding mode otherwise. This shall be consistent with the7 Example. The value of IEEE_REAL (123) is 123.0.specification of ISO/IEC/IEEE 60559:2011 for the convertFromInt operation when A is of type integer, and with
the convertFormat operation otherwise.
17.11.31 IEEE_REM (X, Y)1 Description. Exact remainder.
2 Class. Elemental function.
3 Arguments. The arguments shall be of type real and have the same radix.
4 Restriction. IEEE_REM (X, Y) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) or IEEE_SUP-
PORT_DATATYPE (Y) has the value false.5 Result Characteristics. Real with the kind type parameter of whichever argument has the greater precision.
6 Result Value. This function computes the remainder operation specified in ISO/IEC/IEEE 60559:2011.
7 The result value when X and Y are finite, and Y is nonzero, regardless of the rounding mode, shall be exactly X
− Y*N, where N is the integer nearest to the exact value X/Y; whenever |N − X/Y| = 12 , N shall be even. If the8 When X is finite and Y is infinite, the result value is X. If Y is zero or X is infinite, and neither is a NaN, theresult value is zero, the sign shall be that of X.
IEEE_INVALID exception shall occur; if IEEE_SUPPORT_NAN(X+Y) is true, the result is a NaN. If X is9 Examples. The value of IEEE_REM (4.0, 3.0) is 1.0, the value of IEEE_REM (3.0, 2.0) is −1.0, and the valuesubnormal and Y is infinite, the IEEE_UNDERFLOW exception shall occur. No exception shall signal if X is
finite and normal, and Y is infinite.
of IEEE_REM (5.0, 2.0) is 1.0.1 Description. Round to integer.17.11.32 IEEE_RINT (X [, ROUND])
2 Class. Elemental function.
3 Arguments.
X shall be of type real.4 Restriction. IEEE_RINT (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false.ROUND (optional) shall be of type IEEE_ROUND_TYPE.
⃝c ISO/IEC 2017 – All rights reserved 463
ISO/IEC DIS 1539-1:2017 (E)
5 Result Characteristics. Same as X.
6 Result Value. If ROUND is present, the value of the result is the value of X rounded to an integer according
to the mode specified by ROUND; this is the ISO/IEC/IEEE 60559:2011 operation roundToInteger{rounding}.7 Examples. If the rounding mode is round to nearest, the value of IEEE_RINT (1.1) is 1.0. The value ofOtherwise, the value of the result is that specified for the operation roundIntegralToExact in ISO/IEC/IEEE
60559:2011; this is the value of X rounded to an integer according to the rounding mode. If the result has the
value zero, the sign is that of X.
IEEE_RINT (1.1, IEEE_UP) is 2.0.1 Description. X × 2I .17.11.33 IEEE_SCALB (X, I)
2 Class. Elemental function.
3 Arguments.
X shall be of type real.4 Restriction. IEEE_SCALB (X) shall not be invoked if IEEE_SUPPORT_DATATYPE (X) has the value false.I shall be of type integer.
5 Result Characteristics. Same as X.
6 Result Value.
Case (i): If X × 2I is representable as a normal number, the result has this value.7 Example. The value of IEEE_SCALB (1.0, 2) is 4.0.Case (ii): If X is finite and X × 2I is too large, the IEEE_OVERFLOW exception shall occur. If IEEE_-
SUPPORT_INF (X) is true, the result value is infinity with the sign of X; otherwise, the result
value is SIGN (HUGE (X), X).
Case (iii): If X × 2I is too small and there is loss of accuracy, the IEEE_UNDERFLOW exception shall occur.
The result is the representable number having a magnitude nearest to |2I | and the same sign as X.
Case (iv): If X is infinite, the result is the same as X; no exception signals.
17.11.34 IEEE_SELECTED_REAL_KIND ([P, R, RADIX])1 Description. IEEE kind type parameter value.
2 Class. Transformational function.
3 Arguments. At least one argument shall be present.
P (optional) shall be an integer scalar.4 Result Characteristics. Default integer scalar.R (optional) shall be an integer scalar.
RADIX (optional) shall be an integer scalar.
5 Result Value. If P or R is absent, the result value is the same as if it were present with the value zero. If
RADIX is absent, there is no requirement on the radix of the selected kind. The result has a value equal to a6 Otherwise, the result is −1 if the processor supports an IEEE real type with radix RADIX and exponent rangevalue of the kind type parameter of an ISO/IEC/IEEE 60559:2011 floating-point format with decimal precision,
as returned by the intrinsic function PRECISION, of at least P digits, a decimal exponent range, as returned
by the intrinsic function RANGE, of at least R, and a radix, as returned by the intrinsic function RADIX, of
RADIX, if such a kind type parameter is available on the processor.
464 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
of at least R but not with precision of at least P, −2 if the processor supports an IEEE real type with radix7 If more than one kind type parameter value meets the criteria, the value returned is the one with the smallestRADIX and precision of at least P but not with exponent range of at least R, −3 if the processor supports an
IEEE real type with radix RADIX but with neither precision of at least P nor exponent range of at least R, −4 if
the processor supports an IEEE real type with radix RADIX and either precision of at least P or exponent range
of at least R but not both together, and −5 if the processor supports no IEEE real type with radix RADIX.
decimal precision, unless there are several such values, in which case the smallest of these kind values is returned.8 Example. IEEE_SELECTED_REAL_KIND (6, 30) has the value KIND (0.0) on a machine that supports
ISO/IEC/IEEE 60559:2011 single precision arithmetic for its default real approximation method.1 Description. Set an exception flag.17.11.35 IEEE_SET_FLAG (FLAG, FLAG_VALUE)
2 Class. Pure subroutine.
3 Arguments.
FLAG shall be a scalar or array of type IEEE_FLAG_TYPE. If a value of FLAG is IEEE_INVALID,4 Example. CALL IEEE_SET_FLAG (IEEE_OVERFLOW, .TRUE.) sets the IEEE_OVERFLOW flag to beIEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO, IEEE_UNDERFLOW, or IEEE_INEXACT,
the corresponding exception flag is assigned a value. No two elements of FLAG shall have the same
value.
FLAG_VALUE shall be a logical scalar or array. It shall be conformable with FLAG. If an element has the value
true, the corresponding flag is set to be signaling; otherwise, the flag is set to be quiet.
signaling.1 Description. Set a halting mode.17.11.36 IEEE_SET_HALTING_MODE (FLAG, HALTING)
2 Class. Pure subroutine.
3 Arguments.
FLAG shall be a scalar or array of type IEEE_FLAG_TYPE. It shall have only the values IEEE_-4 Restriction. IEEE_SET_HALTING_MODE (FLAG, HALTING) shall not be invoked if IEEE_SUPPORT_-INVALID, IEEE_OVERFLOW, IEEE_DIVIDE_BY_ZERO, IEEE_UNDERFLOW, or IEEE_-
INEXACT. No two elements of FLAG shall have the same value.
HALTING shall be a logical scalar or array. It shall be conformable with FLAG. If an element has the value
true, the corresponding exception specified by FLAG will cause halting. Otherwise, execution will
continue after this exception.
HALTING (FLAG) has the value false.5 Example. CALL IEEE_SET_HALTING_MODE (IEEE_DIVIDE_BY_ZERO, .TRUE.) causes halting after
a divide_by_zero exception.1 Description. Set floating-point modes.17.11.37 IEEE_SET_MODES (MODES)
2 Class. Subroutine.
3 Argument. MODES shall be a scalar of type IEEE_MODES_TYPE. Its value shall be one that was assigned
⃝c ISO/IEC 2017 – All rights reserved 4654 Example.
ISO/IEC DIS 1539-1:2017 (E)
by a previous invocation of IEEE_GET_MODES to its MODES argument. The floating-point modes (17.7) are
restored to the state at that invocation.
To save the floating-point modes, do a calculation with specific rounding and underflow modes, and restore them1 Description. Set rounding mode.later:
USE, INTRINSIC :: IEEE_ARITHMETIC
TYPE (IEEE_MODES_TYPE) SAVE_MODES
...
CALL IEEE_GET_MODES (SAVE_MODES) ! Save all modes.
CALL IEEE_SET_ROUNDING_MODE (IEEE_TO_ZERO))
CALL IEEE_SET_UNDERFLOW_MODE (GRADUAL=.FALSE.)
... ! calculation with abrupt round-to-zero.
CALL IEEE_SET_MODES (SAVE_MODES) ! Restore all modes.
17.11.38 IEEE_SET_ROUNDING_MODE (ROUND_VALUE [, RADIX])
2 Class. Subroutine.
3 Arguments.
ROUND_VALUE shall be a scalar of type IEEE_ROUND_TYPE. It specifies the rounding mode to be set.4 Restriction. IEEE_SET_ROUNDING_MODE (ROUND_VALUE) shall not be invoked unless IEEE_SUP-RADIX (optional) shall be an integer scalar with the value two or ten. If RADIX is present with the value ten,
the rounding mode set is the decimal rounding mode; otherwise it is the binary rounding mode.
PORT_ROUNDING (ROUND_VALUE, X) is true for some X such that IEEE_SUPPORT_DATATYPE (X)5 Example. To save the binary rounding mode, do a calculation with round to nearest, and restore the roundingis true. IEEE_SET_ROUNDING_MODE (ROUND_VALUE, RADIX) shall not be invoked unless IEEE_-
SUPPORT_ROUNDING (ROUND_VALUE, X) is true for some X with radix RADIX such that IEEE_SUP-
PORT_DATATYPE (X) is true.
mode later:1 Description. Restore floating-point status.USE, INTRINSIC :: IEEE_ARITHMETIC
TYPE (IEEE_ROUND_TYPE) ROUND_VALUE
...
CALL IEEE_GET_ROUNDING_MODE (ROUND_VALUE) ! Store the rounding mode
CALL IEEE_SET_ROUNDING_MODE (IEEE_NEAREST)
... ! calculation with round to nearest
CALL IEEE_SET_ROUNDING_MODE (ROUND_VALUE) ! Restore the rounding mode
17.11.39 IEEE_SET_STATUS (STATUS_VALUE)
2 Class. Subroutine.
3 Argument. STATUS_VALUE shall be a scalar of type IEEE_STATUS_TYPE. Its value shall be one that was
assigned by a previous invocation of IEEE_GET_STATUS to its STATUS_VALUE argument. The floating-4 Example. To store all the exceptions flags, do a calculation involving exception handling, and restore thempoint status (17.7 is restored to the state at that invocation).
466 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
later:1 Description. Set underflow mode.USE, INTRINSIC :: IEEE_EXCEPTIONS
TYPE (IEEE_STATUS_TYPE) STATUS_VALUE
...
CALL IEEE_GET_STATUS (STATUS_VALUE) ! Store the flags
CALL IEEE_SET_FLAG (IEEE_ALL, .FALSE.) ! Set them quiet
... ! calculation involving exception handling
CALL IEEE_SET_STATUS (STATUS_VALUE) ! Restore the flags
17.11.40 IEEE_SET_UNDERFLOW_MODE (GRADUAL)
2 Class. Subroutine.
3 Argument. GRADUAL shall be a logical scalar. If it is true, the underflow mode is set to gradual underflow.
If it is false, the underflow mode is set to abrupt underflow.4 Restriction. IEEE_SET_UNDERFLOW_MODE shall not be invoked unless IEEE_SUPPORT_UNDER-
FLOW_CONTROL (X) is true for some X.5 Example. To perform some calculations with abrupt underflow and then restore the previous mode:
USE, INTRINSIC :: IEEE_ARITHMETIC
LOGICAL SAVE_UNDERFLOW_MODE
...
CALL IEEE_GET_UNDERFLOW_MODE (SAVE_UNDERFLOW_MODE)
CALL IEEE_SET_UNDERFLOW_MODE (GRADUAL=.FALSE.)
... ! Perform some calculations with abrupt underflow
CALL IEEE_SET_UNDERFLOW_MODE (SAVE_UNDERFLOW_MODE)
17.11.41 IEEE_SIGNALING_EQ (A, B)
1 Description. Signaling compares equal.
2 Class. Elemental function.
3 Arguments.
A shall be of type real.4 Restriction. IEEE_SIGNALING_EQ (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasB shall be of the same type and kind type parameter as A.
the value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareSignalingEqual operation in ISO/IEC/IEEE
60559:2011; that is, it is true if and only if A compares equal to B. If A or B is a NaN, the result will be false7 Example. IEEE_SIGNALING_EQ (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and signalsand IEEE_INVALID signals; otherwise, no exception is signaled.
IEEE_INVALID.1 Description. Signaling compares greater than or equal.⃝c ISO/IEC 2017 – All rights reserved 467
ISO/IEC DIS 1539-1:2017 (E)
17.11.42 IEEE_SIGNALING_GE (A, B)
2 Class. Elemental function.
3 Arguments.
A shall be of type real.4 Restriction. IEEE_SIGNALING_GE (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasB shall be of the same type and kind type parameter as A.
the value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareSignalingGreaterEqual operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares greater than or equal to B. If A or7 Example. IEEE_SIGNALING_GE (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and signalsB is a NaN, the result will be false and IEEE_INVALID signals; otherwise, no exception is signaled.
IEEE_INVALID.1 Description. Signaling compares greater than.17.11.43 IEEE_SIGNALING_GT (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_SIGNALING_GT (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasB shall be of the same type and kind type parameter as A.
the value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareSignalingGreater operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares greater than B. If A or B is a NaN, the result will be false7 Example. IEEE_SIGNALING_GT (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and signalsand IEEE_INVALID signals; otherwise, no exception is signaled.
IEEE_INVALID.1 Description. Signaling compares less than or equal.17.11.44 IEEE_SIGNALING_LE (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_SIGNALING_LE (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasB shall be of the same type and kind type parameter as A.
the value false.5 Result Characteristics. Default logical.
468 ⃝6 Result Value. The result has the value specified for the compareSignalingLessEqual operation in ISO/IEC/IEEEc ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
60559:2011; that is, it is true if and only if A compares less than or equal to B. If A or B is a NaN, the result will7 Example. IEEE_SIGNALING_LE (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and signalsbe false and IEEE_INVALID signals; otherwise, no exception is signaled.
IEEE_INVALID.1 Description. Signaling compares less than.17.11.45 IEEE_SIGNALING_LT (A, B)
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Restriction. IEEE_SIGNALING_LT (A, B) shall not be invoked if IEEE_SUPPORT_DATATYPE (A) hasB shall be of the same type and kind type parameter as A.
the value false.5 Result Characteristics. Default logical.
6 Result Value. The result has the value specified for the compareSignalingLess operation in ISO/IEC/IEEE 60559:2011; that is, it is true if and only if A compares less than B. If A or B is a NaN, the result will be false7 Example. IEEE_SIGNALING_LT (1.0, IEEE_VALUE (IEEE_QUIET_NAN)) has the value false and signalsand IEEE_INVALID signals; otherwise, no exception is signaled.
IEEE_INVALID.1 Description. Signaling compares not equal.17.11.46 IEEE_SIGNALING_NE (A, B)