seed_wrap_static_2d Subroutine

private pure subroutine seed_wrap_static_2d(fld, grid, per_x, per_y, north_fold)

Fill the seam ghosts of a static, cell-centred 2-D geometry field (bathymetry, ice draft, cover fraction) from their periodic / north-fold images, on the host, at seed time.

Only the axes this rank holds WHOLE are wrapped locally (nx_phys == nx_global / ny_phys == ny_global); on a decomposed axis the seam ghosts belong to a neighbour rank and are filled by the engine’s init-time halo exchange, which runs later. The fold is applied only on the rank that owns the north edge, and only when that rank holds the whole fold row: on an east-west split (px > 1) it needs the distributed exchange (rdb_ocean_fold_exchange), which is initialised later, so engine_setup folds these fields then (with the init folds). Every field seeded here FROM the unfolded north ghosts is repaired before anything reads it: h_layer and the tracers by the engine’s cold-start fold, the stored wet mask by configure_ocean_land_mask (an elementwise map of the water column, so folding it reproduces the serial ghosts), the z_ref table, the PGF’s bathymetry copy and bt_H_ref by their engine-side rebuild / re-fold after the fold; the barotropic CFL scan reads physical cells only. Composition order matches the engine’s init wrap: periodic first, so the fold reads the wrapped corner columns.

Arguments

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

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

type(hgrid_t), intent(in) :: grid
logical, intent(in) :: per_x

West/east edges are periodic.

logical, intent(in) :: per_y

South/north edges are periodic.

logical, intent(in) :: north_fold

North edge is the tripolar fold.


Calls

proc~~seed_wrap_static_2d~~CallsGraph proc~seed_wrap_static_2d seed_wrap_static_2d interface~fold_north_centre fold_north_centre proc~seed_wrap_static_2d->interface~fold_north_centre proc~ocean_periodic_wrap_centre_2d ocean_periodic_wrap_centre_2d proc~seed_wrap_static_2d->proc~ocean_periodic_wrap_centre_2d 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

Called by

proc~~seed_wrap_static_2d~~CalledByGraph proc~seed_wrap_static_2d seed_wrap_static_2d proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~seed_wrap_static_2d proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean 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

Variables

Type Visibility Attributes Name Initial
logical, private :: fold
logical, private :: wrap_x
logical, private :: wrap_y

Source Code

   pure subroutine seed_wrap_static_2d(fld, grid, per_x, per_y, north_fold)
      !! Fill the seam ghosts of a static, cell-centred 2-D geometry field
      !! (bathymetry, ice draft, cover fraction) from their periodic /
      !! north-fold images, on the host, at seed time.
      !!
      !! Only the axes this rank holds WHOLE are wrapped locally
      !! (`nx_phys == nx_global` / `ny_phys == ny_global`); on a decomposed
      !! axis the seam ghosts belong to a neighbour rank and are filled by
      !! the engine's init-time halo exchange, which runs later.  The fold
      !! is applied only on the rank that owns the north edge, and only when
      !! that rank holds the whole fold row: on an east-west split (px > 1)
      !! it needs the distributed exchange (`rdb_ocean_fold_exchange`), which
      !! is initialised later, so `engine_setup` folds these fields then
      !! (with the init folds).
      !! Every field seeded here FROM the unfolded north ghosts is repaired
      !! before anything reads it: h_layer and the tracers by the engine's
      !! cold-start fold, the stored wet mask by `configure_ocean_land_mask`
      !! (an elementwise map of the water column, so folding it reproduces
      !! the serial ghosts), the z_ref table, the PGF's bathymetry copy and
      !! bt_H_ref by their engine-side rebuild / re-fold after the fold; the
      !! barotropic CFL scan reads physical cells only.  Composition
      !! order matches the engine's init wrap: periodic first, so the fold
      !! reads the wrapped corner columns.
      real(wp), intent(inout) :: fld(:, :)
         !! Cell-centred field, shape `(nx_total, ny_total)`.
      type(hgrid_t), intent(in) :: grid
      logical, intent(in) :: per_x
         !! West/east edges are periodic.
      logical, intent(in) :: per_y
         !! South/north edges are periodic.
      logical, intent(in) :: north_fold
         !! North edge is the tripolar fold.

      logical :: wrap_x, wrap_y, fold

      if (size(fld, 1) /= grid%nx_total .or. size(fld, 2) /= grid%ny_total) return
      wrap_x = per_x .and. grid%nx_phys == grid%nx_global
      wrap_y = per_y .and. grid%ny_phys == grid%ny_global
      fold = north_fold .and. grid%nx_phys == grid%nx_global .and. &
             grid%j_offset_global + grid%ny_phys == grid%ny_global
      if (wrap_x .or. wrap_y) then
         call ocean_periodic_wrap_centre_2d(fld, grid%nx_total, grid%ny_total, &
                                            grid%nx_phys, grid%ny_phys, grid%nghost, &
                                            wrap_x, wrap_y)
      end if
      if (fold) then
         call fold_north_centre(fld, grid%nx_total, grid%ny_total, &
                                grid%nx_phys, grid%ny_phys, grid%nghost)
      end if
   end subroutine seed_wrap_static_2d