Re: multidimensional array order in memory

rusi_pathan wrote:

On Feb 7, 2:39 am, Glen Herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:

Terence wrote:

Given an array X(I,J,K), I was "brought uo" on the rule that arrays
are stored in column-major order; i.e. that the left-most index
changed most rapidly in passing memory-sequentially over the array in
And this implies it is slightly faster to access locations (fewer
computations) if a nest of three loops has the I loop K inside the J
loop, inside the K loop:-

In the old days it may have been slightly faster. With cache on
current machines it can make a very significant difference.
With virtual storage and large arrays it can make a
huge difference.

DO 3 K=1,maxk
DO 2 J=1,maxj
DO 1 I=1,maxi

Is this aove definition more or less still the standard for modern

It is still that way.

Cant modern compilers figure that out automatically meaning I write
straightforward code (K inside J inside I) and the compilers change
the order minimizing cache miss?
You would think :)


Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library:

Support the Original G95 Project:
Support the GNU GFortran Project:

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford