rdb_ocean_fold_apply Module

Orchestration over the pure seam operators in rdb_ocean_fold: dereferences the state slots (outer-shim per-tracer loop) and calls the explicit-shape fold kernels.

Ordering contract: periodic-x is wrapped FIRST, fold SECOND — every fold routine is called AFTER the matching periodic wrap so it reads the already cyclically-wrapped corner columns.

Stagger map: * h_layer, η, tracer hTr → centre fold (copy, no sign flip) * u_face_x_layer, bt_ubt → u-face fold (negate — true vector) * v_face_y_layer, bt_vbt → v-face fold (negate + on-row antisymmetric projection of the fold line, storage row nghost+ny_phys+1 — see the rdb_ocean_fold header)

Every routine no-ops when bc%north_fold is .false. ⇒ non-tripolar runs stay bit-identical. bc%north_fold is RANK-LOCAL: true only on the rank that owns the physical north edge (has_north), so on a north-south split the other ranks leave their north ghosts to the MPI exchange that precedes every call here (exchange → periodic wrap → fold). See the rdb_ocean_fold header for the decomposition limits.

px dispatch

px = 1 (ocean_fold_is_distributed() false): the local kernels, textually unchanged. px > 1: every routine becomes ONE collective group of the owner-routed exchange (rdb_ocean_fold_exchange) over the north rank row — all its ranks have north_fold set and reach the same call — with the same fields, signs and fold-line projection. The optional device_resident only matters on that path (host-side setup calls pass .false., as for the halo primitives).


Uses

  • module~~rdb_ocean_fold_apply~~UsesGraph module~rdb_ocean_fold_apply rdb_ocean_fold_apply module~rdb_constants rdb_constants module~rdb_ocean_fold_apply->module~rdb_constants module~rdb_grid rdb_grid module~rdb_ocean_fold_apply->module~rdb_grid module~rdb_multilayer_state rdb_multilayer_state module~rdb_ocean_fold_apply->module~rdb_multilayer_state module~rdb_ocean_boundary_types rdb_ocean_boundary_types module~rdb_ocean_fold_apply->module~rdb_ocean_boundary_types module~rdb_ocean_fold rdb_ocean_fold module~rdb_ocean_fold_apply->module~rdb_ocean_fold module~rdb_ocean_fold_exchange rdb_ocean_fold_exchange module~rdb_ocean_fold_apply->module~rdb_ocean_fold_exchange pic_types pic_types module~rdb_constants->pic_types module~rdb_grid->module~rdb_constants module~rdb_multilayer_state->module~rdb_constants module~rdb_multilayer_state->module~rdb_grid iso_fortran_env iso_fortran_env module~rdb_multilayer_state->iso_fortran_env module~rdb_efp rdb_efp module~rdb_multilayer_state->module~rdb_efp module~rdb_error_ring rdb_error_ring module~rdb_multilayer_state->module~rdb_error_ring module~rdb_mem_report rdb_mem_report module~rdb_multilayer_state->module~rdb_mem_report module~rdb_tracer rdb_tracer module~rdb_multilayer_state->module~rdb_tracer pic_logger pic_logger module~rdb_multilayer_state->pic_logger module~rdb_ocean_boundary_types->module~rdb_constants module~rdb_ocean_boundary_types->module~rdb_grid module~rdb_ocean_boundary_types->iso_fortran_env module~rdb_ocean_boundary_types->module~rdb_mem_report module~rdb_ocean_status rdb_ocean_status module~rdb_ocean_boundary_types->module~rdb_ocean_status module~rdb_ocean_tide_astro rdb_ocean_tide_astro module~rdb_ocean_boundary_types->module~rdb_ocean_tide_astro pic_ascii pic_ascii module~rdb_ocean_boundary_types->pic_ascii module~rdb_ocean_boundary_types->pic_logger module~rdb_ocean_fold->module~rdb_constants module~rdb_ocean_fold_exchange->module~rdb_constants module~rdb_ocean_fold_exchange->module~rdb_ocean_fold module~rdb_comm_env rdb_comm_env module~rdb_ocean_fold_exchange->module~rdb_comm_env module~rdb_decomp rdb_decomp module~rdb_ocean_fold_exchange->module~rdb_decomp module~rdb_ocean_fold_exchange->module~rdb_error_ring module~rdb_ocean_fold_plan rdb_ocean_fold_plan module~rdb_ocean_fold_exchange->module~rdb_ocean_fold_plan module~rdb_ocean_fold_exchange->module~rdb_ocean_status module~rdb_ocean_fold_exchange->pic_logger pic_mpi_lib pic_mpi_lib module~rdb_ocean_fold_exchange->pic_mpi_lib pic_strings pic_strings module~rdb_ocean_fold_exchange->pic_strings module~rdb_comm_env->module~rdb_constants module~rdb_comm_env->iso_fortran_env module~rdb_comm_env->pic_mpi_lib module~rdb_config rdb_config module~rdb_decomp->module~rdb_config module~rdb_efp->iso_fortran_env ieee_arithmetic ieee_arithmetic module~rdb_efp->ieee_arithmetic module~rdb_error_ring->pic_logger module~rdb_mem_report->module~rdb_constants module~rdb_mem_report->iso_fortran_env module~rdb_mem_report->pic_logger module~rdb_mem_report->pic_strings module~rdb_ocean_tide_astro->module~rdb_constants module~rdb_ocean_tide_astro->iso_fortran_env module~rdb_tracer->module~rdb_constants module~rdb_tracer->module~rdb_grid module~rdb_tracer->iso_fortran_env module~rdb_tracer->module~rdb_mem_report module~rdb_config->module~rdb_constants module~rdb_config->module~rdb_error_ring module~rdb_config->module~rdb_ocean_status module~rdb_config->pic_ascii module~rdb_config->pic_logger module~rdb_config->pic_strings module~rdb_ice_enthalpy rdb_ice_enthalpy module~rdb_config->module~rdb_ice_enthalpy module~rdb_ice_init rdb_ice_init module~rdb_config->module~rdb_ice_init module~rdb_nml_schema rdb_nml_schema module~rdb_config->module~rdb_nml_schema module~rdb_ice_enthalpy->module~rdb_constants module~rdb_ice_init->module~rdb_constants module~rdb_ice_init->module~rdb_grid module~rdb_ice_init->module~rdb_multilayer_state module~rdb_ice_init->module~rdb_ice_enthalpy module~rdb_ice_column rdb_ice_column module~rdb_ice_init->module~rdb_ice_column module~rdb_ice_state rdb_ice_state module~rdb_ice_init->module~rdb_ice_state module~rdb_ocean_metrics rdb_ocean_metrics module~rdb_ice_init->module~rdb_ocean_metrics module~rdb_nml_schema->module~rdb_constants module~rdb_nml_schema->module~rdb_error_ring module~rdb_nml_schema->pic_logger

Used by

  • module~~rdb_ocean_fold_apply~~UsedByGraph module~rdb_ocean_fold_apply rdb_ocean_fold_apply module~rdb_continuity rdb_continuity module~rdb_continuity->module~rdb_ocean_fold_apply module~rdb_ocean_api rdb_ocean_api module~rdb_ocean_api->module~rdb_ocean_fold_apply module~rdb_ocean_dyn rdb_ocean_dyn module~rdb_ocean_api->module~rdb_ocean_dyn module~rdb_ocean_engine rdb_ocean_engine module~rdb_ocean_api->module~rdb_ocean_engine module~rdb_handle rdb_handle module~rdb_ocean_api->module~rdb_handle module~rdb_ocean_diag_derived rdb_ocean_diag_derived module~rdb_ocean_api->module~rdb_ocean_diag_derived module~rdb_ocean_diag_fills rdb_ocean_diag_fills module~rdb_ocean_api->module~rdb_ocean_diag_fills module~rdb_ocean_dyn->module~rdb_ocean_fold_apply module~rdb_ocean_dyn->module~rdb_continuity module~rdb_ocean_halo_state rdb_ocean_halo_state module~rdb_ocean_dyn->module~rdb_ocean_halo_state module~rdb_ocean_engine->module~rdb_ocean_fold_apply module~rdb_ocean_engine->module~rdb_ocean_dyn module~rdb_ocean_engine->module~rdb_ocean_halo_state module~rdb_ocean_setup rdb_ocean_setup module~rdb_ocean_engine->module~rdb_ocean_setup module~rdb_ice_ocean_coupler rdb_ice_ocean_coupler module~rdb_ocean_engine->module~rdb_ice_ocean_coupler module~rdb_ice_transport rdb_ice_transport module~rdb_ocean_engine->module~rdb_ice_transport module~rdb_ocean_data_forcing rdb_ocean_data_forcing module~rdb_ocean_engine->module~rdb_ocean_data_forcing module~rdb_ocean_state rdb_ocean_state module~rdb_ocean_engine->module~rdb_ocean_state module~rdb_ocean_engine->module~rdb_ocean_diag_derived module~rdb_ocean_engine->module~rdb_ocean_diag_fills module~rdb_ocean_halo_state->module~rdb_ocean_fold_apply module~rdb_ocean_setup->module~rdb_ocean_fold_apply module~rdb_ocean_setup->module~rdb_ocean_dyn module~rdb_ocean_setup->module~rdb_ocean_halo_state module~rdb_ocean_setup->module~rdb_ocean_state module~rdb_driver rdb_driver module~rdb_driver->module~rdb_ocean_dyn module~rdb_driver->module~rdb_ocean_engine module~rdb_driver->module~rdb_ocean_state module~rdb_handle->module~rdb_ocean_engine module~rdb_handle->module~rdb_ocean_state module~rdb_ice_ocean_coupler->module~rdb_ocean_halo_state module~rdb_ice_transport->module~rdb_continuity module~rdb_ice_transport->module~rdb_ocean_halo_state module~rdb_ocean_data_forcing->module~rdb_ocean_halo_state module~rdb_ocean_state->module~rdb_continuity module~rdb_ocean_state->module~rdb_ocean_dyn module~rdb_ocean_state->module~rdb_ocean_data_forcing module~rdb_ocean_diag_derived->module~rdb_ocean_state module~rdb_ocean_diag_derived->module~rdb_ocean_diag_fills module~rdb_ocean_diag_fills->module~rdb_ocean_state

Functions

private pure function n_tracers(ms) result(n)

Registered tracers carrying an allocated hTr.

Arguments

Type IntentOptional Attributes Name
type(multilayer_state_t), intent(in) :: ms

Return Value integer


Subroutines

public 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.

Arguments

Type IntentOptional 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: .false. for host-side calls.

public subroutine ocean_fold_wrap_centre_flat(grid, bc, fld, nxt, nyt, nz, device_resident)

Fold the north seam of an arbitrary flat cell-centred (T-stagger) SCALAR field — copy, no sign flip, exactly fold_north_centre’s contract. Exists so a caller holding a sequence-associated flat view of a higher-rank array (the sea-ice category state’s ice_halo_centre_flat pattern — part_size/m_ice/m_snow/ enth_ice/sal_ice/enth_snow/mca_ice/mca_snow, and the per-cell flux diagnostics salt_flux_diag/heat_flux_diag/ sw_thru_diag) can fold it without going through multilayer_state_t. Every one of these is a per-category mass, enthalpy, salinity or fractional area — a scalar, not a vector component — so negate is never offered here. Call AFTER the field’s halo exchange (which also performs the single-rank periodic wrap). No-op when bc%north_fold is .false..

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
real(kind=wp), intent(inout) :: fld(nxt,nyt,nz)
integer, intent(in) :: nxt
integer, intent(in) :: nyt
integer, intent(in) :: nz
logical, intent(in), optional :: device_resident

px > 1 only: .false. for host-side (pre-enter_data) calls.

public subroutine ocean_fold_wrap_eta_2d(grid, bc, eta, device_resident)

Fold a 2D cell-centred η field (driver-level SSH wrap site). No-op when not folding.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
real(kind=wp), intent(inout) :: eta(:,:)
logical, intent(in), optional :: device_resident

px > 1 only: .false. for host-side calls.

public subroutine ocean_fold_wrap_state(grid, bc, ms, device_resident)

Fold the north seam of h_layer, u/v layer faces, and every registered tracer. Call AFTER ocean_periodic_wrap_state. No-op when bc%north_fold is .false.

Arguments

Type IntentOptional 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: .false. for host-side (pre-enter_data) calls.

public subroutine ocean_fold_wrap_stress(grid, bc, tau_x, tau_y, device_resident)

Fold the surface-stress pair: tau_x (u, −) and tau_y (v, − + fold-row projection) — true vector components. Call after the pair’s exchange + periodic wrap. No-op when not folding.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
real(kind=wp), intent(inout) :: tau_x(grid%nx_total+1,grid%ny_total)

x-face stress (nx_total+1, ny_total).

real(kind=wp), intent(inout) :: tau_y(grid%nx_total,grid%ny_total+1)

y-face stress (nx_total, ny_total+1).

logical, intent(in), optional :: device_resident

px > 1 only: .false. for host-side calls.

public subroutine ocean_fold_wrap_time_means(grid, bc, ms)

Fold the pred_corr step time-means u_av (u, −), v_av (v, −, + fold-row projection) and h_av (T) — the stage-entry site that mirrors the prognostic fold for the Coriolis / viscosity inputs. Call after their periodic wrap. No-op when not folding or when the means are not allocated (ssp_rk2). Device-only: unlike the other dispatchers it takes no device_resident flag, because its production caller (run_stage_split) always runs on the mapped state.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
type(multilayer_state_t), intent(inout) :: ms

public subroutine ocean_fold_wrap_visc_rem(grid, bc, visc_rem_u, visc_rem_v, device_resident)

Fold the viscous-remnant pair: visc_rem_u (u-face) and visc_rem_v (v-face) — PR-1’s bt_work%visc_rem_u/v seam. UNLIKE ocean_fold_wrap_stress (its vector twin, tau_x/tau_y), visc_rem is a POSITIVE SCALAR (the fraction of a barotropic acceleration a layer still feels after one implicit-friction step, MOM6 vertvisc_remnant), not a flux/velocity component, so both face kernels are called with negate=.false.: the 180-degree fold still swaps which side of the seam the ghost value comes from, but the value itself does not change sign, and the v-face fold-line duplicate DOF is forced EQUAL (not opposite) across the seam. Call after the pair’s halo exchange + periodic wrap (MOM6’s pass_visc_rem group pass, run after every one of the three vertvisc_remnant calls). No-op when not folding.

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_bc_state_t), intent(in) :: bc
real(kind=wp), intent(inout) :: visc_rem_u(:,:,:)

u-face per-layer remnant, shape (nx_total+1, ny_total, nz).

real(kind=wp), intent(inout) :: visc_rem_v(:,:,:)

v-face per-layer remnant, shape (nx_total, ny_total+1, nz).

logical, intent(in), optional :: device_resident

px > 1 only: .false. for host-side calls.