run_continuity_chain Subroutine

private subroutine run_continuity_chain(grid, metrics, dyn, ct, hd, va, redi, varmix, ms, dt, therm_dt, therm_active, is_lagrangian, h_min_floor, mass_out_weight, h_only, stage_id, step_id, bc, mle)

The slow horizontal continuity + tracer chain (ghost fills → constrained continuity+tracer split → reservoirs → halo/wrap → tracer hdiff → Redi → vertical advection), extracted verbatim from run_stage_split so the pred_corr path can run it AFTER the velocity update + implicit friction (the forward-backward pairing, SPEC §2 C8/§1 fact 5) while the historical ssp_rk2 path keeps it before the applies (bit-identical). h_only selects the predictor’s TR_MODE_NONE (SPEC §2 P9); mass_out_weight is the per-call budget weight (0.5 per SSP stage; 0 for the discarded predictor state, 1 for the corrector).

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(ocean_metrics_t), intent(in) :: metrics
type(ocean_dyn_t), intent(inout) :: dyn
type(continuity_t), intent(inout) :: ct
type(ocean_hdiff_tracer_t), intent(inout) :: hd
type(ocean_vertical_advection_t), intent(inout) :: va
type(ocean_redi_t), intent(inout), optional :: redi
type(ocean_varmix_t), intent(inout), optional :: varmix
type(multilayer_state_t), intent(inout) :: ms
real(kind=wp), intent(in) :: dt
real(kind=wp), intent(in) :: therm_dt
logical, intent(in) :: therm_active
logical, intent(in) :: is_lagrangian
real(kind=wp), intent(in) :: h_min_floor
real(kind=wp), intent(in) :: mass_out_weight
logical, intent(in) :: h_only
integer, intent(in) :: stage_id
integer, intent(in) :: step_id
type(ocean_bc_state_t), intent(inout), optional :: bc
type(ocean_mle_t), intent(inout), optional :: mle

Calls

proc~~run_continuity_chain~~CallsGraph proc~run_continuity_chain run_continuity_chain interface~ocean_halo_centre ocean_halo_centre proc~run_continuity_chain->interface~ocean_halo_centre proc~check_h_positive_or_die check_h_positive_or_die proc~run_continuity_chain->proc~check_h_positive_or_die proc~compute_w_from_continuity compute_w_from_continuity proc~run_continuity_chain->proc~compute_w_from_continuity proc~continuity_tracer_step_split continuity_tracer_step_split proc~run_continuity_chain->proc~continuity_tracer_step_split proc~copy_field_3d copy_field_3d proc~run_continuity_chain->proc~copy_field_3d proc~ocean_accumulate_mass_out ocean_accumulate_mass_out proc~run_continuity_chain->proc~ocean_accumulate_mass_out proc~ocean_apply_conservative_min_thickness ocean_apply_conservative_min_thickness proc~run_continuity_chain->proc~ocean_apply_conservative_min_thickness proc~ocean_dyn_is_thermo_step ocean_dyn_t%ocean_dyn_is_thermo_step proc~run_continuity_chain->proc~ocean_dyn_is_thermo_step proc~ocean_fold_wrap_state ocean_fold_wrap_state proc~run_continuity_chain->proc~ocean_fold_wrap_state proc~ocean_halo_exchange_ml_state ocean_halo_exchange_ml_state proc~run_continuity_chain->proc~ocean_halo_exchange_ml_state proc~ocean_halo_is_decomposed_x ocean_halo_is_decomposed_x proc~run_continuity_chain->proc~ocean_halo_is_decomposed_x proc~ocean_halo_is_decomposed_y ocean_halo_is_decomposed_y proc~run_continuity_chain->proc~ocean_halo_is_decomposed_y proc~ocean_obc_any_open_edge ocean_obc_any_open_edge proc~run_continuity_chain->proc~ocean_obc_any_open_edge proc~ocean_obc_fill_ghosts ocean_obc_fill_ghosts proc~run_continuity_chain->proc~ocean_obc_fill_ghosts proc~ocean_obc_update_reservoirs ocean_obc_update_reservoirs proc~run_continuity_chain->proc~ocean_obc_update_reservoirs proc~ocean_periodic_wrap_state ocean_periodic_wrap_state proc~run_continuity_chain->proc~ocean_periodic_wrap_state proc~probe_ds probe_dS proc~run_continuity_chain->proc~probe_ds proc~profiler_start profiler_start proc~run_continuity_chain->proc~profiler_start proc~profiler_stop profiler_stop proc~run_continuity_chain->proc~profiler_stop proc~redi_apply_flux redi_apply_flux proc~run_continuity_chain->proc~redi_apply_flux proc~refresh_tracer_ghosts refresh_tracer_ghosts proc~run_continuity_chain->proc~refresh_tracer_ghosts proc~rk2_average_field_3d rk2_average_field_3d proc~run_continuity_chain->proc~rk2_average_field_3d proc~tracer_advect_vertical tracer_advect_vertical proc~run_continuity_chain->proc~tracer_advect_vertical proc~tracer_hdiff tracer_hdiff proc~run_continuity_chain->proc~tracer_hdiff proc~ocean_halo_centre_2d ocean_halo_centre_2d interface~ocean_halo_centre->proc~ocean_halo_centre_2d proc~ocean_halo_centre_3d ocean_halo_centre_3d interface~ocean_halo_centre->proc~ocean_halo_centre_3d proc~continuity_tracer_step_split->interface~ocean_halo_centre proc~continuity_tracer_step_split->proc~ocean_halo_is_decomposed_x proc~continuity_tracer_step_split->proc~ocean_halo_is_decomposed_y proc~continuity_tracer_step_split->proc~profiler_start proc~continuity_tracer_step_split->proc~profiler_stop interface~ocean_fold_north_v_face ocean_fold_north_v_face proc~continuity_tracer_step_split->interface~ocean_fold_north_v_face proc~accumulate_flux_x accumulate_flux_x proc~continuity_tracer_step_split->proc~accumulate_flux_x proc~accumulate_flux_y accumulate_flux_y proc~continuity_tracer_step_split->proc~accumulate_flux_y proc~continuity_apply_meridional continuity_apply_meridional proc~continuity_tracer_step_split->proc~continuity_apply_meridional proc~continuity_apply_zonal continuity_apply_zonal proc~continuity_tracer_step_split->proc~continuity_apply_zonal proc~continuity_meridional_flux continuity_meridional_flux proc~continuity_tracer_step_split->proc~continuity_meridional_flux proc~continuity_zonal_flux continuity_zonal_flux proc~continuity_tracer_step_split->proc~continuity_zonal_flux proc~drain_copy_3d drain_copy_3d proc~continuity_tracer_step_split->proc~drain_copy_3d proc~drain_rescale_htr drain_rescale_hTr proc~continuity_tracer_step_split->proc~drain_rescale_htr proc~drain_rescale_htr_budget drain_rescale_hTr_budget proc~continuity_tracer_step_split->proc~drain_rescale_htr_budget proc~mle_fold_x mle_fold_x proc~continuity_tracer_step_split->proc~mle_fold_x proc~mle_fold_y mle_fold_y proc~continuity_tracer_step_split->proc~mle_fold_y proc~ocean_bc_outer_face_tag ocean_bc_outer_face_tag proc~continuity_tracer_step_split->proc~ocean_bc_outer_face_tag proc~ocean_fold_wrap_centre_3d_state ocean_fold_wrap_centre_3d_state proc~continuity_tracer_step_split->proc~ocean_fold_wrap_centre_3d_state proc~ocean_periodic_wrap_centre_3d ocean_periodic_wrap_centre_3d proc~continuity_tracer_step_split->proc~ocean_periodic_wrap_centre_3d proc~pd_limit_meridional_impl pd_limit_meridional_impl proc~continuity_tracer_step_split->proc~pd_limit_meridional_impl proc~pd_limit_zonal_impl pd_limit_zonal_impl proc~continuity_tracer_step_split->proc~pd_limit_zonal_impl proc~tracer_advect_meridional tracer_advect_meridional proc~continuity_tracer_step_split->proc~tracer_advect_meridional proc~tracer_advect_zonal tracer_advect_zonal proc~continuity_tracer_step_split->proc~tracer_advect_zonal proc~efp_carry efp_carry proc~ocean_accumulate_mass_out->proc~efp_carry proc~efp_decompose_impl efp_decompose_impl proc~ocean_accumulate_mass_out->proc~efp_decompose_impl proc~assign_h_layer assign_h_layer proc~ocean_apply_conservative_min_thickness->proc~assign_h_layer proc~build_grounded_mask build_grounded_mask proc~ocean_apply_conservative_min_thickness->proc~build_grounded_mask proc~build_target_field build_target_field proc~ocean_apply_conservative_min_thickness->proc~build_target_field proc~remap_tracer_grounded remap_tracer_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_tracer_grounded proc~remap_x_face_grounded remap_x_face_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_x_face_grounded proc~remap_y_face_grounded remap_y_face_grounded proc~ocean_apply_conservative_min_thickness->proc~remap_y_face_grounded interface~fold_north_centre fold_north_centre proc~ocean_fold_wrap_state->interface~fold_north_centre interface~fold_north_u_face fold_north_u_face proc~ocean_fold_wrap_state->interface~fold_north_u_face interface~fold_north_v_face fold_north_v_face proc~ocean_fold_wrap_state->interface~fold_north_v_face interface~ocean_fold_pack ocean_fold_pack proc~ocean_fold_wrap_state->interface~ocean_fold_pack interface~ocean_fold_unpack ocean_fold_unpack proc~ocean_fold_wrap_state->interface~ocean_fold_unpack proc~n_tracers n_tracers proc~ocean_fold_wrap_state->proc~n_tracers proc~ocean_fold_begin ocean_fold_begin proc~ocean_fold_wrap_state->proc~ocean_fold_begin proc~ocean_fold_end ocean_fold_end proc~ocean_fold_wrap_state->proc~ocean_fold_end proc~ocean_fold_exchange ocean_fold_exchange proc~ocean_fold_wrap_state->proc~ocean_fold_exchange proc~ocean_fold_is_distributed ocean_fold_is_distributed proc~ocean_fold_wrap_state->proc~ocean_fold_is_distributed proc~ocean_halo_exchange_ml_state->interface~ocean_halo_centre proc~ocean_halo_exchange_ml_state->proc~profiler_start proc~ocean_halo_exchange_ml_state->proc~profiler_stop interface~ocean_halo_face_x ocean_halo_face_x proc~ocean_halo_exchange_ml_state->interface~ocean_halo_face_x interface~ocean_halo_face_y ocean_halo_face_y proc~ocean_halo_exchange_ml_state->interface~ocean_halo_face_y proc~oh_count_ml_state oh_count_ml_state proc~ocean_halo_exchange_ml_state->proc~oh_count_ml_state proc~oh_count_suppress_off oh_count_suppress_off proc~ocean_halo_exchange_ml_state->proc~oh_count_suppress_off proc~oh_count_suppress_on oh_count_suppress_on proc~ocean_halo_exchange_ml_state->proc~oh_count_suppress_on proc~is_open_ish is_open_ish proc~ocean_obc_any_open_edge->proc~is_open_ish proc~fill_ghost_east_res fill_ghost_east_res proc~ocean_obc_fill_ghosts->proc~fill_ghost_east_res proc~fill_ghost_east_sign fill_ghost_east_sign proc~ocean_obc_fill_ghosts->proc~fill_ghost_east_sign proc~fill_ghost_north_res fill_ghost_north_res proc~ocean_obc_fill_ghosts->proc~fill_ghost_north_res proc~fill_ghost_north_sign fill_ghost_north_sign proc~ocean_obc_fill_ghosts->proc~fill_ghost_north_sign proc~fill_ghost_south_res fill_ghost_south_res proc~ocean_obc_fill_ghosts->proc~fill_ghost_south_res proc~fill_ghost_south_sign fill_ghost_south_sign proc~ocean_obc_fill_ghosts->proc~fill_ghost_south_sign proc~fill_ghost_west_res fill_ghost_west_res proc~ocean_obc_fill_ghosts->proc~fill_ghost_west_res proc~fill_ghost_west_sign fill_ghost_west_sign proc~ocean_obc_fill_ghosts->proc~fill_ghost_west_sign proc~fill_h_layer_ghosts fill_h_layer_ghosts proc~ocean_obc_fill_ghosts->proc~fill_h_layer_ghosts proc~fill_tracer_ghosts_zerograd fill_tracer_ghosts_zerograd proc~ocean_obc_fill_ghosts->proc~fill_tracer_ghosts_zerograd proc~get_clamped_tracer get_clamped_tracer proc~ocean_obc_fill_ghosts->proc~get_clamped_tracer proc~ocean_obc_fill_ghosts->proc~is_open_ish proc~ocean_obc_update_reservoirs->proc~get_clamped_tracer proc~update_reservoir_meridional_north update_reservoir_meridional_north proc~ocean_obc_update_reservoirs->proc~update_reservoir_meridional_north proc~update_reservoir_meridional_south update_reservoir_meridional_south proc~ocean_obc_update_reservoirs->proc~update_reservoir_meridional_south proc~update_reservoir_zonal_east update_reservoir_zonal_east proc~ocean_obc_update_reservoirs->proc~update_reservoir_zonal_east proc~update_reservoir_zonal_west update_reservoir_zonal_west proc~ocean_obc_update_reservoirs->proc~update_reservoir_zonal_west proc~ocean_periodic_wrap_state->proc~ocean_periodic_wrap_centre_3d proc~ocean_periodic_wrap_face_x_3d ocean_periodic_wrap_face_x_3d proc~ocean_periodic_wrap_state->proc~ocean_periodic_wrap_face_x_3d proc~ocean_periodic_wrap_face_y_3d ocean_periodic_wrap_face_y_3d proc~ocean_periodic_wrap_state->proc~ocean_periodic_wrap_face_y_3d proc~find_or_create_region find_or_create_region proc~profiler_start->proc~find_or_create_region proc~get_wall_time get_wall_time proc~profiler_start->proc~get_wall_time proc~nvtx_range_push nvtx_range_push proc~profiler_start->proc~nvtx_range_push proc~profiler_stop->proc~get_wall_time proc~nvtx_range_pop nvtx_range_pop proc~profiler_stop->proc~nvtx_range_pop proc~redi_apply_flux->proc~ocean_bc_outer_face_tag proc~redi_apply_flux_impl redi_apply_flux_impl proc~redi_apply_flux->proc~redi_apply_flux_impl proc~redi_budget_accumulate redi_budget_accumulate proc~redi_apply_flux->proc~redi_budget_accumulate proc~redi_face_const redi_face_const proc~redi_apply_flux->proc~redi_face_const proc~redi_face_copy redi_face_copy proc~redi_apply_flux->proc~redi_face_copy proc~redi_snapshot redi_snapshot proc~redi_apply_flux->proc~redi_snapshot proc~refresh_tracer_ghosts->interface~ocean_halo_centre proc~refresh_tracer_ghosts->proc~profiler_start proc~refresh_tracer_ghosts->proc~profiler_stop proc~refresh_tracer_ghosts->proc~ocean_fold_wrap_centre_3d_state proc~apply_w_to_h_layer apply_w_to_h_layer proc~tracer_advect_vertical->proc~apply_w_to_h_layer proc~tracer_advect_vertical_one_impl tracer_advect_vertical_one_impl proc~tracer_advect_vertical->proc~tracer_advect_vertical_one_impl proc~tracer_hdiff->proc~ocean_bc_outer_face_tag proc~tracer_hdiff_one_impl tracer_hdiff_one_impl proc~tracer_hdiff->proc~tracer_hdiff_one_impl 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 proc~fold_north_u_face_2d fold_north_u_face_2d interface~fold_north_u_face->proc~fold_north_u_face_2d proc~fold_north_u_face_3d fold_north_u_face_3d interface~fold_north_u_face->proc~fold_north_u_face_3d proc~fold_north_v_face_2d fold_north_v_face_2d interface~fold_north_v_face->proc~fold_north_v_face_2d proc~fold_north_v_face_3d fold_north_v_face_3d interface~fold_north_v_face->proc~fold_north_v_face_3d proc~fold_v_2d fold_v_2d interface~ocean_fold_north_v_face->proc~fold_v_2d proc~fold_v_3d fold_v_3d interface~ocean_fold_north_v_face->proc~fold_v_3d proc~ocean_fold_pack_2d ocean_fold_pack_2d interface~ocean_fold_pack->proc~ocean_fold_pack_2d proc~ocean_fold_pack_3d ocean_fold_pack_3d interface~ocean_fold_pack->proc~ocean_fold_pack_3d proc~ocean_fold_unpack_2d ocean_fold_unpack_2d interface~ocean_fold_unpack->proc~ocean_fold_unpack_2d proc~ocean_fold_unpack_3d ocean_fold_unpack_3d interface~ocean_fold_unpack->proc~ocean_fold_unpack_3d proc~ocean_halo_face_x_2d ocean_halo_face_x_2d interface~ocean_halo_face_x->proc~ocean_halo_face_x_2d proc~ocean_halo_face_x_3d ocean_halo_face_x_3d interface~ocean_halo_face_x->proc~ocean_halo_face_x_3d proc~ocean_halo_face_y_2d ocean_halo_face_y_2d interface~ocean_halo_face_y->proc~ocean_halo_face_y_2d proc~ocean_halo_face_y_3d ocean_halo_face_y_3d interface~ocean_halo_face_y->proc~ocean_halo_face_y_3d local local proc~build_grounded_mask->local reduce reduce proc~build_grounded_mask->reduce proc~build_target_field->local proc~min_thickness_target_column min_thickness_target_column proc~build_target_field->proc~min_thickness_target_column proc~continuity_meridional_flux->proc~ocean_bc_outer_face_tag proc~continuity_meridional_flux->local proc~ppm_cell_limiter ppm_cell_limiter proc~continuity_meridional_flux->proc~ppm_cell_limiter proc~ppm_limit_pos ppm_limit_pos proc~continuity_meridional_flux->proc~ppm_limit_pos proc~ppm_limited_slope ppm_limited_slope proc~continuity_meridional_flux->proc~ppm_limited_slope proc~ppm_mirror_h ppm_mirror_h proc~continuity_meridional_flux->proc~ppm_mirror_h proc~renormalise_meridional_flux_to_vhbt renormalise_meridional_flux_to_vhbt proc~continuity_meridional_flux->proc~renormalise_meridional_flux_to_vhbt proc~volcfl_face volcfl_face proc~continuity_meridional_flux->proc~volcfl_face proc~continuity_zonal_flux->proc~ocean_bc_outer_face_tag proc~continuity_zonal_flux->local proc~continuity_zonal_flux->proc~ppm_cell_limiter proc~continuity_zonal_flux->proc~ppm_limit_pos proc~continuity_zonal_flux->proc~ppm_limited_slope proc~continuity_zonal_flux->proc~ppm_mirror_h proc~renormalise_zonal_flux_to_uhbt renormalise_zonal_flux_to_uhbt proc~continuity_zonal_flux->proc~renormalise_zonal_flux_to_uhbt proc~continuity_zonal_flux->proc~volcfl_face proc~drain_rescale_htr_budget->local proc~fill_ghost_east_res->local proc~fill_ghost_east_sign->local proc~fill_ghost_north_res->local proc~fill_ghost_north_sign->local proc~fill_ghost_south_res->local proc~fill_ghost_south_sign->local proc~fill_ghost_west_res->local proc~fill_ghost_west_sign->local proc~fill_h_layer_ghosts->proc~is_open_ish proc~fill_tracer_ghosts_zerograd->proc~is_open_ish proc~grow_buffers grow_buffers proc~ocean_fold_begin->proc~grow_buffers to_string to_string proc~ocean_fold_begin->to_string warning warning proc~ocean_fold_begin->warning comm_irecv_real_sp_array_n comm_irecv_real_sp_array_n proc~ocean_fold_exchange->comm_irecv_real_sp_array_n comm_isend_real_sp_array_n comm_isend_real_sp_array_n proc~ocean_fold_exchange->comm_isend_real_sp_array_n proc~comm_env_compute_comm comm_env_compute_comm proc~ocean_fold_exchange->proc~comm_env_compute_comm waitall waitall proc~ocean_fold_exchange->waitall proc~ocean_fold_wrap_centre_3d_state->interface~fold_north_centre proc~ocean_fold_wrap_centre_3d_state->interface~ocean_fold_pack proc~ocean_fold_wrap_centre_3d_state->interface~ocean_fold_unpack proc~ocean_fold_wrap_centre_3d_state->proc~n_tracers proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_begin proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_end proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_exchange proc~ocean_fold_wrap_centre_3d_state->proc~ocean_fold_is_distributed proc~ocean_halo_centre_2d_impl ocean_halo_centre_2d_impl proc~ocean_halo_centre_2d->proc~ocean_halo_centre_2d_impl proc~oh_count_centre_2d oh_count_centre_2d proc~ocean_halo_centre_2d->proc~oh_count_centre_2d proc~ocean_halo_centre_3d->proc~ocean_periodic_wrap_centre_3d proc~ocean_halo_centre_3d->comm_irecv_real_sp_array_n proc~ocean_halo_centre_3d->comm_isend_real_sp_array_n proc~ocean_halo_centre_3d->proc~comm_env_compute_comm proc~ew_rank_east ew_rank_east proc~ocean_halo_centre_3d->proc~ew_rank_east proc~ew_rank_west ew_rank_west proc~ocean_halo_centre_3d->proc~ew_rank_west proc~needs_flags needs_flags proc~ocean_halo_centre_3d->proc~needs_flags proc~ns_rank_north ns_rank_north proc~ocean_halo_centre_3d->proc~ns_rank_north proc~ns_rank_south ns_rank_south proc~ocean_halo_centre_3d->proc~ns_rank_south proc~ocean_halo_buffers_ensure_nz ocean_halo_buffers_ensure_nz proc~ocean_halo_centre_3d->proc~ocean_halo_buffers_ensure_nz proc~oh_count_centre_3d oh_count_centre_3d proc~ocean_halo_centre_3d->proc~oh_count_centre_3d proc~oh_count_msgs oh_count_msgs proc~ocean_halo_centre_3d->proc~oh_count_msgs proc~ocean_halo_centre_3d->waitall proc~pd_limit_meridional_impl->local proc~pd_limit_meridional_impl->reduce proc~pd_limit_zonal_impl->local proc~pd_limit_zonal_impl->reduce proc~redi_apply_flux_impl->local proc~redi_face_flux redi_face_flux proc~redi_apply_flux_impl->proc~redi_face_flux proc~remap_tracer_grounded->local proc~remap_column remap_column proc~remap_tracer_grounded->proc~remap_column proc~remap_x_face_grounded->local proc~remap_x_face_grounded->proc~remap_column proc~remap_y_face_grounded->local proc~remap_y_face_grounded->proc~remap_column proc~tracer_advect_meridional_one_impl tracer_advect_meridional_one_impl proc~tracer_advect_meridional->proc~tracer_advect_meridional_one_impl proc~tracer_advect_vertical_one_impl->local proc~tracer_advect_zonal_one_impl tracer_advect_zonal_one_impl proc~tracer_advect_zonal->proc~tracer_advect_zonal_one_impl proc~tracer_hdiff_one_impl->local proc~update_reservoir_meridional_north->local proc~update_reservoir_meridional_south->local proc~update_reservoir_zonal_east->local proc~update_reservoir_zonal_west->local comm_world comm_world proc~comm_env_compute_comm->comm_world proc~decomp_rank_from_coords decomp_rank_from_coords proc~ew_rank_east->proc~decomp_rank_from_coords proc~ew_rank_west->proc~decomp_rank_from_coords proc~fold_north_v_face_2d->local proc~fold_north_v_face_3d->local proc~fold_v_2d->interface~fold_north_v_face proc~fold_v_2d->interface~ocean_fold_pack proc~fold_v_2d->interface~ocean_fold_unpack proc~fold_v_2d->proc~ocean_fold_begin proc~fold_v_2d->proc~ocean_fold_end proc~fold_v_2d->proc~ocean_fold_exchange proc~fold_v_2d->proc~ocean_fold_is_distributed proc~fold_stagger_nrows fold_stagger_nrows proc~fold_v_2d->proc~fold_stagger_nrows proc~fold_v_3d->interface~fold_north_v_face proc~fold_v_3d->interface~ocean_fold_pack proc~fold_v_3d->interface~ocean_fold_unpack proc~fold_v_3d->proc~ocean_fold_begin proc~fold_v_3d->proc~ocean_fold_end proc~fold_v_3d->proc~ocean_fold_exchange proc~fold_v_3d->proc~ocean_fold_is_distributed proc~fold_v_3d->proc~fold_stagger_nrows proc~ns_rank_north->proc~decomp_rank_from_coords proc~ns_rank_south->proc~decomp_rank_from_coords proc~ocean_fold_pack_2d->proc~ocean_fold_pack_3d proc~fold_stagger_family fold_stagger_family proc~ocean_fold_pack_3d->proc~fold_stagger_family proc~ocean_fold_pack_3d->proc~fold_stagger_nrows proc~ocean_fold_unpack_2d->proc~ocean_fold_unpack_3d proc~ocean_fold_unpack_3d->proc~fold_stagger_family proc~ocean_fold_unpack_3d->proc~fold_stagger_nrows proc~ocean_halo_buffers_ensure_nz->to_string proc~ocean_halo_buffers_ensure_nz->warning proc~ocean_halo_centre_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_centre_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_centre_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_centre_2d_impl->proc~ew_rank_east proc~ocean_halo_centre_2d_impl->proc~ew_rank_west proc~ocean_halo_centre_2d_impl->proc~needs_flags proc~ocean_halo_centre_2d_impl->proc~ns_rank_north proc~ocean_halo_centre_2d_impl->proc~ns_rank_south proc~ocean_halo_centre_2d_impl->proc~oh_count_msgs proc~ocean_halo_centre_2d_impl->waitall proc~ocean_periodic_wrap_centre_2d ocean_periodic_wrap_centre_2d proc~ocean_halo_centre_2d_impl->proc~ocean_periodic_wrap_centre_2d proc~ocean_halo_face_x_2d_impl ocean_halo_face_x_2d_impl proc~ocean_halo_face_x_2d->proc~ocean_halo_face_x_2d_impl proc~oh_count_face_x_2d oh_count_face_x_2d proc~ocean_halo_face_x_2d->proc~oh_count_face_x_2d proc~ocean_halo_face_x_3d->proc~ocean_periodic_wrap_face_x_3d proc~ocean_halo_face_x_3d->comm_irecv_real_sp_array_n proc~ocean_halo_face_x_3d->comm_isend_real_sp_array_n proc~ocean_halo_face_x_3d->proc~comm_env_compute_comm proc~ocean_halo_face_x_3d->proc~ew_rank_east proc~ocean_halo_face_x_3d->proc~ew_rank_west proc~ocean_halo_face_x_3d->proc~needs_flags proc~ocean_halo_face_x_3d->proc~ns_rank_north proc~ocean_halo_face_x_3d->proc~ns_rank_south proc~ocean_halo_face_x_3d->proc~ocean_halo_buffers_ensure_nz proc~ocean_halo_face_x_3d->proc~oh_count_msgs proc~ocean_halo_face_x_3d->waitall proc~oh_count_face_x_3d oh_count_face_x_3d proc~ocean_halo_face_x_3d->proc~oh_count_face_x_3d proc~ocean_halo_face_y_2d_impl ocean_halo_face_y_2d_impl proc~ocean_halo_face_y_2d->proc~ocean_halo_face_y_2d_impl proc~oh_count_face_y_2d oh_count_face_y_2d proc~ocean_halo_face_y_2d->proc~oh_count_face_y_2d proc~ocean_halo_face_y_3d->proc~ocean_periodic_wrap_face_y_3d proc~ocean_halo_face_y_3d->comm_irecv_real_sp_array_n proc~ocean_halo_face_y_3d->comm_isend_real_sp_array_n proc~ocean_halo_face_y_3d->proc~comm_env_compute_comm proc~ocean_halo_face_y_3d->proc~ew_rank_east proc~ocean_halo_face_y_3d->proc~ew_rank_west proc~ocean_halo_face_y_3d->proc~needs_flags proc~ocean_halo_face_y_3d->proc~ns_rank_north proc~ocean_halo_face_y_3d->proc~ns_rank_south proc~ocean_halo_face_y_3d->proc~ocean_halo_buffers_ensure_nz proc~ocean_halo_face_y_3d->proc~oh_count_msgs proc~ocean_halo_face_y_3d->waitall proc~oh_count_face_y_3d oh_count_face_y_3d proc~ocean_halo_face_y_3d->proc~oh_count_face_y_3d proc~redi_sublayer_dt redi_sublayer_dT proc~redi_face_flux->proc~redi_sublayer_dt proc~redi_tracer_column redi_tracer_column proc~redi_face_flux->proc~redi_tracer_column rdb_vl_is_live rdb_vl_is_live proc~redi_face_flux->rdb_vl_is_live proc~remap_column_pcm remap_column_pcm proc~remap_column->proc~remap_column_pcm proc~remap_column_plm remap_column_plm proc~remap_column->proc~remap_column_plm proc~remap_column_ppm remap_column_ppm proc~remap_column->proc~remap_column_ppm proc~remap_column_ppm_h4 remap_column_ppm_h4 proc~remap_column->proc~remap_column_ppm_h4 proc~remap_column_pqm remap_column_pqm proc~remap_column->proc~remap_column_pqm proc~renormalise_meridional_flux_to_vhbt->local proc~renormalise_zonal_flux_to_uhbt->local proc~tracer_advect_meridional_one_impl->local proc~tracer_advect_meridional_one_impl->proc~ppm_cell_limiter proc~tracer_advect_meridional_one_impl->proc~ppm_limited_slope proc~tracer_advect_meridional_one_impl->proc~ppm_mirror_h proc~tracer_advect_zonal_one_impl->local proc~tracer_advect_zonal_one_impl->proc~ppm_cell_limiter proc~tracer_advect_zonal_one_impl->proc~ppm_limited_slope proc~tracer_advect_zonal_one_impl->proc~ppm_mirror_h proc~ocean_halo_face_x_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_face_x_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_face_x_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_face_x_2d_impl->proc~ew_rank_east proc~ocean_halo_face_x_2d_impl->proc~ew_rank_west proc~ocean_halo_face_x_2d_impl->proc~needs_flags proc~ocean_halo_face_x_2d_impl->proc~ns_rank_north proc~ocean_halo_face_x_2d_impl->proc~ns_rank_south proc~ocean_halo_face_x_2d_impl->proc~oh_count_msgs proc~ocean_halo_face_x_2d_impl->waitall proc~ocean_periodic_wrap_face_x_2d ocean_periodic_wrap_face_x_2d proc~ocean_halo_face_x_2d_impl->proc~ocean_periodic_wrap_face_x_2d proc~ocean_halo_face_y_2d_impl->comm_irecv_real_sp_array_n proc~ocean_halo_face_y_2d_impl->comm_isend_real_sp_array_n proc~ocean_halo_face_y_2d_impl->proc~comm_env_compute_comm proc~ocean_halo_face_y_2d_impl->proc~ew_rank_east proc~ocean_halo_face_y_2d_impl->proc~ew_rank_west proc~ocean_halo_face_y_2d_impl->proc~needs_flags proc~ocean_halo_face_y_2d_impl->proc~ns_rank_north proc~ocean_halo_face_y_2d_impl->proc~ns_rank_south proc~ocean_halo_face_y_2d_impl->proc~oh_count_msgs proc~ocean_halo_face_y_2d_impl->waitall proc~ocean_periodic_wrap_face_y_2d ocean_periodic_wrap_face_y_2d proc~ocean_halo_face_y_2d_impl->proc~ocean_periodic_wrap_face_y_2d proc~redi_ppm_ave redi_ppm_ave proc~redi_sublayer_dt->proc~redi_ppm_ave proc~redi_signum1 redi_signum1 proc~redi_sublayer_dt->proc~redi_signum1 proc~redi_interface_scalar redi_interface_scalar proc~redi_tracer_column->proc~redi_interface_scalar proc~redi_tracer_column->proc~redi_signum1 rdb_vl_column_conc rdb_vl_column_conc proc~redi_tracer_column->rdb_vl_column_conc proc~boundary_half_jump boundary_half_jump proc~remap_column_plm->proc~boundary_half_jump proc~plm_slope_nonuniform plm_slope_nonuniform proc~remap_column_plm->proc~plm_slope_nonuniform proc~remap_column_ppm->proc~remap_column_plm proc~remap_column_ppm->proc~boundary_half_jump proc~ppm_edge_nonuniform ppm_edge_nonuniform proc~remap_column_ppm->proc~ppm_edge_nonuniform proc~ppm_edge_two_cell ppm_edge_two_cell proc~remap_column_ppm->proc~ppm_edge_two_cell proc~ppm_jump_nonuniform ppm_jump_nonuniform proc~remap_column_ppm->proc~ppm_jump_nonuniform proc~remap_column_ppm_h4->proc~remap_column_plm proc~remap_column_ppm_h4->proc~boundary_half_jump proc~remap_column_pqm->proc~remap_column_ppm proc~remap_column_pqm->proc~boundary_half_jump proc~pqm_end_value_h4 pqm_end_value_h4 proc~remap_column_pqm->proc~pqm_end_value_h4 proc~pqm_solve_diag_dominant pqm_solve_diag_dominant proc~remap_column_pqm->proc~pqm_solve_diag_dominant

Called by

proc~~run_continuity_chain~~CalledByGraph proc~run_continuity_chain run_continuity_chain proc~run_stage_split run_stage_split proc~run_stage_split->proc~run_continuity_chain proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: h_min_pass
integer, private :: tr_mode

Source Code

   subroutine run_continuity_chain(grid, metrics, dyn, ct, hd, va, redi, varmix, ms, &
                                   dt, therm_dt, therm_active, is_lagrangian, &
                                   h_min_floor, mass_out_weight, h_only, &
                                   stage_id, step_id, bc, mle)
      !! The slow horizontal continuity + tracer chain (ghost fills →
      !! constrained continuity+tracer split → reservoirs → halo/wrap →
      !! tracer hdiff → Redi → vertical advection), extracted verbatim
      !! from `run_stage_split` so the pred_corr path can run it AFTER the
      !! velocity update + implicit friction (the forward-backward
      !! pairing, SPEC §2 C8/§1 fact 5) while the historical ssp_rk2
      !! path keeps it before the applies (bit-identical).
      !! `h_only` selects the predictor's TR_MODE_NONE (SPEC §2 P9);
      !! `mass_out_weight` is the per-call budget weight (0.5 per SSP
      !! stage; 0 for the discarded predictor state, 1 for the
      !! corrector).
      type(hgrid_t), intent(in) :: grid
      type(ocean_metrics_t), intent(in) :: metrics
      type(ocean_dyn_t), intent(inout) :: dyn
      type(continuity_t), intent(inout) :: ct
      type(ocean_hdiff_tracer_t), intent(inout) :: hd
      type(ocean_vertical_advection_t), intent(inout) :: va
      type(ocean_redi_t), intent(inout), optional :: redi
      type(ocean_varmix_t), intent(inout), optional :: varmix
      type(multilayer_state_t), intent(inout) :: ms
      real(wp), intent(in) :: dt, therm_dt
      logical, intent(in) :: therm_active, is_lagrangian
      real(wp), intent(in) :: h_min_floor, mass_out_weight
      logical, intent(in) :: h_only
      integer, intent(in) :: stage_id, step_id
      type(ocean_bc_state_t), intent(inout), optional :: bc
      type(ocean_mle_t), intent(inout), optional :: mle

      integer :: tr_mode
      real(wp) :: h_min_pass

      ! ---- 5. Ghost fills at open edges (before continuity PPM) ----
      ! Fill h_layer and tracer hTr ghost cells at any open-ish edge
      ! using zero-gradient (h) and upwind-aware (hTr) logic.
      ! This generalises the CLAMPED-only ghost fill inside
      ! rdb_continuity::tracer_advect_zonal/meridional to cover OPEN /
      ! TIDAL / CHAPMAN / NESTED as well.
      !
      ! Authority split (no conflict): on CLAMPED edges the old fill inside
      ! rdb_continuity runs LAST (once per Lie-split sub-flux, after h_layer
      ! has been updated mid-split) and is the authority — it unconditionally
      ! clamps the ghost to clamped_tracer*h, matching what the BT mode
      ! imposes.  This fill's CLAMPED writes here are simply overwritten by
      ! it.  On the open-class edges (OPEN/TIDAL/CHAPMAN/NESTED) the old fill
      ! is inert, so THIS fill's upwind-aware values survive and govern.
      ! No-op when bc is absent or all edges are WALL.
      if (present(bc)) then
         call ocean_obc_fill_ghosts(grid, bc, ms)
         ! The fill writes the open-edge ghost rows/columns over this tile's
         ! PHYSICAL span only; the corner cells beyond a seam (an MPI seam,
         ! OR the local wrap of a single-rank periodic axis) x an open-edge
         ! ghost row are someone else's fill, which only a refresh delivers,
         ! and the Lie-split advection's first pass reads them.  So refresh
         ! D0-unconditionally, NOT gated on ocean_halo_is_decomposed_x/y():
         ! the halo calls no-op on a single-rank non-periodic axis, re-wrap
         ! a single-rank periodic one and exchange when decomposed.
         ! Collective when decomposed (the gate is the GLOBAL tags).
         if (ocean_obc_any_open_edge(bc)) then
            call ocean_halo_centre(ms%h_layer, ms%nz_ml)
            call refresh_tracer_ghosts(grid, ms, bc=bc)
         end if
      end if

      ! ---- 5b. Slow horizontal continuity + tracer, constrained ----
      ! Pass `bt_uhbt, bt_vhbt` so the per-layer mass fluxes are
      ! renormalised to vertically sum to the barotropic-substep's transport.
      ! After apply_zonal + apply_meridional, `sum_k(h_layer)` equals
      ! `H_ref + bt_eta_end` to machine precision — no h rescale
      ! needed afterwards.  Tracer rides the same renormalised
      ! fluxes ⇒ per-column `T = hTr/h` stays exact.
      call profiler_start("ocean_continuity")
      ! `mle_fold_active = is_thermo_step()` gates the Fox-Kemper fold to
      ! the thermo cadence: the FK transports are computed once per thermo
      ! interval (mle_compute_transports, above), so folding them on the
      ! intervening non-thermo steps would re-apply stale transports.  At
      ! the default dt_therm_ratio = 1 this is .true. every step ⇒ bit-identical.
      !
      ! Phase 2 (6b) horizontal-tracer-advect cadence: ratio == 1 ⇒
      ! TR_MODE_ADVECT (fused every-step advect, bit-identical); ratio > 1
      ! ⇒ TR_MODE_ACCUMULATE (advance h + accumulate ½·flux·dt into
      ! ct%uhtr/vhtr per RK2 stage, hTr frozen).  The boundary drain runs
      ! once per window in ocean_dyn_step_split.
      if (h_only) then
         ! pred_corr PREDICTOR (SPEC §2 P9): continuity advances h (into the
         ! provisional hp, discarded after the stage) and produces u_av via
         ! u_cor, but must not touch tracers or the advect window.
         tr_mode = TR_MODE_NONE
      else if (dyn%dt_tracer_advect_ratio <= 1) then
         tr_mode = TR_MODE_ADVECT
      else
         tr_mode = TR_MODE_ACCUMULATE
      end if
      ! Conservative min-thickness mode: pass h_min=0 so continuity performs
      ! the RAW (non-injecting) h-update; the sub-floor layers are then repaired
      ! conservatively by ocean_apply_conservative_min_thickness below.  The
      ! legacy injecting floor stays the default (h_min=h_min_floor).
      h_min_pass = h_min_floor
      if (ct%conservative_floor) h_min_pass = 0.0_wp
      ! MOM6 time-mean fields (SPEC §2 C7/C9): stash h_in in h_av, average with
      ! h_out after continuity.  NOTE: under the present two-stage scheme this
      ! yields a PER-STAGE mean, not the per-step mean MOM6 forms; it becomes
      ! exact when S4 restructures the outer loop.  Nothing reads it until S3.
      call copy_field_3d(ms%h_layer, ms%h_av_layer, &
                         size(ms%h_layer, 1), size(ms%h_layer, 2), size(ms%h_layer, 3))
      ! SPEC S2b (`&ocean_bt_nml renorm_visc_rem`): forward `visc_rem_u/v`
      ! so the transport-matching inversion runs in the γ-weighted MOM6
      ! form (`u_cor = u + du·γ_k`, Jacobian `dy·h_marg·γ_k`) — a
      ! heavily-frictioned layer receives a smaller share of `du`.  Off ⇒
      ! the historical uniform-`du` renormaliser, bit-identical.
      if (dyn%bt_work%bt_renorm_visc_rem) then
         if (present(bc)) then
            call continuity_tracer_step_split(grid, metrics, ct, ms, dt, &
                                              uhbt=dyn%bt_work%bt_uhbt, &
                                              vhbt=dyn%bt_work%bt_vhbt, bc=bc, mle=mle, &
                                              mle_fold_active=dyn%is_thermo_step(), &
                                              tracer_mode=tr_mode, &
                                              h_min=h_min_pass, &
                                              visc_rem_u=dyn%bt_work%visc_rem_u, &
                                              visc_rem_v=dyn%bt_work%visc_rem_v, &
                                              u_cor=ms%u_av_layer, v_cor=ms%v_av_layer)
         else
            call continuity_tracer_step_split(grid, metrics, ct, ms, dt, &
                                              uhbt=dyn%bt_work%bt_uhbt, &
                                              vhbt=dyn%bt_work%bt_vhbt, mle=mle, &
                                              mle_fold_active=dyn%is_thermo_step(), &
                                              tracer_mode=tr_mode, &
                                              h_min=h_min_pass, &
                                              visc_rem_u=dyn%bt_work%visc_rem_u, &
                                              visc_rem_v=dyn%bt_work%visc_rem_v, &
                                              u_cor=ms%u_av_layer, v_cor=ms%v_av_layer)
         end if
      else if (present(bc)) then
         call continuity_tracer_step_split(grid, metrics, ct, ms, dt, &
                                           uhbt=dyn%bt_work%bt_uhbt, &
                                           vhbt=dyn%bt_work%bt_vhbt, bc=bc, mle=mle, &
                                           mle_fold_active=dyn%is_thermo_step(), &
                                           tracer_mode=tr_mode, &
                                           h_min=h_min_pass, &
                                           u_cor=ms%u_av_layer, v_cor=ms%v_av_layer)
      else
         call continuity_tracer_step_split(grid, metrics, ct, ms, dt, &
                                           uhbt=dyn%bt_work%bt_uhbt, &
                                           vhbt=dyn%bt_work%bt_vhbt, mle=mle, &
                                           mle_fold_active=dyn%is_thermo_step(), &
                                           tracer_mode=tr_mode, &
                                           h_min=h_min_pass, &
                                           u_cor=ms%u_av_layer, v_cor=ms%v_av_layer)
      end if
      ! MOM6 C9: h_av = 0.5*(h_in + h_out).
      call rk2_average_field_3d(ms%h_layer, ms%h_av_layer, &
                                size(ms%h_layer, 1), size(ms%h_layer, 2), size(ms%h_layer, 3))
      ! Conservative minimum-thickness borrow (isopycnal grounding stability).
      ! Only when the knob is on AND we have a positive floor (⇒ VCOORD_LAGRANGIAN
      ! by the setup fail-loud guard).  No-op on any ungrounded column ⇒ the
      ! isopycnal interface structure is untouched where all layers meet floor.
      ! NOT checked under `conservative_floor`: that mode deliberately passes
      ! `h_min = 0`, and the three clamp sites are gated on `h_min_use > 0`, so
      ! the h-update here is genuinely RAW — a transiently negative layer is
      ! legal and is repaired by the borrow below (which flags any
      ! `h < h_floor`, negatives included, and inflates it back). Checking here
      ! would abort on the first benign intermediate. With the injecting floor
      ! the clamp DOES hold, so a negative there is a real defect.
      if (dyn%check_h_positive) then
         call check_h_positive_or_die(grid, ms, "after continuity_tracer_step_split", &
                                      0, dyn%outer_step_count + 1, &
                                      check_layers=.not. ct%conservative_floor)
      end if
      if (ct%conservative_floor .and. h_min_floor > 0.0_wp) then
         call profiler_start("ocean_min_thickness")
         call ocean_apply_conservative_min_thickness(grid, ms, ct%mt_h_new%data, &
                                                     ct%mt_grounded%data, h_min_floor)
         call profiler_stop("ocean_min_thickness")
         if (dyn%check_h_positive) then
            call check_h_positive_or_die(grid, ms, "after conservative_min_thickness", &
                                         0, dyn%outer_step_count + 1, check_layers=.true.)
         end if
      end if
      ! Mass budget: flux_h_layer now holds the total horizontal divergence;
      ! accumulate the boundary outflux for this RK2 stage (weight 0.5).
      call ocean_accumulate_mass_out(ms, ms%flux_h_layer, metrics%areaT, &
                                     grid%nghost, dt, mass_out_weight)
      call profiler_stop("ocean_continuity")
      call probe_dS(grid, ms, "after continuity_tracer_split", stage_id, step_id)

      ! Reservoir update (§1, v2): evolve tres toward T_int / T_data using
      ! the stage's wall-face mass_flux_*_layer values.  Called while those
      ! arrays still hold this stage's fluxes (before any overwrite).
      ! No-op when res_lscale_out == 0 and res_lscale_in == 0 (default).
      if (present(bc)) call ocean_obc_update_reservoirs(grid, bc, ms, dt)

      ! Post-continuity periodic wrap (design §1.5): re-wrap h_layer and
      ! tracers after the Lie-split continuity step and before hdiff, so
      ! the horizontal diffusion kernel reads correct ghost-zone values.
      ! No-op when neither periodic axis is set.
      ! O2: unconditional multi-rank ghost exchange (D0 — no-op on 1 rank).
      call ocean_halo_exchange_ml_state(ms)
      if (present(bc)) call ocean_periodic_wrap_state(grid, bc, ms, &
                                                      skip_x=ocean_halo_is_decomposed_x(), skip_y=ocean_halo_is_decomposed_y())
      ! Tripolar north-fold after the post-continuity periodic wrap, so
      ! hdiff reads fold-consistent ghost values at the seam.
      if (present(bc)) call ocean_fold_wrap_state(grid, bc, ms)

      call profiler_start("ocean_tracer_hdiff")
      call tracer_hdiff(grid, metrics, hd, ms, therm_dt, active=therm_active, bc=bc)
      call profiler_stop("ocean_tracer_hdiff")
      call probe_dS(grid, ms, "after tracer_hdiff", stage_id, step_id)

      ! Redi neutral diffusion (capability [3]) — Phase B.  AUGMENTS the
      ! along-coordinate `tracer_hdiff` above with the rotated (along-
      ! isopycnal) flux, using the Phase-A coefficients built once this
      ! outer step.  THERMO cadence (self-gated inside on `therm_active`
      ! via the same `is_thermo_step` window the coeffs were built under).
      ! No-op when absent / disabled / khtr<=0.
      if (present(redi) .and. therm_active) then
         call profiler_start("ocean_redi")
         ! VarMix seam: feed Redi the spatially-varying KhTr when VarMix is
         ! enabled; otherwise Redi falls back to its scalar khtr.
         if (present(varmix)) then
            if (varmix%enable) then
               call redi_apply_flux(grid, metrics, redi, ms, therm_dt, &
                                    khtr_u_ext=varmix%khtr_u, khtr_v_ext=varmix%khtr_v, bc=bc)
            else
               call redi_apply_flux(grid, metrics, redi, ms, therm_dt, bc=bc)
            end if
         else
            call redi_apply_flux(grid, metrics, redi, ms, therm_dt, bc=bc)
         end if
         call profiler_stop("ocean_redi")
      end if
      ! ---- Vertical advection (Eulerian-z only) ----
      ! In Eulerian-z mode the vertical w-divergence cancels the
      ! horizontal flux divergence per layer, pinning `h_layer` to
      ! reference.  In Lagrangian mode (`vcoord` present and
      ! coord_type /= EULERIAN_Z) we skip this — h_layer is allowed
      ! to evolve under the MOM6-constrained horizontal continuity
      ! alone, and the ALE remap at end of outer step relayers
      ! conservatively onto `vcoord%target_h`.  Skipping here
      ! removes the surface F(nz+1) = 0 vs w(nz+1) ≠ 0 CWC
      ! inconsistency that seeds the salt-baroclinic instability
      ! under realistic β_S.
      if (.not. is_lagrangian) then
         call profiler_start("ocean_vertical_advect")
         call compute_w_from_continuity(grid, va, ms)
         call probe_dS(grid, ms, "after compute_w_from_cont", stage_id, step_id)
         call tracer_advect_vertical(grid, va, ms, therm_dt, active=therm_active)
         call probe_dS(grid, ms, "after tracer_advect_vertical", stage_id, step_id)
         call profiler_stop("ocean_vertical_advect")
      end if
   end subroutine run_continuity_chain