FORTRAN ARRAY ADDRESSING


    DIMENSION A(100, 100, 100)    DIMENSION A(100, 100, 100)
    X = 1.0                       X = 1.0
    DO 10, K=1, 100               DO 10, I=1, 100
    DO 10, J=1, 100               DO 10, J=1, 100
    DO 10, I=1, 100               DO 10, K=1, 100
10  A(I,J,K) = X              10  A(I,J,K) = X
    END                           END

  "RIGHT"                       "WRONG"


The "RIGHT" method references each element of the array A in
the natural order the array is stored in memory.  This
program took 45 seconds to run on a VAX 750.

The "WRONG" method references each element of the array A in
a manner which causes a lot of intensive page faulting to
occur.  This program took 1 and 1/2 hours to run on a VAX
750.

See file PAGE_FAULTS_AND_ARRAY_ADDRESSING.DOC for more information.


NOTE:  The above example is for FORTRAN.  Other programming languages
       may not follow the same convention.  For instance, PASCAL stores
       arrays with the last subscript changing most often, which is
       opposite to that of FORTRAN.


David W. Deley