ocean_fold_wrap_centre_3d_state Subroutine

public subroutine ocean_fold_wrap_centre_3d_state(grid, bc, ms, device_resident)

Fold ONLY h_layer + tracers (centre fields) — the continuity mid-split site, which re-wraps the centre fields between the zonal and meridional Lie-split halves. No-op when not folding.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
type(multilayer_state_t), intent(inout) :: ms
logical, intent(in), optional :: device_resident

px > 1 only: .false. for host-side calls.


Calls

proc~~ocean_fold_wrap_centre_3d_state~~CallsGraph proc~ocean_fold_wrap_centre_3d_state ocean_fold_wrap_centre_3d_state interface~fold_north_centre fold_north_centre proc~ocean_fold_wrap_centre_3d_state->interface~fold_north_centre interface~ocean_fold_pack ocean_fold_pack proc~ocean_fold_wrap_centre_3d_state->interface~ocean_fold_pack interface~ocean_fold_unpack ocean_fold_unpack proc~ocean_fold_wrap_centre_3d_state->interface~ocean_fold_unpack proc~n_tracers n_tracers proc~ocean_fold_wrap_centre_3d_state->proc~n_tracers proc~ocean_fold_begin ocean_fold_begin proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_begin proc~ocean_fold_end ocean_fold_end proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_end proc~ocean_fold_exchange ocean_fold_exchange proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_exchange proc~ocean_fold_is_distributed ocean_fold_is_distributed proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_is_distributed proc~fold_north_centre_2d fold_north_centre_2d interface~fold_north_centre->proc~fold_north_centre_2d proc~fold_north_centre_3d fold_north_centre_3d interface~fold_north_centre->proc~fold_north_centre_3d proc~ocean_fold_pack_2d ocean_fold_pack_2d interface~ocean_fold_pack->proc~ocean_fold_pack_2d proc~ocean_fold_pack_3d ocean_fold_pack_3d interface~ocean_fold_pack->proc~ocean_fold_pack_3d proc~ocean_fold_unpack_2d ocean_fold_unpack_2d interface~ocean_fold_unpack->proc~ocean_fold_unpack_2d proc~ocean_fold_unpack_3d ocean_fold_unpack_3d interface~ocean_fold_unpack->proc~ocean_fold_unpack_3d proc~grow_buffers grow_buffers proc~ocean_fold_begin->proc~grow_buffers to_string to_string proc~ocean_fold_begin->to_string warning warning proc~ocean_fold_begin->warning comm_irecv_real_sp_array_n comm_irecv_real_sp_array_n proc~ocean_fold_exchange->comm_irecv_real_sp_array_n comm_isend_real_sp_array_n comm_isend_real_sp_array_n proc~ocean_fold_exchange->comm_isend_real_sp_array_n proc~comm_env_compute_comm comm_env_compute_comm proc~ocean_fold_exchange->proc~comm_env_compute_comm waitall waitall proc~ocean_fold_exchange->waitall comm_world comm_world proc~comm_env_compute_comm->comm_world proc~ocean_fold_pack_2d->proc~ocean_fold_pack_3d proc~fold_stagger_family fold_stagger_family proc~ocean_fold_pack_3d->proc~fold_stagger_family proc~fold_stagger_nrows fold_stagger_nrows proc~ocean_fold_pack_3d->proc~fold_stagger_nrows proc~ocean_fold_unpack_2d->proc~ocean_fold_unpack_3d proc~ocean_fold_unpack_3d->proc~fold_stagger_family proc~ocean_fold_unpack_3d->proc~fold_stagger_nrows

Called by

proc~~ocean_fold_wrap_centre_3d_state~~CalledByGraph proc~ocean_fold_wrap_centre_3d_state ocean_fold_wrap_centre_3d_state proc~continuity_gm_apply continuity_gm_apply proc~continuity_gm_apply->proc~ocean_fold_wrap_centre_3d_state proc~continuity_tracer_step_split continuity_tracer_step_split proc~continuity_tracer_step_split->proc~ocean_fold_wrap_centre_3d_state proc~refresh_tracer_ghosts refresh_tracer_ghosts proc~refresh_tracer_ghosts->proc~ocean_fold_wrap_centre_3d_state proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->proc~continuity_tracer_step_split proc~run_continuity_chain->proc~refresh_tracer_ghosts proc~run_gm_step run_gm_step proc~run_gm_step->proc~continuity_gm_apply proc~run_stage run_stage proc~run_stage->proc~continuity_tracer_step_split proc~run_stage_split run_stage_split proc~run_stage_split->proc~refresh_tracer_ghosts proc~run_stage_split->proc~run_continuity_chain proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~run_stage proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_gm_step proc~ocean_dyn_step_split->proc~run_stage_split proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step proc~engine_step->proc~ocean_dyn_step_split proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step

Variables

Type Visibility Attributes Name Initial
integer, private :: it
integer, private :: nghost
integer, private :: nx
integer, private :: nx_phys
integer, private :: ny
integer, private :: ny_phys
integer, private :: nz

Source Code

   subroutine ocean_fold_wrap_centre_3d_state(grid, bc, ms, device_resident)
      !! Fold ONLY h_layer + tracers (centre fields) — the continuity
      !! mid-split site, which re-wraps the centre fields between the
      !! zonal and meridional Lie-split halves.  No-op when not folding.
      type(hgrid_t), intent(in) :: grid
      type(ocean_bc_state_t), intent(in) :: bc
      type(multilayer_state_t), intent(inout) :: ms
      logical, intent(in), optional :: device_resident
         !! px > 1 only: `.false.` for host-side calls.

      integer :: it
      integer :: nx, ny, nz, nx_phys, ny_phys, nghost

      if (.not. bc%north_fold) return

      nx = grid%nx_total
      ny = grid%ny_total
      nz = ms%nz_ml
      nx_phys = grid%nx_phys
      ny_phys = grid%ny_phys
      nghost = grid%nghost

      if (ocean_fold_is_distributed()) then
         ! One group: h + every hTr (all T, copy).
         call ocean_fold_begin(nghost*nz*(1 + n_tracers(ms)))
         call ocean_fold_pack(ms%h_layer, nx, ny, nz, FOLD_STAG_T, device_resident)
         if (allocated(ms%tracers)) then
            do it = 1, size(ms%tracers)
               if (.not. allocated(ms%tracers(it)%hTr)) cycle
               call ocean_fold_pack(ms%tracers(it)%hTr, nx, ny, nz, FOLD_STAG_T, device_resident)
            end do
         end if
         call ocean_fold_exchange(device_resident)
         call ocean_fold_unpack(ms%h_layer, nx, ny, nz, FOLD_STAG_T, .false., device_resident)
         if (allocated(ms%tracers)) then
            do it = 1, size(ms%tracers)
               if (.not. allocated(ms%tracers(it)%hTr)) cycle
               call ocean_fold_unpack(ms%tracers(it)%hTr, nx, ny, nz, FOLD_STAG_T, .false., &
                                      device_resident)
            end do
         end if
         call ocean_fold_end()
         return
      end if

      call fold_north_centre(ms%h_layer, nx, ny, nz, &
                             nx_phys, ny_phys, nghost)
      if (allocated(ms%tracers)) then
         do it = 1, size(ms%tracers)
            if (.not. allocated(ms%tracers(it)%hTr)) cycle
            call fold_north_centre(ms%tracers(it)%hTr, nx, ny, nz, &
                                   nx_phys, ny_phys, nghost)
         end do
      end if
   end subroutine ocean_fold_wrap_centre_3d_state