24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Arrays<br />

Each subscript expression must be an integer expression and must be in the range defined by the upper and<br />

lower dimension bounds of the corresponding dimension. The number of subscript expressions must be<br />

equal to the dimension of the array.<br />

If an array has n elements then there is a 1-to-1 correspondence between the elements of the array and the<br />

integers from 1 to n. Each subscript has a subscript value associated with it which determines which<br />

element of the array is being referenced. If the subscript value is i then the ith element of the array is the<br />

one referenced. The subscript value depends on the subscript expressions and on the dimensions of the<br />

array. The following table describes how to compute the subscript value.<br />

<br />

n Dimension Subscript Subscript<br />

Declarator<br />

Value<br />

1 (J1:K1) (S1) 1+(S1-J1)<br />

2 (J1:K1,J2:K2) (S1,S2) 1+(S1-J1)<br />

+(S2-J2)*D1<br />

3 (J1:K1,J2:K2,J3:K3) (S1,S2,S3) 1+(S1-J1)<br />

+(S2-J2)*D1<br />

+(S3-J3)*D2*D1<br />

. . . .<br />

. . . .<br />

. . . .<br />

n (J1:K1,...,Jn:Kn) (S1,...,Sn) 1+(S1-J1)<br />

+(S2-J2)*D1<br />

+(S3-J3)*D2*D1<br />

+<br />

+(Sn-Jn)*Dn-1*Dn-2*...*D1<br />

Notes:<br />

1. n is the number of dimensions, 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!