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

ID 标签 689125
已更新 12/26/2018
版本 Latest
公共

author-image

作者

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

.
 
"