Visible to Intel only — GUID: GUID-ADBCF029-FA12-40F0-A131-BE2E92FE77BF
Visible to Intel only — GUID: GUID-ADBCF029-FA12-40F0-A131-BE2E92FE77BF
Specification Expressions
A specification expression is a restricted scalar integer expression that you can use in specifications such as length type parameters and array bounds. Unless a specification expression is in an interface body, the specification part of a subprogram or BLOCK construct, a derived type definition, or the declaration type spec of a FUNCTION statement, it must be a constant expression.
In a restricted expression, each operation is intrinsic or defined by a specification function and each primary is one of the following:
A constant or subobject of a constant
An object designator with a base object that is one of the following:
A dummy argument that does not have the OPTIONAL or INTENT (OUT) attribute
In a common block
Made accessible by use or host association
An array constructor where each element and each scalar integer expression of each DO loop is a restricted expression
A structure constructor whose components are restricted expression
A specification inquiry where each designator or function argument is a restricted expression or a variable whose properties inquired about are not one of the following:
Dependent on the upper bound of the last dimension of an assumed-size array
Deferred
Defined by an expression that is not a restricted expression
A specification inquiry that is a constant expression
A reference to the PRESENT intrinsic function
A reference to any other intrinsic function where each argument is a restricted expression
A reference to an intrinsic transformational function from the intrinsic module ISO_C_BINDING where each argument is a restricted expression
A reference to a specification function where each argument is a restricted expression
A type parameter of the derived type being defined
A DO variable within an array constructor, where each scalar integer expression of the corresponding implied-DO is a restricted expression
A restricted expression enclosed in parentheses, where each subscript, section subscript, substring starting and ending point, and type parameter value is a restricted expression
A specification inquiry is a reference to one of the following:
An intrinsic inquiry function other than PRESENT
A type parameter inquiry
An intrinsic inquiry function from the modules IEEE_ARITHMETIC or IEEE_EXCEPTIONS
The function C_SIZEOF from the intrinsic module ISO_C_BINDING
The COMPILER_VERSION or COMPILER_OPTIONS inquiry function from the intrinsic module ISO_FORTRAN_ENV
Specification functions can be used in specification expressions to determine the attributes of data objects.
A function is a specification function if it is a pure function and is not one of the following:
A standard intrinsic function
An internal function
A statement function
A function with a dummy procedure argument
Evaluation of a specification expression must not directly or indirectly cause invocation of a procedure defined by the subprogram in which it appears.
The requirement that specification functions be pure ensures that they cannot have side effects that could affect other objects being declared in the same specification.
The restriction that specification functions cannot be internal ensures that they cannot use host association to inquire about other objects being declared in the same specification. The restriction against recursion prevents the creation of a new instance of a procedure during construction of that procedure.
A variable in a specification expression must have its type and type parameters (if any) specified in one of the following ways:
By a previous declaration in the same scoping unit
By the implicit typing rules currently in effect for the scoping unit
By host or use association
If a variable in a specification expression is typed by the implicit typing rules, its appearance in any subsequent type declaration statement must confirm the implied type and type parameters.
If a specification expression includes a specification inquiry that depends on a type parameter or an array bound or cobound of an entity specified in the same specification statement, the type parameter or array bound or cobound must be specified in a previous specification statement (or to the left of the inquiry function in the same statement). The previous specification cannot be in the same entity declaration unless the specification inquiry appears in an initialization.
If a specification expression includes a reference to the value of an element of an array specified in the same specification statement, the array must be completely specified in previous declarations.
If a specification expression references a generic entity in the specification part of a scoping unit, the generic entity cannot have any specific procedures in it that are defined in the scoping unit or its host scoping unit subsequent to the specification expression.
Specification expressions used in specification expression in a component definition statement have the following additional restrictions:
There can be no references to specification functions.
The intrinsic functions ALLOCATED, ASSOCIATED, COMMAND_ARGUMENT_COUNT, EXTENDS_TYPE_OF, GET_TEAM, NUM_IMAGES, PRESENT, SAME_TYPE_AS, TEAM_NUMBER, and THIS_IMAGE cannot appear.
Every specification inquiry is a constant expression.
The value does not depend on the value of a variable.
References to the intrinsic TRANSFER function are permitted only if each argument is a constant expression, and each ultimate pointer component of the SOURCE argument is disassociated.
The Intel® Fortran compiler limits the number of arguments to a function reference in a specification expression to 255.
Examples
The following shows valid specification expressions:
POPCNT(I) + J ! I and J are scalar integer variables UBOUND(ARRAY_B,20) ! ARRAY_B is an assumed-shape dummy array