A specification expression is a restricted expression that is of type integer and has a scalar value. This type of expression appears only in the declaration of array bounds and character lengths.
In a restricted expression, each operation is intrinsic and each operand is one of the following:
A constant or subobject of a constant
A variable that is one of the following:
A dummy argument that does not have the OPTIONAL or INTENT (OUT) attribute (or the subobject of such a variable)
In a common block (or the subobject of such a variable)
Made accessible by use or host association (or the subobject of such a variable)
A structure constructor whose components are restricted expressions
An implied-DO variable within an array constructor, where the bounds and strides of the corresponding implied-DO are restricted expressions
A reference to one of the following inquiry functions:
BIT_SIZE |
MINEXPONENT |
DIGITS |
PRECISION |
EPSILON |
RADIX |
HUGE |
RANGE |
ILEN |
SHAPE |
KIND |
SIZE |
LBOUND |
SIZEOF |
LEN |
TINY |
MAXEXPONENT |
UBOUND |
Each function argument must be one of the following:
A restricted expression
A variable whose properties inquired about are not dependent on the upper bound of the last dimension of an assumed-size array, are not defined by an expression that is not a restricted expression, or are not definable by an ALLOCATE or pointer assignment statement.
A reference to any other intrinsic function where each argument is a restricted expression.
A reference to a specification function where each argument is a restricted expression
An array constructor where each element and the bounds and strides of each implied-DO, are expressions whose primaries are restricted expressions
Another restricted expression enclosed in parentheses
Each subscript, section subscript, and substring starting and ending point must be a restricted expression.
Specification functions can be used in specification expressions to indicate the attributes of data objects. A specification function is a pure function. It cannot have a dummy procedure argument or be any of the following:
An intrinsic function
An internal function
A statement function
Defined as RECURSIVE
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 invokes an inquiry function for a type parameter or an array bound of an object, the type parameter or array bound must be specified in a prior specification statement (or to the left of the inquiry function in the same statement).
In a specification expression, the number of arguments for a function reference is limited to 255.
The following shows valid specification expressions:
MAX(I) + J ! I and J are scalar integer variables
UBOUND(ARRAY_B,20) ! ARRAY_B is an assumed-shape dummy array