FORTRAN 77 Language Reference

Examples

Example 1: Arrays in a main program:


       DIMENSION M(4,4), V(1000) 
       ... 
       END 

In the above example, M is specified as an array of dimensions 4 ¥4 and V is specified as an array of dimension 1000.

Example 2: An adjustable array in a subroutine:


       SUBROUTINE INV( M, N ) 
       DIMENSION M( N, N ) 
       ... 
       END 

In the above example, the formal arguments are an array, M, and a variable N. M is specified to be a square array of dimensions N¥ N.

Example 3: Lower and upper bounds:


       DIMENSION HELIO (-3:3, 4, 3:9) 
       ... 
       END 

In the above example, HELIO is a 3-dimensional array. The first element is HELIO(-3,1,3) and the last element is HELIO(3,4,9).

Example 4: Dummy array with lower and upper bounds:


       SUBROUTINE ENHANCE( A, NLO, NHI ) 
       DIMENSION A(NLO : NHI) 
       ... 
       END 

Example 5: Noninteger bounds


       PARAMETER ( LO = 1, HI = 9.3 ) 
       DIMENSION A(HI, HI*3 + LO ) 
       ... 
       END

:

In the above example, A is an array of dimension 9¥28.

Example 6: Adjustable array with noninteger bounds:


       SUBROUTINE ENHANCE( A, X, Y ) 
       DIMENSION A(X : Y) 
       ... 
       END

Example 7: Assumed-size arrays:


       SUBROUTINE RUN(A,B,N)
       DIMENSION A(*), B(N,*)
       ...