ocean_periodic_wrap_centre_2d Subroutine

public pure subroutine ocean_periodic_wrap_centre_2d(fld, nx_total, ny_total, nx_phys, ny_phys, nghost, wrap_x, wrap_y)

Fill ghost cells of a cell-centred 2D field (e.g. η, bt_H_ref) with the periodically-matching interior values. Explicit-shape dummies avoid per-launch descriptor-walk memcpys.

Arguments

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

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

integer, intent(in) :: nx_total
integer, intent(in) :: ny_total
integer, intent(in) :: nx_phys
integer, intent(in) :: ny_phys
integer, intent(in) :: nghost
logical, intent(in) :: wrap_x

Wrap ghost columns (west ↔ east).

logical, intent(in) :: wrap_y

Wrap ghost rows (south ↔ north).


Called by

proc~~ocean_periodic_wrap_centre_2d~~CalledByGraph proc~ocean_periodic_wrap_centre_2d ocean_periodic_wrap_centre_2d proc~engine_setup engine_setup proc~engine_setup->proc~ocean_periodic_wrap_centre_2d proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~engine_setup->proc~ocean_state_seed_from_cfg interface~ocean_halo_centre ocean_halo_centre 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~ocean_halo_exchange_ml_state ocean_halo_exchange_ml_state proc~engine_setup->proc~ocean_halo_exchange_ml_state proc~evp_build_masks_impl evp_build_masks_impl proc~evp_build_masks_impl->proc~ocean_periodic_wrap_centre_2d proc~ice_evp_dynamics_impl ice_evp_dynamics_impl proc~ice_evp_dynamics_impl->proc~ocean_periodic_wrap_centre_2d proc~ice_evp_dynamics_impl->proc~evp_build_masks_impl proc~ocean_halo_centre_2d_impl ocean_halo_centre_2d_impl proc~ocean_halo_centre_2d_impl->proc~ocean_periodic_wrap_centre_2d proc~rdb_ocean_set_bathymetry rdb_ocean_set_bathymetry proc~rdb_ocean_set_bathymetry->proc~ocean_periodic_wrap_centre_2d proc~seed_wrap_static_2d seed_wrap_static_2d proc~seed_wrap_static_2d->proc~ocean_periodic_wrap_centre_2d 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~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup 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~ice_evp_dynamics ice_evp_dynamics proc~ice_evp_dynamics->proc~ice_evp_dynamics_impl proc~ocean_halo_bt_group_2d_wide ocean_halo_bt_group_2d_wide proc~ocean_halo_bt_group_2d_wide->proc~ocean_halo_centre_2d_impl proc~ocean_halo_centre_2d ocean_halo_centre_2d proc~ocean_halo_centre_2d->proc~ocean_halo_centre_2d_impl proc~ocean_halo_centre_2d_wide ocean_halo_centre_2d_wide proc~ocean_halo_centre_2d_wide->proc~ocean_halo_centre_2d_impl proc~ocean_state_seed_from_cfg->proc~seed_wrap_static_2d interface~ocean_halo_centre->proc~ocean_halo_centre_2d proc~barotropic_substep_nonlinear barotropic_substep_nonlinear proc~barotropic_substep_nonlinear->proc~ocean_halo_bt_group_2d_wide proc~ocean_halo_bt_group_2d ocean_halo_bt_group_2d proc~barotropic_substep_nonlinear->proc~ocean_halo_bt_group_2d proc~bt_wide_entry_exchange_impl bt_wide_entry_exchange_impl proc~bt_wide_entry_exchange_impl->proc~ocean_halo_bt_group_2d_wide proc~bt_wide_entry_exchange_impl->proc~ocean_halo_centre_2d_wide proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~engine_enter_data->proc~ocean_halo_bt_group_2d_wide proc~engine_enter_data->proc~ocean_halo_bt_group_2d proc~engine_enter_data->proc~ocean_halo_exchange_ml_state proc~ice_evp_step ice_evp_step proc~ice_evp_step->proc~ice_evp_dynamics proc~ocean_halo_bt_group_2d->proc~ocean_halo_centre_2d 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~barotropic_substep_nonlinear_interior barotropic_substep_nonlinear_interior proc~barotropic_substep_nonlinear_interior->proc~barotropic_substep_nonlinear proc~bt_wide_entry_exchange bt_wide_t%bt_wide_entry_exchange proc~bt_wide_entry_exchange->proc~bt_wide_entry_exchange_impl proc~bt_wide_substep bt_wide_substep proc~bt_wide_substep->proc~barotropic_substep_nonlinear proc~configure_ocean_land_mask->interface~ocean_halo_centre proc~continuity_gm_apply continuity_gm_apply proc~continuity_gm_apply->interface~ocean_halo_centre proc~continuity_tracer_step_split continuity_tracer_step_split proc~continuity_tracer_step_split->interface~ocean_halo_centre proc~engine_step_ice->proc~ice_evp_step proc~ocean_halo_exchange_ice_fluxes ocean_halo_exchange_ice_fluxes proc~engine_step_ice->proc~ocean_halo_exchange_ice_fluxes proc~ice_halo_centre_flat ice_halo_centre_flat proc~ice_halo_centre_flat->interface~ocean_halo_centre proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->interface~ocean_halo_centre proc~run_stage_split run_stage_split proc~ocean_dyn_step_split->proc~run_stage_split proc~ocean_halo_exchange_ice_fluxes->interface~ocean_halo_centre proc~ocean_halo_exchange_ml_state->interface~ocean_halo_centre proc~refresh_tracer_ghosts refresh_tracer_ghosts proc~refresh_tracer_ghosts->interface~ocean_halo_centre proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->interface~ocean_halo_centre proc~run_continuity_chain->proc~continuity_tracer_step_split proc~run_continuity_chain->proc~ocean_halo_exchange_ml_state proc~run_continuity_chain->proc~refresh_tracer_ghosts proc~run_stage_split->interface~ocean_halo_centre proc~run_stage_split->proc~ocean_halo_bt_group_2d proc~run_stage_split->proc~barotropic_substep_nonlinear_interior proc~run_stage_split->proc~bt_wide_entry_exchange proc~run_stage_split->proc~bt_wide_substep proc~run_stage_split->proc~ocean_halo_exchange_ml_state proc~run_stage_split->proc~refresh_tracer_ghosts proc~run_stage_split->proc~run_continuity_chain proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split proc~ocean_halo_exchange_ice_state 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_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_ice proc~run_gm_step run_gm_step proc~run_gm_step->proc~continuity_gm_apply proc~run_gm_step->proc~ocean_halo_exchange_ml_state proc~run_stage run_stage proc~run_stage->proc~continuity_tracer_step_split

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j

Source Code

   pure subroutine ocean_periodic_wrap_centre_2d(fld, nx_total, ny_total, &
                                                 nx_phys, ny_phys, nghost, &
                                                 wrap_x, wrap_y)
      !! Fill ghost cells of a cell-centred 2D field (e.g. η, bt_H_ref)
      !! with the periodically-matching interior values.
      !! Explicit-shape dummies avoid per-launch descriptor-walk memcpys.
      integer, intent(in) :: nx_total, ny_total, nx_phys, ny_phys, nghost
      real(wp), intent(inout) :: fld(nx_total, ny_total)
         !! Cell-centred field, shape (nx_total, ny_total).
      logical, intent(in) :: wrap_x
         !! Wrap ghost columns (west ↔ east).
      logical, intent(in) :: wrap_y
         !! Wrap ghost rows (south ↔ north).

      integer :: i, j

      ! X-wrap first, then Y-wrap in a separate loop.  The two passes must
      ! not share a single do-concurrent because the Y-wrap reads ghost
      ! columns that the X-wrap writes (data dependency across iterations).
      if (wrap_x) then
         do concurrent(j=1:ny_total, i=1:nx_total)
            ! West ghosts: fld(1..nghost, j) := fld(nx_phys+1..nx_phys+nghost, j)
            if (i <= nghost) then
               fld(i, j) = fld(i + nx_phys, j)
            end if
            ! East ghosts: fld(nx_phys+nghost+1..nx_total, j) := fld(nghost+1..2*nghost, j)
            if (i > nx_phys + nghost) then
               fld(i, j) = fld(i - nx_phys, j)
            end if
         end do
      end if
      if (wrap_y) then
         do concurrent(j=1:ny_total, i=1:nx_total)
            ! South ghosts: fld(i, 1..nghost) := fld(i, ny_phys+1..ny_phys+nghost)
            if (j <= nghost) then
               fld(i, j) = fld(i, j + ny_phys)
            end if
            ! North ghosts: fld(i, ny_phys+nghost+1..ny_total) := fld(i, nghost+1..2*nghost)
            if (j > ny_phys + nghost) then
               fld(i, j) = fld(i, j - ny_phys)
            end if
         end do
      end if
   end subroutine ocean_periodic_wrap_centre_2d