FORTRAN Reference Manual

Language Elements
FORTRAN Reference Manual—528615-001
2-15
Dimensioning an Array
bound. The number of elements in each dimension is one greater than the difference
between the upper and lower bounds.
The following statement declares and dimensions the array DICTIONARY, a one
dimensional character array. The first element is DICTIONARY(1) and the last element
is DICTIONARY(100). Each of the 100 elements of DICTIONARY consists of 10
characters.
CHARACTER * 10 dictionary (100)
The following statement declares and dimensions the array CUSTOMERS. FORTRAN
determines the array type implicitly as real. The array has seven dimensions—the
maximum for a FORTRAN array:
DIMENSION customers (31, 5, 24, 52, 2, 1, 165)
Table 2-3 shows the organization of the array declared by the statement:
DIMENSION ta (6,6)
Table 2-4 shows the organization of the array declared by the statement:
DIMENSION tb (-3:2,-2:3)
Note that TA and TB are exactly the same size. TA, however, is based at 1,1 whereas
TB is based at -3,2.
Table 2-3. Array Based at One
ta(1,1) ta(1,2) ta(1,3) ta(1,4) ta(1,5) ta(1,6)
ta(2,1) ta(2,2) ta(2,3) ta(2,4) ta(2,5) ta(2,6)
ta(3,1) ta(3,2) ta(3,3) ta(3,4) ta(3,5) ta(3,6)
ta(4,1) ta(4,2) ta(4,3) ta(4,4) ta(4,5) ta(4,6)
ta(5,1) ta(5,2) ta(5,3) ta(5,4) ta(5,5) ta(5,6)
ta(6,1) ta(6,2) ta(6,3) ta(6,4) ta(6,5) ta(6,6)
Table 2-4. Array With Negative Subscripts
tb(-3,-2) tb(-3,-1) tb(-3,0) tb(-3,1) tb(-3,2) tb(-3,3)
tb(-2,-2) tb(-2,-1) tb(-2,0) tb(-2,1) tb(-2,2) tb(-2,3)
tb(-1,-2) tb(-1,-1) tb(-1,0) tb(-1,1) tb(-1,2) tb(-1,3)
tb(0,-2) tb(0,-1) tb(0,0) tb(0,1) tb(0,2) tb(0,3)
tb(1,-2) tb(1,-1) tb(1,0)\ tb(1,1) tb(1,2) tb(1,3)
tb(2,-2) tb(2,-1) tb(2,0) tb(2,1) tb(2,2) tb(2,3)