Performance Tools for Software Developers - Bounds Expression Variables Must Be Declared Before Use

ID 660064
Updated 12/26/2018
Version Latest
Public

author-image

By

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)
real a(n+1)

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)
real a(b)
integer 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)
integer b
real a(b)

The Intel® Fortran Compiler enforces this rule of the Fortran language standard and gives an error if it is violated

.