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 | Intent | Optional | 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: |
| 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 |
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