Skip to content

adam_fnl_mpih_global

ADAM, global FNL MPI handler singleton — single program-scope mpih_fnl_object instance.

Provides the GPU-aware MPI handler (FUNDAL mpih_object) as a program-scope singleton, mirroring the CPU-side adam_mpih_global pattern.

Unlike the six per-realm FNL objects (field/ib/rk/weno/coil/fwlayer), the MPI handler is genuinely program-scope: it wraps the process rank/size, the bound GPU device, and the local communicator — all one-per-process, not one-per-realm. FUNDAL's mpih_object even associates its device members (mydev, local_comm, ...) to fundal_env global variables, so there is exactly one device context regardless of realm count. Promoting it to a per-realm value component duplicates the handler and re-runs device init per realm, corrupting the CUDA primary context on the multi-realm path. True singleton here.

Init-once discipline: FUNDAL's initialize is intent(out) (it wipes self) and runs the device init + communicator split under do_device_init. It must therefore be called exactly once per process. is_initialized guards that: the first realm initializes the singleton; subsequent realms skip. See prism_fnl_object%initialize_prism.

fortran
 if (.not. mpih_fnl_is_initialized) then
    call mpih_fnl%initialize(do_mpi_init=..., do_device_init=.true., verbose=.true.)
    mpih_fnl_is_initialized = .true.
 endif

Source: src/lib/fnl/adam_fnl_mpih_global.F90

Dependencies

Variables

NameTypeAttributesDescription
mpih_fnltype(mpih_object)targetProgram-scope GPU MPI handler singleton.
mpih_fnl_is_initializedlogicalInit-once guard (FUNDAL initialize is intent(out)).