FORTRAN 77 Language Reference

Array Declarators

An array declarator specifies the name and properties of an array.

The syntax of an array declarator is:

a (  d [, d ] ...  )


A dimension declarator has the form:

[ dl:] du


An array must appear only once in an array declarator within a program unit (main program, subroutine, function, or block common). The compiler flags multiple or duplicate array declarations within the same unit as errors.

The number of dimensions in an array is the number of dimension declarators. The minimum number of dimensions is one; the maximum is seven. For an assumed-size array, the last dimension can be an asterisk.

The lower bound indicates the first element of the dimension, and the upper bound indicates the last element of the dimension. In a one-dimensional array, these are the first and last elements of the array.

Example: Array declarator, lower and upper bounds:

	REAL V(-5:5)

In the above example, V is an array of real numbers, with 1 dimension and 11 elements. The first element is V(-5); the last element is V(5).

Example: Default lower bound of 1:

	REAL V(1000)

In the above example, V is an array of real numbers, with 1 dimension and 1000 elements. The first element is V(1); the last element is V(1000).

Example: Arrays can have as many as 7 dimensions:

	REAL TAO(2,2,3,4,5,6,10)

Example: Lower bounds other than one:

	REAL A(3:5, 7, 3:5), B(0:2)

Example: Character arrays:

	CHARACTER M(3,4)*7, V(9)*4

The array M has 12 elements, each of which consists of 7 characters.

The array V has 9 elements, each of which consists of 4 characters.

The following restrictions on bounds apply:

Adjustable Arrays

An adjustable array is an array that is a dummy argument or local array@ with one or more of its dimensions or bounds as an expression of integer variables that are either themselves dummy arguments, or are in a common block.

You can declare adjustable arrays in the usual DIMENSION or type statements. In f77, you can also declare adjustable arrays in a RECORD statement, if that RECORD statement is not inside a structure declaration block.

Example: Adjustable arrays;

	REAL A(3:5, L, M:N), B(N+1:2*N) ! These arrays are dummy args
	REAL C(N+1,2*N)  !  This array is local

The restrictions are:

If the array is local to the routine, memory is allocated on entry to the routine and deallocated on return to the caller.@

Assumed-Size Arrays

An assumed-size array is an array that is a dummy argument, and which has an asterisk as the upper bound of the last dimension.

You can declare assumed-size arrays in the usual DIMENSION, COMMON, or type statements.

Ihe following f77 extensions allow you to:@

Example: Assumed-size with the upper bound of the last dimension an asterisk:

	  INTEGER A(5, *), B(*), C(0:1, 2:*)

An assumed-size array cannot be used in an I/O list.