Could nSites be moved to be the last dimension in multi-site Fortran data? It would (Edit: or not) resolve the following problems:
Single-site subroutines such as prebas() and initBiomasses() require contiguous data because the arrays have explicit shapes. However, in Fortran's column-major memory layout, single-site slices of multiPrebas() data are strided (non-contiguous) because nSites is the first dimension in the multi-site data.
GFortran plays it safe and automatically generates contiguous copies of the data for the subroutines. This works correctly but is relying on undefined behavior and is unnecessary work.
I've been working on building Rprebasso for WebR. The compiler in the standard workflow is Flang which doesn't create contiguous temporaries for explicit-shape arrays. Instead, subroutines get the wrong data.
Edit: I'm starting to think I was a bit naive and this is not the only change needed to ensure contiguity of slices.
Could
nSitesbe moved to be the last dimension in multi-site Fortran data? It would (Edit: or not) resolve the following problems:Single-site subroutines such as
prebas()andinitBiomasses()require contiguous data because the arrays have explicit shapes. However, in Fortran's column-major memory layout, single-site slices ofmultiPrebas()data are strided (non-contiguous) becausenSitesis the first dimension in the multi-site data.GFortran plays it safe and automatically generates contiguous copies of the data for the subroutines. This works correctly but is relying on undefined behavior and is unnecessary work.
I've been working on building Rprebasso for WebR. The compiler in the standard workflow is Flang which doesn't create contiguous temporaries for explicit-shape arrays. Instead, subroutines get the wrong data.
Edit: I'm starting to think I was a bit naive and this is not the only change needed to ensure contiguity of slices.