aosprey / mckpp-f90

Multi-Column configuration of the K Profile Parameterisation mixed-layer ocean model (F90 version)
GNU General Public License v3.0
2 stars 0 forks source link

Reorder arrays #15

Open aosprey opened 3 years ago

aosprey commented 3 years ago

Arrays are dimensioned as array(npts,nz) which means that the npts dimension varies fastest. So it is more efficient to access elements 1 level at a time, eg:

do k = 1,  nz
  do n = 1,  npts 
    array(n,k) 
  end do 
end do 

However in KPP, we actually access data the other way around, as the physics code operates on one grid point at a time. So it would be much more efficient if the levels were contiguous in memory, and the arrays dimensioned as array(nz,npts).

This would also make the MPI parallelisation easier, as we would be parallelising over the outer dimension.

For 3d arrays the position of the extra dimension depends on the access patterns - so I need to check this.