In the Fortran language, expressions used for array bound and character variable length declarations are called specification expressions. For example, consider the following source fragment:
subroutine sub (a, n)
Here, n+1 is a specification expression that defines the bounds of the array a. In most cases, variables can be declared in any order, but there are special rules for specification expressions, one of which is that any variable in the expression must have its type and type parameters (kind, length) specified by a previous declaration or by the implicit typing rules in effect. For example, the following is not legal Fortran:
subroutine sub (a, b)
In this case, the implicit type of b is real, but a specification expression must be integer. It does not matter that variable b is later declared to be integer, this code is not legal Fortran. The correct order is:
subroutine sub (a,b)
The Intel® Fortran Compiler enforces this rule of the Fortran language standard and gives an error if it is violated.
Performance Tools for Software Developers - Bounds Expression Variables Must Be Declared Before Use
For more complete information about compiler optimizations, see our Optimization Notice.