The DIMENSION attribute specifies that an object is an array, and defines the shape of the array.
The DIMENSION attribute can be specified in a type declaration statement or a DIMENSION statement, and takes one of the following forms:
Type Declaration Statement:
In a type declaration statement, any array specification following an array overrides any array specification following DIMENSION.
Rules and Behavior
The DIMENSION attribute allocates a number of storage elements to each array named, one storage element to each array element in each dimension. The size of each storage element is determined by the data type of the array.
The total number of storage elements assigned to an array is equal to the number produced by multiplying together the number of elements in each dimension in the array specification. For example, the following statement defines ARRAY as having 16 real elements of 4 bytes each and defines MATRIX as having 125 integer elements of 4 bytes each:
DIMENSION ARRAY(4,4), MATRIX(5,5,5)
An array can also be declared in the following statements: ALLOCATABLE, POINTER, TARGET, and COMMON.
The following examples show type declaration statements specifying the DIMENSION attribute:
REAL, DIMENSION(10, 10) :: A, B, C(10, 15) ! Specification following C ! overrides the one following ! DIMENSION REAL, ALLOCATABLE, DIMENSION(:) :: E
The following are examples of the DIMENSION statement:
DIMENSION BOTTOM(12,24,10) DIMENSION X(5,5,5), Y(4,85), Z(100) DIMENSION MARK(4,4,4,4) SUBROUTINE APROC(A1,A2,N1,N2,N3) DIMENSION A1(N1:N2), A2(N3:*) CHARACTER(LEN = 20) D DIMENSION A(15), B(15, 40), C(-5:8, 7), D(15)
For More Information: