Intel® Fortran Compiler 18.0 Developer Guide and Reference

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 and each primary is one of the following:

A specification inquiry is a reference to one of the following:

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, does not have a dummy procedure argument, and is not one of the following:

NOTE

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.

Evaluation of a specification expression must not directly or indirectly cause invocation of a procedure defined by the subprogram in which it appears.

A variable in a specification expression must have its type and type parameters (if any) specified in one of the following ways:

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 of an entity specified in the same specification statement, the type parameter or array bound 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. 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.

In the specification part of a module or submodule, if a specification expression includes a reference to a generic entity, that generic entity must have no specific procedures defined in the module or submodule subsequent to the specification expression.

In a specification expression, the number of arguments for a function reference is limited 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

See Also