visc_rem_halo_refresh Subroutine

private subroutine visc_rem_halo_refresh(grid, bt_work, bc)

Exchange bt_work%visc_rem_u/v face halos right after production — MOM6’s pass_visc_rem group pass, run after every one of the three vertvisc_remnant calls. MPI halo first, then the periodic wrap, then the tripolar fold — the same ordering contract every other seam fill in this module follows (ocean_halo_exchange_ml_state then ocean_periodic_wrap_state then ocean_fold_wrap_state). visc_rem is a POSITIVE SCALAR on a face (the viscous-remnant fraction), not a true-vector flux component, so the fold uses ocean_fold_wrap_visc_rem (copy across the seam), NOT ocean_fold_wrap_stress’s negate-on-fold vector contract. bc absent (e.g. a direct unit-test call with no boundary state) ⇒ periodic wrap + fold are skipped; the halo exchange itself is unconditional (no-op on 1 rank, D0).

Arguments

Type IntentOptional Attributes Name
type(hgrid_t), intent(in) :: grid
type(barotropic_workstate_t), intent(inout) :: bt_work
type(ocean_bc_state_t), intent(in), optional :: bc

Calls

proc~~visc_rem_halo_refresh~~CallsGraph proc~visc_rem_halo_refresh visc_rem_halo_refresh interface~ocean_halo_face_x ocean_halo_face_x proc~visc_rem_halo_refresh->interface~ocean_halo_face_x interface~ocean_halo_face_y ocean_halo_face_y proc~visc_rem_halo_refresh->interface~ocean_halo_face_y proc~ocean_fold_wrap_visc_rem ocean_fold_wrap_visc_rem proc~visc_rem_halo_refresh->proc~ocean_fold_wrap_visc_rem proc~ocean_halo_is_decomposed_x ocean_halo_is_decomposed_x proc~visc_rem_halo_refresh->proc~ocean_halo_is_decomposed_x proc~ocean_halo_is_decomposed_y ocean_halo_is_decomposed_y proc~visc_rem_halo_refresh->proc~ocean_halo_is_decomposed_y proc~ocean_periodic_wrap_face_x_3d ocean_periodic_wrap_face_x_3d proc~visc_rem_halo_refresh->proc~ocean_periodic_wrap_face_x_3d proc~ocean_periodic_wrap_face_y_3d ocean_periodic_wrap_face_y_3d proc~visc_rem_halo_refresh->proc~ocean_periodic_wrap_face_y_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 interface~fold_north_u_face fold_north_u_face proc~ocean_fold_wrap_visc_rem->interface~fold_north_u_face interface~fold_north_v_face fold_north_v_face proc~ocean_fold_wrap_visc_rem->interface~fold_north_v_face interface~ocean_fold_pack ocean_fold_pack proc~ocean_fold_wrap_visc_rem->interface~ocean_fold_pack interface~ocean_fold_unpack ocean_fold_unpack proc~ocean_fold_wrap_visc_rem->interface~ocean_fold_unpack proc~ocean_fold_begin ocean_fold_begin proc~ocean_fold_wrap_visc_rem->proc~ocean_fold_begin proc~ocean_fold_end ocean_fold_end proc~ocean_fold_wrap_visc_rem->proc~ocean_fold_end proc~ocean_fold_exchange ocean_fold_exchange proc~ocean_fold_wrap_visc_rem->proc~ocean_fold_exchange proc~ocean_fold_is_distributed ocean_fold_is_distributed proc~ocean_fold_wrap_visc_rem->proc~ocean_fold_is_distributed 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~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~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_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~ew_rank_east ew_rank_east proc~ocean_halo_face_x_3d->proc~ew_rank_east proc~ew_rank_west ew_rank_west proc~ocean_halo_face_x_3d->proc~ew_rank_west proc~needs_flags needs_flags proc~ocean_halo_face_x_3d->proc~needs_flags proc~ns_rank_north ns_rank_north proc~ocean_halo_face_x_3d->proc~ns_rank_north proc~ns_rank_south ns_rank_south proc~ocean_halo_face_x_3d->proc~ns_rank_south proc~ocean_halo_buffers_ensure_nz ocean_halo_buffers_ensure_nz proc~ocean_halo_face_x_3d->proc~ocean_halo_buffers_ensure_nz proc~oh_count_face_x_3d oh_count_face_x_3d proc~ocean_halo_face_x_3d->proc~oh_count_face_x_3d proc~oh_count_msgs oh_count_msgs proc~ocean_halo_face_x_3d->proc~oh_count_msgs proc~ocean_halo_face_x_3d->waitall 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~oh_count_face_y_3d oh_count_face_y_3d proc~ocean_halo_face_y_3d->proc~oh_count_face_y_3d proc~ocean_halo_face_y_3d->proc~oh_count_msgs proc~ocean_halo_face_y_3d->waitall 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 local local proc~fold_north_v_face_2d->local proc~fold_north_v_face_3d->local 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~fold_stagger_nrows fold_stagger_nrows 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_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

Called by

proc~~visc_rem_halo_refresh~~CalledByGraph proc~visc_rem_halo_refresh visc_rem_halo_refresh proc~visc_rem_precompute visc_rem_precompute proc~visc_rem_precompute->proc~visc_rem_halo_refresh proc~vmix_apply_in_stage vmix_apply_in_stage proc~vmix_apply_in_stage->proc~visc_rem_halo_refresh proc~vmix_apply_in_stage->proc~visc_rem_precompute proc~run_stage run_stage proc~run_stage->proc~vmix_apply_in_stage proc~run_stage_split run_stage_split proc~run_stage_split->proc~visc_rem_precompute proc~run_stage_split->proc~vmix_apply_in_stage proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~run_stage 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 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

Variables

Type Visibility Attributes Name Initial
integer, private :: nz

Source Code

   subroutine visc_rem_halo_refresh(grid, bt_work, bc)
      !! Exchange `bt_work%visc_rem_u/v` face halos right after
      !! production — MOM6's `pass_visc_rem` group pass, run after
      !! every one of the three `vertvisc_remnant` calls.  MPI
      !! halo first, then the periodic wrap, then the tripolar fold —
      !! the same ordering contract every other seam fill in this module
      !! follows (`ocean_halo_exchange_ml_state` then
      !! `ocean_periodic_wrap_state` then `ocean_fold_wrap_state`).
      !! `visc_rem` is a POSITIVE SCALAR on a face (the viscous-remnant
      !! fraction), not a true-vector flux component, so the fold uses
      !! `ocean_fold_wrap_visc_rem` (copy across the seam), NOT
      !! `ocean_fold_wrap_stress`'s negate-on-fold vector contract.
      !! `bc` absent (e.g. a direct unit-test call with no boundary
      !! state) ⇒ periodic wrap + fold are skipped; the halo exchange
      !! itself is unconditional (no-op on 1 rank, D0).
      type(hgrid_t), intent(in) :: grid
      type(barotropic_workstate_t), intent(inout) :: bt_work
      type(ocean_bc_state_t), intent(in), optional :: bc

      integer :: nz

      nz = size(bt_work%visc_rem_u, 3)

      ! GATED on an actually-decomposed axis (mirrors the `u_av_layer`/
      ! `v_av_layer` seam fill in `run_stage_split`): the halo specifics
      ! take EXPLICIT-SHAPE dummies sized from the comm module's own
      ! `oh_nx_total`/`oh_ny_total`, which a direct unit-test call that
      ! never runs `ocean_halo_init` leaves at 0 — a mis-shaped device
      ! dummy, not a benign no-op, on the GPU build.
      if (ocean_halo_is_decomposed_x() .or. ocean_halo_is_decomposed_y()) then
         call ocean_halo_face_x(bt_work%visc_rem_u, nz)
         call ocean_halo_face_y(bt_work%visc_rem_v, nz)
      end if
      if (.not. present(bc)) return
      if (bc%periodic_x .or. bc%periodic_y) then
         call ocean_periodic_wrap_face_x_3d( &
            bt_work%visc_rem_u, size(bt_work%visc_rem_u, 1), size(bt_work%visc_rem_u, 2), &
            nz, grid%nx_phys, grid%ny_phys, grid%nghost, &
            bc%periodic_x .and. .not. ocean_halo_is_decomposed_x(), &
            bc%periodic_y .and. .not. ocean_halo_is_decomposed_y())
         call ocean_periodic_wrap_face_y_3d( &
            bt_work%visc_rem_v, size(bt_work%visc_rem_v, 1), size(bt_work%visc_rem_v, 2), &
            nz, grid%nx_phys, grid%ny_phys, grid%nghost, &
            bc%periodic_x .and. .not. ocean_halo_is_decomposed_x(), &
            bc%periodic_y .and. .not. ocean_halo_is_decomposed_y())
      end if
      ! Tripolar north-fold seam — periodic-FIRST-fold-SECOND, as above.
      if (bc%north_fold) call ocean_fold_wrap_visc_rem(grid, bc, bt_work%visc_rem_u, bt_work%visc_rem_v)
   end subroutine visc_rem_halo_refresh