ALLC.TRUE.) NXT (1+(1.3,2.0»
A subscript expression may not be a logical expresslon.
A subscript expression may not be a complex expression.
Note: The elements of an array are stored in column-major order.
To step through the elements of the array in the linearized order defined as "column-major order," each subscript varies Cin steps of 1) from its lowest valid value to its highest valid value, such that each subscript expression completes a full cycle before the next subscript expression to the right is incrQmented. Thus, the leftmost subscript expression varies most rapidly, and the
rightmost subexpression varies least rapidly.
The following list is the order of an array named C defined with three dimensions:
DIMENSION CC1:3,1:2,1:4)
C(l,l,l) C(2,1,1) C(3,1,1) Cl,2,1) C(2,2,1) C(3,2,1) C(1,1,2) C(2,1,2) CC3,1,2) Cl,2,2) CC2,2,2) C(3,2,2) CCl,1,3) C(2,1,3) CC3,1,3) Cl,2,3) CC2,2,3) CC3,2,3) CCl,1,4) C(2,1,4) CC3,1,4) Cl,2,4) C(2,2,4) C(3,2,4) SIZE AND TYPE DECLARATION OF AN ARRAY
The size (number of elements) of an array is declared by
specifying, in a subscript, the number of dimensions in the array and the size of each dimension. Each dimension is represented by an optional lower bound (~1) and a requ;red upper bound (g2) in the form:
syntax
[gl:] g2 )
is an array name.
where:
gl
g2
is the lower dimensi on bound. It is opt; onal. If el (wi th its followi ng colon) is not speci fi ed, its value is assumed to be 1.
is the upper di mensi on bound and must always be specified.
The colon represents the range of values for an array's subscript.
For example,
DIMENSION A(O:9),BC3,-2:5)
DIMENSION ARAYC-3:-1),DARY(-3:ID3**IDl) DIMENSION IARY(3)
The upper and lower bounds (gl and g2) are arithmetic expressions in whi ch all constants and vari abIes are of type integer.
• If the array name is an
actual
argument, the express; ons can contain only constants or names of constants of type integer.• The value of the lower bound may be POSt ti ve, negati ve, or zero. It is assumed to be 1 if it is not specified.
22 VS FORTRAN Language Reference
• A maximum of seven dimensions is permitted. The size of each
Signed or unsigned integer constants Names of integer constants
Variables that are dummy arguments or appear in a common-block in that subprogram
• The upper dimension bound of the last dimension of a dummy
alphabetic sequence in "VS FORTRAN Statement Descriptions."
The type of an array name is determined by the conventions for explicitly declared in the subprogram by constants. Instead, the array declarators appearing in an explicit specification
statement or DIMENSION statement in the subprogram may contain dummy arguments or variables in common that are integer variables
"adjustable array" or an "object-time dimension array."
The absolute dimensions of an array must be declared in the subprogram that calls another subprogram, passing it dimension information).
Integer variables in the explicit specification or DIMENSION statement that provide dimension information may be redefined within the subprogram but the redefinitions have no effect on the size of the array. The size of the array is determined at the
CHARACTER SUBSTRINGS
Cha~acter arrays are specified in the same manner as for the other data types. (See "DIMENSION Statement" on page 70 and "Explicit Type Statement" on page 82.) The length of each array element is either the standard length of 1 or may be declared larger with a type or IMPLICIT statement. Each character array element is treated as a single entity. Portions of an array element can be accessed through substring notation.
A character substring is a contiguous portion of a character variable or character array element. A character substring is identified by a substring reference. It may be assigned values and may be referred to. A substring reference is local to a program unit.
the form of a substring reference is:
~
syntax
~1:~2)
is a character variable name or a subscripted character array name (see "Array Elements" on page 20).
~1 and e2
are substring expressions.
Substring expressions are optional, but the colon (:) is always required inside the parentheses. The colon represents a range of values. If gl is omitted, a value of one is implied for gl. If g2 is omitted, a value equal to the length of the characver variable or array element is implied for g2. Both gl and ~2 may be omitted;
for example, the form ~(:) is equivalent to~.
The value of gl specifies the leftmost character position and the value of e2 specifies the rightmbst character position of the
substrin~ The substring information (if any) must be specified after the subscript information (if any).
• The values of ~1 and ~2 must be integer, positive, and nonzero.
• The value of ~1 must be less than or equal to the value of g2.
• The values of e1 and e2 must be less than or equal to the number of characters~ontained in the corresponding variable name or array element.
Examples:
Example 1:
Given the following statements:
CHARACTER*5 CH(lO) CH(2)='ABCDE' then
CH(2)(l:2) has the value AB.
CH(2)(:3) has the value ABC.
CH(2)(3~) has the value CDE.
Example 2:
SUBSTG(:)
=
SYMNAMSUBST3(3:l5) = SYMB3
SUBST5(5:9) = SUBARI(2)(1:) 24 VS FORTRAN Language Reference
VS FORTRAN EXPRESSIONS
VS FORTRAN provides four kinds of expressions: arithmetic, character, relational, and logical.
• The value of an arithmetic expression is always a number whose type is integer, real, or complex.
• The value of a character expression is a character string.
• The value of a relational or logical expression is always a logical value: .TRUE. or .FALSE ..
EVALUATION OF EXPRESSIONS
VS FORTRAN expressions are evaluated according to the following rules:
• Any variable, array element, function, or character substring referred to as an operand in an expression must be defined (that is, must have been assigned a value) at the time the reference is executed.
In an expression, an integer operand must be defined with an integer value, rather than a statement number. (See "ASSIGN
Stat~ment" on page 46.) If a character string or a substring is referred to, all of the characters referred to must be defined at the time the reference is executed.
• The execution of a function reference in a statement must not alter the value of any other entity within the statement in which the function reference appears. The execution of a function reference in a sta~ement must not alter the value of any entity in COMMON that affects the value of any other function reference in that statement.
If a function reference in a statement alters the value of an actual argument of the function, that argument or any
associated entities must not appear elsewhere in the statement. For example, the following statements are
prohibited if the reference to the function F defines I or if the reference to the function G defines X:
A(I)
=
F(I)Y = G(X)
+X
The data type of an expression in which a function reference appears does not affect the evaluation of the actual
arguments of the function.
• Any array element reference requires the evaluation of its subscript. The data tYPQ of an expression in which an array reference appears does not affect, nor is it affected by, the evaluation of the subscript.
• Any execution of a substring reference requires the
evaluation of its substring expressions. The data type of an expression in which a substring name appears does not affect, nor is it affected by, the evaluation of the substring
expressions.
ARITHMETIC EXPRESSIONS
The simplest arithmetic expression consists of a primary, which
ARITHMETIC OPERATORS
element, function reference, or another expression enclosed in parentheses. The primary may be either integer, real, or complex.
In an expression consisting of a single primary, the type of the primary is the type of the expression. Examples of arithmetic expressions are shown in Figure 6.
primary Type of primary Type Length
3 Integer constant Integer 4
A Real variable Real 4
3.1403 Real constant Real 8
3.1403 Double precision constant Double 8 precision
(2.0,5.7) Complex constant Complex 8
SItHX) Real function reference Real 4
( M~B+C) Parenthesized real Real 4 expression
Figure 6. Examples of Arithmetic Expressions
More complicated arithmetic expressions containing two or more primaries may be formed by using arithmetic operators that express the computation(s) to be performed.
The arithmetic operators are shown in Figure 7.