Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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

    • A local variable of the procedure containing the BLOCK construct in which the restricted expression appears

    • A local variable of an outer BLOCK construct containing the BLOCK construct in which the restricted expression appears

    • 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, and where any final subroutine that is invoked is pure

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

  • An 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.

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.

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.

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