In Fortran, Cactus currently declares grid functions e.g. as (this is the expansion of DECLARE_CCTK_ARGUMENTS)
REAL*8 gxx (X0metric,X1metric,X2metric)
where X0metric etc. are integers passed into the routine. Each grid function group has its own, independent size. This has two disadvantages:
- The compiler does not know that all grid functions have the same size (namely cctk_lsh), and thus has to perform array index calculations separately for each group
- The argument list is longer than neded
The enclosed patch declares grid functions via cctk_lsh. Grid arrays are still declared independently.
This reduces the code size of e.g. GRHydro/GRHydro_Tmunu.F90 from 6836 to 6241 bytes on my system. I have not attempted to measure a performance difference.