ocean_periodic_wrap_centre_3d Subroutine

public subroutine ocean_periodic_wrap_centre_3d(fld, nx_total, ny_total, nz, nx_phys, ny_phys, nghost, wrap_x, wrap_y, no_wait)

Fill ghost cells of a cell-centred 3D field (e.g. h_layer, hTr, T, S). no_wait (optional, default .false.): when .true., loops issue on OpenACC queue 1 and the routine returns WITHOUT syncing, so a batched caller can pipeline many tiny ghost-slab wraps and !$acc wait(1) once. Default ⇒ self-contained blocking wrap. Not pure (directives).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: fld(nx_total,ny_total,nz)

Cell-centred field, shape (nx_total, ny_total, nz).

integer, intent(in) :: nx_total
integer, intent(in) :: ny_total
integer, intent(in) :: nz
integer, intent(in) :: nx_phys
integer, intent(in) :: ny_phys
integer, intent(in) :: nghost
logical, intent(in) :: wrap_x
logical, intent(in) :: wrap_y
logical, intent(in), optional :: no_wait

Called by

proc~~ocean_periodic_wrap_centre_3d~~CalledByGraph proc~ocean_periodic_wrap_centre_3d ocean_periodic_wrap_centre_3d proc~continuity_gm_apply continuity_gm_apply proc~continuity_gm_apply->proc~ocean_periodic_wrap_centre_3d interface~ocean_halo_centre ocean_halo_centre proc~continuity_gm_apply->interface~ocean_halo_centre proc~continuity_tracer_step_split continuity_tracer_step_split proc~continuity_tracer_step_split->proc~ocean_periodic_wrap_centre_3d proc~continuity_tracer_step_split->interface~ocean_halo_centre proc~drain_wrap_centre drain_wrap_centre proc~drain_wrap_centre->proc~ocean_periodic_wrap_centre_3d proc~ocean_halo_centre_3d ocean_halo_centre_3d proc~ocean_halo_centre_3d->proc~ocean_periodic_wrap_centre_3d proc~ocean_periodic_wrap_state ocean_periodic_wrap_state proc~ocean_periodic_wrap_state->proc~ocean_periodic_wrap_centre_3d proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_periodic_wrap_centre_3d proc~run_stage_split->proc~ocean_periodic_wrap_state proc~run_stage_split->interface~ocean_halo_centre proc~run_continuity_chain run_continuity_chain proc~run_stage_split->proc~run_continuity_chain proc~ocean_halo_exchange_ml_state ocean_halo_exchange_ml_state proc~run_stage_split->proc~ocean_halo_exchange_ml_state proc~refresh_tracer_ghosts refresh_tracer_ghosts proc~run_stage_split->proc~refresh_tracer_ghosts interface~ocean_halo_centre->proc~ocean_halo_centre_3d proc~continuity_tracer_drain continuity_tracer_drain proc~continuity_tracer_drain->proc~drain_wrap_centre proc~engine_setup engine_setup proc~engine_setup->proc~ocean_periodic_wrap_state proc~engine_setup->interface~ocean_halo_centre proc~configure_ocean_land_mask configure_ocean_land_mask proc~engine_setup->proc~configure_ocean_land_mask proc~engine_setup->proc~ocean_halo_exchange_ml_state proc~ocean_halo_exchange_ice_state ocean_halo_exchange_ice_state proc~engine_setup->proc~ocean_halo_exchange_ice_state proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split proc~ocean_dyn_step_split->interface~ocean_halo_centre proc~ocean_dyn_step_split->proc~continuity_tracer_drain proc~run_gm_step run_gm_step proc~ocean_dyn_step_split->proc~run_gm_step proc~run_continuity_chain->proc~continuity_tracer_step_split proc~run_continuity_chain->proc~ocean_periodic_wrap_state proc~run_continuity_chain->interface~ocean_halo_centre proc~run_continuity_chain->proc~ocean_halo_exchange_ml_state proc~run_continuity_chain->proc~refresh_tracer_ghosts proc~run_gm_step->proc~continuity_gm_apply proc~run_gm_step->proc~ocean_periodic_wrap_state proc~run_gm_step->proc~ocean_halo_exchange_ml_state proc~run_stage run_stage proc~run_stage->proc~continuity_tracer_step_split proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~engine_enter_data engine_enter_data proc~complete_ocean_create->proc~engine_enter_data proc~configure_ocean_land_mask->interface~ocean_halo_centre proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~engine_step engine_step proc~driver_run_ocean->proc~engine_step proc~ocean_dyn_flush_tracer_window ocean_dyn_flush_tracer_window proc~driver_run_ocean->proc~ocean_dyn_flush_tracer_window proc~driver_run_ocean->proc~engine_enter_data proc~engine_step_ice engine_step_ice proc~driver_run_ocean->proc~engine_step_ice proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~engine_step->proc~ocean_dyn_step_split proc~ocean_dyn_step ocean_dyn_step proc~engine_step->proc~ocean_dyn_step proc~ice_halo_centre_flat ice_halo_centre_flat proc~ice_halo_centre_flat->interface~ocean_halo_centre proc~ocean_dyn_flush_tracer_window->proc~continuity_tracer_drain proc~ocean_dyn_step->proc~continuity_tracer_drain proc~ocean_dyn_step->proc~run_stage proc~ocean_halo_exchange_ice_fluxes ocean_halo_exchange_ice_fluxes proc~ocean_halo_exchange_ice_fluxes->interface~ocean_halo_centre proc~ocean_halo_exchange_ml_state->interface~ocean_halo_centre proc~refresh_tracer_ghosts->interface~ocean_halo_centre proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~engine_enter_data->proc~ocean_halo_exchange_ml_state proc~engine_step_ice->proc~ocean_halo_exchange_ice_fluxes proc~engine_step_ice->proc~ocean_halo_exchange_ice_state proc~ocean_halo_exchange_ice_state->proc~ice_halo_centre_flat proc~ocean_halo_exchange_ice_transport ocean_halo_exchange_ice_transport proc~ocean_halo_exchange_ice_transport->proc~ice_halo_centre_flat proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create proc~rdb_ocean_set_tracer rdb_ocean_set_tracer proc~rdb_ocean_set_tracer->proc~ocean_dyn_flush_tracer_window proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step proc~rdb_ocean_step->proc~engine_step_ice proc~ice_transport_step ice_transport_step proc~ice_transport_step->proc~ocean_halo_exchange_ice_transport

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
integer, private :: k
logical, private :: lwait

Source Code

   subroutine ocean_periodic_wrap_centre_3d(fld, nx_total, ny_total, nz, &
                                            nx_phys, ny_phys, nghost, &
                                            wrap_x, wrap_y, no_wait)
      !! Fill ghost cells of a cell-centred 3D field (e.g. h_layer, hTr, T, S).
      !! `no_wait` (optional, default .false.): when .true., loops issue on
      !! OpenACC queue 1 and the routine returns WITHOUT syncing, so a batched
      !! caller can pipeline many tiny ghost-slab wraps and `!$acc wait(1)`
      !! once. Default ⇒ self-contained blocking wrap. Not `pure` (directives).
      integer, intent(in) :: nx_total, ny_total, nz, nx_phys, ny_phys, nghost
      real(wp), intent(inout) :: fld(nx_total, ny_total, nz)
         !! Cell-centred field, shape (nx_total, ny_total, nz).
      logical, intent(in) :: wrap_x
      logical, intent(in) :: wrap_y
      logical, intent(in), optional :: no_wait

      integer :: i, j, k
      logical :: lwait

      lwait = .true.   ! default: blocking (wait) — safe for non-batched callers
      if (present(no_wait)) lwait = .not. no_wait

      ! X-wrap first, then Y-wrap in a separate loop.  Two passes needed
      ! because the Y-wrap reads the x-ghost columns the X-pass just wrote.
      ! Same queue ⇒ ordered ⇒ the X→Y dependency holds.
      !$acc kernels async(1)
      if (wrap_x) then
         do concurrent(k=1:nz, j=1:ny_total, i=1:nx_total)
            if (i <= nghost) then
               fld(i, j, k) = fld(i + nx_phys, j, k)
            end if
            if (i > nx_phys + nghost) then
               fld(i, j, k) = fld(i - nx_phys, j, k)
            end if
         end do
      end if
      if (wrap_y) then
         do concurrent(k=1:nz, j=1:ny_total, i=1:nx_total)
            if (j <= nghost) then
               fld(i, j, k) = fld(i, j + ny_phys, k)
            end if
            if (j > ny_phys + nghost) then
               fld(i, j, k) = fld(i, j - ny_phys, k)
            end if
         end do
      end if
      !$acc end kernels
      if (lwait) then
         !$acc wait(1)
      end if
   end subroutine ocean_periodic_wrap_centre_3d