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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(inout) | :: | fld(:,:) |
Cell-centred field, shape |
||
| 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. |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | fold | ||||
| logical, | private | :: | wrap_x | ||||
| logical, | private | :: | wrap_y |
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