ultimate argument coarray by a different image.
(4) If the value of the entity or any subobject of it is affected through the dummy argument, then at
any time during the invocation and execution of the procedure, either before or after the definition,
it may be referenced only through that dummy argument unless
⃝c ISO/IEC 2017 – All rights reserved 321
ISO/IEC DIS 1539-1:2017 (E)
(a) the dummy argument has the POINTER attribute,NOTE 15.33(b) the dummy argument is a scalar, assumed-shape, or assumed-rank object, and has the TAR-
GET attribute but not the INTENT (IN) or CONTIGUOUS attributes, and the actual argu-
ment is a target other than a coindexed object or an array section with a vector subscript,
(c) the dummy argument is an assumed-rank object with the TARGET attribute and not the
INTENT (IN) attribute, and the actual argument is a scalar target, or
(d) the dummy argument is a coarray and the reference is a coindexed reference of its corresponding
ultimate argument coarray by a different image.
In
SUBROUTINE OUTER
REAL, POINTER :: A (:)
...
ALLOCATE (A (1:N))
...
CALL INNER (A)
...
CONTAINS
SUBROUTINE INNER (B)
REAL :: B (:)...
END SUBROUTINE INNER
SUBROUTINE SET (C, D)
REAL, INTENT (OUT) :: CREAL, INTENT (IN) :: D
C = D
END SUBROUTINE SET
END SUBROUTINE OUTER
an assignment statement such as
A (1) = 1.0would not be permitted during the execution of INNER because this would be changing A without using
B, but statements such as
B (1) = 1.0or
CALL SET (B (1), 1.0)would be allowed. Similarly,
DEALLOCATE (A)would not be allowed because this affects the allocation of B without using B. In this case,
DEALLOCATE (B)also would not be permitted. If B were declared with the POINTER attribute, either of the statements
DEALLOCATE (A)and
DEALLOCATE (B)would be permitted, but not both.
322 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)NOTE 15.34
If there is a partial or complete overlap between the effective arguments of two different dummy arguments
of the same procedure and the dummy arguments have neither the POINTER nor TARGET attribute,
the overlapped portions cannot be defined, redefined, or become undefined during the execution of the
procedure. For example, in
CALL SUB (A (1:5), A (3:9))the array section A (3:5) cannot be defined, redefined, or become undefined through the first dummy
argument because it is part of the argument associated with the second dummy argument and cannot be
defined, redefined, or become undefined through the second dummy argument because it is part of the
argument associated with the first dummy argument. The array section A (1:2) remains definable through
the first dummy argument and A (6:9) remains definable through the second dummy argument.
This restriction applies equally to pointer targets. In
REAL, DIMENSION (10), TARGET :: Athe array section B (3:5) cannot be defined because it is part of the argument associated with the secondREAL, DIMENSION (:), POINTER :: B, C
B => A (1:5)
C => A (3:9)
CALL SUB (B, C) ! The dummy arguments of SUB are neither pointers nor targets.
dummy argument. The array section C (1:3) cannot be defined because it is part of the argument associated
with the first dummy argument. The array section A (1:2), which is associated with B (1:2), remains
definable through the first dummy argument and A (6:9), which is associated with C (4:7), remains definable
through the second dummy argument.
NOTE 15.35
In
MODULE DATA
REAL :: W, X, Y, Z
END MODULE DATA
PROGRAM MAIN
USE DATA
...
CALL INIT (X)
...
END PROGRAM MAIN
SUBROUTINE INIT (V)
USE DATA
...
READ (*, *) V
...
END SUBROUTINE INIT
variable X cannot be directly referenced at any time during the execution of INIT because it is being defined
through the dummy argument V. X can be (indirectly) referenced through V. W, Y, and Z can be directly
referenced. X can, of course, be directly referenced once execution of INIT is complete.
NOTE 15.36
The restrictions on entities associated with dummy arguments are intended to facilitate a variety of optim-
izations in the translation of the subprogram, including implementations of argument association in which
the value of an actual argument that is neither a pointer nor a target is maintained in a register or in local
storage.
⃝
c ISO/IEC 2017 – All rights reserved 323
ISO/IEC DIS 1539-1:2017 (E)1 A function is invoked during expression evaluation by a function-reference or by a defined operation (10.1.6).NOTE 15.37
The exception to the aliasing restrictions for dummy coarrays enables cross-image access while the procedure
is executing. Because nonatomic accesses from different images typically need to be separated by an image
control statement, code optimization within segments is not unduly inhibited.
15.5.3 Function reference
When it is invoked, all actual argument expressions are evaluated, then the arguments are associated, and then1 A subroutine is invoked by execution of a CALL statement, execution of a defined assignment statement (<IP_ADDRESS>),the function is executed. When execution of the function is complete, the value of the function result is available
for use in the expression that caused the function to be invoked. The characteristics of the function result (15.3.3)
are determined by the interface of the function. If a reference to an elemental function (15.8) is an elemental
reference, all array arguments shall have the same shape.
15.5.4 Subroutine reference
defined input/output (<IP_ADDRESS>.3), or finalization(7.5.6). When a subroutine is invoked, all actual argument1 The rules for interpreting a procedure reference depend on whether the procedure name in the reference isexpressions are evaluated, then the arguments are associated, and then the subroutine is executed. When the
actions specified by the subroutine are completed, the execution of the CALL statement, the execution of the
defined assignment statement, the processing of an input or output list item, or finalization of an object is
also completed. If a CALL statement includes one or more alternate return specifiers among its arguments, a branch to one
of the statements indicated might occur, depending on the action specified by the subroutine. If a reference to an elemental
subroutine (15.8) is an elemental reference, at least one actual argument shall correspond to an INTENT (OUT)
or INTENT (INOUT) dummy argument, all such actual arguments shall be arrays, and all actual arguments
shall be conformable.
15.5.5 Resolving named procedure references
<IP_ADDRESS> Establishment of procedure names
established by the available declarations and specifications to be generic in the scoping unit containing the2 A procedure name is established to be generic in a scoping unitreference, is established to be only specific in the scoping unit containing the reference, or is not established.
(1) if that scoping unit contains an interface block with that name;3 A procedure name is established to be only specific in a scoping unit if it is established to be specific and not(2) if that scoping unit contains a GENERIC statement with a generic-spec that is that name;
(3) if that scoping unit contains an INTRINSIC attribute specification for that name and it is the generic
name of an intrinsic procedure;
(4) if that scoping unit contains a USE statement that makes that procedure name accessible and the
corresponding name in the module is established to be generic; or
(5) if that scoping unit contains no declarations of that name, that scoping unit has a host scoping unit,
and that name is established to be generic in the host scoping unit.
established to be generic. It is established to be specific4 A procedure name is not established in a scoping unit if it is neither established to be generic nor established to(1) if that scoping unit contains a module subprogram, internal subprogram, or statement function statement
that defines a procedure with that name;
(2) if that scoping unit is of a subprogram that defines a procedure with that name;
(3) if that scoping unit contains an INTRINSIC attribute specification for that name and it is the name of a specific
intrinsic procedure;
(4) if that scoping unit contains an explicit EXTERNAL attribute specification for that name;
324 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
(5) if that scoping unit contains a USE statement that makes that procedure name accessible and the
corresponding name in the module is established to be specific; or
(6) if that scoping unit contains no declarations of that name, that scoping unit has a host scoping unit,
and that name is established to be specific in the host scoping unit.
be specific.1 If the reference is consistent with a nonelemental reference to one of the specific interfaces of a generic interface<IP_ADDRESS> Resolving procedure references to names established to be generic
that has that name and either is defined in the scoping unit in which the reference appears or is made accessible2 Otherwise, if the reference is consistent with an elemental reference to one of the specific interfaces of a genericby a USE statement in the scoping unit, the reference is to the specific procedure in the interface block that
provides that interface. The rules in <IP_ADDRESS>.5 ensure that there can be at most one such specific procedure.
interface that has that name and either is defined in the scoping unit in which the reference appears or is made3 Otherwise, if the scoping unit contains either an INTRINSIC attribute specification for that name or a USEaccessible by a USE statement in the scoping unit, the reference is to the specific elemental procedure in the
interface block that provides that interface. The rules in <IP_ADDRESS>.5 ensure that there can be at most one such
specific elemental procedure.
statement that makes that name accessible from a module in which the corresponding name is specified to have4 Otherwise, if the scoping unit has a host scoping unit, the name is established to be generic in that host scopingthe INTRINSIC attribute, and if the reference is consistent with the interface of that intrinsic procedure, the
reference is to that intrinsic procedure.
unit, and there is agreement between the scoping unit and the host scoping unit as to whether the name is a5 Otherwise, if the name is that of an intrinsic procedure and the reference is consistent with that intrinsic procedure,function name or a subroutine name, the name is resolved by applying the rules in this subclause to the host
scoping unit as if the reference appeared there.
the reference is to that intrinsic procedure.NOTE 15.38
Because of the renaming facility of the USE statement, the name in the reference can be different from the
usual name of the intrinsic procedure.
NOTE 15.39
These rules allow particular specific procedures with the same generic identifier to be used for particular
array ranks and a general elemental version to be used for other ranks. For example, given an interface
block such as
INTERFACE RANF
ELEMENTAL FUNCTION SCALAR_RANF(X)
REAL, INTENT(IN) :: X
END FUNCTION SCALAR_RANF
FUNCTION VECTOR_RANDOM(X)
REAL X(:)REAL VECTOR_RANDOM(SIZE(X))
END FUNCTION VECTOR_RANDOM
END INTERFACE RANF
and a declaration such as:
REAL A(10,10), AA(10,10)then the statement
⃝c ISO/IEC 2017 – All rights reserved 325
ISO/IEC DIS 1539-1:2017 (E)
NOTE 15.39 (cont.)A = RANF(AA)
is an elemental reference to SCALAR_RANF. The statement
A(6:10,2) = RANF(AA(6:10,2))
is a nonelemental reference to VECTOR_RANDOM.
<IP_ADDRESS> Resolving procedure references to names established to be only specific 1 If the name has the EXTERNAL attribute, • if it is a procedure pointer, the reference is to its target;2 If the name is that of an accessible external procedure, internal procedure, module procedure, intrinsic procedure,• if it is a dummy procedure that is not a procedure pointer, the reference is to the effective argument
corresponding to that name;
• otherwise, the reference is to the external procedure with that name.
or statement function, the reference is to that procedure.1 If the name is the name of a dummy argument of the scoping unit, the dummy argument is a dummy procedureNOTE 15.40
Because of the renaming facility of the USE statement, the name in the reference can be different from the
original name of the procedure.
<IP_ADDRESS> Resolving procedure references to names not established
and the reference is to that dummy procedure. That is, the procedure invoked by executing that reference is the2 Otherwise, if the name is the name of an intrinsic procedure, and if there is agreement between the reference andeffective argument corresponding to that dummy procedure.
the status of the intrinsic procedure as being a function or subroutine, the reference is to that intrinsic procedure.3 Otherwise, the reference is to an external procedure with that name.
15.5.6 Resolving type-bound procedure references1 If the binding-name in a procedure-designator (R1522) is that of a specific type-bound procedure, the procedure
referenced is the one bound to that name in the dynamic type of the data-ref .2 If the binding-name in a procedure-designator is that of a generic type bound procedure, the generic binding with
that name in the declared type of the data-ref is used to select a specific binding using the following criteria.3 The reference is to the procedure bound to the same name as the selected specific binding in the dynamic type• If the reference is consistent with one of the specific bindings of that generic binding, that specific binding
is selected.
• Otherwise, the reference shall be consistent with an elemental reference to one of the specific bindings of
that generic binding; that specific binding is selected.
of the data-ref .1 Intrinsic procedures are defined as an inherent part of the processor. A standard-conforming processor shall326 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
15.6 Procedure definition
15.6.1 Intrinsic procedure definition
include the intrinsic procedures described in Clause 16, but may include others. However, a standard-conforming1 A procedure is defined by the initial SUBROUTINE or FUNCTION statement of a subprogram, and each ENTRYprogram shall not make use of intrinsic procedures other than those described in Clause 16.
15.6.2 Procedures defined by subprograms
<IP_ADDRESS> General
statement defines an additional procedure (<IP_ADDRESS>).2 A subprogram is specified to have the NON_RECURSIVE attribute, or to be elemental (15.8), pure (15.7), or a
separate module subprogram (<IP_ADDRESS>) by a prefix in its initial SUBROUTINE or FUNCTION statement.3 The NON_RECURSIVE prefix-spec shall not appear if any procedure defined by the subprogram directly orR1526 prefix is prefix-spec [ prefix-spec ] ...
R1527 prefix-spec is declaration-type-spec
or ELEMENTAL
or IMPURE
or MODULE
or NON_RECURSIVE
or PURE
or RECURSIVE
C1543 (R1526) A prefix shall contain at most one of each prefix-spec.
C1544 (R1526) A prefix shall not specify both PURE and IMPURE.
C1545 (R1526) A prefix shall not specify both NON_RECURSIVE and RECURSIVE.
C1546 An elemental procedure shall not have the BIND attribute.
C1547 (R1526) MODULE shall appear only in the function-stmt or subroutine-stmt of a module subprogram or
of a nonabstract interface body that is declared in the scoping unit of a module or submodule.
C1548 (R1526) If MODULE appears in the prefix of a module subprogram, it shall have been declared to be a
separate module procedure in the containing program unit or an ancestor of that program unit.
C1549 (R1526) If MODULE appears in the prefix of a module subprogram, the subprogram shall specify the
same characteristics and dummy argument names as its corresponding module procedure interface body.
C1550 (R1526) If MODULE appears in the prefix of a module subprogram and a binding label is specified, it
shall be the same as the binding label specified in the corresponding module procedure interface body.
C1551 (R1526) If MODULE appears in the prefix of a module subprogram, NON_RECURSIVE shall appear
if and only if NON_RECURSIVE appears in the prefix in the corresponding module procedure interface
body.
indirectly invokes itself or any other procedure defined by the subprogram. If a subprogram defines a function whose name is4 If the prefix-spec PURE appears, or the prefix-spec ELEMENTAL appears and IMPURE does not appear, thedeclared with an asterisk type-param-value, no procedure defined by the subprogram shall directly or indirectly invoke itself or any
other procedure defined by the subprogram.
subprogram is a pure subprogram and shall meet the additional constraints of 15.7.5 If the prefix-spec ELEMENTAL appears, the subprogram is an elemental subprogram and shall meet the additional⃝c ISO/IEC 2017 – All rights reserved 327
ISO/IEC DIS 1539-1:2017 (E)
constraints of <IP_ADDRESS> A proc-language-binding-spec specifies that the procedure defined or declared by the statement is interoperableR1528 proc-language-binding-spec is language-binding-spec
(18.3.7).1 A function subprogram is a subprogram that has a FUNCTION statement as its first statement.C1552 A proc-language-binding-spec with a NAME= specifier shall not be specified in the function-stmt or
subroutine-stmt of an internal procedure, or of an interface body for an abstract interface or a dummy
procedure.
C1553 If proc-language-binding-spec is specified for a function, the function result shall be an interoperable scalar
variable.
C1554 If proc-language-binding-spec is specified for a procedure, each of its dummy arguments shall be an inter-
operable procedure (18.3.7) or a variable that is interoperable (18.3.5, 18.3.6), assumed-shape, assumed-
rank, assumed-type, of type CHARACTER with assumed length, or that has the ALLOCATABLE or
POINTER attribute.
C1555 A variable that is a dummy argument of a procedure that has a proc-language-binding-spec shall be
assumed-type or of interoperable type and kind type parameters.
C1556 If proc-language-binding-spec is specified for a procedure, it shall not have a default-initialized dummy
argument with the ALLOCATABLE or POINTER attribute.
C1557 If proc-language-binding-spec is specified for a procedure, it shall not have a dummy argument that is a
coarray.
C1558 If proc-language-binding-spec is specified for a procedure, it shall not have an array dummy argument
with the VALUE attribute.
<IP_ADDRESS> Function subprogram
R1529 function-subprogram is function-stmt2 The name of the function is function-name.[ specification-part ]
[ execution-part ]
[ internal-subprogram-part ]
end-function-stmt
R1530 function-stmt is [ prefix ] FUNCTION function-name
( [ dummy-arg-name-list ] ) [ suffix ]
C1559 (R1530) If RESULT appears, result-name shall not be the same as function-name and shall not be the same
as the entry-name in any ENTRY statement in the subprogram.
C1560 (R1530) If RESULT appears, the function-name shall not appear in any specification statement in the
scoping unit of the function subprogram.
R1531 dummy-arg-name is name
C1561 (R1531) A dummy-arg-name shall be the name of a dummy argument.
R1532 suffix is proc-language-binding-spec [ RESULT ( result-name ) ]
or RESULT ( result-name ) [ proc-language-binding-spec ]
R1533 end-function-stmt is END [ FUNCTION [ function-name ] ]
328 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
C1562 (R1529) An internal function subprogram shall not contain an internal-subprogram-part.
C1563 (R1533) If a function-name appears in the end-function-stmt, it shall be identical to the function-name
specified in the function-stmt.
3 The type and type parameters (if any) of the result of the function defined by a function subprogram may be
specified by a type specification in the FUNCTION statement or by the name of the function result appearing4 If RESULT appears, the name of the function result of the function is result-name and all occurrences of thein a type declaration statement in the specification part of the function subprogram. They shall not be specified
both ways. If they are not specified either way, they are determined by the implicit typing rules in effect within
the function subprogram. If the function result is an array, allocatable, or a pointer, this shall be specified by
specifications of the name of the function result within the function body. The specifications of the function
result attributes, the specification of dummy argument attributes, and the information in the procedure heading
collectively define the characteristics of the function (15.3.1).
function name in execution-part statements in its scope refer to the function itself. If RESULT does not appear,the name of the function result is function-name and all occurrences of the function name in execution-part
statements in its scope are references to the function result. On completion of execution of the function, the value
returned is that of its function result. If the function result is a data pointer, the shape of the value returned by
the function is determined by the shape of the function result when the execution of the function is completed. If
the function result is not a pointer, its value shall be defined by the function. If the function result is a pointer,
on return the pointer association status of the function result shall not be undefined.
NOTE 15.41
The function result is similar to any other entity (variable or procedure pointer) local to a function sub-
program. Its existence begins when execution of the function is initiated and ends when execution of the
function is terminated. However, because the final value of this entity is used subsequently in the evaluation
of the expression that invoked the function, an implementation might defer releasing the storage occupied
by that entity until after its value has been used in expression evaluation.
NOTE 15.42
The following is an example of the declaration of an interface body with the BIND attribute, and a reference
to the procedure declared.
USE, INTRINSIC :: ISO_C_BINDING
INTERFACE
FUNCTION JOE (I, J, R) BIND(C,NAME="FrEd")
USE, INTRINSIC :: ISO_C_BINDINGINTEGER(C_INT) :: JOE
INTEGER(C_INT), VALUE :: I, J
REAL(C_FLOAT), VALUE :: R
END FUNCTION JOE
END INTERFACE
INT = JOE(1_C_INT, 3_C_INT, 4.0_C_FLOAT)
END PROGRAM
The invocation of the function JOE results in a reference to a function with a binding label "FrEd". FrEd
could be a C function described by the C prototype
int FrEd(int n, int m, float x);
⃝c ISO/IEC 2017 – All rights reserved 329
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> Subroutine subprogram 1 A subroutine subprogram is a subprogram that has a SUBROUTINE statement as its first statement. R1534 subroutine-subprogram is subroutine-stmt2 The name of the subroutine is subroutine-name.[ specification-part ]
[ execution-part ]
[ internal-subprogram-part ]
end-subroutine-stmt
R1535 subroutine-stmt is [ prefix ] SUBROUTINE subroutine-name
[ ( [ dummy-arg-list ] ) [ proc-language-binding-spec ] ]
C1564 (R1535) The prefix of a subroutine-stmt shall not contain a declaration-type-spec.
R1536 dummy-arg is dummy-arg-name
or *
R1537 end-subroutine-stmt is END [ SUBROUTINE [ subroutine-name ] ]
C1565 (R1534) An internal subroutine subprogram shall not contain an internal-subprogram-part.
C1566 (R1537) If a subroutine-name appears in the end-subroutine-stmt, it shall be identical to the subroutine-
name specified in the subroutine-stmt.
<IP_ADDRESS> Instances of a subprogram1 When a procedure defined by a subprogram is invoked, an instance of that subprogram is created. Each instance
has an independent sequence of execution and an independent set of dummy arguments, unsaved local variables,2 When a statement function is invoked, an instance of that statement function is created.and unsaved local procedure pointers. Saved local entities are shared by all instances of the subprogram.
3 When execution of an instance completes it ceases to exist.
4 The caller of an instance of a procedure is the instance of the main program, subprogram, or statement function
that invoked it. The call sequence of an instance of a procedure is its caller, followed by the call sequence of its1 A separate module procedure is a module procedure defined by a separate-module-subprogram, by a function-caller. The call sequence of the main program is empty. The host instance of an instance of a statement function
or an internal procedure that is invoked by its name is the first element of the call sequence that is an instance
of the host of the statement function or internal subprogram. The host instance of an internal procedure that is
invoked via a dummy procedure or procedure pointer is the host instance of the associating entity from when the
argument association or pointer association was established (19.5.5). The host instance of a module procedure is
the module or submodule in which it is defined. A main program or external subprogram has no host instance.
<IP_ADDRESS> Separate module procedures
subprogram whose initial statement contains the keyword MODULE, or by a subroutine-subprogram whose initial2 A separate module procedure shall not be defined more than once.statement contains the keyword MODULE.
R1538 separate-module-subprogram is mp-subprogram-stmt
[ specification-part ]
[ execution-part ]
[ internal-subprogram-part ]
end-mp-subprogram-stmt
R1539 mp-subprogram-stmt is MODULE PROCEDURE procedure-name
330 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
R1540 end-mp-subprogram-stmt is END [PROCEDURE [procedure-name]]
C1567 (R1538) The procedure-name shall have been declared to be a separate module procedure in the containing
program unit or an ancestor of that program unit.
C1568 (R1540) If a procedure-name appears in the end-mp-subprogram-stmt, it shall be identical to the procedure-
name in the mp-subprogram-stmt.
3 The interface of a procedure defined by a separate-module-subprogram is explicitly declared by the mp-subprogram-
stmt to be the same as its module procedure interface body. It has the NON_RECURSIVE attribute if and only1 An ENTRY statement permits a procedure reference to begin with a particular executable statement within the function or subroutineif it was declared to have that attribute by the interface body. If it is a function its result name is determined
by the FUNCTION statement in the interface body.
NOTE 15.43
A separate module procedure can be accessed by use association only if its interface body is declared in the
specification part of a module and is public.
<IP_ADDRESS> ENTRY statement
subprogram in which the ENTRY statement appears.2 Optionally, a subprogram may have one or more ENTRY statements.R1541 entry-stmt is ENTRY entry-name [ ( [ dummy-arg-list ] ) [ suffix ] ]
C1569 (R1541) If RESULT appears, the entry-name shall not appear in any specification or type declaration statement in the
scoping unit of the function program.
C1570 (R1541) An entry-stmt shall appear only in an external-subprogram or a module-subprogram that does not define a separate
module procedure. An entry-stmt shall not appear within an executable-construct.
C1571 (R1541) RESULT shall appear only if the entry-stmt is in a function subprogram.
C1572 (R1541) A dummy-arg shall not be an alternate return indicator if the ENTRY statement is in a function subprogram.
C1573 (R1541) If RESULT appears, result-name shall not be the same as the function-name in the FUNCTION statement and
shall not be the same as the entry-name in any ENTRY statement in the subprogram.
3 If the ENTRY statement is in a function subprogram, an additional function is defined by that subprogram. The name of the
function is entry-name and the name of its result is result-name or is entry-name if no result-name is provided. The dummy4 If the ENTRY statement is in a subroutine subprogram, an additional subroutine is defined by that subprogram. The name of thearguments of the function are those specified in the ENTRY statement. If the characteristics of the result of the function named in
the ENTRY statement are the same as the characteristics of the result of the function named in the FUNCTION statement, their
result names identify the same entity, although their names need not be the same. Otherwise, they are storage associated and shall
all be nonpointer, nonallocatable scalar variables that are default integer, default real, double precision real, default complex, or
default logical.
subroutine is entry-name. The dummy arguments of the subroutine are those specified in the ENTRY statement.5 The order, number, types, kind type parameters, and names of the dummy arguments in an ENTRY statement may differ from the
order, number, types, kind type parameters, and names of the dummy arguments in the FUNCTION or SUBROUTINE statement6 Because an ENTRY statement defines an additional function or an additional subroutine, it is referenced in the same manner as anyin the containing subprogram.
other function or subroutine (15.5).7 In a subprogram, a dummy argument specified in an ENTRY statement shall not appear in an executable statement preceding that
ENTRY statement, unless it also appears in a FUNCTION, SUBROUTINE, or ENTRY statement that precedes the executable8 In a subprogram, a dummy argument specified in an ENTRY statement shall not appear in the expression of a statement function⃝c ISO/IEC 2017 – All rights reserved 331
ISO/IEC DIS 1539-1:2017 (E)
statement. A function result specified by a result-name in an ENTRY statement shall not appear in any executable statement that
precedes the first RESULT clause with that name.
that precedes the first dummy-arg with that name in the subprogram. A function result specified by a result-name in an ENTRY9 If a dummy argument appears in an executable statement, the execution of the executable statement is permitted during thestatement shall not appear in the expression of a statement function that precedes the first RESULT clause with that name.
execution of a reference to the function or subroutine only if the dummy argument appears in the dummy argument list of the10 If a dummy argument is used in a specification expression to specify an array bound or character length of an object, the appearancereferenced procedure.
of the object in a statement that is executed during a procedure reference is permitted only if the dummy argument appears in the11 The NON_RECURSIVE and RECURSIVE keywords are not used in an ENTRY statement. Instead, the presence or absence ofdummy argument list of the referenced procedure and it is present (<IP_ADDRESS>).
NON_RECURSIVE in the initial SUBROUTINE or FUNCTION statement controls whether the procedure defined by an ENTRY12 The keywords PURE and IMPURE are not used in an ENTRY statement. Instead, the procedure defined by an ENTRY statementstatement is permitted to reference itself or another procedure defined by the subprogram.
is pure if and only if the subprogram is a pure subprogram.13 The keyword ELEMENTAL is not used in an ENTRY statement. Instead, the procedure defined by an ENTRY statement is elemental
if and only if ELEMENTAL is specified in the SUBROUTINE or FUNCTION statement.1 Execution of the RETURN statement completes execution of the instance of the subprogram in which it appears.<IP_ADDRESS> RETURN statement
R1542 return-stmt is RETURN [ scalar-int-expr ]
C1574 (R1542) The return-stmt shall be in the inclusive scope of a function or subroutine subprogram.
C1575 (R1542) The scalar-int-expr is allowed only in the inclusive scope of a subroutine subprogram.
If the expression appears and has a value n between 1 and the number of asterisks in the dummy argument list, the CALL statement2 Execution of an end-function-stmt, end-mp-subprogram-stmt, or end-subroutine-stmt is equivalent to executionthat invoked the subroutine branches (11.2) to the branch target statement identified by the nth alternate return specifier in the
actual argument list of the referenced procedure. If the expression is omitted or has a value outside the required range, there is no
transfer of control to an alternate return.
of a RETURN statement with no expression.1 The CONTAINS statement separates the body of a main program, module, submodule, or subprogram from any<IP_ADDRESS> CONTAINS statement
R1543 contains-stmt is CONTAINS
internal or module subprograms it might contain, or it introduces the type-bound procedure part of a derived-type1 A procedure may be defined by means other than Fortran. The interface of a procedure defined by means otherdefinition (7.5.5). The CONTAINS statement is not executable.
15.6.3 Definition and invocation of procedures by means other than Fortran
than Fortran may be specified by an interface body or procedure declaration statement. A reference to such a2 A procedure defined by means other than Fortran that is invoked by a Fortran procedure and does not causeprocedure is made as though it were defined by an external subprogram.
termination of execution shall return to its caller.3 If the interface of a procedure has a proc-language-binding-spec, the procedure is interoperable (18.10).332 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
NOTE 15.44
Examples of code that might cause a transfer of control that bypasses the normal return mechanism of
a Fortran procedure are setjmp and longjmp in C and exception handling in other languages. No such
behavior is permitted by this document.
4 Interoperation with C functions is described in 18.10.
NOTE 15.45For explanatory information on definition of procedures by means other than Fortran, see subclause C.10.2.
15.6.4 Statement function 1 A statement function is a function defined by a single statement.
R1544 stmt-function-stmt is function-name ( [ dummy-arg-name-list ] ) = scalar-expr2 The definition of a statement function with the same name as an accessible entity from the host shall be preceded by the declarationC1576 (R1544) Each primary in scalar-expr shall be a constant (literal or named), a reference to a variable, a reference to a
function, or an expression in parentheses. Each operation shall be intrinsic. If scalar-expr contains a reference to a
function, the reference shall not require an explicit interface, the function shall not require an explicit interface unless it is
an intrinsic function, the function shall not be a transformational intrinsic, and the result shall be scalar. If an argument to
a function is an array, it shall be an array name. If a reference to a statement function appears in scalar-expr, its definition
shall have been provided earlier in the scoping unit and shall not be the name of the statement function being defined.
C1577 (R1544) Named constants in scalar-expr shall have been declared earlier in the scoping unit or made accessible by use
or host association. If array elements appear in scalar-expr, the array shall have been declared as an array earlier in the
scoping unit or made accessible by use or host association.
C1578 (R1544) If a dummy-arg-name, variable, function reference, or dummy function reference is typed by the implicit typing
rules, its appearance in any subsequent type declaration statement shall confirm this implied type and the values of any
implied type parameters.
C1579 (R1544) The function-name and each dummy-arg-name shall be specified, explicitly or implicitly, to be scalar.
C1580 (R1544) A given dummy-arg-name shall not appear more than once in a given dummy-arg-name-list.
C1581 A statement function shall not be of a parameterized derived type.
of its type in a type declaration statement.3 The dummy arguments have a scope of the statement function statement. Each dummy argument has the same type and type
parameters as the entity of the same name in the scoping unit containing the statement function statement.4 A statement function shall not be supplied as an actual argument.
5 Execution of a statement function consists of evaluating the expression using the values of the actual arguments for the values of the
corresponding dummy arguments and, if necessary, converting the result to the declared type and type parameters of the function.6 A function reference in the scalar expression shall not cause a dummy argument of the statement function to become redefined or
undefined.1 A pure procedure is15.7 Pure procedures
• a pure intrinsic procedure (16.1),• a module procedure in an intrinsic module, if it is specified to be pure,
• defined by a pure subprogram,
⃝c ISO/IEC 2017 – All rights reserved 333
ISO/IEC DIS 1539-1:2017 (E)
• a dummy procedure that has been specified to be PURE, or2 A pure subprogram is a subprogram that has the prefix-spec PURE or that has the prefix-spec ELEMENTAL• a statement function that references only pure functions and does not contain the designator of a variable with the VOLATILE
attribute.
and does not have the prefix-spec IMPURE. The following additional constraints apply to pure subprograms.1 An elemental procedure is an elemental intrinsic procedure or a procedure that is defined by an elemental sub-C1582 The specification-part of a pure function subprogram shall specify that all its nonpointer dummy data
objects have the INTENT (IN) or the VALUE attribute.
C1583 The function result of a pure function shall not be such that finalization of a reference to the function
would reference an impure procedure.
C1584 The function result of a pure function shall not be both polymorphic and allocatable, or have a poly-
morphic allocatable ultimate component.
C1585 The specification-part of a pure subroutine subprogram shall specify the intents of all its nonpointer
dummy data objects that do not have the VALUE attribute.
C1586 An INTENT (OUT) dummy argument of a pure procedure shall not be such that finalization of the
actual argument would reference an impure procedure.
C1587 An INTENT (OUT) dummy argument of a pure procedure shall not be polymorphic or have a poly-
morphic allocatable ultimate component.
C1588 A local variable of a pure subprogram, or of a BLOCK construct within a pure subprogram, shall not
have the SAVE or VOLATILE attribute.
NOTE 15.46
Variable initialization in a type-declaration-stmt or a data-stmt implies the SAVE attribute; therefore, such
initialization is also disallowed.
C1589 The specification-part of a pure subprogram shall specify that all its dummy procedures are pure.
C1590 If a procedure that is neither an intrinsic procedure nor a statement function is used in a context that requires
it to be pure, then its interface shall be explicit in the scope of that use. The interface shall specify that
the procedure is pure.
C1591 All internal subprograms in a pure subprogram shall be pure.
C1592 A designator of a variable with the VOLATILE attribute shall not appear in a pure subprogram.
C1593 In a pure subprogram any designator with a base object that is in common or accessed by host or use
association, is a pointer dummy argument of a pure function, is a dummy argument with the INTENT
(IN) attribute, is a coindexed object, or an object that is storage associated with any such variable, shall
not be used
(1) in a variable definition context (19.6.7),
(2) in a pointer association context (19.6.8),
(3) as the data-target in a pointer-assignment-stmt,
(4) as the expr corresponding to a component in a structure-constructor if the component has the
POINTER attribute or has a pointer component at any level of component selection,
(5) as the expr of an intrinsic assignment statement in which the variable is of a derived type if the
derived type has a pointer component at any level of component selection,
(6) as the source-expr in a SOURCE= specifier if the designator is of a derived type that has a pointer
component at any level of component selection,
(7) as an actual argument corresponding to a dummy argument with the POINTER attribute, or
334 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
(8) as the actual argument to the function C_LOC from the intrinsic module ISO_C_BINDING.
NOTE 15.47
Item 5 requires that processors be able to determine if entities with the PRIVATE attribute or with private
components have a pointer component.
C1594 Any procedure referenced in a pure subprogram, including one referenced via a defined operation, defined
assignment, defined input/output, or finalization, shall be pure.
C1595 A statement that might result in the deallocation of a polymorphic entity is not permitted in a pure
procedure.
NOTE 15.48
This includes intrinsic assignment to a variable that has a potential subobject component that is poly-
morphic and allocatable.

C1598 A pure subprogram shall not contain an image control statement (11.6.1).
NOTE 15.49
The above constraints are designed to guarantee that a pure procedure is free from side effects (modifications
of data visible outside the procedure), which means that it is safe to reference it in constructs such as DO
CONCURRENT and FORALL, where there is no explicit order of evaluation.
The constraints on pure subprograms appear to be complicated, but it is not necessary for a programmer
to be intimately familiar with them. From the programmer’s point of view, these constraints can be
summarized as follows: a pure subprogram cannot contain any operation that could conceivably result in
an assignment or pointer assignment to a common variable, a variable accessed by use or host association, or an
INTENT (IN) dummy argument; nor can a pure subprogram contain any operation that could conceivably
perform any external file input/output or execute an image control statement (including a STOP statement).
Note the use of the word conceivably; it is not sufficient for a pure subprogram merely to be side-effect
free in practice. For example, a function that contains an assignment to a global variable but in a block
that is not executed in any invocation of the function is nevertheless not a pure function. The exclusion of
functions of this nature is required if strict compile-time checking is to be used.
It is expected that most library procedures will conform to the constraints required of pure procedures, and
so can be declared pure and referenced in DO CONCURRENT constructs, FORALL statements and constructs,
and within user-defined pure procedures.
NOTE 15.50
Pure subroutines are included to allow subroutine calls from pure procedures in a safe way, and to allow
forall-assignment-stmts to be defined assignments. The constraints for pure subroutines are based on the same
principles as for pure functions, except that side effects to INTENT (OUT), INTENT (INOUT), and pointer
dummy arguments are permitted.
15.8 Elemental procedures
15.8.1 Elemental procedure declaration and interface
program. An elemental procedure has only scalar dummy arguments, but may have array actual arguments.2 An elemental subprogram has the prefix-spec ELEMENTAL. An elemental subprogram is a pure subprogram⃝c ISO/IEC 2017 – All rights reserved 335
ISO/IEC DIS 1539-1:2017 (E)
unless it has the prefix-spec IMPURE. The following additional constraints apply to elemental subprograms.3 In a reference to an elemental procedure, if any argument is an array, each actual argument that corresponds toC1599 All dummy arguments of an elemental procedure shall be scalar noncoarray dummy data objects and
shall not have the POINTER or ALLOCATABLE attribute.
C15100 The result of an elemental function shall be scalar, and shall not have the POINTER or ALLOCATABLE
attribute.
C15101 The specification-part of an elemental subprogram shall specify the intents of all of its dummy arguments
that do not have the VALUE attribute.
C15102 In the specification-expr that specifies a type parameter value of the result of an elemental function, an
object designator with a dummy argument of the function as the base object shall appear only as the
subject of a specification inquiry (10.1.11), and that specification inquiry shall not depend on a property
that is deferred.
an INTENT (OUT) or INTENT (INOUT) dummy argument shall be an array. All actual arguments shall be1 If a generic name or a specific name is used to reference an elemental function, the shape of the result is theconformable. An array actual argument is considered to be associated with the scalar dummy arguments of the
procedure throughout the entire execution of the elemental reference; thus, the restrictions on actions specified
in <IP_ADDRESS> apply to the entirety of the actual array argument.
15.8.2 Elemental function actual arguments and results
same as the shape of the actual argument with the greatest rank. If there are no actual arguments or the actual1 In a reference to an elemental subroutine, if the actual arguments corresponding to INTENT (OUT) and INTENTarguments are all scalar, the result is scalar. In the array case, the values of the elements, if any, of the result are
the same as would have been obtained if the scalar function had been applied separately, in array element order,
to corresponding elements of each array actual argument.
NOTE 15.51
An example of an elemental reference to the intrinsic function MAX:
if X and Y are arrays of shape (M, N),
MAX (X, 0.0, Y)
is an array expression of shape (M, N) whose elements have values
MAX (X(I, J), 0.0, Y(I, J)), I = 1, 2, ..., M, J = 1, 2, ..., N
15.8.3 Elemental subroutine actual arguments
(INOUT) dummy arguments are arrays, the values of the elements, if any, of the results are the same as would1 Intrinsic procedures are divided into eight classes: inquiry functions, elemental functions, transformational func-be obtained if the subroutine had been applied separately, in array element order, to corresponding elements of
each array actual argument.
336 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
16 Intrinsic procedures and modules
16.1 Classes of intrinsic procedures
tions, elemental subroutines, pure subroutines, atomic subroutines, collective subroutines, and (impure) sub-2 An intrinsic inquiry function is one whose result depends on the properties of one or more of its arguments insteadroutines.
of their values; in fact, these argument values may be undefined. Unless the description of an intrinsic inquiry3 An atomic subroutine is an intrinsic subroutine that performs an atomic action. The semantics of atomic actionsfunction states otherwise, these arguments are permitted to be unallocated allocatable variables or pointers that
are undefined or disassociated. An elemental intrinsic function is one that is specified for scalar arguments,
but may be applied to array arguments as described in 15.8. All other intrinsic functions are transformational
functions; they almost all have one or more array arguments or an array result. All standard intrinsic functions
are pure.
are described in 16.5.4 A collective subroutine is an intrinsic subroutine that performs a cooperative calculation on a team of images
without requiring synchronization. The semantics of collective subroutines are described in 16.6.5 The subroutine MOVE_ALLOC with noncoarray argument FROM, and the elemental subroutine MVBITS, are
pure. No other standard intrinsic subroutine is pure.6 Generic names of standard intrinsic procedures are listed in 16.7. In most cases, generic functions accept argu-
ments of more than one type and the type of the result is the same as the type of the arguments. Specific names of7 If an intrinsic procedure is used as an actual argument to a procedure, its specific name shall be used and it may be referenced instandard intrinsic functions with corresponding generic names are listed in 16.8.
the called procedure only with scalar arguments. If an intrinsic procedure does not have a specific name, it shall not be used as an8 Elemental intrinsic procedures behave as described in 15.8.actual argument (<IP_ADDRESS>).
16.2 Arguments to intrinsic procedures1 All intrinsic procedures may be invoked with either positional arguments or argument keywords (15.5). The16.2.1 General rules
descriptions in 16.7 through 16.9 give the argument keyword names and positional sequence for standard intrinsicprocedures.
2 Many of the intrinsic procedures have optional arguments. These arguments are identified by the notation “optional” in the argument descriptions. In addition, the names of the optional arguments are enclosed in square3 The dummy arguments of the specific intrinsic procedures in 16.8 have INTENT (IN). The dummy arguments of the intrinsicbrackets in description headings and in lists of procedures. The valid forms of reference for procedures with
optional arguments are described in 15.5.2.
NOTE 16.1
The text CMPLX (X [, Y, KIND]) indicates that Y and KIND are both optional arguments. Valid ref-
erence forms include CMPLX(x), CMPLX(x, y), CMPLX(x, KIND=kind), CMPLX(x, y, kind), and CM-
PLX(KIND=kind, X=x, Y=y).
⃝c ISO/IEC 2017 – All rights reserved 337
ISO/IEC DIS 1539-1:2017 (E)
NOTE 16.2
Some intrinsic procedures impose additional requirements on their optional arguments. For example, SE-
LECTED_REAL_KIND requires that at least one of its optional arguments be present, and RANDOM_-
SEED requires that at most one of its optional arguments be present.
procedures in 16.9 have INTENT (IN) if the intent is not stated explicitly.4 The actual argument corresponding to an intrinsic function dummy argument named KIND shall be a scalar
integer constant expression and its value shall specify a representation method for the function result that exists5 Intrinsic subroutines that assign values to arguments of type character do so in accordance with the rules ofon the processor.
intrinsic assignment (<IP_ADDRESS>).6 In a reference to the intrinsic subroutine MVBITS, the actual arguments corresponding to the TO and FROM
dummy arguments may be the same variable and may be associated scalar variables or associated array variables7 An argument to an intrinsic procedure other than ASSOCIATED, NULL, or PRESENT shall be a data object.all of whose corresponding elements are associated. Apart from this, the actual arguments in a reference to an
intrinsic subroutine shall be such that the execution of the intrinsic subroutine would satisfy the restrictions of
<IP_ADDRESS>.
16.2.2 The shape of array arguments1 Unless otherwise specified, the intrinsic inquiry functions accept array arguments for which the shape need not
be defined. The shape of array arguments to transformational and elemental intrinsic functions shall be defined.1 Some array intrinsic functions have an optional MASK argument of type logical that is used by the function to16.2.3 Mask arguments
select the elements of one or more arguments to be operated on by the function. Any element not selected by the2 The MASK affects only the value of the function, and does not affect the evaluation, prior to invoking themask need not be defined at the time the function is invoked.
function, of arguments that are array expressions.1 Some array intrinsic functions are “reduction” functions; that is, they reduce the rank of an array by collapsing16.2.4 DIM arguments and reduction functions
one dimension (or all dimensions, usually producing a scalar result). These functions have a DIM argument that2 The process of reducing a dimension usually combines the selected elements with a simple operation such ascan specify the dimension to be reduced.
addition or an intrinsic function such as MAX, but more sophisticated reductions are also provided, e.g. by1 The bit manipulation procedures are described in terms of a model for the representation and behavior of bitsCOUNT and MAXLOC.
16.3 Bit model
16.3.1 General
on a processor.2 For the purposes of these procedures, a bit is defined to be a binary digit w located at position k of a nonnegative
integer scalar object based on a model nonnegative integer defined by338 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
z−1
X
j= wk × 2k k=0and for which wk may have the value 0 or 1. This defines a sequence of bits wz−1 . . . w0 , with wz−1 the leftmost
bit and w0 the rightmost bit. The positions of bits in the sequence are numbered from right to left, with the
position of the rightmost bit being zero. The length of a sequence of bits is z. An example of a model number
compatible with the examples used in 16.4 would have z = 32, thereby defining a 32-bit integer.
3 The interpretation of a negative integer as a sequence of bits is processor dependent.
4 The inquiry function BIT_SIZE provides the value of the parameter z of the model.
5 Effectively, this model defines an integer object to consist of z bits in sequence numbered from right to left from
0 to z − 1. This model is valid only in the context of the use of such an object as the argument or result of an
intrinsic procedure that interprets that object as a sequence of bits. In all other contexts, the model defined for
an integer in 16.4 applies. In particular, whereas the models are identical for r = 2 and wz−1 = 0, they do not
correspond for r ̸= 2 or wz−1 = 1 and the interpretation of bits in such objects is processor dependent.
16.3.2 Bit sequence comparisons 1 When bit sequences of unequal length are compared, the shorter sequence is considered to be extended to the
length of the longer sequence by padding with zero bits on the left.2 Bit sequences are compared from left to right, one bit at a time, until unequal bits are found or all bits have been
compared and found to be equal. If unequal bits are found, the sequence with zero in the unequal position is1 When a boz-literal-constant is the argument A of the intrinsic function INT or REAL,considered to be less than the sequence with one in the unequal position. Otherwise the sequences are considered
to be equal.
16.3.3 Bit sequences as arguments to INT and REAL
• if the length of the sequence of bits specified by A is less than the size in bits of a scalar variable of theC1601 If a boz-literal-constant is truncated as an argument to the intrinsic function REAL, the discarded bitssame type and kind type parameter as the result, the boz-literal-constant is treated as if it were extended
to a length equal to the size in bits of the result by padding on the left with zero bits, and
• if the length of the sequence of bits specified by A is greater than the size in bits of a scalar variable of the
same type and kind type parameter as the result, the boz-literal-constant is treated as if it were truncated
from the left to a length equal to the size in bits of the result.
shall all be zero.NOTE 16.3
The result values of the intrinsic functions CMPLX and DBLE are defined by references to the intrinsic
function REAL with the same arguments. Therefore, the padding and truncation of boz-literal-constant
arguments to those intrinsic functions is the same as for the intrinsic function REAL.
1 The numeric manipulation and inquiry functions are described in terms of a model for the representation and
16.4 Numeric models
behavior of numbers on a processor. The model has parameters that are determined so as to make the model2 The model set for integer i is defined bybest fit the machine on which the program is executed.
⃝c ISO/IEC 2017 – All rights reserved 339
ISO/IEC DIS 1539-1:2017 (E)
q−1
X
i=s× wk × rk k=0where r is an integer exceeding one, q is a positive integer, each wk is a nonnegative integer less than r, and s is
+1 or −1. The integer parameters r and q determine the set of model integers.
3 The model set for real x is defined by
0 or
p
x= s×b ×where b and p are integers exceeding one; each fk is a nonnegative integer less than b, with f1 nonzero; s is e
fk × b−k
k=1
+1 or −1; and e is an integer that lies between some integer maximum emax and some integer minimum emin
inclusively. For x = 0, its exponent e and digits fk are defined to be zero. The integer parameters b, p, emin , and
emax determine the set of model floating-point numbers.
4 The parameters of the integer and real models are available for each representation method of the integer and real types. The parameters characterize the set of available numbers in the definition of the model. Intrinsic5 There is also an extended model set for each kind of real x; this extended model is the same as the ordinaryfunctions provide the values of some parameters and other values related to the models.
model except that there are no limits on the range of the exponent e.1 An atomic subroutine is an intrinsic subroutine that performs an action on its ATOM argument, and if it has anNOTE 16.4
Some of the function descriptions use the models
X30
i=s× wk × 2k
k=0
and
24
!
1 X
e
x = 0 or s × 2 × + fk × 2−k , −126 ≤ e ≤ 127
2
k=2
16.5 Atomic subroutines
OLD argument, determination of the value to be assigned to that argument, atomically. Definition or evaluation2 For any two executions in unordered segments of atomic subroutines whose ATOM argument is the same object,of any argument other than ATOM is not performed atomically.
the effect is as if one of the executions is performed completely before the other execution begins. Which executionis performed first is processor dependent. The sequence of atomic actions within ordered segments is specified in
5.3.5. If successive atomic subroutine invocations on image P redefine a variable atomically in segments Pi and
Pj , atomic references to that variable from image Q in a segment Qk that is unordered relative to Pi and Pj may
observe the changes in the value of that variable in any order.
3 Atomic operations shall make asynchronous progress. If a variable X on image P is defined by an atomic subroutine on image Q, image R repeatedly references X [P ] by an atomic subroutine in an unordered segment,4 If the STAT argument is present in an invocation of an atomic subroutine and no error condition occurs, it isand no other image defines X [P ] in an unordered segment, image R shall eventually receive the value assigned
340 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
by image Q, even if none of the images P , Q, or R execute an image control statement until after the definition
of X [P ] by image Q and the reception of that value by image R.
assigned the value zero.5 If the STAT argument is present in an invocation of an atomic subroutine and an error condition occurs, any
other argument that is not INTENT (IN) becomes undefined. If the ATOM argument is on a failed image, an6 If the STAT argument is not present in an invocation of an atomic subroutine and an error condition occurs,error condition occurs and the value STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_-
ENV is assigned to the STAT argument. If any other error condition occurs, the STAT argument is assigned a
processor-dependent positive value that is different from the value of STAT_FAILED_IMAGE.
error termination is initiated.1 Successful execution of a collective subroutine performs a calculation on all the images of the current team andNOTE 16.5
The properties of atomic subroutines are intended to support custom synchronization mechanisms. The
program will need to handle all possible orderings of sequences of atomic subroutine executions that can
arise as a consequence of the above rules; note that the orderings can appear to be different on different
images even in the same program execution.
16.6 Collective subroutines
assigns a computed value on one or all of them. If it is invoked by one image, it shall be invoked by the same2 Before execution of the first CHANGE TEAM statement on an image, in between executions of CHANGEstatement on all active images of its current team in segments that are not ordered with respect to each other;
corresponding references participate in the same collective computation.
TEAM and/or END TEAM statements, and after the last execution of an END TEAM statement, the sequence3 If the A argument in a reference to a collective subroutine is a coarray, the corresponding ultimate arguments onof invocations of collective subroutines shall be the same on all active images of a team. A collective subroutine
shall not be referenced when an image control statement is not permitted to be executed (for example, in a
procedure invoked from a CRITICAL construct).
C1602 A reference to a collective subroutine shall not appear in a context where an image control statement is
not permitted to appear.
all active images of the current team shall be corresponding coarrays as described in <IP_ADDRESS> If the STAT argument is present in a reference to a collective subroutine on one image, it shall be present on all
the corresponding references.5 If the STAT argument is present in a reference to a collective subroutine and its execution is successful, it is
assigned the value zero.6 If the STAT argument is present in a reference to a collective subroutine and an error condition occurs, it is
assigned a positive value and the A argument becomes undefined.7 If the STAT argument is present and the current team contains stopped images, an error condition occurs and
the value STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV is assigned to the STAT8 If the STAT argument is not present in a reference to a collective subroutine and an error condition occurs, errorargument. Otherwise, if the current team contained failed images, an error condition occurs and the value
STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV is assigned to the STAT argument.
If any other error condition occurs, the STAT argument is assigned a processor-dependent positive value that is
different from the value of STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
termination is initiated.9 If the ERRMSG argument is present in a reference to a collective subroutine and an error condition occurs, it is⃝c ISO/IEC 2017 – All rights reserved 341
ISO/IEC DIS 1539-1:2017 (E)
assigned an explanatory message, truncated or padded with blanks if required. If no error condition occurs, the1 For all of the standard intrinsic procedures, the arguments shown are the names that shall be used for argumentdefinition status and value of ERRMSG are unchanged.
NOTE 16.6
The argument A becomes undefined if an error condition occurs during execution of a collective subroutine
because it is intended to allow the processor to use A for intermediate values during calculation.
NOTE 16.7
Although the calculations performed by a collective subroutine have some internal synchronizations, a
reference to a collective subroutine is not an image control statement.
16.7 Standard generic intrinsic procedures
keywords if the keyword form is used for actual arguments.2 In the Class column of Table 16.1,NOTE 16.8
For example, a reference to CMPLX can be written in the form CMPLX (A, B, M) or in the form CM-
PLX (Y = B, KIND = M, X = A).
NOTE 16.9
Many of the argument keywords have names that are indicative of their usage. For example:
KIND Describes the kind type parameter of the result
STRING, STRING_A An arbitrary character string
BACK Controls the direction of string scan
(forward or backward)
MASK A mask to be applied to the arguments
DIM A selected dimension of an array argument
A indicates that the procedure is an atomic subroutine,C indicates that the procedure is a collective subroutine,
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 when the FROM argument is not a coarray, S indicates that the procedure is an impure subroutine, andT indicates that the procedure in a transformational function.
Table 16.1: Standard generic intrinsic procedure summary
Procedure Arguments Class Description
ABS (A) E Absolute value.
ACHAR (I [, KIND]) E Character from ASCII code value.
ACOS (X) E Arccosine (inverse cosine) function.
ACOSH (X) E Inverse hyperbolic cosine function.
ADJUSTL (STRING) E Left-justified string value.
ADJUSTR (STRING) E Right-justified string value.
AIMAG (Z) E Imaginary part of a complex number.
AINT (A [, KIND]) E Truncation toward 0 to a whole number.
342 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
Table 16.1: Standard generic intrinsic procedure summary (cont.)
Procedure Arguments Class Description
ALL (MASK) or (MASK, DIM) T Array reduced by .AND. operator. ALLOCATED (ARRAY) or (SCALAR) I Allocation status of allocatable variable. ANINT (A [, KIND]) E Nearest whole number. ANY (MASK) or (MASK, DIM) T Array reduced by .OR. operator. ASIN (X) E Arcsine (inverse sine) function. ASINH (X) E Inverse hyperbolic sine function. ASSOCIATED (POINTER [, TARGET]) I Pointer association status inquiry. ATAN (X) or (Y, X) E Arctangent (inverse tangent) function. ATAN2 (Y, X) E Arctangent (inverse tangent) function. ATANH (X) E Inverse hyperbolic tangent function. ATOMIC_ADD (ATOM, VALUE [, STAT]) A Atomic addition. ATOMIC_AND (ATOM, VALUE [, STAT]) A Atomic bitwise AND. ATOMIC_CAS (ATOM, OLD, COMPARE, A Atomic compare and swap. VALUE [, STAT])
ATOMIC_DEFINE (ATOM, VALUE [, STAT]) A Define a variable atomically. ATOMIC_FETCH_- (ATOM, VALUE, OLD A Atomic fetch and add. ADD [, STAT]) ATOMIC_FETCH_- (ATOM, VALUE, OLD A Atomic fetch and bitwise AND. AND [, STAT]) ATOMIC_FETCH_- (ATOM, VALUE, OLD A Atomic fetch and bitwise OR. OR [, STAT]) ATOMIC_FETCH_- (ATOM, VALUE, OLD A Atomic fetch and bitwise exclusive OR. XOR [, STAT]) ATOMIC_OR (ATOM, VALUE [, STAT]) A Atomic bitwise OR. ATOMIC_REF (VALUE, ATOM [, STAT]) A Reference a variable atomically. ATOMIC_XOR (ATOM, VALUE [, STAT]) A Atomic bitwise exclusive OR. BESSEL_J0 (X) E Bessel function of the 1st kind, order 0. BESSEL_J1 (X) E Bessel function of the 1st kind, order 1. BESSEL_JN (N, X) E Bessel function of the 1st kind, order N. BESSEL_JN (N1, N2, X) T Bessel functions of the 1st kind. BESSEL_Y0 (X) E Bessel function of the 2nd kind, order 0. BESSEL_Y1 (X) E Bessel function of the 2nd kind, order 1. BESSEL_YN (N, X) E Bessel function of the 2nd kind, order N. BESSEL_YN (N1, N2, X) T Bessel functions of the 2nd kind. BGE (I, J) E Bitwise greater than or equal to. BGT (I, J) E Bitwise greater than. BIT_SIZE (I) I Number of bits in integer model 16.3. BLE (I, J) E Bitwise less than or equal to. BLT (I, J) E Bitwise less than. BTEST (I, POS) E Test single bit in an integer. CEILING (A [, KIND]) E Least integer greater than or equal to A. CHAR (I [, KIND]) E Character from code value. CMPLX (X [, KIND]) or E Conversion to complex type. (X [, Y, KIND])
CO_BROADCAST (A, SOURCE_IMAGE [, C Broadcast value to images. STAT, ERRMSG])
CO_MAX (A [, RESULT_IMAGE, C Compute maximum value across images. STAT, ERRMSG])
CO_MIN (A [, RESULT_IMAGE, C Compute minimum value across images. STAT, ERRMSG])
CO_REDUCE (A, OPERATION [, C Generalized reduction across images. RESULT_IMAGE, STAT,⃝ERRMSG])
c ISO/IEC 2017 – All rights reserved 343
ISO/IEC DIS 1539-1:2017 (E)
Table 16.1: Standard generic intrinsic procedure summary (cont.)
Procedure Arguments Class Description CO_SUM (A [, RESULT_IMAGE, C Compute sum across images. STAT, ERRMSG])
COMMAND_ARGU- ( ) T Number of command arguments. MENT_COUNT
CONJG (Z) E Conjugate of a complex number. COS (X) E Cosine function. COSH (X) E Hyperbolic cosine function. COSHAPE (COARRAY [, KIND]) I Sizes of codimensions of a coarray. COUNT (MASK [, DIM, KIND]) T Logical array reduced by counting true values.
CPU_TIME (TIME) S Processor time used. CSHIFT (ARRAY, SHIFT [, DIM]) T Circular shift of an array. DATE_AND_TIME ([DATE, TIME, ZONE, S Date and time. VALUES])
DBLE (A) E Conversion to double precision real. DIGITS (X) I Significant digits in numeric model. DIM (X, Y) E Maximum of X − Y and zero. DOT_PRODUCT (VECTOR_A, T Dot product of two vectors. VECTOR_B)
DPROD (X, Y) E Double precision real product. DSHIFTL (I, J, SHIFT) E Combined left shift. DSHIFTR (I, J, SHIFT) E Combined right shift. EOSHIFT (ARRAY, SHIFT [, T End-off shift of the elements of an array. BOUNDARY, DIM])
EPSILON (X) I Model number that is small compared to 1.
ERF (X) E Error function. ERFC (X) E Complementary error function. ERFC_SCALED (X) E Scaled complementary error function. EVENT_QUERY (EVENT, COUNT [, STAT]) S Query event count. EXECUTE_COM- (COMMAND [, WAIT, S Execute a command line. MAND_LINE EXITSTAT, CMDSTAT, CMDMSG])
EXP (X) E Exponential function. EXPONENT (X) E Exponent of floating-point number. EXTENDS_TYPE_- (A, MOLD) I Dynamic type extension inquiry. OF
FAILED_IMAGES ([TEAM, KIND]) T Indices of failed images. FINDLOC (ARRAY, VALUE, DIM [, T Location(s) of a specified value. MASK, KIND, BACK]) or(ARRAY, VALUE [, MASK,
KIND, BACK])
FLOOR (A [, KIND]) E Greatest integer less than or equal to A. FRACTION (X) E Fractional part of number. GAMMA (X) E Gamma function. GET_COMMAND ([COMMAND, LENGTH, S Get program invocation command. STATUS, ERRMSG])
GET_COMMAND_- (NUMBER [, VALUE, S Get program invocation argument.  MENT_VARIABLE LENGTH, STATUS, TRIM_NAME, ERRMSG])
344 c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
Table 16.1: Standard generic intrinsic procedure summary (cont.) Procedure Arguments Class Description
GET_TEAM ([LEVEL]) T Team. HUGE (X) I Largest model number. HYPOT (X, Y) E Euclidean distance function. IACHAR (C [, KIND]) E ASCII code value for character. IALL (ARRAY, DIM [, MASK]) or T Array reduced by IAND function. (ARRAY [, MASK])
IAND (I, J) E Bitwise AND. IANY (ARRAY, DIM [, MASK]) or T Array reduced by IOR function. (ARRAY [, MASK])
IBCLR (I, POS) E I with bit POS replaced by zero. IBITS (I, POS, LEN) E Specified sequence of bits. IBSET (I, POS) E I with bit POS replaced by one. ICHAR (C [, KIND]) E Code value for character. IEOR (I, J) E Bitwise exclusive OR. IMAGE_INDEX (COARRAY, SUB) or I Image index from cosubscripts. (COARRAY, SUB, TEAM)or (COARRAY, SUB,
TEAM_NUMBER)
IMAGE_STATUS (IMAGE [, TEAM]) T Image execution state. INDEX (STRING, SUBSTRING [, E Character string search. BACK, KIND])
INT (A [, KIND]) E Conversion to integer type. IOR (I, J) E Bitwise inclusive OR. IPARITY (ARRAY, DIM [, MASK]) or T Array reduced by IEOR function. (ARRAY [, MASK])
ISHFT (I, SHIFT) E Logical shift. ISHFTC (I, SHIFT [, SIZE]) E Circular shift of the rightmost bits. IS_CONTIGUOUS (ARRAY) I Array contiguity test (8.5.7). IS_IOSTAT_END (I) E IOSTAT value test for end of file. IS_IOSTAT_EOR (I) E IOSTAT value test for end of record. KIND (X) I Value of the kind type parameter of X. LBOUND (ARRAY [, DIM, KIND]) I Lower bound(s). LCOBOUND (COARRAY [, DIM, KIND]) I Lower cobound(s) of a coarray. LEADZ (I) E Number of leading zero bits. LEN (STRING [, KIND]) I Length of a character entity. LEN_TRIM (STRING [, KIND]) E Length without trailing blanks. LGE (STRING_A, STRING_B) E ASCII greater than or equal. LGT (STRING_A, STRING_B) E ASCII greater than. LLE (STRING_A, STRING_B) E ASCII less than or equal. LLT (STRING_A, STRING_B) E ASCII less than. LOG (X) E Natural logarithm. LOG_GAMMA (X) E Logarithm of the absolute value of the gamma function.
LOG10 (X) E Common logarithm. LOGICAL (L [, KIND]) E Conversion between kinds of logical. MASKL (I [, KIND]) E Left justified mask. MASKR (I [, KIND]) E Right justified mask. MATMUL (MATRIX_A, MATRIX_B) T Matrix multiplication. MAX (A1, A2 [, A3, ...]) E Maximum value. MAXEXPONENT (X) I Maximum exponent of a real model. MAXLOC (ARRAY, DIM [, MASK, T Location(s) of maximum value. KIND, BACK]) or (ARRAY⃝[, MASK, KIND, BACK])
c ISO/IEC 2017 – All rights reserved 345
ISO/IEC DIS 1539-1:2017 (E)
Table 16.1: Standard generic intrinsic procedure summary (cont.)
Procedure Arguments Class Description MAXVAL (ARRAY, DIM [, MASK]) or T Maximum value(s) of array. (ARRAY [, MASK])
MERGE (TSOURCE, FSOURCE, E Expression value selection. MASK)
MERGE_BITS (I, J, MASK) E Merge of bits under mask. MIN (A1, A2 [, A3, ...]) E Minimum value. MINEXPONENT (X) I Minimum exponent of a real model. MINLOC (ARRAY, DIM [, MASK, T Location(s) of minimum value. KIND, BACK]) or (ARRAY[, MASK, KIND, BACK])
MINVAL (ARRAY, DIM [, MASK]) or T Minimum value(s) of array. (ARRAY [, MASK])
MOD (A, P) E Remainder function. MODULO (A, P) E Modulo function. MOVE_ALLOC (FROM, TO [, STAT, PS Move an allocation. ERRMSG])
MVBITS (FROM, FROMPOS, LEN, ES Copy a sequence of bits. TO, TOPOS)
NEAREST (X, S) E Adjacent machine number. NEW_LINE (A) I Newline character. NINT (A [, KIND]) E Nearest integer. NORM2 (X) or (X, DIM) T L2 norm of an array. NOT (I) E Bitwise complement. NULL ([MOLD]) T Disassociated pointer or unallocated al- locatable entity.
NUM_IMAGES ( ) or (TEAM) or (TEAM_- T Number of images. NUMBER)
OUT_OF_RANGE (X, MOLD [, ROUND]) E Whether a value cannot be converted safely.
PACK (ARRAY, MASK [, T Array packed into a vector. VECTOR])
PARITY (MASK) or (MASK, DIM) T Array reduced by .NEQV. operator. POPCNT (I) E Number of one bits. POPPAR (I) E Parity expressed as 0 or 1. PRECISION (X) I Decimal precision of a real model. PRESENT (A) I Presence of optional argument. PRODUCT (ARRAY, DIM [, MASK]) or T Array reduced by multiplication. (ARRAY [, MASK])
RADIX (X) I Base of a numeric model. RANDOM_INIT (REPEATABLE, IMAGE_- S Initialise the pseudorandom number DISTINCT) generator.
RANDOM_NUMBER (HARVEST) S Generate pseudorandom number(s). RANDOM_SEED ([SIZE, PUT, GET]) S Restart or query the pseudorandom number generator.
RANGE (X) I Decimal exponent range of a numeric model (16.4).
RANK (A) I Rank of a data object. REAL (A [, KIND]) E Conversion to real type. REDUCE (ARRAY, OPERATION, T General reduction of array DIM [, MASK, IDENTITY,ORDERED]) or (ARRAY,
OPERATION [, MASK,
IDENTITY, ORDERED])
346 c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
Table 16.1: Standard generic intrinsic procedure summary (cont.) Procedure Arguments Class Description
REPEAT (STRING, NCOPIES) T Repetitive string concatenation. RESHAPE (SOURCE, SHAPE [, PAD, T Arbitrary shape array construction. ORDER])
RRSPACING (X) E Reciprocal of relative spacing of model numbers.
SAME_TYPE_AS (A, B) I Dynamic type equality test. SCALE (X, I) E Real number scaled by radix power. SCAN (STRING, SET [, BACK, E Character set membership search. KIND])
SELECTED_CHAR_- (NAME) T Character kind selection. KIND
SELECTED_INT_- (R) T Integer kind selection. KIND
SELECTED_REAL_- ([P, R, RADIX]) T Real kind selection. KIND
SET_EXPONENT (X, I) E Real value with specified exponent. SHAPE (SOURCE [, KIND]) I Shape of an array or a scalar. SHIFTA (I, SHIFT) E Right shift with fill. SHIFTL (I, SHIFT) E Left shift. SHIFTR (I, SHIFT) E Right shift. SIGN (A, B) E Magnitude of A with the sign of B. SIN (X) E Sine function. SINH (X) E Hyperbolic sine function. SIZE (ARRAY [, DIM, KIND]) I Size of an array or one extent. SPACING (X) E Spacing of model numbers. SPREAD (SOURCE, DIM, NCOPIES) T Value replicated in a new dimension. SQRT (X) E Square root. STOPPED_IMAGES ([TEAM, KIND]) T Indices of stopped images. STORAGE_SIZE (A [, KIND]) I Storage size in bits. SUM (ARRAY, DIM [, MASK]) or T Array reduced by addition. (ARRAY [, MASK])
SYSTEM_CLOCK ([COUNT, COUNT_RATE, S Query system clock. COUNT_MAX])
TAN (X) E Tangent function. TANH (X) E Hyperbolic tangent function. TEAM_NUMBER ([TEAM]) T Team number. THIS_IMAGE ([TEAM]) T Index of the invoking image. THIS_IMAGE (COARRAY [, TEAM]) or T Cosubscript(s) for this image. (COARRAY, DIM [,TEAM])
TINY (X) I Smallest positive model number. TRAILZ (I) E Number of trailing zero bits. TRANSFER (SOURCE, MOLD [, SIZE]) T Transfer physical representation. TRANSPOSE (MATRIX) T Transpose of an array of rank two. TRIM (STRING) T String without trailing blanks. UBOUND (ARRAY [, DIM, KIND]) I Upper bound(s). UCOBOUND (COARRAY [, DIM, KIND]) I Upper cobound(s) of a coarray. UNPACK (VECTOR, MASK, FIELD) T Vector unpacked into an array. VERIFY (STRING, SET [, BACK, E Character set non-membership search. KIND])3 The effect of calling EXECUTE_COMMAND_LINE on any image other than image 1 in the initial team is
processor dependent.4 If RANDOM_INIT or RANDOM_SEED is called in a segment A, and RANDOM_INIT, RANDOM_SEED, or⃝c ISO/IEC 2017 – All rights reserved 347
ISO/IEC DIS 1539-1:2017 (E)
RANDOM_NUMBER is called in segment B, then segments A and B shall be ordered. It is processor dependent5 The use of all other standard intrinsic procedures in unordered segments is subject only to their argument usewhether each image uses a separate random number generator, or if some or all images use common random
number generators.
following the rules in <IP_ADDRESS> Except for AMAX0, AMIN0, MAX1, and MIN1, the result type of the specific function is the same that the result type of the16.8 Specific names for standard intrinsic functions
corresponding generic function reference would be if it were invoked with the same arguments as the specific function.2 A function listed in Table 16.3 is not permitted to be used as an actual argument (15.5.1, C1534), as a target in a procedure
pointer assignment statement (<IP_ADDRESS>, C1030), as an initial target in a procedure declaration statement (<IP_ADDRESS>, C1519), or to1 Detailed specifications of the standard generic intrinsic procedures are provided in 16.9 in alphabetical order.specify an interface (<IP_ADDRESS>, C1515).
Table 16.2: Unrestricted specific intrinsic functions
Specific name Generic name Argument type and kind
ABS ABS default real
ACOS ACOS default real
AIMAG AIMAG default complex
AINT AINT default real
ALOG LOG default real
ALOG10 LOG10 default real
AMOD MOD default real
ANINT ANINT default real
ASIN ASIN default real
ATAN ATAN (X) default real
ATAN2 ATAN2 default real
CABS ABS default complex
CCOS COS default complex
CEXP EXP default complex
CLOG LOG default complex
CONJG CONJG default complex
COS COS default real
COSH COSH default real
CSIN SIN default complex
CSQRT SQRT default complex
DABS ABS double precision real
DACOS ACOS double precision real
DASIN ASIN double precision real
DATAN ATAN double precision real
DATAN2 ATAN2 double precision real
DCOS COS double precision real
DCOSH COSH double precision real
DDIM DIM double precision real
DEXP EXP double precision real
DIM DIM default real
DINT AINT double precision real
DLOG LOG double precision real
DLOG10 LOG10 double precision real
DMOD MOD double precision real
DNINT ANINT double precision real
DPROD DPROD default real
DSIGN SIGN double precision real
DSIN SIN double precision real
DSINH SINH double precision real
DSQRT SQRT double precision real
DTAN TAN double precision real
DTANH TANH double precision real
EXP EXP default real
IABS ABS default integer
IDIM DIM default integer
IDNINT NINT double precision real
INDEX INDEX default character
348 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
Unrestricted specific intrinsic functions (cont.)
Specific name Generic name Argument type and kind
ISIGN SIGN default integer
LEN LEN default character
MOD MOD default integer
NINT NINT default real
SIGN SIGN default real
SIN SIN default real
SINH SINH default real
SQRT SQRT default real
TAN TAN default real
TANH TANH default real
Table 16.3: Restricted specific intrinsic functions
Specific name Generic name Argument type and kind
AMAX0 (. . . ) REAL (MAX (. . . )) default integer
AMAX1 MAX default real
AMIN0 (. . . ) REAL (MIN (. . . )) default integer
AMIN1 MIN default real
CHAR CHAR default integer
DMAX1 MAX double precision real
DMIN1 MIN double precision real
FLOAT REAL default integer
ICHAR ICHAR default character
IDINT INT double precision real
IFIX INT default real
INT INT default real
LGE LGE default character
LGT LGT default character
LLE LLE default character
LLT LLT default character
MAX0 MAX default integer
MAX1 (. . . ) INT (MAX (. . . )) default real
MIN0 MIN default integer
MIN1 (. . . ) INT (MIN (. . . )) default real
REAL REAL default integer
SNGL REAL double precision real
16.9 Specifications of the standard intrinsic procedures
16.9.1 General
2 The types and type parameters of standard intrinsic procedure arguments and function results are determined
by these specifications. The “Argument(s)” paragraphs specify requirements on the actual arguments of the3 If an IEEE infinity is assigned or returned by an intrinsic procedure, the intrinsic module IEEE_ARITHMETICprocedures. The result characteristics are sometimes specified in terms of the characteristics of the arguments. A
program shall not invoke an intrinsic procedure under circumstances where a value to be assigned to a subroutine
argument or returned as a function result is not representable by objects of the specified type and type parameters.
is accessible, and the actual arguments were finite numbers, the flag IEEE_OVERFLOW or IEEE_DIVIDE_-1 Description. Absolute value.BY_ZERO shall signal. If an IEEE NaN is assigned or returned, the actual arguments were finite numbers, the
intrinsic module IEEE_ARITHMETIC is accessible, and the exception IEEE_INVALID is supported, the flag
IEEE_INVALID shall signal. If no IEEE infinity or NaN is assigned or returned, these flags shall have the same
status as when the intrinsic procedure was invoked.
⃝c ISO/IEC 2017 – All rights reserved 349
ISO/IEC DIS 1539-1:2017 (E)
16.9.2 ABS (A)
2 Class. Elemental function.
3 Argument. A shall be of type integer, real, or complex.
4 Result Characteristics. The same as A except that if A is complex, the result is real.
5 Result Value. If A is of type integer or real, the value of thep result is |A|; if A is complex with value (x, y), the result is equal to a processor-dependent approximation to x2 + y 2 computed without undue overflow or6 Example. ABS ((3.0, 4.0)) has the value 5.0 (approximately).underflow.
16.9.3 ACHAR (I [, KIND])1 Description. Character from ASCII code value.
2 Class. Elemental function. 3 Arguments. I shall be of type integer.4 Result Characteristics. Character of length one. If KIND is present, the kind type parameter is that specifiedKIND (optional) shall be a scalar integer constant expression.
by the value of KIND; otherwise, the kind type parameter is that of default character.5 Result Value. If I has a value in the range 0 ≤ I ≤ 127, the result is the character in position I of the ASCII
collating sequence, provided the processor is capable of representing that character in the character kind of the6 Example. ACHAR (88) has the value ’X’.result; otherwise, the result is processor dependent. ACHAR (IACHAR (C)) shall have the value C for any
character C capable of representation as a default character.
16.9.4 ACOS (X)1 Description. Arccosine (inverse cosine) function.
2 Class. Elemental function. 3 Argument. X shall be of type real with a value that satisfies the inequality |X| ≤ 1, or of type complex. 4 Result Characteristics. Same as X. 5 Result Value. The result has a value equal to a processor-dependent approximation to arccos(X). If it is real it is expressed in radians and lies in the range 0 ≤ ACOS (X) ≤ π. If it is complex the real part is expressed in6 Example. ACOS (0.54030231) has the value 1.0 (approximately).radians and lies in the range 0 ≤ REAL (ACOS (X)) ≤ π.
16.9.5 ACOSH (X)1 Description. Inverse hyperbolic cosine function.
2 Class. Elemental function. 3 Argument. X shall be of type real or complex. 350 ⃝4 Result Characteristics. Same as X.c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
5 Result Value. The result has a value equal to a processor-dependent approximation to the inverse hyperbolic cosine function of X. If the result is complex the imaginary part is expressed in radians and lies in the range6 Example. ACOSH (1.5430806) has the value 1.0 (approximately).0 ≤ AIMAG (ACOSH (X)) ≤ π
16.9.6 ADJUSTL (STRING)1 Description. Left-justified string value.
2 Class. Elemental function. 3 Argument. STRING shall be of type character. 4 Result Characteristics. Character of the same length and kind type parameter as STRING. 5 Result Value. The value of the result is the same as STRING except that any leading blanks have been deleted and the same number of trailing blanks have been inserted.6 Example. ADJUSTL (’ WORD’) has the value ’WORD ’.
16.9.7 ADJUSTR (STRING)1 Description. Right-justified string value.
2 Class. Elemental function. 3 Argument. STRING shall be of type character. 4 Result Characteristics. Character of the same length and kind type parameter as STRING. 5 Result Value. The value of the result is the same as STRING except that any trailing blanks have been deleted and the same number of leading blanks have been inserted.6 Example. ADJUSTR (’WORD ’) has the value ’ WORD’.
16.9.8 AIMAG (Z)1 Description. Imaginary part of a complex number.
2 Class. Elemental function. 3 Argument. Z shall be of type complex. 4 Result Characteristics. Real with the same kind type parameter as Z. 5 Result Value. If Z has the value (x, y), the result has the value y. 6 Example. AIMAG ((2.0, 3.0)) has the value 3.0. 16.9.9 AINT (A [, KIND])1 Description. Truncation toward 0 to a whole number.
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Result Characteristics. The result is of type real. If KIND is present, the kind type parameter is that specifiedKIND (optional) shall be a scalar integer constant expression.
⃝c ISO/IEC 2017 – All rights reserved 351
ISO/IEC DIS 1539-1:2017 (E)
by the value of KIND; otherwise, the kind type parameter is that of A.5 Result Value. If |A| < 1, AINT (A) has the value 0; if |A| ≥ 1, AINT (A) has a value equal to the integer
whose magnitude is the largest integer that does not exceed the magnitude of A and whose sign is the same as6 Examples. AINT (2.783) has the value 2.0.  Array reduced by .AND. operator.
2 Class. Transformational function. 3 Arguments. MASK shall be a logical array.4 Result Characteristics. The result is of type logical with the same kind type parameter as MASK. It is scalarDIM shall be an integer scalar with value in the range 1 ≤ DIM ≤ n, where n is the rank of MASK.
if DIM does not appear or n = 1; otherwise, the result has rank n − 1 and shape [d1 , d2 , . . . , dDIM−1 , dDIM+1 ,5 Result Value.. . . , dn ] where [d1 , d2 , . . . , dn ] is the shape of MASK.
Case (i): The result of ALL (MASK) has the value true if all elements of MASK are true or if MASK has6 Examples.size zero, and the result has value false if any element of MASK is false.
Case (ii): If MASK has rank one, ALL (MASK, DIM) is equal to ALL (MASK).
Case (i): The value of ALL ([.TRUE., .FALSE., .TRUE.]) is false.1 Description. Allocation status of allocatable variable.
1 3 5 0 3 5
Case (ii): If B is the array and C is the array then ALL (B /= C, DIM = 1) is
2 4 6 7 4 8
[true, false, false] and ALL (B /= C, DIM = 2) is [false, false].
16.9.11 ALLOCATED (ARRAY) or ALLOCATED (SCALAR)
2 Class. Inquiry function. 3 Arguments. ARRAY shall be an allocatable array.4 Result Characteristics. Default logical scalar.SCALAR shall be an allocatable scalar.
5 Result Value. The result has the value true if the argument (ARRAY or SCALAR) is allocated and has the value false if the argument is unallocated.1 Description. Nearest whole number.16.9.12 ANINT (A [, KIND])
2 Class. Elemental function. 352 ⃝3 Arguments.c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
A shall be of type real.4 Result Characteristics. The result is of type real. If KIND is present, the kind type parameter is that specifiedKIND (optional) shall be a scalar integer constant expression.
by the value of KIND; otherwise, the kind type parameter is that of A.5 Result Value. The result is the integer nearest A, or if there are two integers equally near A, the result is
whichever such integer has the greater magnitude.6 Examples. ANINT (2.783) has the value 3.0. ANINT (−2.783) has the value −3.0.
16.9.13 ANY (MASK) or ANY (MASK, DIM)1 Description. Array reduced by .OR. operator.
2 Class. Transformational function. 3 Arguments. MASK shall be a logical array.4 Result Characteristics. The result is of type logical with the same kind type parameter as MASK. It is scalarDIM shall be an integer scalar with a value in the range 1 ≤ DIM ≤ n, where n is the rank of MASK.
if DIM does not appear or n = 1; otherwise, the result has rank n − 1 and shape [d1 , d2 , . . . , dDIM−1 , dDIM+1 ,5 Result Value.. . . , dn ] where [d1 , d2 , . . . , dn ] is the shape of MASK.
Case (i): The result of ANY (MASK) has the value true if any element of MASK is true and has the value6 Examples.false if no elements are true or if MASK has size zero.
Case (ii): If MASK has rank one, ANY (MASK, DIM) is equal to ANY (MASK).
Case (i): The value of ANY ([.TRUE., .FALSE., .TRUE.]) is true.1 Description. Arcsine (inverse sine) function.
1 3 5 0 3 5
Case (ii): If B is the array and C is the array then ANY (B /= C, DIM = 1) is
2 4 6 7 4 8
[true, false, true] and ANY (B /= C, DIM = 2) is [true, true].
16.9.14 ASIN (X)
2 Class. Elemental function. 3 Argument. X shall be of type real with a value that satisfies the inequality |X| ≤ 1, or of type complex. 4 Result Characteristics. Same as X. 5 Result Value. The result has a value equal to a processor-dependent approximation to arcsin(X). If it is real it is expressed in radians and lies in the range −π/2 ≤ ASIN (X) ≤ π/2. If it is complex the real part is expressed6 Example. ASIN (0.84147098) has the value 1.0 (approximately).in radians and lies in the range −π/2 ≤ REAL (ASIN (X)) ≤ π/2.
⃝c ISO/IEC 2017 – All rights reserved 3531 Description. Inverse hyperbolic sine function.
ISO/IEC DIS 1539-1:2017 (E)
16.9.15 ASINH (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 the inverse hyperbolic sine function of X. If the result is complex the imaginary part is expressed in radians and lies in the range6 Example. ASINH (1.1752012) has the value 1.0 (approximately).−π/2 ≤ AIMAG (ASINH (X)) ≤ π/2.
16.9.16 ASSOCIATED (POINTER [, TARGET])1 Description. Pointer association status inquiry.
2 Class. Inquiry function. 3 Arguments. POINTER shall be a pointer. It may be of any type or may be a procedure pointer. Its pointer association4 Result Characteristics. Default logical scalar.status shall not be undefined.
TARGET (optional) shall be allowable as the data-target or proc-target in a pointer assignment statement (10.2.2)
in which POINTER is data-pointer-object or proc-pointer-object. If TARGET is a pointer then its
pointer association status shall not be undefined.
5 Result Value. Case (i): If TARGET is absent, the result is true if and only if POINTER is associated with a target.6 Examples. ASSOCIATED (CURRENT, HEAD) is true if CURRENT is associated with the target HEAD.Case (ii): If TARGET is present and is a procedure, the result is true if and only if POINTER is associated
with TARGET and, if TARGET is an internal procedure, they have the same host instance.
Case (iii): If TARGET is present and is a procedure pointer, the result is true if and only if POINTER and
TARGET are associated with the same procedure and, if the procedure is an internal procedure,
they have the same host instance.
Case (iv): If TARGET is present and is a scalar target, the result is true if and only if TARGET is not a zero-
sized storage sequence and POINTER is associated with a target that occupies the same storage
units as TARGET.
Case (v): If TARGET is present and is an array target, the result is true if and only if POINTER is associated
with a target that has the same shape as TARGET, is neither of size zero nor an array whose elements
are zero-sized storage sequences, and occupies the same storage units as TARGET in array element
order.
Case (vi): If TARGET is present and is a scalar pointer, the result is true if and only if POINTER and
TARGET are associated, the targets are not zero-sized storage sequences, and they occupy the
same storage units.
Case (vii): If TARGET is present and is an array pointer, the result is true if and only if POINTER and
TARGET are both associated, have the same shape, are neither of size zero nor arrays whose
elements are zero-sized storage sequences, and occupy the same storage units in array element
order.
354 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
NOTE 16.10
The references to TARGET in the above cases are referring to properties that might be possessed by the
actual argument, so the case of TARGET being a disassociated pointer will be covered by case (iii), (vi),
or (vii).
After the execution of1 Description. Arctangent (inverse tangent) function.A_PART => A (:N)
ASSOCIATED (A_PART, A) is true if N is equal to UBOUND (A, DIM = 1). After the execution of
NULLIFY (CUR); NULLIFY (TOP)
ASSOCIATED (CUR, TOP) is false.
16.9.17 ATAN (X) or ATAN (Y, X)
2 Class. Elemental function. 3 Arguments. Y shall be of type real.4 Result Characteristics. Same as X.X If Y appears, X shall be of type real with the same kind type parameter as Y. If Y has the value
zero, X shall not have the value zero. If Y does not appear, X shall be of type real or complex.
5 Result Value. If Y appears, the result is the same as the result of ATAN2 (Y,X). If Y does not appear, the result has a value equal to a processor-dependent approximation to arctan(X) whose real part is expressed in6 Example. ATAN (1.5574077) has the value 1.0 (approximately).radians and lies in the range −π/2 ≤ ATAN (X) ≤ π/2.
16.9.18 ATAN2 (Y, X)1 Description. Arctangent (inverse tangent) function.
2 Class. Elemental function. 3 Arguments. Y shall be of type real.4 Result Characteristics. Same as X.X shall be of the same type and kind type parameter as Y. If Y has the value zero, X shall not have
the value zero.
5 Result Value. The result has a value equal to a processor-dependent approximation to the principal value of the argument of the complex number (X, Y), expressed in radians. It lies in the range −π ≤ ATAN2 (Y,X)≤ π and is equal to a processor-dependent approximation to a value of arctan(Y/X) if X ̸= 0. If Y > 0, the
result is positive. If Y = 0 and X > 0, the result is Y. If Y = 0 and X < 0, then the result is approximately
π if Y is positive real zero or the processor does not distinguish between positive and negative real zero, and
approximately −π if Y is negative real zero. If Y < 0, the result is negative. If X = 0, the absolute value of the
result is approximately π/2.
1 1
6 Examples. ATAN2 (1.5574077, 1.0) has the value 1.0 (approximately). If Y has the value and X −1 −1
−1 1 3π/4 π/4
has the value , the value of ATAN2 (Y, X) is approximately . −1 1 −3π/4 −π/4
⃝c ISO/IEC 2017 – All rights reserved 355
ISO/IEC DIS 1539-1:2017 (E)
16.9.19 ATANH (X) 1 Description. Inverse 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 the inverse hyperbolic
tangent function of X. If the result is complex the imaginary part is expressed in radians and lies in the range6 Example. ATANH (0.76159416) has the value 1.0 (approximately).−π/2 ≤ AIMAG (ATANH (X)) ≤ π/2.
16.9.20 ATOMIC_ADD (ATOM, VALUE [, STAT])1 Description. Atomic addition.
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_ADD (I [3], 42) will cause I on image 3 to become defined with the value 46 if theKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of ATOM + VALUE.
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The values of VALUE and ATOM +
VALUE shall be representable in kind ATOMIC_INT_KIND.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
value of I [3] is 4 when the atomic operation is executed.1 Description. Atomic bitwise AND.16.9.21 ATOMIC_AND (ATOM, VALUE [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_AND (I [3], 6) will cause I on image 3 to become defined with the value 4 if theKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IAND (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
value of I [3] is 5 when the atomic operation is executed.1 Description. Atomic compare and swap.356 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
16.9.22 ATOMIC_CAS (ATOM, OLD, COMPARE, NEW [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. If the value of I on image 3 is equal to 13 at the beginning of the atomic operation performed byKIND from the intrinsic module ISO_FORTRAN_ENV, or of type logical with kind ATOMIC_-
LOGICAL_KIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT)
argument. If an error condition occurs, ATOM becomes undefined; otherwise, if ATOM is of type
integer and equal to COMPARE, or of type logical and equivalent to COMPARE, it becomes defined
with the value of NEW.
OLD shall be scalar and of the same type and kind as ATOM. It is an INTENT (OUT) argument. If
an error condition occurs, it becomes undefined; otherwise, it becomes defined with the value that
ATOM had at the start of the atomic operation.
COMPARE shall be scalar and of the same type and kind as ATOM. It is an INTENT (IN) argument.
NEW shall be scalar and of the same type and kind as ATOM. It is an INTENT (IN) argument.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
CALL ATOMIC_CAS (I [3], OLD, 0, 1), the value of I on image 3 will be unchanged, and OLD will become1 Description. Define a variable atomically.defined with the value 13. If the value of I on image 3 is equal to 0 at the beginning of the atomic operation
performed by CALL ATOMIC_CAS (I [3], OLD, 0, 1), I on image 3 will become defined with the value 1, and
OLD will become defined with the value 0.
16.9.23 ATOMIC_DEFINE (ATOM, VALUE [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_DEFINE (I [3], 4) causes I on image 3 to become defined with the value 4.KIND from the intrinsic module ISO_FORTRAN_ENV, or of type logical with kind ATOMIC_-
LOGICAL_KIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (OUT)
argument. On successful execution, it becomes defined with the value of VALUE. If an error
condition occurs, it becomes undefined.
VALUE shall be scalar and of the same type as ATOM. It is an INTENT (IN) argument.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
16.9.24 ATOMIC_FETCH_ADD (ATOM, VALUE, OLD [, STAT])1 Description. Atomic fetch and add.
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_FETCH_ADD (I [3], 7, J) will cause I on image 3 to become defined with the value⃝c ISO/IEC 2017 – All rights reserved 357
ISO/IEC DIS 1539-1:2017 (E)
KIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of ATOM + VALUE.
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The values of VALUE and ATOM +
VALUE shall be representable in kind ATOMIC_INT_KIND.
OLD shall be scalar and of the same type and kind as ATOM. It is an INTENT (OUT) argument. If
an error condition occurs, it becomes undefined; otherwise, it becomes defined with the value that
ATOM had at the start of the atomic operation.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
12, and J to become defined with the value 5, if the value of I [3] is 5 when the atomic operation is executed.1 Description. Atomic fetch and bitwise AND.16.9.25 ATOMIC_FETCH_AND (ATOM, VALUE, OLD [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_FETCH_AND (I [3], 6, J) will cause I on image 3 to become defined with the valueKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IAND (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
OLD shall be scalar and of the same type and kind as ATOM. It is an INTENT (OUT) argument. If
an error condition occurs, it becomes undefined; otherwise, it becomes defined with the value that
ATOM had at the start of the atomic operation.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
4, and J to become defined with the value 5, if the value of I [3] is 5 when the atomic operation is executed.1 Description. Atomic fetch and bitwise OR.16.9.26 ATOMIC_FETCH_OR (ATOM, VALUE, OLD [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_FETCH_OR (I [3], 1, J) will cause I on image 3 to become defined with the valueKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IOR (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
OLD shall be scalar and of the same type and kind as ATOM. It is an INTENT (OUT) argument. If
an error condition occurs, it becomes undefined; otherwise, it becomes defined with the value that
ATOM had at the start of the atomic operation.
358 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
3, and J to become defined with the value 2, if the value of I [3] is 2 when the atomic operation is executed.1 Description. Atomic fetch and bitwise exclusive OR.16.9.27 ATOMIC_FETCH_XOR (ATOM, VALUE, OLD [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_FETCH_XOR (I [3], 1, J) will cause I on image 3 to become defined with the valueKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IEOR (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
OLD shall be scalar and of the same type and kind as ATOM. It is an INTENT (OUT) argument. If
an error condition occurs, it becomes undefined; otherwise, it becomes defined with the value that
ATOM had at the start of the atomic operation.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
2, and J to become defined with the value 3, if the value of I [3] is 3 when the atomic operation is executed.1 Description. Atomic bitwise OR.16.9.28 ATOMIC_OR (ATOM, VALUE [, STAT])
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_OR (I [3], 1) will cause I on image 3 to become defined with the value 3 if the valueKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IOR (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
of I [3] is 2 when the atomic operation is executed.1 Description. Reference a variable atomically.16.9.29 ATOMIC_REF (VALUE, ATOM [, STAT])
2 Class. Atomic subroutine.
⃝c ISO/IEC 2017 – All rights reserved 3593 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
VALUE shall be scalar and of the same type as ATOM. It is an INTENT (OUT) argument. On successful4 Example. CALL ATOMIC_REF (VAL, I [3]) causes VAL to become defined with the value of I on image 3.execution, it becomes defined with the value of ATOM. If an error condition occurs, it becomes
undefined.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-
KIND from the intrinsic module ISO_FORTRAN_ENV, or of type logical with kind ATOMIC_LO-
GICAL_KIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (IN) argument.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
16.9.30 ATOMIC_XOR (ATOM, VALUE [, STAT])1 Description. Atomic bitwise exclusive OR.
2 Class. Atomic subroutine.
3 Arguments.
ATOM shall be a scalar coarray or coindexed object. It shall be of type integer with kind ATOMIC_INT_-4 Example. CALL ATOMIC_XOR (I [3], 1) will cause I on image 3 to become defined with the value 2 if theKIND from the intrinsic module ISO_FORTRAN_ENV. It is an INTENT (INOUT) argument. If
an error condition occurs, ATOM becomes undefined; otherwise, it becomes defined with the value
of IEOR (ATOM, INT (VALUE, ATOMIC_INT_KIND)).
VALUE shall be an integer scalar. It is an INTENT (IN) argument. The value of VALUE shall be repres-
entable in kind ATOMIC_INT_KIND.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument. It is assigned a value as specified in 16.5. If an error condition occurs
and STAT is not present, error termination is initiated.
value of I [3] is 3 when the atomic operation is executed.1 Description. Bessel function of the 1st kind, order <IP_ADDRESS> BESSEL_J0 (X)
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to the Bessel function of
the first kind and order zero of X.6 Example. BESSEL_J0 (1.0) has the value 0.765 (approximately).
16.9.32 BESSEL_J1 (X)1 Description. Bessel function of the 1st kind, order 1.
2 Class. Elemental function.
3 Argument. X shall be of type real.
4 Result Characteristics. Same as X.
360 ⃝c ISO/IEC 2017 – All rights reserved5 Result Value. The result has a value equal to a processor-dependent approximation to the Bessel function of
ISO/IEC DIS 1539-1:2017 (E)
the first kind and order one of X.6 Example. BESSEL_J1 (1.0) has the value 0.440 (approximately).
16.9.33 BESSEL_JN (N, X) or BESSEL_JN (N1, N2, X)1 Description. Bessel functions of the 1st kind.
2 Class.
Case (i): BESSEL_JN (N,X) is an elemental function.3 Arguments.Case (ii): BESSEL_JN (N1,N2,X) is a transformational function.
N shall be of type integer and nonnegative.4 Result Characteristics. Same type and kind as X. The result of BESSEL_JN (N1, N2, X) is a rank-one arrayN1 shall be an integer scalar with a nonnegative value.
N2 shall be an integer scalar with a nonnegative value.
X shall be of type real; if the function is transformational, X shall be scalar.
with extent MAX (N2−N1+1, 0).5 Result Value.
Case (i): The result value of BESSEL_JN (N, X) is a processor-dependent approximation to the Bessel6 Example. BESSEL_JN (2, 1.0) has the value 0.115 (approximately).function of the first kind and order N of X.
Case (ii): Element i of the result value of BESSEL_JN (N1, N2, X) is a processor-dependent approximation
to the Bessel function of the first kind and order N1+i − 1 of X.
16.9.34 BESSEL_Y0 (X)1 Description. Bessel function of the 2nd kind, order 0.
2 Class. Elemental function.
3 Argument. X shall be of type real. Its value shall be greater than zero.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to the Bessel function of
the second kind and order zero of X.6 Example. BESSEL_Y0 (1.0) has the value 0.088 (approximately).
16.9.35 BESSEL_Y1 (X)1 Description. Bessel function of the 2nd kind, order 1.
2 Class. Elemental function.
3 Argument. X shall be of type real. Its value shall be greater than zero.
4 Result Characteristics. Same as X.
5 Result Value. The result has a value equal to a processor-dependent approximation to the Bessel function of
the second kind and order one of X.6 Example. BESSEL_Y1 (1.0) has the value −0.781 (approximately).⃝c ISO/IEC 2017 – All rights reserved 361
ISO/IEC DIS 1539-1:2017 (E)
16.9.36 BESSEL_YN (N, X) or BESSEL_YN (N1, N2, X)1 Description. Bessel functions of the 2nd kind.
2 Class.
Case (i): BESSEL_YN (N, X) is an elemental function.3 Arguments.Case (ii): BESSEL_YN (N1, N2, X) is a transformational function.
N shall be of type integer and nonnegative.4 Result Characteristics. Same type and kind as X. The result of BESSEL_YN (N1, N2, X) is a rank-one arrayN1 shall be an integer scalar with a nonnegative value.
N2 shall be an integer scalar with a nonnegative value.
X shall be of type real; if the function is transformational, X shall be scalar. Its value shall be greater
than zero.
with extent MAX (N2−N1+1, 0).5 Result Value.
Case (i): The result value of BESSEL_YN (N, X) is a processor-dependent approximation to the Bessel6 Example. BESSEL_YN (2, 1.0) has the value −1.651 (approximately).function of the second kind and order N of X.
Case (ii): Element i of the result value of BESSEL_YN (N1, N2, X) is a processor-dependent approximation
to the Bessel function of the second kind and order N1+i − 1 of X.
16.9.37 BGE (I, J)1 Description. Bitwise greater than or equal to.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer or a boz-literal-constant.4 Result Characteristics. Default logical.J shall be of type integer or a boz-literal-constant.
5 Result Value. The result is true if the sequence of bits represented by I is greater than or equal to the sequence
of bits represented by J, according to the method of bit sequence comparison in 16.3.2; otherwise the result is6 The interpretation of a boz-literal-constant as a sequence of bits is described in 7.7. The interpretation of anfalse.
integer value as a sequence of bits is described in 16.3.7 Example. If BIT_SIZE (J) has the value 8, BGE (Z’FF’, J) has the value true for any value of J. BGE (0, −1)
has the value false.1 Description. Bitwise greater than.16.9.38 BGT (I, J)
2 Class. Elemental function.
362 ⃝c ISO/IEC 2017 – All rights reserved3 Arguments.
ISO/IEC DIS 1539-1:2017 (E)
I shall be of type integer or a boz-literal-constant.4 Result Characteristics. Default logical.J shall be of type integer or a boz-literal-constant.
5 Result Value. The result is true if the sequence of bits represented by I is greater than the sequence of bits
represented by J, according to the method of bit sequence comparison in 16.3.2; otherwise the result is false.6 The interpretation of a boz-literal-constant as a sequence of bits is described in 7.7. The interpretation of an
integer value as a sequence of bits is described in 16.3.7 Example. BGT (Z’FF’, Z’FC’) has the value true. BGT (0, −1) has the value false.
16.9.39 BIT_SIZE (I)1 Description. Number of bits in integer model 16.3.
2 Class. Inquiry function.
3 Argument. I shall be of type integer. It may be a scalar or an array.
4 Result Characteristics. Scalar integer with the same kind type parameter as I.
5 Result Value. The result has the value of the number of bits z of the model integer defined for bit manipulation
contexts in 16.3.6 Example. BIT_SIZE (1) has the value 32 if z of the model is 32.
16.9.40 BLE (I, J)1 Description. Bitwise less than or equal to.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer or a boz-literal-constant.4 Result Characteristics. Default logical.J shall be of type integer or a boz-literal-constant.
5 Result Value. The result is true if the sequence of bits represented by I is less than or equal to the sequence of
bits represented by J, according to the method of bit sequence comparison in 16.3.2; otherwise the result is false.6 The interpretation of a boz-literal-constant as a sequence of bits is described in 7.7. The interpretation of an
integer value as a sequence of bits is described in 16.3.7 Example. BLE (0, J) has the value true for any value of J. BLE (−1, 0) has the value false.
16.9.41 BLT (I, J)1 Description. Bitwise less than.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer or a boz-literal-constant.4 Result Characteristics. Default logical.J shall be of type integer or a boz-literal-constant.
⃝c ISO/IEC 2017 – All rights reserved 363
ISO/IEC DIS 1539-1:2017 (E)
5 Result Value. The result is true if the sequence of bits represented by I is less than the sequence of bits
represented by J, according to the method of bit sequence comparison in 16.3.2; otherwise the result is false.6 The interpretation of a boz-literal-constant as a sequence of bits is described in 7.7. The interpretation of an
integer value as a sequence of bits is described in 16.3.7 Example. BLT (0, −1) has the value true. BLT (Z’FF’, Z’FC’) has the value false.
16.9.42 BTEST (I, POS)1 Description. Test single bit in an integer.
2 Class. Elemental function.
3 Arguments.
I shall be of type integer.4 Result Characteristics. Default logical.POS shall be of type integer. It shall be nonnegative and be less than BIT_SIZE (I).
5 Result Value. The result has the value true if bit POS of I has the value 1 and has the value false if bit POS
of I has the value 0. The model for the interpretation of an integer value as a sequence of bits is in 16.3.
1 2
1 Description. Compute maximum value across images.
6 Examples. BTEST (8, 3) has the value true. If A has the value , the value of BTEST (A, 2) is 3 41 Description. Least integer greater than or equal to A.false false true false
and the value of BTEST (2, A) is .
false true false false
16.9.43 CEILING (A [, KIND])
2 Class. Elemental function. 3 Arguments. A shall be of type real.4 Result Characteristics. Integer. If KIND is present, the kind type parameter is that specified by the value ofKIND (optional) shall be a scalar integer constant expression.
KIND; otherwise, the kind type parameter is that of default integer type.5 Result Value. The result has a value equal to the least integer greater than or equal to A.
6 Examples. CEILING (3.7) has the value 4. CEILING (−3.7) has the value −3. 16.9.44 CHAR (I [, KIND])1 Description. Character from code value.
2 Class. Elemental function. 3 Arguments. I shall be of type integer with a value in the range 0 ≤ I ≤ n − 1, where n is the number of characters4 Result Characteristics. Character of length one. If KIND is present, the kind type parameter is that specifiedin the collating sequence associated with the specified kind type parameter.
KIND (optional) shall be a scalar integer constant expression.
364 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
by the value of KIND; otherwise, the kind type parameter is that of default character.5 Result Value. The result is the character in position I of the collating sequence associated with the spe-
cified kind type parameter. ICHAR (CHAR (I, KIND (C))) shall have the value I for 0 ≤ I ≤ n − 1 and6 Example. CHAR (88) has the value ’X’ on a processor using the ASCII collating sequence for default characters.CHAR (ICHAR (C), KIND (C)) shall have the value C for any character C capable of representation in the
processor.
16.9.45 CMPLX (X [, KIND]) or CMPLX (X [, Y, KIND])1 Description. Conversion to complex type.
2 Class. Elemental function. 3 Arguments for CMPLX(X [, KIND]). X shall be of type complex.4 Arguments for CMPLX(X [, Y, KIND]).KIND (optional) shall be a scalar integer constant expression.
X shall be of type integer or real, or a boz-literal-constant.5 Result Characteristics. The result is of type complex. If KIND is present, the kind type parameter is thatY (optional) shall be of type integer or real, or a boz-literal-constant.
KIND (optional) shall be a scalar integer constant expression.
specified by the value of KIND; otherwise, the kind type parameter is that of default real kind.6 Result Value. If Y is absent and X is not complex, it is as if Y were present with the value zero. If KIND is
absent, it is as if KIND were present with the value KIND (0.0). If X is complex, the result is the same as that7 Example. CMPLX (−3) has the value (−3.0, 0.0).of CMPLX (REAL (X), AIMAG (X), KIND). The result of CMPLX (X, Y, KIND) has the complex value whose
real part is REAL (X, KIND) and whose imaginary part is REAL (Y, KIND).
16.9.46 CO_BROADCAST (A, SOURCE_IMAGE [, STAT, ERRMSG])1 Description. Broadcast value to images.
2 Class. Collective subroutine. 3 Arguments. A shall have the same shape, dynamic type, and type parameter values, in corresponding references.4 The semantics of STAT and ERRMSG are described in 16.6.It shall not be a coindexed object. It is an INTENT (INOUT) argument. If no error condition
occurs, A becomes defined, as if by intrinsic assignment, on all images in the current team with the
value of A on image SOURCE_IMAGE.
SOURCE_IMAGE shall be an integer scalar. It is an INTENT (IN) argument. Its value shall be that of an
image index of an image in the current team. The value shall be the same in all corresponding
references.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument.
ERRMSG (optional) shall be a noncoindexed default character scalar. It is an INTENT (INOUT) argument.
⃝c ISO/IEC 2017 – All rights reserved 3655 Example. If A is the array [1, 5, 3] on image one, after execution of
ISO/IEC DIS 1539-1:2017 (E)
CALL CO_BROADCAST (A, 1)the value of A on all images of the current team is [1, 5, 3].
16.9.47 CO_MAX (A [, RESULT_IMAGE, STAT, ERRMSG]) 2 Class. Collective subroutine.
3 Arguments.
A shall be of type integer, real, or character. It shall have the same shape, type, and type parameter4 The semantics of STAT and ERRMSG are described in 16.6.values, in corresponding references. It shall not be a coindexed object. It is an INTENT (INOUT)
argument. If it is scalar, the computed value is equal to the maximum value of A in all corresponding
references. If it is an array each element of the computed value is equal to the maximum value of
all corresponding elements of A in all corresponding references.
The computed value is assigned to A if no error condition occurs, and either RESULT_IMAGE is
absent, or the executing image is the one identified by RESULT_IMAGE. Otherwise, A becomes
undefined.
RESULT_IMAGE (optional) shall be an integer scalar. It is an INTENT (IN) argument. Its presence, and value
if present, shall be the same in all corresponding references. If it is present, its value shall be that
of an image index in the current team.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument.
ERRMSG (optional) shall be a noncoindexed default character scalar. It is an INTENT (INOUT) argument.
5 Example. If the number of images in the current team is two and A is the array [1, 5, 3] on one image and [4,
1, 6] on the other image, the value of A after executing the statement CALL CO_MAX (A) is [4, 5, 6] on both1 Description. Compute minimum value across images.images.
16.9.48 CO_MIN (A [, RESULT_IMAGE, STAT, ERRMSG])
2 Class. Collective subroutine.
3 Arguments.
A shall be of type integer, real, or character. It shall have the same shape, type, and type parameter4 The semantics of STAT and ERRMSG are described in 16.6.values, in corresponding references. It shall not be a coindexed object. It is an INTENT (INOUT)
argument. If it is scalar, the computed value is equal to the minimum value of A in all corresponding
references. If it is an array each element of the computed value is equal to the minimum value of
all corresponding elements of A in all corresponding references.
The computed value is assigned to A if no error condition occurs, and either RESULT_IMAGE is
absent, or the executing image is the one identified by RESULT_IMAGE. Otherwise, A becomes
undefined.
RESULT_IMAGE (optional) shall be an integer scalar. It is an INTENT (IN) argument. Its presence, and value
if present, shall be the same in all corresponding references. If it is present, its value shall be that
of an image index in the current team.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument.
ERRMSG (optional) shall be a noncoindexed default character scalar. It is an INTENT (INOUT) argument.
366 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
5 Example. If the number of images in the current team is two and A is the array [1, 5, 3] on one image and [4,
1, 6] on the other image, the value of A after executing the statement CALL CO_MIN (A) is [1, 1, 3] on both1 Description. Generalized reduction across images.images.
16.9.49 CO_REDUCE (A, OPERATION [, RESULT_IMAGE, STAT, ERRMSG])
2 Class. Collective subroutine.
3 Arguments.
A shall not be polymorphic. It shall have the same shape, type, and type parameter values, in4 The semantics of STAT and ERRMSG are described in 16.6.corresponding references. It shall not be a coindexed object. It is an INTENT (INOUT) argument.
If A is scalar, the computed value is the result of the reduction operation of applying OPERATION
to the values of A in all corresponding references. If A is an array, each element of the computed
value is equal to the result of the reduction operation of applying OPERATION to corresponding
elements of A in all corresponding references.
The computed value is assigned to A if no error condition occurs, and either RESULT_IMAGE is
absent, or the executing image is the one identified by RESULT_IMAGE. Otherwise, A becomes
undefined.
OPERATION shall be a pure function with exactly two arguments; the result and each argument shall be
a scalar, nonallocatable, nonpointer, nonpolymorphic data object with the same type and type
parameters as A. The arguments shall not be optional. If one argument has the ASYNCHRONOUS,
TARGET, or VALUE attribute, the other shall have that attribute. OPERATION shall implement
a mathematically associative operation. OPERATION shall be the same function on all images in
corresponding references.
The computed value of a reduction operation over a set of values is the result of an iterative process.
Each iteration involves the evaluation of OPERATION (x, y) for x and y in the set, the removal of
x and y from the set, and the addition of the value of OPERATION (x, y) to the set. The process
terminates when the set has only one element; this is the computed value.
RESULT_IMAGE (optional) shall be an integer scalar. It is an INTENT (IN) argument. Its presence, and value
if present, shall be the same in all corresponding references. If it is present, its value shall be that
of an image index in the current team.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument.
ERRMSG (optional) shall be a noncoindexed default character scalar. It is an INTENT (INOUT) argument.
5 Example. The subroutine below demonstrates how to use CO_REDUCE to create a collective counterpart to
the intrinsic function ALL:SUBROUTINE co_all(boolean)
LOGICAL, INTENT(INOUT) :: boolean
CALL CO_REDUCE(boolean,both)
CONTAINS
PURE FUNCTION both(lhs,rhs) RESULT(lhs_and_rhs)
LOGICAL, INTENT(IN) :: lhs,rhsEND FUNCTION bothLOGICAL :: lhs_and_rhs
lhs_and_rhs = lhs .AND. rhs
END SUBROUTINE co_all
⃝c ISO/IEC 2017 – All rights reserved 367
ISO/IEC DIS 1539-1:2017 (E)
NOTE 16.11If the OPERATION function is not mathematically commutative, the result of calling CO_REDUCE can
depend on the order of evaluations.
16.9.50 CO_SUM (A [, RESULT_IMAGE, STAT, ERRMSG]) 1 Description. Compute sum across images.
2 Class. Collective subroutine.
3 Arguments.
A shall be of numeric type. It shall have the same shape, type, and type parameter values, in cor-4 The semantics of STAT and ERRMSG are described in 16.6.responding references. It shall not be a coindexed object. It is an INTENT (INOUT) argument.
If it is scalar, the computed value is equal to a processor-dependent approximation to the sum of
the values of A in corresponding references. If it is an array, each element of the computed value
is equal to a processor-dependent approximation to the sum of all corresponding elements of A in
corresponding references.
The computed value is assigned to A if no error condition occurs, and either RESULT_IMAGE is
absent, or the executing image is the one identified by RESULT_IMAGE. Otherwise, A becomes
undefined.
RESULT_IMAGE (optional) shall be an integer scalar. It is an INTENT (IN) argument. Its presence, and value
if present, shall be the same in all corresponding references. If it is present, its value shall be that
of an image index in the current team.
STAT (optional) shall be a noncoindexed integer scalar with a decimal exponent range of at least four. It is an
INTENT (OUT) argument.
ERRMSG (optional) shall be a noncoindexed default character scalar. It is an INTENT (INOUT) argument.