halo_allreduce_max Subroutine

public subroutine halo_allreduce_max(local_val, global_val)

MPI_Allreduce with MPI_MAX — max-type reductions are exact in FP, so a global max stays layout-reproducible (ocean-MPI plan D5). Used for auto_n_inner’s global gravity-wave CFL (shared n_inner).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: local_val
real(kind=wp), intent(out) :: global_val

Calls

proc~~halo_allreduce_max~~CallsGraph proc~halo_allreduce_max halo_allreduce_max allreduce allreduce proc~halo_allreduce_max->allreduce proc~comm_env_compute_comm comm_env_compute_comm proc~halo_allreduce_max->proc~comm_env_compute_comm comm_world comm_world proc~comm_env_compute_comm->comm_world

Called by

proc~~halo_allreduce_max~~CalledByGraph proc~halo_allreduce_max halo_allreduce_max proc~ice_transport_step ice_transport_step proc~ice_transport_step->proc~halo_allreduce_max proc~ocean_console_stats_report ocean_console_stats_report proc~ocean_console_stats_report->proc~halo_allreduce_max proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~ocean_console_stats_report proc~engine_step_ice engine_step_ice proc~driver_run_ocean->proc~engine_step_ice proc~engine_step_ice->proc~ice_transport_step proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_ice

Variables

Type Visibility Attributes Name Initial
type(comm_t), private :: comm

Source Code

   subroutine halo_allreduce_max(local_val, global_val)
      !! MPI_Allreduce with MPI_MAX — max-type reductions are exact in FP,
      !! so a global max stays layout-reproducible (ocean-MPI plan D5).
      !! Used for auto_n_inner's global gravity-wave CFL (shared n_inner).
      real(wp), intent(in) :: local_val
      real(wp), intent(out) :: global_val

      type(comm_t) :: comm

      comm = comm_env_compute_comm()
      ! Single rank: the reduction is the identity, so return this rank's
      ! own contribution without entering a collective.  Not just an
      ! optimisation -- pic-mpi's serial backend (PIC_ENABLE_MPI=OFF)
      ! deliberately `error stop`s in `allreduce`, pushing the size()==1
      ! case onto the caller.  This IS that case.
      if (comm%size() == 1) then
         global_val = local_val
         return
      end if
      call allreduce(comm, local_val, global_val, op=MPI_MAX)

   end subroutine halo_allreduce_max