7.5.6 Final subroutines <IP_ADDRESS> FINAL statement R753 final-procedure-stmt is FINAL [ :: ] final-subroutine-name-list C787 (R753) A final-subroutine-name shall be the name of a module procedure with exactly one dummy argument. That argument shall be nonoptional and shall be a noncoarray, nonpointer, nonallocatable,nonpolymorphic variable of the derived type being defined. All length type parameters of the dummy
argument shall be assumed. The dummy argument shall not have the INTENT (OUT) or VALUE
attribute.
C788 (R753) A final-subroutine-name shall not be one previously specified as a final subroutine for that type. C789 (R753) A final subroutine shall not have a dummy argument with the same kind type parameters and rank as the dummy argument of another final subroutine of that type.
C790 (R753) If a final subroutine has an assumed-rank dummy argument, no other final subroutine of that type shall have a dummy argument with the same kind type parameters.1 The FINAL statement specifies that each procedure it names is a final subroutine. A final subroutine might be
executed when a data entity of that type is finalized (<IP_ADDRESS>).2 A derived type is finalizable if and only if it has a final subroutine or a nonpointer, nonallocatable component of
finalizable type. A nonpointer data entity is finalizable if and only if it is of finalizable type. No other entity is1 Only finalizable entities are finalized. When an entity is finalized, the following steps are carried out in sequence.finalizable.
⃝c ISO/IEC 2017 – All rights reserved 83
ISO/IEC DIS 1539-1:2017 (E)
NOTE 7.45
Final subroutines are effectively always “accessible”. They are called for entity finalization regardless of the
accessibility of the type, its other type-bound procedures, or the subroutine name itself.
NOTE 7.46
Final subroutines are not inherited through type extension and cannot be overridden. The final subroutines
of the parent type are called after any additional final subroutines of an extended type are called.
<IP_ADDRESS> The finalization process
(1) If the dynamic type of the entity has a final subroutine whose dummy argument has the same kind2 If several entities are to be finalized as a consequence of an event specified in <IP_ADDRESS>, the order in which theytype parameters and rank as the entity being finalized, it is called with the entity as an actual
argument. Otherwise, if there is an elemental final subroutine whose dummy argument has the same
kind type parameters as the entity being finalized, or a final subroutine whose dummy argument is
assumed-rank with the same kind type parameters as the entity being finalized, it is called with the
entity as an actual argument. Otherwise, no subroutine is called at this point.
(2) All finalizable components that appear in the type definition are finalized in a processor-dependent
order. If the entity being finalized is an array, each finalizable component of each element of that
entity is finalized separately.
(3) If the entity is of extended type and the parent type is finalizable, the parent component is finalized.
are finalized is processor dependent. During this process, execution of a final subroutine for one of these entities1 When an intrinsic assignment statement is executed (<IP_ADDRESS>), if the variable is not an unallocated allocatableshall not reference or define any of the other entities that have already been finalized.
NOTE 7.47
An implementation might need to ensure that when an event causes more than one coarray to be deallocated,
they are deallocated in the same order on all images in the current team.
<IP_ADDRESS> When finalization occurs
variable, it is finalized after evaluation of expr and before the definition of the variable. If the variable is an2 When a pointer is deallocated its target is finalized. When an allocatable entity is deallocated, it is finalizedallocated allocatable variable, or has an allocated allocatable subobject, that would be deallocated by intrinsic
assignment, the finalization occurs before the deallocation.
unless it is the variable in an intrinsic assignment statement or a subobject thereof. If an error condition occurs3 A nonpointer, nonallocatable object that is not a dummy argument or function result is finalized immediatelyduring deallocation, it is processor dependent whether finalization occurs.
before it would become undefined due to execution of a RETURN or END statement (19.6.6, item (3)).4 A nonpointer nonallocatable local variable of a BLOCK construct is finalized immediately before it would become
undefined due to termination of the BLOCK construct (19.6.6, item (23)).5 If an executable construct references a nonpointer function, the result is finalized after execution of the innermost
executable construct containing the reference.6 If a specification expression in a scoping unit references a function, the result is finalized before execution of the
executable constructs in the scoping unit.7 When a procedure is invoked, a nonpointer, nonallocatable, INTENT (OUT) dummy argument of that procedure
is finalized before it becomes undefined. The finalization caused by INTENT (OUT) is considered to occur within8 If an object is allocated via pointer allocation and later becomes unreachable due to all pointers associated with84 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
the invoked procedure; so for elemental procedures, an INTENT (OUT) argument will be finalized only if a scalar
or elemental final subroutine is available, regardless of the rank of the actual argument.
that object having their pointer association status changed, it is processor dependent whether it is finalized. If it1 If image execution is terminated, either by an error (e.g. an allocation failure) or by execution of a stop-stmt,is finalized, it is processor dependent as to when the final subroutines are called.
NOTE 7.48
If finalization is used for storage management, it often needs to be combined with defined assignment.
<IP_ADDRESS> Entities that are not finalized
error-stop-stmt, or end-program-stmt, entities existing immediately prior to termination are not finalized.1 A derived type, other than the type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING, thatNOTE 7.49
A nonpointer, nonallocatable object that has the SAVE attribute is never finalized as a direct consequence
of the execution of a RETURN or END statement.
7.5.7 Type extension
<IP_ADDRESS> Extensible, extended, and abstract types
does not have the BIND attribute or the SEQUENCE attribute is an extensible type.2 A type with the EXTENDS attribute is an extended type; its parent type is the type named in the EXTENDS
type-attr-spec.3 An extensible type that does not have the EXTENDS attribute is an extension type of itself only. An extendedNOTE 7.50
The name of the parent type might be a local name introduced via renaming in a USE statement.
type is an extension of itself and of all types for which its parent type is an extension.4 An abstract type is a type that has the ABSTRACT attribute.
NOTE 7.51The DEFERRED attribute (7.5.5) defers the implementation of a type-bound procedure to extensions of
the type; it can appear only in an abstract type. The dynamic type of an object cannot be abstract;
therefore, a deferred type-bound procedure cannot be invoked. An extension of an abstract type need not
be abstract if it has no deferred type-bound procedures. A short example of an abstract type is:
TYPE, ABSTRACT :: FILE_HANDLE
PROCEDURE(OPEN_FILE), DEFERRED, PASS(HANDLE) :: OPEN
...
For a more elaborate example see C.2.4.
| <IP_ADDRESS> |
Inheritance
1 An extended type includes all of the type parameters, all of the components, and the nonoverridden (<IP_ADDRESS>)
type-bound procedures of its parent type. These are inherited by the extended type from the parent type. They2 An extended type has a scalar, nonpointer, nonallocatable, parent component with the type and type parameters
of the parent type. The name of this component is the parent type name. If the extended type is defined in a3 If a generic binding specified in a type definition has the same generic-spec as an inherited binding, it extends
the generic interface and shall satisfy the requirements specified in <IP_ADDRESS>.5. |
TYPE, EXTENDS(POINT) :: COLOR_POINT ! An extension of TYPE(POINT) ! Components X and Y, and component name POINT, inherited from parentINTEGER :: COLOR
<IP_ADDRESS> Type-bound procedure overriding
1 If a specific type-bound procedure specified in a type definition has the same binding name as an accessible
type-bound procedure from the parent type then the binding specified in the type definition overrides the one2 The overriding and overridden type-bound procedures shall satisfy the following conditions.from the parent type.
• Either both shall have a passed-object dummy argument or neither shall.• If the overridden type-bound procedure is pure then the overriding one shall also be pure.
• Either both shall be elemental or neither shall.
• They shall have the same number of dummy arguments.
• Passed-object dummy arguments, if any, shall correspond by name and position.
• Dummy arguments that correspond by position shall have the same names and characteristics, except for
the type of the passed-object dummy arguments.
• Either both shall be subroutines or both shall be functions having the same result characteristics (15.3.3).
• If the overridden type-bound procedure is PUBLIC then the overriding one shall not be PRIVATE.
86 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)3 A binding of a type and a binding of an extension of that type correspond if the latter binding is the same binding
as the former, overrides a corresponding binding, or is an inherited corresponding binding.NOTE 7.56
The following is an example of procedure overriding, expanding on the example in NOTE 7.44.
TYPE, EXTENDS (POINT) :: POINT_3D
REAL :: Z
PROCEDURE, PASS :: LENGTH => POINT_3D_LENGTH
END TYPE POINT_3D
...
and in the module-subprogram-part of the same module:
REAL FUNCTION POINT_3D_LENGTH ( A, B )
CLASS (POINT_3D), INTENT (IN) :: ACLASS (POINT), INTENT (IN) :: B
SELECT TYPE(B)
CLASS IS(POINT_3D)
POINT_3D_LENGTH = SQRT( (A%X-B%X)**2 + (A%Y-B%Y)**2 + (A%Z-B%Z)**2 )
PRINT *, ’In POINT_3D_LENGTH, dynamic type of argument is incorrect.’
END FUNCTION POINT_3D_LENGTH
| 7.5.8 |
Derived-type values
1 The component value of
• a pointer component is its pointer association,2 The set of values of a particular derived type consists of all possible sequences of the component values of its
components.1 A derived-type specifier is used in several contexts to specify a particular derived type and type parameters.
R754 derived-type-spec is type-name [ ( type-param-spec-list ) ]2 Type parameter values that do not have type parameter keywords specified correspond to type parameters in type
parameter order (<IP_ADDRESS>). If a type parameter keyword appears, the value corresponds to the type parameter3 The value of a type parameter for which no type-param-value has been specified is its default value.
7.5.10 Construction of derived-type values1 A derived-type definition implicitly defines a corresponding structure constructor that allows construction of
scalar values of that derived type. The type and type parameters of a constructed value are specified by a derived2 In the absence of a component keyword, each component-data-source is assigned to the corresponding component
in component order (<IP_ADDRESS>). If a component keyword appears, the expr is assigned to the component named3 If a component with default initialization has no corresponding component-data-source, then the default initial-
ization is applied to that component.  If the component data source is a pointer,6 If a component of a derived type is allocatable, the corresponding constructor expression shall be a reference
to the intrinsic function NULL with no arguments, an allocatable entity of the same rank, or shall evaluate to7 If the component is allocatable and the expression is an allocatable entity, the corresponding component of the
constructor has the same allocation status as that allocatable entity. If it is allocated, it has the same bounds;8 If the component is allocatable and the expression is not an allocatable entity, the component has an allocation
status of allocated and the same bounds as the expression; if a length parameter of the component is deferred,1 Intrinsic assignment of derived-type entities is described in 10.2.1. This document does not specify any intrinsic
operations on derived-type entities. Any operation on derived-type entities or defined assignment (<IP_ADDRESS>) for1 An enumeration is a set of enumerators. An enumerator is a named integer constant. An enumeration definition
specifies the enumeration and its set of enumerators of the corresponding integer kind.2 For an enumeration, the kind is selected such that an integer type with that kind is interoperable (18.3.2) with the
corresponding C enumeration type. The corresponding C enumeration type is the type that would be declared3 The companion processor (5.5.7) shall be one that uses the same representation for the types declared by all C
enumeration specifiers that specify the same values in the same order.4 An enumerator is treated as if it were explicitly declared with the PARAMETER attribute. The enumerator is
defined in accordance with the rules of intrinsic assignment (10.2) with the value determined as follows. |
The kind type parameter for this enumeration is processor dependent, but the processor is required to select
a kind sufficient to represent the values 4, 9, and 10, which are the values of its enumerators. The following
declaration might be equivalent to the above enumeration definition.
INTEGER (SELECTED_INT_KIND (2)), PARAMETER :: RED = 4, BLUE = 9, YELLOW = 10
An entity of the same kind type parameter value can be declared using the intrinsic function KIND with
one of the enumerators as its argument, for example
INTEGER (KIND (RED)) :: X
| ⃝c ISO/IEC 2017 – All rights reserved | |||||||
| 91 | |||||||
|
| |||||||
|
ISO/IEC DIS 1539-1:2017 (E)
NOTE 7.66
| |||||||
| 1 A binary, octal, or hexadecimal constant (boz-literal-constant) is a sequence of digits that represents an ordered | |||||||
sequence of bits. Such a constant has no type.2 The hex-digits A through F represent the numbers ten through fifteen, respectively; they may be represented | |||||||
by their lower-case equivalents. Each digit of a boz-literal-constant represents a sequence of bits, according to1 An array constructor constructs a rank-one array value from a sequence of scalar values, array values, and implied | |||||||
DO loops.2 If type-spec is omitted, corresponding length type parameters of the declared type of each ac-value expression | |||||||
shall have the same value; in this case, the declared type and type parameters of the array constructor are those3 If type-spec appears, it specifies the declared type and type parameters of the array constructor. Each ac-value | |||||||
expression in the array-constructor shall be compatible with intrinsic assignment to a variable of this type and4 The dynamic type of an array constructor is the same as its declared type. | |||||||
|
5 The character length of an ac-value in an ac-implied-do whose iteration count is zero shall not depend on the
value of the ac-do-variable and shall not depend on the value of an expression that is not a constant expression.6 If an ac-value is a scalar expression, its value specifies an element of the array constructor. If an ac-value is
an array expression, the values of the elements of the expression, in array element order (<IP_ADDRESS>), specify the7 For an ac-implied-do, the loop initialization and execution is the same as for a DO construct. 8 An empty sequence forms a zero-sized array.
⃝c ISO/IEC 2017 – All rights reserved 93ISO/IEC DIS 1539-1:2017 (E)
NOTE 7.67
| |||||||
|
ISO/IEC DIS 1539-1:2017 (E)8 Attribute declarations and specifications | |||||||
| |||||||
| 1 Every data object has a type and rank and may have type parameters and other properties that determine the | |||||||
uses of the object. Collectively, these properties are the attributes of the object. The declared type of a named2 A function has a type and rank and may have type parameters and other attributes that determine the uses of | |||||||
the function. The type, rank, and type parameters are the same as those of the function result.3 A subroutine does not have a type, rank, or type parameters, but may have other attributes that determine the | |||||||
uses of the subroutine.1 The type declaration statement specifies the declared type of the entities in the entity declaration list. The type | |||||||
and type parameters are those specified by declaration-type-spec, except that the character length type parameter2 The type declaration statement also specifies the attributes whose keywords appear in the attr-spec, except that | |||||||
the DIMENSION attribute may be specified or overridden for an entity by the appearance of array-spec in its3 A name that identifies a specific intrinsic function has a type as specified in 16.8. An explicit type declaration statement is not | |||||||
required; however, it is permitted. Specifying a type for a generic intrinsic function name in a type declaration4 If initialization appears for a nonpointer entity, | |||||||
• its type and type parameters shall conform as specified for intrinsic assignment (<IP_ADDRESS>); | |||||||
| |||||||
|
ISO/IEC DIS 1539-1:2017 (E)NOTE 8.1 (cont.) | |||||||
INTEGER (SHORT) K ! Range at least -9999 to 9999.(The last line above uses a type definition from NOTE 7.22.) | |||||||
| |||||||
| 1 An automatic data object is a nondummy data object with a type parameter or array bound that depends on | |||||||
the value of a specification-expr that is not a constant expression.2 If a type parameter in a declaration-type-spec or in a char-length in an entity-decl for a local variable of a | |||||||
subprogram or BLOCK construct is defined by an expression that is not a constant expression, the type parameter1 The appearance of initialization in an entity-decl for an entity without the PARAMETER attribute specifies that | |||||||
the entity is a variable with explicit initialization. Explicit initialization alternatively may be specified in a DATA2 If null-init appears, the initial association status of the object is disassociated. If initial-data-target appears, the | |||||||
object is initially associated with the target.3 Explicit initialization of a variable that is not in a common block implies the SAVE attribute, which may be confirmed | |||||||
by explicit specification.1 An attribute may be explicitly specified by an attr-spec in a type declaration statement or by an attribute | |||||||
specification statement (8.6). The following constraints apply to attributes.1 The accessibility attribute specifies the accessibility of an entity via a particular identifier. | |||||||
R807 access-spec is PUBLIC2 An access-spec in a type declaration statement specifies the accessibility of the names of all the entities declared | |||||||
by that statement. An access-spec in a derived-type-stmt specifies the accessibility of the derived type name.3 An identifier that is specified in a module or is accessible in a module by use association has either the PUB- | |||||||
LIC attribute or PRIVATE attribute. An identifier whose accessibility is not explicitly specified has default4 The default accessibility attribute for a module is PUBLIC unless it has been changed by a PRIVATE statement. | |||||||
Only an identifier that has the PUBLIC attribute in that module is available to be accessed from that module1 A variable with the ALLOCATABLE attribute is a variable for which space is allocated during execution. | |||||||
NOTE 8.4 | |||||||
| |||||||
| 1 An entity with the ASYNCHRONOUS attribute is a variable that may be subject to asynchronous input/output | |||||||
or asynchronous communication.2 The base object of a variable shall have the ASYNCHRONOUS attribute in a scoping unit if | |||||||
• the variable is a dummy argument or appears in an executable statement or specification expression in that3 Use of a variable in an asynchronous data transfer statement can imply the ASYNCHRONOUS attribute; see | |||||||
subclause <IP_ADDRESS>.4 An object with the ASYNCHRONOUS attribute may be associated with an object that does not have the | |||||||
ASYNCHRONOUS attribute, including by use (14.2.2) or host association (<IP_ADDRESS>). If an object that is not a1 The BIND attribute for a variable or common block specifies that it is capable of interoperating with a C variable | |||||||
whose name has external linkage (18.9).2 If the value of the scalar-default-char-constant-expr after discarding leading and trailing blanks has nonzero | |||||||
length, it shall be valid as an identifier on the companion processor.3 The BIND attribute for a common block implies the SAVE attribute, which may be confirmed by explicit specification. | |||||||
8.5.6 CODIMENSION attribute1 The CODIMENSION attribute specifies that an entity is a coarray. The coarray-spec specifies its corank or | |||||||
corank and cobounds.1 A coarray with the ALLOCATABLE attribute has a specified corank, but its cobounds are determined by | |||||||
allocation or argument association.2 The corank of an allocatable coarray is equal to the number of colons in its deferred-coshape-spec-list. | |||||||
|
3 The cobounds of an unallocated allocatable coarray are undefined. No part of such a coarray shall be referenced
or defined; however, the coarray may appear as an argument to an intrinsic inquiry function as specified in 16.1.4 The cobounds of an allocated allocatable coarray are those specified when the coarray is allocated. 5 The cobounds of an allocatable coarray are unaffected by any subsequent redefinition or undefinition of the
variables on which the cobounds’ expressions depend.1 An explicit-coshape coarray is a named coarray that has its corank and cobounds declared by an explicit-coshape-
spec.2 The corank is equal to one plus the number of upper-cobounds.
100 ⃝3 If an explicit-coshape coarray is a local variable of a subprogram or BLOCK construct and has cobounds that are
not constant expressions, the cobounds are determined on entry to a procedure defined by the subprogram, or4 The values of each lower-cobound and upper-cobound determine the cobounds of the coarray along a particular
codimension. The cosubscript range of the coarray in that codimension is the set of integer values between and1 The CONTIGUOUS attribute specifies that an assumed-shape array is contiguous, that an array pointer can
only be pointer associated with a contiguous target, or that an assumed-rank dummy data object is contiguous.2 An object is contiguous if it is
(1) an object with the CONTIGUOUS attribute,3 An object is not contiguous if it is an array subobject, and
• the object has two or more elements,
| |||||||
|
| |||||||
| ISO/IEC DIS 1539-1:2017 (E) | |||||||
| 4 It is processor dependent whether any other object is contiguous. | |||||||
NOTE 8.10 | |||||||
| |||||||
| 1 The DIMENSION attribute specifies that an entity is assumed-rank or an array. An assumed-rank dummy data | |||||||
object has the rank, shape, and size of its effective argument; otherwise, the rank or rank and shape is specified1 An explicit-shape array is an array whose shape is explicitly declared by an explicit-shape-spec-list. The rank is | |||||||
equal to the number of explicit-shape-specs.2 An explicit-shape array that is a named local variable of a subprogram or BLOCK construct may have bounds | |||||||
that are not constant expressions. The bounds, and hence shape, are determined on entry to a procedure defined3 The values of each lower-bound and upper-bound determine the bounds of the array along a particular dimension | |||||||
and hence the extent of the array in that dimension. If lower-bound appears it specifies the lower bound; otherwise1 An assumed-shape array is a nonallocatable nonpointer dummy argument array that takes its shape from its | |||||||
effective argument.2 The rank is equal to the number of colons in the assumed-shape-spec-list. | |||||||
|
3 The extent of a dimension of an assumed-shape array dummy argument is the extent of the corresponding
dimension of its effective argument. If the lower bound value is d and the extent of the corresponding dimension1 A deferred-shape array is an allocatable array or an array pointer. (An allocatable array has the ALLOCATABLE
attribute; an array pointer has the POINTER attribute.)2 The rank is equal to the number of colons in the deferred-shape-spec-list. 3 The size, bounds, and shape of an unallocated allocatable array or a disassociated array pointer are undefined.
No part of such an array shall be referenced or defined; however, the array may appear as an argument to an4 The bounds of each dimension of an allocated allocatable array are those specified when the array is allocated
or, if it is a dummy argument, when it is argument associated with an allocated effective argument.5 The bounds of each dimension of an associated array pointer, and hence its shape, may be specified
• in an ALLOCATE statement (9.7.1) when the target is allocated,
| |||||||
|
| |||||||
| ISO/IEC DIS 1539-1:2017 (E) | |||||||
| 6 The bounds of an array pointer or allocatable array are unaffected by any subsequent redefinition or undefinition | |||||||
of variables on which the bounds’ expressions depend.1 An assumed-size array is a dummy argument array whose size is assumed from that of its effective argument, or | |||||||
the associate name of a RANK ( * ) block in a SELECT RANK construct. The rank and extents may differ for2 The size of an assumed-size array is determined as follows. | |||||||
• If the effective argument associated with the assumed-size dummy array is an array of any type other than3 The rank is equal to one plus the number of explicit-shape-specs. | |||||||
|
4 An assumed-size array has no upper bound in its last dimension and therefore has no extent in its last dimension
and no shape. An assumed-size array shall not appear in a context that requires its shape.5 If a list of explicit-shape-specs appears, it specifies the bounds of the first rank−1 dimensions. If lower-bound
appears it specifies the lower bound of the last dimension; otherwise that lower bound is 1. An assumed-size6 If an assumed-size array has bounds that are not constant expressions, the bounds are determined on entry to
the procedure. The bounds of such an array are unaffected by the redefinition or undefinition of any variable1 An implied-shape array is a named constant that takes its shape from the constant-expr in its declaration. A
named constant is declared to be an implied-shape array with an array-spec that is an implied-shape-or-assumed-2 The rank of an implied-shape array is the number of assumed-implied-specs in its array-spec. 3 The extent of each dimension of an implied-shape array is the same as the extent of the corresponding dimension
of the constant-expr. The lower bound of each dimension is lower-bound, if it appears, and 1 otherwise; the upper1 An assumed-rank entity is a dummy data object whose rank is assumed from its effective argument, or the associate
name of a RANK DEFAULT block in a SELECT RANK construct; this rank can be zero. An assumed-rank1 The EXTERNAL attribute specifies that an entity is an external procedure, dummy procedure, procedure pointer,
or block data subprogram.2 If an external procedure or dummy procedure is used as an actual argument or is the target of a procedure pointer
assignment, it shall be declared to have the EXTERNAL attribute.3 A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer.
NOTE 8.14
1 The INTENT attribute specifies the intended use of a dummy argument. An INTENT (IN) dummy argument
is suitable for receiving data from the invoking scoping unit, an INTENT (OUT) dummy argument is suitable2 The INTENT (IN) attribute for a nonpointer dummy argument specifies that it shall neither be defined nor
become undefined during the invocation and execution of the procedure. The INTENT (IN) attribute for a3 The INTENT (OUT) attribute for a nonpointer dummy argument specifies that the dummy argument becomes
undefined on invocation of the procedure, except for any subcomponents that are default-initialized (<IP_ADDRESS>). Any4 The INTENT (INOUT) attribute for a nonpointer dummy argument specifies that any actual argument that
corresponds to the dummy argument shall be definable. The INTENT (INOUT) attribute for a pointer dummy5 If no INTENT attribute is specified for a dummy argument, its use is subject to the limitations of its effective
argument (15.5.2).6 If a nonpointer object has an INTENT attribute, then all of its subobjects have the same INTENT attribute.
NOTE 8.16 | |||||||
TYPE (PERSON), INTENT (IN) :: FROM
TYPE (PERSON), INTENT (OUT) :: TO
| 106 | ||||||||
c ISO/IEC 2017 – All rights reservedNOTE 8.17 | ||||||||
|
If a dummy argument is a nonpointer derived-type object with a pointer component, then the pointer as a pointer is a subobject of the dummy argument, but the target of the pointer is not. Therefore, the restrictions on subobjects of the dummy argument apply to the pointer in contexts where it is used as a pointer, but not in contexts where it is dereferenced to indicate its target. For example, if X is a nonpointer dummy argument of derived type with an integer pointer component P, and X is INTENT (IN), then the statement X%P => NEW_TARGET is prohibited, but X%P = 0 is allowed (provided that X%P is associated with a definable target). Similarly, the INTENT restrictions on pointer dummy arguments apply only to the association of the dummy argument; they do not restrict the operations allowed on its target.
NOTE 8.18Argument intent specifications serve several purposes in addition to documenting the intended use of dummy arguments. A processor can check whether an INTENT (IN) dummy argument is used in a way that could redefine it. A slightly more sophisticated processor could check to see whether an INTENT (OUT) dummy argument could possibly be referenced before it is defined. If the procedure’s interface is explicit, the processor can also verify that actual arguments corresponding to INTENT (OUT) or INTENT (INOUT) dummy arguments are definable. A more sophisticated processor could use this information to optimize the translation of the referencing scoping unit by taking advantage of the fact that actual arguments corresponding to INTENT (IN) dummy arguments will not be changed and that any prior value of an actual argument corresponding to an INTENT (OUT) dummy argument will not be referenced and could thus be discarded. INTENT (OUT) means that the value of the argument after invoking the procedure is entirely the result of executing that procedure. If an argument might not be redefined and it is desired to have the argument retain its value in that case, INTENT (OUT) cannot be used because it would cause the argument to become undefined; however, INTENT (INOUT) can be used, even if there is no explicit reference to the value of the dummy argument. INTENT (INOUT) is not equivalent to omitting the INTENT attribute. The actual argument corresponding to an INTENT (INOUT) dummy argument is always required to be definable, while an actual argument corresponding to a dummy argument without an INTENT attribute need be definable only if the dummy argument is actually redefined. | ||||||||
| 8.5.11 |
INTRINSIC attribute
1 The INTRINSIC attribute specifies that the entity is an intrinsic procedure. The procedure name may be a
generic name (16.7), a specific name (16.8), or both.2 If the specific name of an intrinsic procedure (16.8) is used as an actual argument, the name shall be explicitly specified to have the
INTRINSIC attribute. Note that a specific intrinsic procedure listed in Table 16.3 is not permitted to be used as an actual argument1 The OPTIONAL attribute specifies that the dummy argument need not have a corresponding actual argument
in a reference to the procedure (<IP_ADDRESS>).1 The PARAMETER attribute specifies that an entity is a named constant. The entity has the value specified by
its constant-expr, converted, if necessary, to the type, type parameters and shape of the entity.2 A named constant shall not be referenced unless it has been defined previously; it may be defined previously in
the same statement.1 Entities with the POINTER attribute can be associated with different data objects or procedures during execution
of a program. A pointer is either a data pointer or a procedure pointer.2 A data pointer shall not be referenced unless it is pointer associated with a target object that is defined. A data
pointer shall not be defined unless it is pointer associated with a target object that is definable.3 If a data pointer is associated, the values of its deferred type parameters are the same as the values of the
corresponding type parameters of its target.4 A procedure pointer shall not be referenced unless it is pointer associated with a target procedure.
NOTE 8.21
1 The PROTECTED attribute imposes limitations on the usage of module entities.
C853 The PROTECTED attribute shall be specified only in the specification part of a module.2 Other than within the module in which an entity is given the PROTECTED attribute, or within any of its
descendants,3 If an object has the PROTECTED attribute, all of its subobjects have the PROTECTED attribute.
NOTE 8.22 | |||||||
SUBROUTINE set_temperature_c(c)
REAL, INTENT(IN) :: ctemp_c = c
temp_f = temp_c*(9.0/5.0) + 32
The PROTECTED attribute ensures that the variables temp_c and temp_f cannot be modified other than
via the set_temperature_c procedure, thus keeping them consistent with each other.
| 8.5.16 |
SAVE attribute
1 The SAVE attribute specifies that a local variable of a program unit or subprogram retains its association status,
allocation status, definition status, and value after execution of a RETURN or END statement unless it is a2 The SAVE attribute specifies that a local variable of a BLOCK construct retains its association status, allocation
status, definition status, and value after termination of the construct unless it is a pointer and its target becomes3 Giving a common block the SAVE attribute confers the attribute on all entities in the common block.
C858 An entity with the SAVE attribute shall be a common block, variable, or procedure pointer.4 A variable, common block, or procedure pointer declared in the scoping unit of a main program, module, or
submodule implicitly has the SAVE attribute, which may be confirmed by explicit specification. If a common block1 The TARGET attribute specifies that a data object may have a pointer associated with it (10.2.2). An object
without the TARGET attribute shall not have a pointer associated with it.2 If an object has the TARGET attribute, then all of its nonpointer subobjects also have the TARGET attribute.
NOTE 8.23
1 The VALUE attribute specifies a type of argument association (<IP_ADDRESS>) for a dummy argument.
C862 An entity with the VALUE attribute shall be a dummy data object. It shall not be an assumed-size1 The VOLATILE attribute specifies that an object may be referenced, defined, or become undefined, by means
not specified by the program. A pointer with the VOLATILE attribute may additionally have its association2 A noncoarray object that has the VOLATILE attribute may be associated with an object that does not have
the VOLATILE attribute, including by use (14.2.2) or host association (<IP_ADDRESS>). If an object that is not a3 A pointer should have the VOLATILE attribute if its target has the VOLATILE attribute. If, by means not
specified by the program, the target is referenced, defined, or becomes undefined, the pointer shall have the4 If an object has the VOLATILE attribute, then all of its subobjects also have the VOLATILE attribute. 5 The Fortran processor should use the most recent definition of a volatile object each time its value is required.
When a volatile object is defined by means of Fortran, it should make that definition available to the non-Fortran1 An access-stmt with an access-id-list specifies the accessibility attribute, PUBLIC or PRIVATE, of each access-id
in the list that is not a module name. An access-stmt without an access-id list specifies the default accessibility | ||||
specifies a default of public accessibility. The statement
specifies a default of private accessibility. If no such statement appears in a module, the default is public
accessibility.
⃝c ISO/IEC 2017 – All rights reserved 111
ISO/IEC DIS 1539-1:2017 (E)
2 If an identifier is accessed by use association and not declared in the module, and the name of every module
from which it is accessed appears in an access-stmt in the scoping unit, its default accessibility is PRIVATE ifthe access-spec in every such access-stmt is PRIVATE, or PUBLIC if the access-spec in any such access-stmt is
PUBLIC.
NOTE 8.26
Examples of accessibility statements are:
PUBLIC :: A, B, C, ASSIGNMENT (=), OPERATOR (+)
NOTE 8.27
The following is an example of using an accessibility statement on a module name.
MODULE m2USE m1
! We want to use the types and procedures in m1, but we only want to
! re-export m_type from m1, and export our own procedures.
PRIVATE m1
PUBLIC m_type
... definitions for our own entities and module procedures.
8.6.2 ALLOCATABLE statement R829 allocatable-stmt is ALLOCATABLE [ :: ] allocatable-decl-list R830 allocatable-decl is object-name [ ( array-spec ) ] [ lbracket coarray-spec rbracket ]1 The ALLOCATABLE statement specifies the ALLOCATABLE attribute (8.5.3) for a list of objects.
NOTE 8.28An example of an ALLOCATABLE statement is:
REAL A, B (:), SCALAR
ALLOCATABLE :: A (:, :), B, SCALAR
8.6.3 ASYNCHRONOUS statement R831 asynchronous-stmt is ASYNCHRONOUS [ :: ] object-name-list
1 The ASYNCHRONOUS statement specifies the ASYNCHRONOUS attribute (8.5.4) for a list of objects.
8.6.4 BIND statement1 The BIND statement specifies the BIND attribute for a list of variables and common blocks.R832 bind-stmt is language-binding-spec [ :: ] bind-entity-list
R833 bind-entity is entity-name
or / common-block-name /
C872 (R832) If the language-binding-spec has a NAME= specifier, the bind-entity-list shall consist of a single
bind-entity.
112 ⃝c ISO/IEC 2017 – All rights reserved1 The CODIMENSION statement specifies the CODIMENSION attribute (8.5.6) for a list of objects.
ISO/IEC DIS 1539-1:2017 (E)
8.6.5 CODIMENSION statement
R834 codimension-stmt is CODIMENSION [ :: ] codimension-decl-list
R835 codimension-decl is coarray-name lbracket coarray-spec rbracket
NOTE 8.29An example of a CODIMENSION statement is:
CODIMENSION a[*], b[3,*], c[:]
8.6.6 CONTIGUOUS statement R836 contiguous-stmt is CONTIGUOUS [ :: ] object-name-list
1 The CONTIGUOUS statement specifies the CONTIGUOUS attribute (8.5.7) for a list of objects.
8.6.7 DATA statement1 The DATA statement specifies explicit initialization (8.4).R837 data-stmt is DATA data-stmt-set [ [ , ] data-stmt-set ] ...
2 If a nonpointer variable has default initialization, it shall not appear in a data-stmt-object-list.
3 A variable that appears in a DATA statement and has not been typed previously may appear in a subsequent type
declaration only if that declaration confirms the implicit typing. An array name, array section, or array element4 Except for variables in named common blocks, a named variable has the SAVE attribute if any part of it is initializedthat appears in a DATA statement shall have had its array properties established by a previous specification
statement.
in a DATA statement, and this may be confirmed by explicit specification.5 The data-stmt-object-list is expanded to form a sequence of pointers and scalar variables, referred to as “sequenceR838 data-stmt-set is data-stmt-object-list / data-stmt-value-list /
R839 data-stmt-object is variable
or data-implied-do
R840 data-implied-do is ( data-i-do-object-list , [ integer-type-spec :: ] data-i-do-variable =
scalar-int-constant-expr ,
scalar-int-constant-expr
[ , scalar-int-constant-expr ] )
R841 data-i-do-object is array-element
or scalar-structure-component
or data-implied-do
R842 data-i-do-variable is do-variable
C873 A data-stmt-object or data-i-do-object shall not be a coindexed variable.
C874 (R839) A data-stmt-object that is a variable shall be a designator. Each subscript, section subscript,
substring starting point, and substring ending point in the variable shall be a constant expression.
C875 (R839) A variable whose designator appears as a data-stmt-object or a data-i-do-object shall not be a
dummy argument, accessed by use or host association, in a named common block unless the DATA statement is
in a block data program unit, in blank common, a function name, a function result name, an automatic data
object, or an allocatable variable.
⃝c ISO/IEC 2017 – All rights reserved 113
ISO/IEC DIS 1539-1:2017 (E)
C876 (R839) A data-i-do-object or a variable that appears as a data-stmt-object shall not be an object designator
in which a pointer appears other than as the entire rightmost part-ref .
C877 (R841) The array-element shall be a variable.
C878 (R841) The scalar-structure-component shall be a variable.
C879 (R841) The scalar-structure-component shall contain at least one part-ref that contains a subscript-list.
C880 (R841) In an array-element or scalar-structure-component that is a data-i-do-object, any subscript shall
be a constant expression, and any primary within that subscript that is a data-i-do-variable shall be a
DO variable of this data-implied-do or of a containing data-implied-do.
R843 data-stmt-value is [ data-stmt-repeat * ] data-stmt-constant
R844 data-stmt-repeat is scalar-int-constant
or scalar-int-constant-subobject
C881 (R844) The data-stmt-repeat shall be positive or zero. If the data-stmt-repeat is a named constant, it
shall have been defined previously.
R845 data-stmt-constant is scalar-constant
or scalar-constant-subobject
or signed-int-literal-constant
or signed-real-literal-constant
or null-init
or initial-data-target
or structure-constructor
C882 (R845) If a DATA statement constant value is a named constant or a structure constructor, the named
constant or derived type shall have been defined previously.
C883 (R845) If a data-stmt-constant is a structure-constructor, it shall be a constant expression.
R846 int-constant-subobject is constant-subobject
C884 (R846) int-constant-subobject shall be of type integer.
R847 constant-subobject is designator
C885 (R847) constant-subobject shall be a subobject of a constant.
C886 (R847) Any subscript, substring starting point, or substring ending point shall be a constant expression.
of variables” in subsequent text. A nonpointer array whose unqualified name appears as a data-stmt-object or6 The data-stmt-value-list is expanded to form a sequence of data-stmt-constants. A data-stmt-repeat indicates thedata-i-do-object is equivalent to a complete sequence of its array elements in array element order (<IP_ADDRESS>). An
array section is equivalent to the sequence of its array elements in array element order. A data-implied-do is
expanded to form a sequence of array elements and structure components, under the control of the data-i-do-
variable, as in the DO construct (<IP_ADDRESS>).
number of times the following data-stmt-constant is to be included in the sequence; omission of a data-stmt-repeat7 A zero-sized array or a data-implied-do with an iteration count of zero contributes no variables to the expandedhas the effect of a repeat factor of 1.
sequence of variables, but a zero-length scalar character variable does contribute a variable to the expanded8 The expanded sequences of variables and data-stmt-constants are in one-to-one correspondence. Each data-stmt-sequence. A data-stmt-constant with a repeat factor of zero contributes no data-stmt-constants to the expanded
sequence of scalar data-stmt-constants.
114 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
constant specifies the initial value, initial data target, or null-init for the corresponding variable. The lengths of9 A data-stmt-constant shall be null-init or initial-data-target if and only if the corresponding data-stmt-object hasthe two expanded sequences shall be the same.
the POINTER attribute. If data-stmt-constant is null-init, the initial association status of the corresponding data10 A data-stmt-constant other than boz-literal-constant, null-init, or initial-data-target shall be compatible with itsstatement object is disassociated. If data-stmt-constant is initial-data-target the corresponding data statement
object shall be data-pointer-initialization compatible (<IP_ADDRESS>) with the initial data target; the data statement
object is initially associated with the target.
corresponding variable according to the rules of intrinsic assignment (<IP_ADDRESS>). The variable is initially defined11 If a data-stmt-constant is a boz-literal-constant, the corresponding variable shall be of type integer. The boz-with the value specified by the data-stmt-constant; if necessary, the value is converted according to the rules of
intrinsic assignment (<IP_ADDRESS>) to a value that agrees in type, type parameters, and shape with the variable.
literal-constant is treated as if it were converted by the intrinsic function INT (16.9.100) to type integer with the1 The DIMENSION statement specifies the DIMENSION attribute (8.5.8) for a list of objects.kind type parameter of the variable.
NOTE 8.30
Examples of DATA statements are:
CHARACTER (LEN = 10) NAME
INTEGER, DIMENSION (0:9) :: MILES
REAL, DIMENSION (100, 100) :: SKEW
TYPE (NODE), POINTER :: HEAD_OF_LIST
TYPE (PERSON) MYNAME, YOURNAME
DATA NAME / ’JOHN DOE’ /, MILES / 10 * 0 /
DATA ((SKEW (K, J), J = 1, K), K = 1, 100) / 5050 * 0.0 /
DATA ((SKEW (K, J), J = K + 1, 100), K = 1, 99) / 4950 * 1.0 /
DATA HEAD_OF_LIST / NULL() /
DATA MYNAME / PERSON (21, ’JOHN SMITH’) /
DATA YOURNAME % AGE, YOURNAME % NAME / 35, ’FRED BROWN’ /
The character variable NAME is initialized with the value JOHN DOE with padding on the right because
the length of the constant is less than the length of the variable. All ten elements of the integer array
MILES are initialized to zero. The two-dimensional array SKEW is initialized so that the lower triangle
of SKEW is zero and the strict upper triangle is one. The structures MYNAME and YOURNAME are
declared using the derived type PERSON from NOTE 7.15. The pointer HEAD_OF_LIST is declared
using the derived type NODE from NOTE 7.35; it is initially disassociated. MYNAME is initialized by a
structure constructor. YOURNAME is initialized by supplying a separate value for each component.
8.6.8 DIMENSION statement
R848 dimension-stmt is DIMENSION [ :: ] array-name ( array-spec )
[ , array-name ( array-spec ) ] ...
NOTE 8.31An example of a DIMENSION statement is:
DIMENSION A (10), B (10, 70), C (:)
⃝c ISO/IEC 2017 – All rights reserved 115
ISO/IEC DIS 1539-1:2017 (E)
8.6.9 INTENT statement R849 intent-stmt is INTENT ( intent-spec ) [ :: ] dummy-arg-name-list
1 The INTENT statement specifies the INTENT attribute (8.5.10) for the dummy arguments in the list.
NOTE 8.32An example of an INTENT statement is:
SUBROUTINE EX (A, B)
INTENT (INOUT) :: A, B
8.6.10 OPTIONAL statement R850 optional-stmt is OPTIONAL [ :: ] dummy-arg-name-list
1 The OPTIONAL statement specifies the OPTIONAL attribute (8.5.12) for the dummy arguments in the list.
NOTE 8.33An example of an OPTIONAL statement is:
SUBROUTINE EX (A, B)
OPTIONAL :: B
8.6.11 PARAMETER statement
1 The PARAMETER statement specifies the PARAMETER attribute (8.5.13) and the values for the named con-
stants in the list.2 If a named constant is defined by a PARAMETER statement, it shall not be subsequently declared to have aR851 parameter-stmt is PARAMETER ( named-constant-def-list )
R852 named-constant-def is named-constant = constant-expr
type or type parameter value that differs from the type and type parameters it would have if declared implicitly3 The constant expression that corresponds to a named constant shall have type and type parameters that conform(8.7). A named array constant defined by a PARAMETER statement shall have its rank specified in a prior
specification statement.
with the named constant as specified for intrinsic assignment (<IP_ADDRESS>). If the named constant has implied shape,4 The value of each named constant is that specified by the corresponding constant expression; if necessary, thethe expression shall have the same rank as the named constant; otherwise, the expression shall either be scalar
or have the same shape as the named constant.
value is converted according to the rules of intrinsic assignment (<IP_ADDRESS>) to a value that agrees in type, type1 The POINTER statement specifies the POINTER attribute (8.5.14) for a list of entities.parameters, and shape with the named constant.
NOTE 8.34
An example of a PARAMETER statement is:
PARAMETER (MODULUS = MOD (28, 3), NUMBER_OF_SENATORS = 100)
8.6.12 POINTER statement
R853 pointer-stmt is POINTER [ :: ] pointer-decl-list
R854 pointer-decl is object-name [ ( deferred-shape-spec-list ) ]
or proc-entity-name
116 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
C887 A proc-entity-name shall have the EXTERNAL attribute.
NOTE 8.35An example of a POINTER statement is:
TYPE (NODE) :: CURRENT
POINTER :: CURRENT, A (:, :)
8.6.13 PROTECTED statement R855 protected-stmt is PROTECTED [ :: ] entity-name-list
1 The PROTECTED statement specifies the PROTECTED attribute (8.5.15) for a list of entities.
8.6.14 SAVE statement1 A SAVE statement with a saved entity list specifies the SAVE attribute (8.5.16) for a list of entities. A SAVER856 save-stmt is SAVE [ [ :: ] saved-entity-list ]
R857 saved-entity is object-name
or proc-pointer-name
or / common-block-name /
R858 proc-pointer-name is name
C888 (R856) If a SAVE statement with an omitted saved entity list appears in a scoping unit, no other
appearance of the SAVE attr-spec or SAVE statement is permitted in that scoping unit.
C889 A proc-pointer-name shall be the name of a procedure pointer.
statement without a saved entity list is treated as though it contained the names of all allowed items in the same1 The TARGET statement specifies the TARGET attribute (8.5.17) for a list of objects.scoping unit.
NOTE 8.36
An example of a SAVE statement is:
SAVE A, B, C, / BLOCKA /, D
8.6.15 TARGET statement
R859 target-stmt is TARGET [ :: ] target-decl-list
R860 target-decl is object-name [ ( array-spec ) ]
[ lbracket coarray-spec rbracket ]
NOTE 8.37An example of a TARGET statement is:
TARGET :: A (1000, 1000), B
8.6.16 VALUE statement R861 value-stmt is VALUE [ :: ] dummy-arg-name-list ⃝c ISO/IEC 2017 – All rights reserved 117
ISO/IEC DIS 1539-1:2017 (E)
1 The VALUE statement specifies the VALUE attribute (8.5.18) for a list of dummy arguments.
8.6.17 VOLATILE statement1 The VOLATILE statement specifies the VOLATILE attribute (8.5.19) for a list of objects.R862 volatile-stmt is VOLATILE [ :: ] object-name-list
8.7 IMPLICIT statement1 In a scoping unit, an IMPLICIT statement specifies a type, and possibly type parameters, for all implicitly
typed data entities whose names begin with one of the letters specified in the statement. An IMPLICIT NONE2 A letter-spec consisting of two letters separated by a minus is equivalent to writing a list containing all of the lettersstatement can indicate that no implicit typing rules are to apply in a particular scoping unit, or that external
and dummy procedures need to be explicitly given the EXTERNAL attribute.
R863 implicit-stmt is IMPLICIT implicit-spec-list
or IMPLICIT NONE [ ( [ implicit-none-spec-list ] ) ]
R864 implicit-spec is declaration-type-spec ( letter-spec-list )
R865 letter-spec is letter [ – letter ]
R866 implicit-none-spec is EXTERNAL
or TYPE
C890 (R863) If an IMPLICIT NONE statement appears in a scoping unit, it shall precede any PARAMETER
statements that appear in the scoping unit. No more than one IMPLICIT NONE statement shall appear
in a scoping unit.
C891 The same implicit-none-spec shall not appear more than once in a given implicit-stmt.
C892 If an IMPLICIT NONE statement in a scoping unit has an implicit-none-spec of TYPE or has no implicit-
none-spec-list, there shall be no other IMPLICIT statements in the scoping unit.
C893 (R865) If the minus and second letter appear, the second letter shall follow the first letter alphabetically.
C894 If IMPLICIT NONE with an implicit-none-spec of EXTERNAL appears within a scoping unit, the
name of an external or dummy procedure in that scoping unit or in a contained subprogram or BLOCK
construct shall have an explicit interface or be explicitly declared to have the EXTERNAL attribute.
in alphabetical order in the alphabetic sequence from the first letter through the second letter. For example, A–C3 In each scoping unit, there is a mapping, which may be null, between each of the letters A, B, ..., Z and ais equivalent to A, B, C. The same letter shall not appear as a single letter, or be included in a range of letters,
more than once in all of the IMPLICIT statements in a scoping unit.
type (and type parameters). An IMPLICIT statement specifies the mapping for the letters in its letter-spec-4 Any data entity that is not explicitly declared by a type declaration statement, is not an intrinsic function, islist. IMPLICIT NONE with an implicit-none-spec of TYPE or with no implicit-none-spec-list specifies the null
mapping for all the letters. If a mapping is not specified for a letter, the default for a program unit or an interface
body is default integer if the letter is I, J, ..., or N and default real otherwise, and the default for a BLOCK
construct, internal subprogram, or module subprogram is the mapping in the host scoping unit.
not a component, and is not accessed by use or host association is declared implicitly to be of the type (andtype parameters) mapped from the first letter of its name, provided the mapping is not null. The mapping for
the first letter of the data entity shall either have been established by a prior IMPLICIT statement or be the
default mapping for the letter. An explicit type specification in a FUNCTION statement overrides an IMPLICIT
statement for the result of that function.
118 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
NOTE 8.38
The following are examples of the use of IMPLICIT statements:
...
FUNCTION FUN (I) ! Not all data entities need to INTEGER FUN ! be declared explicitly
FUNCTION JFUN (J) ! All data entities need to INTEGER JFUN, J ! be declared explicitly....
IMPLICIT COMPLEX (C)
...
C = (3.0, 2.0) ! C is implicitly declared COMPLEX
SUBROUTINE SUB1
IMPLICIT INTEGER (A, C)END SUBROUTINE SUB1C = (0.0, 0.0) ! C is host associated and of
! type complex
Z = 1.0 ! Z is implicitly declared REAL
A = 2 ! A is implicitly declared INTEGER
CC = 1 ! CC is implicitly declared INTEGER
...
SUBROUTINE SUB2
Z = 2.0 ! Z is implicitly declared REAL andEND SUBROUTINE SUB2! is different from the variable of
! the same name in SUB1
...
SUBROUTINE SUB3
USE EXAMPLE_MODULE ! Accesses integer function FUNEND SUBROUTINE SUB3! by use association
Q = FUN (K) ! Q is implicitly declared REAL and
... ! K is implicitly declared INTEGER
NOTE 8.39
The following is an example of a mapping to a derived type that is inaccessible in the local scope:
IMPLICIT TYPE(BLOB) (A)
INTEGER :: I
TYPE(BLOB) :: B
⃝
c ISO/IEC 2017 – All rights reserved 119
ISO/IEC DIS 1539-1:2017 (E)
NOTE 8.39 (cont.)
INTEGER :: BLOB
...
AA = B
...
In the subroutine STEVE, it is not possible to explicitly declare a variable to be of type BLOB because
BLOB has been given a different meaning, but implicit mapping for the letter A still maps to type BLOB,
so AA is of type BLOB.
NOTE 8.40
Implicit typing is not affected by BLOCK constructs. For example, in
SUBROUTINE S(N)...
IF (N>0) THEN
NSQP = CEILING (SQRT (DBLE (N)))
...
IF (N>0) THEN
PRINT *,NSQP
even if the only two appearances of NSQP are within the BLOCK constructs, the scope of NSQP is the whole
subroutine S.
NOTE 8.41
In the subprogram
SUBROUTINE EXAMPLE (X, Y)IMPLICIT NONE (EXTERNAL)
REAL, EXTERNAL :: G
REAL :: X, Y
X = F (Y) ! Invalid: F lacks the EXTERNAL attribute.
X = G (Y) ! Valid: G has the EXTERNAL attribute.
the referenced function F needs to have the EXTERNAL attribute (8.5.9).
| 8.8 |
IMPORT statement
| |||||||||||||||||||||||
IMPORT, NONE
...
DO i=1,n ! Forces I to be locally declared.
NOTE 8.43
The IMPORT, ALL statement can be used to confirm the default rules and prevent accidental “shadowing”
of host entities:
SUBROUTINE outerREAL x
...
SUBROUTINE inner
| ⃝c ISO/IEC 2017 – All rights reserved | |
| 121 | |
|
| |
|
ISO/IEC DIS 1539-1:2017 (E)
NOTE 8.43 (cont.) | |
IMPORT, NONE
!IMPORT, ONLY: X
X = 1.0
is not conformant. The variable X is implicitly declared in the scoping unit of the main program. The
statement IMPORT, NONE makes X inaccessible in the BLOCK construct. If the IMPORT, NONE
statement is replaced with the IMPORT statement in the comment, the program is conformant.
NOTE 8.46
The IMPORT statement can be used to allow module procedures to have dummy arguments that are
procedures with assumed-shape arguments of an opaque type. For example:
...
PRIVATE ! T is an opaque type
SUBROUTINE PROCESS(X,Y,RESULT,MONITOR)
TYPE(T),INTENT(IN) :: X(:,:),Y(:,:)TYPE(T),INTENT(OUT) :: RESULT(:,:)
SUBROUTINE MONITOR(ITERATION_NUMBER,CURRENT_ESTIMATE)
INTEGER,INTENT(IN) :: ITERATION_NUMBER
TYPE(T),INTENT(IN) :: CURRENT_ESTIMATE(:,:)
...
122 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)NOTE 8.46 (cont.)
The MONITOR dummy procedure requires an explicit interface because it has an assumed-shape array
argument, but TYPE(T) would not be available inside the interface body without the IMPORT statement.
| 8.9 |
NAMELIST statement
1 A NAMELIST statement specifies a group of named data objects, which may be referred to by a single name for
the purpose of data transfer (12.6, 13.11).2 The order in which the values appear on output is the same as the order of the namelist-group-objects in the
namelist group object list; if a variable appears more than once as a namelist-group-object for the same namelist3 Any namelist-group-name may occur more than once in the NAMELIST statements in a scoping unit. The
namelist-group-object-list following each successive appearance of the same namelist-group-name in a scoping4 A namelist group object may be a member of more than one namelist group. 5 A namelist group object shall either be accessed by use or host association or shall have its declared type, kind
type parameters of the declared type, and rank specified by previous specification statements or the procedure1 An EQUIVALENCE statement is used to specify the sharing of storage units by two or more objects in a scoping unit. This causes
storage association (19.5.3) of the objects that share the storage units.2 If the equivalenced objects have differing type or type parameters, the EQUIVALENCE statement does not cause type conversion or
imply mathematical equivalence. If a scalar and an array are equivalenced, the scalar does not have array properties and the array1 An EQUIVALENCE statement specifies that the storage sequences (<IP_ADDRESS>) of the data objects specified in an equivalence-set are
storage associated. All of the nonzero-sized sequences in the equivalence-set, if any, have the same first storage unit, and all of2 If any data object in an equivalence-set has the SAVE attribute, all other objects in the equivalence-set have the SAVE attribute;
this may be confirmed by explicit specification.1 A default character data object shall not be equivalenced to an object that is not default character and not of a character sequence
type. The lengths of equivalenced default character objects need not be the same.2 An EQUIVALENCE statement specifies that the storage sequences of all the default character data objects specified in an equivalence-
set are storage associated. All of the nonzero-sized sequences in the equivalence-set, if any, have the same first character storage unit,1 For a nonzero-sized array, the use of the array name unqualified by a subscript list as an equivalence-object has the same effect as
using an array element designator that identifies the first element of the array.1 An EQUIVALENCE statement shall not specify that the same storage unit is to occur more than once in a storage sequence. 2 An EQUIVALENCE statement shall not specify that consecutive storage units are to be nonconsecutive.
8.10.2 COMMON statement1 The COMMON statement specifies blocks of physical storage, called common blocks, that can be accessed by any of the scoping
units in a program. Thus, the COMMON statement provides a global data facility based on storage association (19.5.3).2 A common block that does not have a name is called blank common.
R873 common-stmt is COMMON3 In each COMMON statement, the data objects whose names appear in a common block object list following a common block name
are declared to be in that common block. If the first common block name is omitted, all data objects whose names appear in the4 Any common block name or an omitted common block name for blank common may occur more than once in one or more COMMON
statements in a scoping unit. The common block list following each successive appearance of the same common block name in a5 The form variable-name (array-spec) specifies the DIMENSION attribute for that variable. 6 If derived-type objects of numeric sequence type or character sequence type (<IP_ADDRESS>) appear in common, it is as if the individual
components were enumerated directly in the common list.1 For each common block in a scoping unit, a common block storage sequence is formed as follows:
(1) A storage sequence is formed consisting of the sequence of storage units in the storage sequences (<IP_ADDRESS>) of all data2 Only COMMON statements and EQUIVALENCE statements appearing in the scoping unit contribute to common block storage
sequences formed in that scoping unit.1 The size of a common block is the size of its common block storage sequence, including any extensions of the sequence resulting from
equivalence association.1 Within a program, the common block storage sequences of all nonzero-sized common blocks with the same name have the same first
storage unit, and the common block storage sequences of all zero-sized common blocks with the same name are storage associated2 A nonpointer object that is default integer, default real, double precision real, default complex, default logical, or of numeric sequence
type shall be associated only with nonpointer objects of these types and kinds.3 A nonpointer object that is default character or of character sequence type shall be associated only with nonpointer objects of these
types and kinds.4 A nonpointer object of a derived type that is not a numeric sequence or character sequence type shall be associated only with
nonpointer objects of the same type.5 A nonpointer object of intrinsic type but which is not default integer, default real, double precision real, default complex, default
logical, or default character shall be associated only with nonpointer objects of the same type and type parameters.6 A data pointer shall be storage associated only with data pointers of the same type and rank. Data pointers that are storage
associated shall have deferred the same type parameters; corresponding nondeferred type parameters shall have the same value.7 An object with the TARGET attribute shall be storage associated only with another object that has the TARGET attribute and the
same type and type parameters.1 A blank common block has the same properties as a named common block, except for the following.
• Execution of a RETURN or END statement might cause data objects in a named common block to become undefined unless
1 An EQUIVALENCE statement shall not cause the storage sequences of two different common blocks to be associated.
126 ⃝ c ISO/IEC 2017 – All rights reserved2 Equivalence association shall not cause a derived-type object with default initialization to be associated with an object in a common
block.3 Equivalence association shall not cause a common block storage sequence to be extended by adding storage units preceding the first
storage unit of the first object specified in a COMMON statement for the common block.ISO/IEC DIS 1539-1:2017 (E)
(Blank page)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E)2 An allocate-object or a bound or type parameter of an allocate-object shall not depend on the value of stat-variable, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
the value of errmsg-variable, or on the value, bounds, length type parameters, allocation status, or association3 source-expr shall not be allocated within the ALLOCATE statement in which it appears; nor shall it depend on | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
the value, bounds, deferred type parameters, allocation status, or association status of any allocate-object in that4 If an ALLOCATE statement has a SOURCE= specifier and an allocate-object that is a coarray, source-expr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shall not have a dynamic type of C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING, or5 If type-spec is specified, each allocate-object is allocated with the specified dynamic type and type parameter | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
values; if source-expr is specified, each allocate-object is allocated with the dynamic type and type parameter6 If a type-param-value in a type-spec in an ALLOCATE statement is an asterisk, it denotes the current value of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
that assumed type parameter. If it is an expression, subsequent redefinition or undefinition of any entity in the1 When an ALLOCATE statement is executed for an array for which allocate-shape-spec-list is specified, the values | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
of the lower bound and upper bound expressions determine the bounds of the array. Subsequent redefinition2 When an ALLOCATE statement is executed for a coarray, the values of the lower cobound and upper cobound | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
expressions determine the cobounds of the coarray. Subsequent redefinition or undefinition of any entities in the3 If an allocation specifies a coarray, its dynamic type and the values of corresponding type parameters shall be the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
same on every active image in the current team. The values of corresponding bounds and corresponding cobounds4 When an ALLOCATE statement is executed for which an allocate-object is a coarray, there is an implicit syn- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chronization of all active images in the current team. If the current team contains a stopped or failed image,5 If source-expr is a pointer, it shall be associated with a target. If source-expr is allocatable, it shall be allocated. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
6 When an ALLOCATE statement is executed for an array with no allocate-shape-spec-list, the bounds of source-
expr determine the bounds of the array. Subsequent changes to the bounds of source-expr do not affect the array7 If SOURCE= appears, source-expr shall be conformable with allocation. If an allocate-object is not polymorphic
and the source-expr is polymorphic with a dynamic type that differs from its declared type, the value provided for8 If MOLD= appears and source-expr is a variable, its value need not be defined. 9 If type-spec appears and the value of a length type parameter it specifies differs from the value of the corresponding
nondeferred type parameter specified in the declaration of any allocate-object, an error condition occurs. If the10 The set of error conditions for an ALLOCATE statement is processor dependent. If an error condition occurs
during execution of an ALLOCATE statement that does not contain the STAT= specifier, error termination is1 The allocation status of an allocatable entity is one of the following at any time.
• The status of an allocatable variable becomes “allocated” if it is allocated by an ALLOCATE statement, if2 At the beginning of execution of a program, allocatable variables are unallocated. 3 When the allocation status of an allocatable variable changes, the allocation status of any associated allocat-
able variable changes accordingly. Allocation of an allocatable variable establishes values for the deferred type4 An unsaved allocatable local variable of a procedure has a status of unallocated at the beginning of each invocation
of the procedure. An unsaved allocatable local variable of a construct has a status of unallocated at the beginningISO/IEC DIS 1539-1:2017 (E) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 When an object of derived type is created by an ALLOCATE statement, any allocatable ultimate components | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
have an allocation status of unallocated unless the SOURCE= specifier appears and the corresponding component6 If the evaluation of a function would change the allocation status of a variable and if a reference to the function | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
appears in an expression in which the value of the function is not needed to determine the value of the expression,1 Allocation of a pointer creates an object that implicitly has the TARGET attribute. Following successful execution | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
of an ALLOCATE statement for a pointer, the pointer is associated with the target and may be used to reference2 At the beginning of execution of a function whose result is a pointer, the association status of the result pointer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
is undefined. Before such a function returns, it shall either associate a target with this pointer or cause the1 A pointer-object shall not depend on the value, bounds, or association status of another pointer-object in the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
same NULLIFY statement.2 Execution of a NULLIFY statement causes each pointer-object to become disassociated. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NOTE 9.21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
deallocated and the pointers to be disassociated.2 An allocate-object shall not depend on the value, bounds, allocation status, or association status of anotherR940 deallocate-stmt is DEALLOCATE ( allocate-object-list [ , dealloc-opt-list ] )
R941 dealloc-opt is STAT = stat-variable
or ERRMSG = errmsg-variable
C952 (R941) No dealloc-opt shall appear more than once in a given dealloc-opt-list.
142 ⃝
c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
allocate-object in the same DEALLOCATE statement; it also shall not depend on the value of the stat-variable3 The set of error conditions for a DEALLOCATE statement is processor dependent. If an error condition occursor errmsg-variable in the same DEALLOCATE statement.
during execution of a DEALLOCATE statement that does not contain the STAT= specifier, error termination is4 When more than one allocated object is deallocated by execution of a DEALLOCATE statement, the order ofinitiated. The STAT= specifier is described in 9.7.4. The ERRMSG= specifier is described in 9.7.5.
deallocation is processor dependent.1 Deallocating an unallocated allocatable variable causes an error condition in the DEALLOCATE statement.NOTE 9.22
An example of a DEALLOCATE statement is:
DEALLOCATE (X, B)
<IP_ADDRESS> Deallocation of allocatable variables
Deallocating an allocatable variable with the TARGET attribute causes the pointer association status of any2 When the execution of a procedure is terminated by execution of a RETURN or END statement, an unsavedpointer associated with it to become undefined. An allocatable variable shall not be deallocated if it or any
subobject of it is argument associated with a dummy argument or construct associated with an associate name.
allocatable local variable of the procedure retains its allocation and definition status if it is a function result or a3 When a BLOCK construct terminates, any unsaved allocated allocatable local variable of the construct is deal-subobject thereof; otherwise, if it is allocated it will be deallocated.
located.4 If an executable construct references a function whose result is allocatable or has an allocatable subobject, and
the function reference is executed, an allocatable result and any allocated allocatable subobject of the result is5 If a function whose result is allocatable or has an allocatable subobject is referenced in the specification part of adeallocated after execution of the innermost executable construct containing the reference.
scoping unit, and the function reference is executed, an allocatable result and any allocated allocatable subobject6 When a procedure is invoked, any allocated allocatable object that is an actual argument corresponding to anof the result is deallocated before execution of the executable constructs of the scoping unit.
INTENT (OUT) allocatable dummy argument is deallocated; any allocated allocatable object that is a subobject7 When an intrinsic assignment statement (<IP_ADDRESS>) is executed, any noncoarray allocated allocatable subobject ofof an actual argument corresponding to an INTENT (OUT) dummy argument is deallocated. If a Fortran proced-
ure that has an INTENT (OUT) allocatable dummy argument is invoked by a C function and the corresponding
argument in the C function call is a C descriptor that describes an allocated allocatable variable, the variable
is deallocated on entry to the Fortran procedure. If a C function is invoked from a Fortran procedure via an
interface with an INTENT (OUT) allocatable dummy argument and the corresponding actual argument in the
reference to the C function is an allocated allocatable variable, the variable is deallocated on invocation (before
execution of the C function begins).
the variable is deallocated before the assignment takes place.8 When a variable of derived type is deallocated, any allocated allocatable subobject is deallocated. If an error
condition occurs during deallocation, it is processor dependent whether an allocated allocatable subobject is9 If an allocatable component is a subobject of a finalizable object, that object is finalized before the component isdeallocated.
automatically deallocated.10 When a statement that deallocates a coarray is executed, there is an implicit synchronization of all active images⃝c ISO/IEC 2017 – All rights reserved 143
ISO/IEC DIS 1539-1:2017 (E)
in the current team. If the current team contains a stopped or failed image, an error condition occurs. If no11 If an allocate-object is a coarray dummy argument, its ultimate argument (<IP_ADDRESS>) shall be the same coarray onother error condition occurs, execution on the active images of the segment (11.6.2) following the statement is
delayed until all other active images in the current team have executed the same statement the same number of
times in this team. The segments that executed before the statement on an active image of this team precede
the segments that execute after the statement on another active image of this team. A coarray shall not become
deallocated on an image unless it is successfully deallocated on all active images in this team.
those images.12 The effect of automatic deallocation is the same as that of a DEALLOCATE statement without a dealloc-opt-list.
NOTE 9.23In the following example:
REAL, ALLOCATABLE :: TEMP(:)
REAL, ALLOCATABLE, SAVE :: X(:)
...
on return from subroutine PROCESS, the allocation status of X is preserved because X has the SAVE
attribute. TEMP does not have the SAVE attribute, so it will be deallocated if it was allocated. On the
next invocation of PROCESS, TEMP will have an allocation status of unallocated.
NOTE 9.24
For example, executing a RETURN, END, or END BLOCK statement, or deallocating an object that has
an allocatable subobject, can cause deallocation of a coarray, and thus an implicit synchronization of all
active images in the current team.
| <IP_ADDRESS> |
Deallocation of pointer targets
1 If a pointer appears in a DEALLOCATE statement, its association status shall be defined. Deallocating a pointer
that is disassociated or whose target was not created by an ALLOCATE statement causes an error condition2 If a pointer appears in a DEALLOCATE statement, it shall be associated with the whole of an object that was
created by allocation. The pointer shall have the same dynamic type and type parameters as the allocated object,1 A stat-variable should have a decimal exponent range of at least four; otherwise the processor-dependent error
code might not be representable in the variable.2 This rest of this subclause applies where an alloc-opt or dealloc-opt that is a STAT= specifier appears in an
ALLOCATE or DEALLOCATE statement.3 The stat-variable shall not be allocated or deallocated within the ALLOCATE or DEALLOCATE statement
in which it appears; nor shall it depend on the value, bounds, deferred type parameters, allocation status, orassociation status of any allocate-object in that statement. The stat-variable shall not depend on the value of the
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 Successful execution of the ALLOCATE or DEALLOCATE statement causes the stat-variable to become defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||
with a value of zero.5 If an ALLOCATE or DEALLOCATE statement with a coarray allocate-object is executed when the current team | ||||||||||||||||||||||||||||||||||||||||||||||||||||
contains a stopped image, the stat-variable becomes defined with the value STAT_STOPPED_IMAGE from the6 If stat-variable became defined with the value STAT_FAILED_IMAGE, each allocate-object is successfully al- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
located or deallocated on all the active images of the current team. If any other error condition occurs, each1 The errmsg-variable shall not be allocated or deallocated within the ALLOCATE or DEALLOCATE statement | ||||||||||||||||||||||||||||||||||||||||||||||||||||
in which it appears; nor shall it depend on the value, bounds, deferred type parameters, allocation status, or2 If an error condition occurs during execution of an ALLOCATE or DEALLOCATE statement with an ERRMSG= | ||||||||||||||||||||||||||||||||||||||||||||||||||||
specifier, the errmsg-variable is assigned an explanatory message, truncated or padded according to the rules ofISO/IEC DIS 1539-1:2017 (E) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
(Blank page) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1 An intrinsic operation requires the values of its operands. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
2 Execution of a function reference in the logical expression in an IF statement (<IP_ADDRESS>), the mask expression in a
WHERE statement (<IP_ADDRESS>), or the concurrent-limits and concurrent-steps in a FORALL statement (10.2.4) is permitted to3 The appearance of an array constructor requires the evaluation of each scalar-int-expr of the ac-implied-do-control
in any ac-implied-do it may contain.4 When an elemental binary operation is applied to a scalar and an array or to two arrays of the same shape, the
operation is performed element-by-element on corresponding array elements of the array operands.5 When an elemental unary operator operates on an array operand, the operation is performed element-by-element,
and the result is the same shape as the operand. If an elemental operation is intrinsically pure or is implemented1 An intrinsic operation is either a unary or binary operation. An intrinsic unary operation is an operation of
the form intrinsic-operator x2 where x2 is of an intrinsic type (7.4) listed in Table 10.2 for the unary intrinsic2 An intrinsic binary operation is an operation of the form x1 intrinsic-operator x2 where x1 and x2 are conformable
and of the intrinsic types (7.4) listed in Table 10.2 for the binary intrinsic operator.3 A numeric intrinsic operation is an intrinsic operation for which the intrinsic-operator is a numeric operator (+,
–, *, /, or **). A numeric intrinsic operator is the operator in a numeric intrinsic operation.4 The character intrinsic operation is the intrinsic operation for which the intrinsic-operator is (//) and both
operands are of type character with the same kind type parameter. The character intrinsic operator is the5 A logical intrinsic operation is an intrinsic operation for which the intrinsic-operator is .AND., .OR., .NOT.,
.EQV., or .NEQV. and both operands are of type logical. A logical intrinsic operator is the operator in a logical6 A relational intrinsic operator is an intrinsic-operator that is .EQ., .NE., .GT., .GE., .LT., .LE., ==, /=, >,
>=, <, or <=. A relational intrinsic operation is an intrinsic operation for which the intrinsic-operator is a7 The interpretations defined in subclause 10.1.5 apply to both scalars and arrays; the interpretation for arrays is
obtained by applying the interpretation for scalars element by element. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
I I, R L, L
| .GT., .GE., .LT., .LE. | |||||||||||||||||||||||||||||||||||||||||||||||
| R I, R L, L | |||||||||||||||||||||||||||||||||||||||||||||||
>, >=, <, <= C C L | |||||||||||||||||||||||||||||||||||||||||||||||
character, and logical, respectively. Where more than one type for x2 isNOTE 10.14 | |||||||||||||||||||||||||||||||||||||||||||||||
| For example, if X is of type real and J is of type integer, the expression X + J is of type real. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1 The two operands of numeric intrinsic binary operations may be of different numeric types or different kind | |||||||||||||||||||||||||||||||||||||||||||||||
type parameters. Except for a value of type real or complex raised to an integer power, if the operands have2 A numeric operation is used to express a numeric computation. Evaluation of a numeric operation produces a | |||||||||||||||||||||||||||||||||||||||||||||||
numeric value. The permitted data types for operands of the numeric intrinsic operations are specified in <IP_ADDRESS>.3 The numeric operators and their interpretation in an expression are given in Table 10.3, where x1 denotes the | |||||||||||||||||||||||||||||||||||||||||||||||
operand to the left of the operator and x2 denotes the operand to the right of the operator.4 The interpretation of a division operation depends on the types of the operands (<IP_ADDRESS>.2). | |||||||||||||||||||||||||||||||||||||||||||||||
|
5 If x1 and x2 are of type integer and x2 has a negative value, the interpretation of x1 ** x2 is the same as the
interpretation of 1/(x1 ** ABS (x2 )), which is subject to the rules of integer division (<IP_ADDRESS>.2).1 One operand of type integer may be divided by another operand of type integer. Although the mathematical
quotient of two integers is not necessarily an integer, Table 10.2 specifies that an expression involving the division1 In the case of a complex value raised to a complex power, the value of the operation x1 ** x2 is the principal
value of xx1 2 .1 The execution of any numeric operation whose result is not defined by the arithmetic used by the processor is
prohibited. Raising a negative real value to a real power is prohibited.2 Once the interpretation of a numeric intrinsic operation is established, the processor may evaluate any mathem-
atically equivalent expression, provided that the integrity of parentheses is not violated.3 Two expressions of a numeric type are mathematically equivalent if, for all possible values of their primaries, their
mathematical values are equal. However, mathematically equivalent expressions of numeric type may produceISO/IEC DIS 1539-1:2017 (E)
NOTE 10.17
| |||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E)NOTE 10.20 | |||||||||||||||||||||||||||||||||||||||||||||||
|
Each operand in a numeric intrinsic operation has a type that can depend on the order of evaluation used by the processor. For example, in the evaluation of the expression
Z + R + Iwhere Z, R, and I represent data objects of complex, real, and integer type, respectively, the type of the operand that is added to I could be either complex or real, depending on which pair of operands (Z and R, R and I, or Z and I) is added first. | |||||||||||||||||||||||||||||||||||||||||||||||
| <IP_ADDRESS> | |||||||||||||||||||||||||||||||||||||||||||||||
Character intrinsic operation
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1 The character intrinsic operator // is used to concatenate two operands of type character with the same kind | |||||||||||||||||||||||||||||||||||||||||||||||
type parameter. Evaluation of the character intrinsic operation produces a result of type character.2 The interpretation of the character intrinsic operator // when used to form an expression is given in Table 10.4, | |||||||||||||||||||||||||||||||||||||||||||||||
where x1 denotes the operand to the left of the operator and x2 denotes the operand to the right of the operator.3 The result of the character intrinsic operation x1 // x2 is a character string whose value is the value of x1 | |||||||||||||||||||||||||||||||||||||||||||||||
concatenated on the right with the value of x2 and whose length is the sum of the lengths of x1 and x2 . Parentheses1 A processor is only required to evaluate as much of the character intrinsic operation as is required by the context | |||||||||||||||||||||||||||||||||||||||||||||||
in which the expression appears.1 A logical operation is used to express a logical computation. Evaluation of a logical operation produces a result | |||||||||||||||||||||||||||||||||||||||||||||||
of type logical. The permitted types for operands of the logical intrinsic operations are specified in <IP_ADDRESS>.2 The logical operators and their interpretation when used to form an expression are given in Table 10.5, where x1 | |||||||||||||||||||||||||||||||||||||||||||||||
denotes the operand to the left of the operator and x2 denotes the operand to the right of the operator.3 The values of the logical intrinsic operations are shown in Table 10.6. | |||||||||||||||||||||||||||||||||||||||||||||||
Table 10.6: The values of operations involving logical intrinsic operators | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| true true | |||||||||||||||||||||||||||||||||||||||||||||||
false true true true false
| |||||||||||||||||||||||||||||||||||||||||||||||
| <IP_ADDRESS>.2 | |||||||||||||||||||||||||||||||||||||||||||||||
|
Evaluation of logical intrinsic operations
1 Once the interpretation of a logical intrinsic operation is established, the processor may evaluate any other
expression that is logically equivalent, provided that the integrity of parentheses in any expression is not violated.2 Two expressions of type logical are logically equivalent if their values are equal for all possible values of their
primaries.1 A relational intrinsic operation is used to compare values of two operands using the relational intrinsic operators
.LT., .LE., .GT., .GE., .EQ., .NE., <, <=, >, >=, ==, and /=. The permitted types for operands of the2 The operators <, <=, >, >=, ==, and /= always have the same interpretations as the operators .LT., .LE.,
.GT., .GE., .EQ., and .NE., respectively.3 Evaluation of a relational intrinsic operation produces a default logical result. 4 The interpretation of the relational intrinsic operators is given in Table 10.7, where x1 denotes the operand to
the left of the operator and x2 denotes the operand to the right of the operator.5 A numeric relational intrinsic operation is interpreted as having the logical value true if and only if the values of
the operands satisfy the relation specified by the operator.6 In the numeric relational operation
x1 rel-op x2if the types or kind type parameters of x1 and x2 differ, their values are converted to the type and kind type
7 A character relational intrinsic operation is interpreted as having the logical value true if and only if the values
of the operands satisfy the relation specified by the operator.8 For a character relational intrinsic operation, the operands are compared one character at a time in order,
beginning with the first character of each character operand. If the operands are of unequal length, the shorter1 Once the interpretation of a relational intrinsic operation is established, the processor may evaluate any other
expression that is relationally equivalent, provided that the integrity of parentheses in any expression is not2 Two relational intrinsic operations are relationally equivalent if their logical values are equal for all possible values
of their primaries.1 A defined operation is either a unary operation or a binary operation. A unary defined operation is an operation
that has the form defined-unary-op x2 or intrinsic-operator x2 and that is defined by a function and a generic2 A function defines the unary operation op x2 if
(1) the function is specified with a FUNCTION (<IP_ADDRESS>) or ENTRY (<IP_ADDRESS>) statement that specifies one3 If d2 is an array, the shape of x2 shall match the shape of d2 . 4 A binary defined operation is an operation that has the form x1 defined-binary-op x2 or x1 intrinsic-operator x2
and that is defined by a function and a generic interface.5 A function defines the binary operation x1 op x2 if
(1) the function is specified with a FUNCTION (<IP_ADDRESS>) or ENTRY (<IP_ADDRESS>) statement that specifies
| |||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E) | |||||||||||||||||||||||||||||||||||||||||||||||
the operation.6 If d1 or d2 is an array, the shapes of x1 and x2 shall match the shapes of d1 and d2 , respectively.
NOTE 10.27 | |||||||||||||||||||||||||||||||||||||||||||||||
| <IP_ADDRESS> | |||||||||||||||||||||||||||||||||||||||||||||||
|
Interpretation of a defined operation
1 The interpretation of a defined operation is provided by the function that defines the operation. 2 The operators <, <=, >, >=, ==, and /= always have the same interpretations as the operators .LT., .LE.,
.GT., .GE., .EQ., and .NE., respectively.1 Once the interpretation of a defined operation is established, the processor may evaluate any other expression
that is equivalent, provided that the integrity of parentheses is not violated.2 Two expressions of derived type are equivalent if their values are equal for all possible values of their primaries.
10.1.7 Evaluation of operands1 It is not necessary for a processor to evaluate all of the operands of an expression, or to evaluate entirely each
operand, if the value of the expression can be determined otherwise.2 If a statement contains a function reference in a part of an expression that need not be evaluated, all entities that
would have become defined in the execution of that reference become undefined at the completion of evaluation3 If a statement contains a function reference in a part of an expression that need not be evaluated, no invocation
of that function in that part of the expression shall execute an image control statement other than CRITICAL1 The rules for evaluation specified in subclause 10.1.5 state certain conditions under which a processor may
evaluate an expression that is different from the one specified by applying the rules given in 10.1.2 and rules for1 The type, type parameters, and shape of an expression depend on the operators and on the types, type parameters,
and shapes of the primaries used in the expression, and are determined recursively from the syntactic form of the2 If an expression is a polymorphic primary or defined operation, the type parameters and the declared and dynamic
types of the expression are the same as those of the primary or defined operation. Otherwise the type parameters1 The type, type parameters, and shape of a primary are determined according to whether the primary is a literal
constant, designator, array constructor, structure constructor, function reference, type parameter inquiry, type2 If a primary is a parenthesized expression, its type, type parameters, and shape are those of the expression. 3 The associated target object is referenced if a pointer appears as
• a primary in an intrinsic or defined operation,
4 The type, type parameters, and shape of the primary are those of the target. If the pointer is not associated with
a target, it may appear as a primary only as an actual argument in a reference to a procedure whose corresponding5 A disassociated array pointer or an unallocated allocatable array has no shape but does have rank. The type,
type parameters, and rank of the result of the intrinsic function NULL (16.9.144) depend on context.1 The type of the result of an intrinsic operation [x1 ] op x2 is specified by Table 10.2. The shape of the result of
an intrinsic operation is the shape of x2 if op is unary or if x1 is scalar, and is the shape of x1 otherwise.2 The type, type parameters, and shape of the result of a defined operation [x1 ] op x2 are specified by the function
defining the operation (10.1.6).3 An expression of an intrinsic type has a kind type parameter. An expression of type character also has a character
length parameter.4 The type parameters of the result of an intrinsic operation are as follows.
• For an expression x1 // x2 where // is the character intrinsic operator and x1 and x2 are of type character,
1 An elemental operation is an intrinsic operation or a defined operation for which the function is elemental (15.8). 2 For all elemental binary operations, the two operands shall be conformable. In the case where one is a scalar and
the other an array, the scalar is treated as if it were an array of the same shape as the array operand with every1 A specification expression is an expression with limitations that make it suitable for use in specifications such as
length type parameters (C704) and array bounds (R817, R818). A specification-expr shall be a constant expression2 A restricted expression is an expression in which each operation is intrinsic or defined by a specification function
and each primary is3 where each subscript, section subscript, substring starting point, substring ending point, and type parameter
value is a restricted expression, and where any final subroutine that is invoked is pure.4 A specification inquiry is a reference to
(1) an intrinsic inquiry function other than PRESENT,
| |||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E)5 A function is a specification function if it is a pure function, is not a standard intrinsic function, is not an internal | |||||||||||||||||||||||||||||||||||||||||||||||
function, is not a statement function, and does not have a dummy procedure argument.6 Evaluation of a specification expression shall not directly or indirectly cause a procedure defined by the subpro- | |||||||||||||||||||||||||||||||||||||||||||||||
gram in which it appears to be invoked.7 A variable in a specification expression shall have its type and type parameters, if any, specified by a previous | |||||||||||||||||||||||||||||||||||||||||||||||
declaration in the same scoping unit, by the implicit typing rules in effect for the scoping unit, or by host or use8 If a specification expression includes a specification inquiry that depends on a type parameter, array bound, | |||||||||||||||||||||||||||||||||||||||||||||||
or cobound of an entity specified in the same specification-part, the type parameter, array bound, or cobound9 A generic entity referenced in a specification expression in the specification-part of a scoping unit shall have no | |||||||||||||||||||||||||||||||||||||||||||||||
specific procedures defined in the scoping unit, or its host scoping unit, subsequent to the specification expression.1 A constant expression is an expression with limitations that make it suitable for use as a kind type parameter, | |||||||||||||||||||||||||||||||||||||||||||||||
initializer, or named constant. It is an expression in which each operation is intrinsic, and each primary is2 If a constant expression includes a specification inquiry that depends on a type parameter or an array bound of | |||||||||||||||||||||||||||||||||||||||||||||||
an entity specified in the same specification-part, the type parameter or array bound shall be specified in a prior3 A generic entity referenced in a constant expression in the specification-part of a scoping unit shall have no specific | |||||||||||||||||||||||||||||||||||||||||||||||
procedures defined in that scoping unit, or its host scoping unit, subsequent to the constant expression.1 An assignment-stmt shall meet the requirements of either a defined assignment statement or an intrinsic assign- | |||||||||||||||||||||||||||||||||||||||||||||||
ment statement.1 An intrinsic assignment statement is an assignment statement that is not a defined assignment statement | |||||||||||||||||||||||||||||||||||||||||||||||
(<IP_ADDRESS>). In an intrinsic assignment statement,2 If the variable in an intrinsic assignment statement is a coindexed object, | |||||||||||||||||||||||||||||||||||||||||||||||
• the variable shall not be polymorphic, | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||
| ISO/IEC DIS 1539-1:2017 (E) | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 If the variable is a pointer, it shall be associated with a definable target such that the type, type parameters, | |||||||||||||||||||||||||||||||||||||||||||||||
and shape of the target and expr conform. If the variable is a coarray or a coindexed object, it shall not be an1 Execution of an intrinsic assignment causes, in effect, the evaluation of the expression expr and all expressions | |||||||||||||||||||||||||||||||||||||||||||||||
within variable (10.1), the possible conversion of expr to the type and type parameters of the variable (Table2 If the variable is a pointer, the value of expr is assigned to the target of the variable. | |||||||||||||||||||||||||||||||||||||||||||||||
|
3 If the variable is an unallocated allocatable array, expr shall have the same rank. If the variable is an allocated
allocatable variable, it is deallocated if expr is an array of different shape, any corresponding length type parameter4 Both variable and expr may contain references to any portion of the variable.
NOTE 10.375 If expr is a scalar and the variable is an array, the expr is treated as if it were an array of the same shape as the
variable with every element of the array equal to the scalar value of expr.6 If the variable is an array, the assignment is performed element-by-element on corresponding array elements of
the variable and expr.7 The processor may perform the element-by-element assignment in any order.
NOTE 10.398 For an intrinsic assignment statement where the variable is of numeric type, the expr can have a different numeric
type or kind type parameter, in which case the value of expr is converted to the type and kind type parameter9 For an intrinsic assignment statement where the variable is of type logical, the expr can have a different kind
type parameter, in which case the value of expr is converted to the kind type parameter of the variable.10 For an intrinsic assignment statement where the variable is of type character, the expr can have a different
character length parameter in which case the conversion of expr to the length of the variable is as follows.11 For an intrinsic assignment statement where the variable is of type character, if expr has a different kind type para-
meter, each character c in expr is converted to the kind type parameter of the variable by ACHAR (IACHAR(c),12 For an intrinsic assignment of the type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING,
or of the type TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV, the variable becomes undefined13 An intrinsic assignment where the variable is of derived type is performed as if each component of the variable
were assigned from the corresponding component of expr using pointer assignment (10.2.2) for each pointer14 The processor may perform the component-by-component assignment in any order or by any means that has the
same effect.1 A defined assignment statement is an assignment statement that is defined by a subroutine and a generic interface
(7.5.5, <IP_ADDRESS>.3) that specifies ASSIGNMENT (=).2 A subroutine defines the defined assignment x1 = x2 if
(1) the subroutine is specified with a SUBROUTINE (<IP_ADDRESS>) or ENTRY (<IP_ADDRESS>) statement that specifies
| |||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E) | |||||||||||||||||||||||||||||||||||||||||||||||
(a) the ranks of x1 and x2 match those of d1 and d2 or3 If d1 or d2 is an array, the shapes of x1 and x2 shall match the shapes of d1 and d2 , respectively. If the subroutine
is elemental, x2 shall be conformable with x1 .1 The interpretation of a defined assignment is provided by the subroutine that defines it. | |||||||||||||||||||||||||||||||||||||||||||||||
| 2 If the defined assignment is an elemental assignment and the variable in the assignment is an array, the defined | |||||||||||||||||||||||||||||||||||||||||||||||
assignment is performed element-by-element, on corresponding elements of the variable and expr. If expr is a1 Pointer assignment causes a pointer to become associated with a target or causes its pointer association status | |||||||||||||||||||||||||||||||||||||||||||||||
to become disassociated or undefined. Any previous association between the pointer and a target is broken.2 Pointer assignment for a pointer component of a structure may also take place by execution of a derived-type | |||||||||||||||||||||||||||||||||||||||||||||||
intrinsic assignment statement (<IP_ADDRESS>).ISO/IEC DIS 1539-1:2017 (E) | |||||||||||||||||||||||||||||||||||||||||||||||
|
C1016 (R1033) If data-target is unlimited polymorphic, data-pointer-object shall be unlimited polymorphic, or
of a type with the BIND attribute or the SEQUENCE attribute.C1017 (R1033) If bounds-spec-list is specified, the number of bounds-specs shall equal the rank of data-pointer-
object.C1018 (R1033) If bounds-remapping-list is specified, the number of bounds-remappings shall equal the rank of
data-pointer-object.C1019 (R1033) If bounds-remapping-list is not specified, the ranks of data-pointer-object and data-target shall
be the same.C1020 (R1033) A coarray data-target shall have the VOLATILE attribute if and only if the data-pointer-object
has the VOLATILE attribute.C1021 (R1034) A variable-name shall have the POINTER attribute. C1022 (R1034) A scalar-variable shall be a data-ref . C1023 (R1034) A data-pointer-component-name shall be the name of a component of scalar-variable that is a
data pointer.C1024 (R1034) A data-pointer-object shall not be a coindexed object.
| |||||||||||||||||||||||||||||||||||||||||||||||
|
ISO/IEC DIS 1539-1:2017 (E)C1031 (R1040) The proc-target shall not be a nonintrinsic elemental procedure. | |||||||||||||||||||||||||||||||||||||||||||||||
|
1 In a pointer assignment statement, data-pointer-object or proc-pointer-object denotes the pointer object and
data-target or proc-target denotes the pointer target.2 For pointer assignment performed by a derived-type intrinsic assignment statement, the pointer object is the
pointer component of the variable and the pointer target is the corresponding component of expr.1 If the pointer object is not polymorphic (<IP_ADDRESS>) and the pointer target is polymorphic with dynamic type that
differs from its declared type, the assignment target is the ancestor component of the pointer target that has the2 If the pointer target is not a pointer, the pointer object becomes pointer associated with the assignment target;
if the pointer target is a pointer with a target that is not on the same image, the pointer association status of the3 If the pointer object is polymorphic, it assumes the dynamic type of the pointer target. If the pointer object is
of a type with the BIND attribute or the SEQUENCE attribute, the dynamic type of the pointer target shall be4 If the pointer target is a disassociated pointer, all nondeferred type parameters of the declared type of the pointer
object that correspond to nondeferred type parameters of the pointer target shall have the same values as the5 Otherwise, all nondeferred type parameters of the declared type of the pointer object shall have the same values
as the corresponding type parameters of the pointer target.6 If the pointer object has nondeferred type parameters that correspond to deferred type parameters of the pointer
target, the pointer target shall not be a pointer with undefined association status.7 If the pointer object has the CONTIGUOUS attribute, the pointer target shall be contiguous. 8 If the target of a pointer is a coarray, the pointer shall have the VOLATILE attribute if and only if the coarray
has the VOLATILE attribute.9 If bounds-remapping-list appears, it specifies the upper and lower bounds of each dimension of the pointer,
and thus the extents; the pointer target shall be simply contiguous (9.5.4) or of rank one, and shall not be a10 If no bounds-remapping-list appears, the extent of a dimension of the pointer object is the extent of the corres-
ponding dimension of the pointer target. If bounds-spec-list appears, it specifies the lower bounds; otherwise,ISO/IEC DIS 1539-1:2017 (E)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1 If the pointer target is not a pointer, the pointer object becomes pointer associated with the pointer target. | |||||||||||||||||||||||||||||||||||||||||||||||
Otherwise, the pointer association status of the pointer object becomes that of the pointer target; if the pointer2 The host instance (<IP_ADDRESS>) of an associated procedure pointer is the host instance of its target. | |||||||||||||||||||||||||||||||||||||||||||||||
|
3 If the pointer object has an explicit interface, its characteristics shall be the same as the pointer target except
that the pointer target may be pure even if the pointer object is not pure and the pointer target may be an4 If the characteristics of the pointer object or the pointer target are such that an explicit interface is required,
both the pointer object and the pointer target shall have an explicit interface.5 If the pointer object has an implicit interface and is explicitly typed or referenced as a function, the pointer target
shall be a function. If the pointer object has an implicit interface and is referenced as a subroutine, the pointer6 If the pointer object is a function with an implicit interface, the pointer target shall be a function with the same
type; corresponding type parameters shall have the same value.7 If procedure-name is a specific procedure name that is also a generic name, only the specific procedure is associated
with the pointer object.1 A masked array assignment is either a WHERE statement or a WHERE construct. It is used to mask the
evaluation of expressions and assignment of values in array assignment statements, according to the value of a2 If a where-construct contains a where-stmt, a masked-elsewhere-stmt, or another where-construct then each mask-
expr within the where-construct shall have the same shape. In each where-assignment-stmt, the mask-expr and | |||||||||||||||||||||||||||||||||||||||||||||||
RAINING = .TRUE.
<IP_ADDRESS> Interpretation of masked array assignments
1 When a WHERE statement or a where-construct-stmt is executed, a control mask is established. In addition,
when a WHERE construct statement is executed, a pending control mask is established. If the statement does2 Each statement in a WHERE construct is executed in sequence.not appear as part of a where-body-construct, the mask-expr of the statement is evaluated, and the control mask is
established to be the value of mask-expr. The pending control mask is established to have the value .NOT. mask-
expr upon execution of a WHERE construct statement that does not appear as part of a where-body-construct.
The mask-expr is evaluated only once.
3 Upon execution of a masked-elsewhere-stmt, the following actions take place in sequence.
(1) The control mask mc is established to have the value of the pending control mask.4 The mask-expr is evaluated at most once.(2) The pending control mask is established to have the value mc .AND. (.NOT. mask-expr).
(3) The control mask mc is established to have the value mc .AND. mask-expr.
5 Upon execution of an ELSEWHERE statement, the control mask is established to have the value of the pending
control mask. No new pending control mask value is established.6 Upon execution of an ENDWHERE statement, the control mask and pending control mask are established to
have the values they had prior to the execution of the corresponding WHERE construct statement. Followingthe execution of a WHERE statement that appears as a where-body-construct, the control mask is established to
have the value it had prior to the execution of the WHERE statement.
NOTE 10.50
The establishment of control masks and the pending control mask is illustrated with the following example:
WHERE(cond1) ! Statement 1
...
ELSEWHERE(cond2) ! Statement 2
...
ELSEWHERE ! Statement 3
...
Following execution of statement 1, the control mask has the value cond1 and the pending
mask has the value (.NOT. cond1) .AND. cond2 and the pending control mask has the value
control mask has the value .NOT. cond1. Following execution of statement 2, the control (.NOT. cond1) .AND. (.NOT. cond2). Following execution of statement 3, the control mask has the value
(.NOT. cond1) .AND. (.NOT. cond2). The false condition values are propagated through the execution of
the masked ELSEWHERE statement.
7 Upon execution of a WHERE construct statement that is part of a where-body-construct, the pending control
mask is established to have the value mc .AND. (.NOT. mask-expr). The control mask is then established to8 Upon execution of a WHERE statement that is part of a where-body-construct, the control mask is establishedhave the value mc .AND. mask-expr. The mask-expr is evaluated at most once.
176 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
to have the value mc .AND. mask-expr. The pending control mask is not altered.9 If a nonelemental function reference occurs in the expr or variable of a where-assignment-stmt or in a mask-expr,
the function is evaluated without any masked control; that is, all of its argument expressions are fully evaluated10 If an elemental operation or function reference occurs in the expr or variable of a where-assignment-stmt or in aand the function is fully evaluated. If the result is an array and the reference is not within the argument list
of a nonelemental function, elements corresponding to true values in the control mask are selected for use in
evaluating the expr, variable or mask-expr.
mask-expr, and is not within the argument list of a nonelemental function reference, the operation is performed11 If an array constructor appears in a where-assignment-stmt or in a mask-expr, the array constructor is evaluatedor the function is evaluated only for the elements corresponding to true values of the control mask.
without any masked control and then the where-assignment-stmt is executed or the mask-expr is evaluated.12 When a where-assignment-stmt is executed, the values of expr that correspond to true values of the control mask
are assigned to the corresponding elements of the variable.13 The value of the control mask is established by the execution of a WHERE statement, a WHERE construct
statement, an ELSEWHERE statement, a masked ELSEWHERE statement, or an ENDWHERE statement.Subsequent changes to the value of entities in a mask-expr have no effect on the value of the control mask. The
execution of a function reference in the mask expression of a WHERE statement is permitted to affect entities in
the assignment statement.
NOTE 10.51
Examples of function references in masked array assignments are:
WHERE (A > 0.0)
A = LOG (A) ! LOG is invoked only for positive elements.
A = A / SUM (LOG (A)) ! LOG is invoked for all elements
! because SUM is transformational
10.2.4 FORALL <IP_ADDRESS> Form of the FORALL Construct
1 The FORALL construct allows multiple assignments, masked array (WHERE) assignments, and nested FORALL constructs and
statements to be controlled by a single concurrent-control-list and scalar-mask-expr.ISO/IEC DIS 1539-1:2017 (E)R1050 forall-construct is forall-construct-stmt
[forall-body-construct ] ...
end-forall-stmt
R1051 forall-construct-stmt is [forall-construct-name :] FORALL concurrent-header
R1052 forall-body-construct is forall-assignment-stmt
or where-stmt
or where-construct
or forall-construct
or forall-stmt
R1053 forall-assignment-stmt is assignment-stmt
or pointer-assignment-stmt
R1054 end-forall-stmt is END FORALL [forall-construct-name ]
⃝c ISO/IEC 2017 – All rights reserved 177
C1035 (R1054) If the forall-construct-stmt has a forall-construct-name, the end-forall-stmt shall have the same forall-construct- name. If the end-forall-stmt has a forall-construct-name, the forall-construct-stmt shall have the same forall-construct-name.
C1036 (R1052) A statement in a forall-body-construct shall not define an index-name of the forall-construct. C1037 (R1052) Any procedure referenced in a forall-body-construct, including one referenced by a defined operation, assignment, or finalization, shall be a pure procedure.
C1038 (R1052) A forall-body-construct shall not be a branch target.
2 The scope and attributes of an index-name in a concurrent-header in a FORALL construct or statement are described in 19.4.
<IP_ADDRESS> Execution of the FORALL construct1 There are three stages in the execution of a FORALL construct:<IP_ADDRESS>.1 Execution stages
(1) determination of the values for index-name variables,(2) evaluation of the scalar-mask-expr, and
(3) execution of the FORALL body constructs.
<IP_ADDRESS>.2 Determination of the values for index variables
1 The values of the index variables are determined as they are for the DO CONCURRENT statement (<IP_ADDRESS>.2).
<IP_ADDRESS>.3 Evaluation of the mask expression1 The mask expression is evaluated as it is for the DO CONCURRENT statement (<IP_ADDRESS>.2).
<IP_ADDRESS>.4 Execution of the FORALL body constructs1 The forall-body-constructs are executed in the order in which they appear. Each construct is executed for all active combinations of
the index-name values with the following interpretation:2 Execution of a forall-assignment-stmt that is an assignment-stmt causes the evaluation of expr and all expressions within variable
for all active combinations of index-name values. These evaluations may be done in any order. After all these evaluations have been3 Execution of a forall-assignment-stmt that is a pointer-assignment-stmt causes the evaluation of all expressions within data-targetperformed, each expr value is assigned to the corresponding variable. The assignments may occur in any order.
and data-pointer-object or proc-target and proc-pointer-object, the determination of any pointers within data-pointer-object or proc-4 In a forall-assignment-stmt, a defined assignment subroutine shall not reference any variable that becomes defined by the statement.pointer-object, and the determination of the target for all active combinations of index-name values. These evaluations may be done
in any order. After all these evaluations have been performed, each data-pointer-object or proc-pointer-object is associated with the
corresponding target. These associations may occur in any order.
NOTE 10.525 Each statement in a where-construct (10.2.3) within a forall-construct is executed in sequence. When a where-stmt, where-construct-If a variable defined in an assignment statement within a FORALL construct is referenced in a later statement in that construct,
the later statement uses the value(s) computed in the preceding assignment statement, not the value(s) the variable had prior
to execution of the FORALL.
stmt or masked-elsewhere-stmt is executed, the statement’s mask-expr is evaluated for all active combinations of index-name values6 Execution of a forall-stmt or forall-construct causes the evaluation of the concurrent-limit and concurrent-step expressions in theas determined by the outer forall-constructs, masked by any control mask corresponding to outer where-constructs. Any where-
assignment-stmt is executed for all active combinations of index-name values, masked by the control mask in effect for the where-
assignment-stmt.
concurrent-control-list for all active combinations of the index-name values of the outer FORALL construct. The set of combinations1 The FORALL statement allows a single assignment statement or pointer assignment statement to be controlled by a set of index178 ⃝c ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
of index-name values for the inner FORALL is the union of the sets defined by these limits and steps for each active combination of the
outer index-name values; it also includes the outer index-name values. The scalar-mask-expr is then evaluated for all combinations
of the index-name values of the inner construct to produce a set of active combinations for the inner construct. If there is no
scalar-mask-expr, it is as if it appeared with the value true. Each statement in the inner FORALL is then executed for each active
combination of the index-name values.
<IP_ADDRESS> The FORALL statement
values and an optional mask expression.2 A FORALL statement is equivalent to a FORALL construct containing a single forall-body-construct that is a forall-assignment-stmt.R1055 forall-stmt is FORALL concurrent-header forall-assignment-stmt
3 The scope of an index-name in a forall-stmt is the statement itself (19.4).
<IP_ADDRESS> Restrictions on FORALL constructs and statements1 A many-to-one assignment is more than one assignment to the same object, or association of more than one target with the same
pointer, whether the object is referenced directly or indirectly through a pointer. A many-to-one assignment shall not occur withina single statement in a FORALL construct or statement. It is possible to assign or pointer-assign to the same object in different
assignment or pointer assignment statements in a FORALL construct.
NOTE 10.53
The appearance of each index-name in the identification of the left-hand side of an assignment statement is helpful in eliminating
many-to-one assignments, but it is not sufficient to guarantee there will be none. For example, the following is allowed
FORALL (I = 1:10)
A (INDEX (I)) = B(I)
if and only if INDEX(1:10) contains no repeated values.
2 Within the scope of a FORALL construct, a nested FORALL statement or FORALL construct shall not have the same index-name.
The concurrent-header expressions within a nested FORALL may depend on the values of outer index-name variables.ISO/IEC DIS 1539-1:2017 (E)⃝c ISO/IEC 2017 – All rights reserved 179
(Blank page)
2 Executable constructs may be used to control which blocks of a program are executed or how many times a block
180 c ISO/IEC 2017 – All rights reserved11 Execution control
ISO/IEC DIS 1539-1:2017 (E)
11.1 Executable constructs containing blocks 11.1.1 Blocks 1 The following are executable constructs that contain blocks: • ASSOCIATE construct;• BLOCK construct;
• CHANGE TEAM construct;
• CRITICAL construct;
• DO construct;
• IF construct;
• SELECT CASE construct;
• SELECT RANK construct;
• SELECT TYPE construct.
R1101 block is [ execution-part-construct ] ...
is executed. Blocks are always bounded by statements that are particular to the construct in which they areembedded.
NOTE 11.1
An example of a construct containing a block is:
IF (A > 0.0) THEN
B = SQRT (A) ! These two statements
C = LOG (A) ! form a block.
11.1.2 Rules governing blocks <IP_ADDRESS> Control flow in blocks
1 Transfer of control to the interior of a block from outside the block is prohibited, except for the return from a
procedure invoked within the block. Transfers within a block and transfers from the interior of a block to outside2 Subroutine and function references (15.5.3, 15.5.4) may appear in a block.the block may occur.
<IP_ADDRESS> Execution of a block1 Execution of a block begins with the execution of the first executable construct in the block.
2 Execution of the block is completed when
• execution of the last executable construct in the block completes without branching to a statement withinthe block,
• a branch (11.2) within the block that has a branch target outside the block occurs,
⃝c ISO/IEC 2017 – All rights reserved 181
ISO/IEC DIS 1539-1:2017 (E)
• a RETURN statement within the block is executed, or• an EXIT statement or CYCLE statement statement that belongs to a construct that contains the block is
executed.
NOTE 11.2
The action that takes place at the terminal boundary depends on the particular construct and on the block
within that construct.
11.1.3 ASSOCIATE construct <IP_ADDRESS> Purpose and form of the ASSOCIATE construct
1 The ASSOCIATE construct associates named entities with expressions or variables during the execution of its
block. These named construct entities (19.4) are associating entities (<IP_ADDRESS>). The names are associate names.1 Execution of an ASSOCIATE construct causes evaluation of every expression within every selector that is aR1102 associate-construct is associate-stmt
block
end-associate-stmt
R1103 associate-stmt is [ associate-construct-name : ] ASSOCIATE
(association-list )
R1104 association is associate-name => selector
R1105 selector is expr
or variable
C1101 (R1104) If selector is not a variable or is a variable that has a vector subscript, neither associate-name
nor any subobject thereof shall appear in a variable definition context (19.6.7).
C1102 (R1104) An associate-name shall not be the same as another associate-name in the same associate-stmt.
C1103 (R1105) variable shall not be a coindexed object.
C1104 (R1105) expr shall not be a variable.
C1105 (R1105) expr shall not be a designator of a procedure pointer or a function reference that returns a
procedure pointer.
R1106 end-associate-stmt is END ASSOCIATE [ associate-construct-name ]
C1106 (R1106) If the associate-stmt of an associate-construct specifies an associate-construct-name, the corres-
ponding end-associate-stmt shall specify the same associate-construct-name. If the associate-stmt of an
associate-construct does not specify an associate-construct-name, the corresponding end-associate-stmt
shall not specify an associate-construct-name.
<IP_ADDRESS> Execution of the ASSOCIATE construct
variable designator and evaluation of every other selector, followed by execution of its block. During execution of2 The other attributes of the associating entity are described in <IP_ADDRESS>.that block each associate name identifies an entity which is associated (<IP_ADDRESS>) with the corresponding selector.
The associating entity assumes the declared type and type parameters of the selector. If and only if the selector
is polymorphic, the associating entity is polymorphic.
3 It is permissible to branch to an end-associate-stmt only from within its ASSOCIATE construct.
182 ⃝1 Within an ASSOCIATE, CHANGE TEAM, or SELECT TYPE construct, each associating entity has the samec ISO/IEC 2017 – All rights reserved
ISO/IEC DIS 1539-1:2017 (E)
<IP_ADDRESS> Other attributes of associate names
rank as its associated selector. The lower bound of each dimension is the result of the intrinsic function LBOUND2 Within an ASSOCIATE, SELECT RANK, or SELECT TYPE construct, each associating entity has the same(16.9.109) applied to the corresponding dimension of selector. The upper bound of each dimension is one less
than the sum of the lower bound and the extent. The associating entity does not have the ALLOCATABLE or
POINTER attributes; it has the TARGET attribute if and only if the selector is a variable and has either the
TARGET or POINTER attribute.
corank as its associated selector. If the selector is a coarray, the cobounds of each codimension of the associating3 Within a CHANGE TEAM construct, the associating entity is a coarray. Its corank and cobounds are as specifiedentity are the same as those of the selector.
in its codimension-decl.4 Within an ASSOCIATE, CHANGE TEAM, SELECT RANK, or SELECT TYPE construct, the associating
entity has the ASYNCHRONOUS or VOLATILE attribute if and only if the selector is a variable and has the5 The associating entity itself is a variable, but if the selector is not a definable variable, the associating entityattribute. If the associating entity is polymorphic, it assumes the dynamic type and type parameter values of the
selector. If the selector has the OPTIONAL attribute, it shall be present. The associating entity is contiguous if
and only if the selector is contiguous.