Phase 1: Initialise MPI, cache world rank/size Call this before reading config. Idempotent: a second call is a no-op, so multiple entry points / testdrive cases can call it.
subroutine comm_env_init() !! Phase 1: Initialise MPI, cache world rank/size !! Call this before reading config. Idempotent: a second call is a !! no-op, so multiple entry points / testdrive cases can call it. if (env_initialised) return call pic_mpi_init() comm_global = comm_world() cached_rank = comm_global%rank() cached_size = comm_global%size() ! Default: all ranks are compute, compute_comm = comm_world comm_compute = comm_global cached_compute_rank = cached_rank cached_compute_size = cached_size env_initialised = .true. end subroutine comm_env_init