Motivation
GEOS_SolarGridComp.F90 contains a do b = 1,nBlocks loop inside SORADCORE (which is an internal subroutine of RUN) that processes RRTMGP shortwave radiative transfer in chunks of columns. Each iteration is independent — inputs are read-only slices colS:colE of shared arrays, outputs are written to non-overlapping colS:colE slices, and all per-block temporaries are allocated fresh each iteration. This makes the loop an excellent candidate for ! PARALLEL DO.
Approach
To safely introduce OpenMP we will first refactor cautiously, keeping the code compilable and correct at each step before any OpenMP directives are added:
- Extract loop body into a subroutine — pull the body of
do b = 1,nBlocks into a new contained subroutine (e.g. PROCESS_RRTMGP_BLOCK). Per-block allocatables become local variables (thread-private by construction); shared arrays become explicit dummy arguments.
- Verify bit-reproducibility with the extracted subroutine before touching anything else.
- Add
! PARALLEL DO to the loop calling the new subroutine.
- Verify correctness under OpenMP.
Assumption
RRTMGP library routines called within the block loop (rte_sw, gas/cloud optics kernels, etc.) are assumed to be thread-safe. This has been confirmed by RRTMGP developers. No locking around RRTMGP calls is therefore required.
Tracking
Step-by-step plan and code changes tracked in the associated PR.
Motivation
GEOS_SolarGridComp.F90contains ado b = 1,nBlocksloop insideSORADCORE(which is an internal subroutine ofRUN) that processes RRTMGP shortwave radiative transfer in chunks of columns. Each iteration is independent — inputs are read-only slicescolS:colEof shared arrays, outputs are written to non-overlappingcolS:colEslices, and all per-block temporaries are allocated fresh each iteration. This makes the loop an excellent candidate for! PARALLEL DO.Approach
To safely introduce OpenMP we will first refactor cautiously, keeping the code compilable and correct at each step before any OpenMP directives are added:
do b = 1,nBlocksinto a new contained subroutine (e.g.PROCESS_RRTMGP_BLOCK). Per-block allocatables become local variables (thread-private by construction); shared arrays become explicit dummy arguments.! PARALLEL DOto the loop calling the new subroutine.Assumption
RRTMGP library routines called within the block loop (
rte_sw, gas/cloud optics kernels, etc.) are assumed to be thread-safe. This has been confirmed by RRTMGP developers. No locking around RRTMGP calls is therefore required.Tracking
Step-by-step plan and code changes tracked in the associated PR.