fold_north_v_face_2d Subroutine

private pure subroutine fold_north_v_face_2d(v, nx_total, ny_face, nx_phys, ny_phys, nghost, negate)

2D y-face (Cv) fold: north-halo fill + on-line antisymmetric projection at the fold row. Used for the barotropic bt_vbt field in the BT fast loop. negate (default .true., see the u-face twin) selects true-vector (sign flip + self-conjugate zero) vs. scalar (copy + self-conjugate left unchanged, matching fold_north_corner_2d’s scalar contract) — a scalar on a v-face (e.g. visc_rem_v) is the SAME physical attribute of the SAME face seen from both sides of the seam, so the duplicated DOF at the fold line must agree, not cancel.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: v(nx_total,ny_face)

y-face 2D field, shape (nx_total, ny_total+1).

integer, intent(in) :: nx_total
integer, intent(in) :: ny_face
integer, intent(in) :: nx_phys
integer, intent(in) :: ny_phys
integer, intent(in) :: nghost
logical, intent(in), optional :: negate

.true. (default) = true-vector component; .false. = scalar.


Calls

proc~~fold_north_v_face_2d~~CallsGraph proc~fold_north_v_face_2d fold_north_v_face_2d local local proc~fold_north_v_face_2d->local

Called by

proc~~fold_north_v_face_2d~~CalledByGraph proc~fold_north_v_face_2d fold_north_v_face_2d interface~fold_north_v_face fold_north_v_face interface~fold_north_v_face->proc~fold_north_v_face_2d proc~drain_wrap_face_y drain_wrap_face_y proc~drain_wrap_face_y->interface~fold_north_v_face proc~fold_v_2d fold_v_2d proc~fold_v_2d->interface~fold_north_v_face proc~fold_v_3d fold_v_3d proc~fold_v_3d->interface~fold_north_v_face proc~ocean_fold_wrap_state ocean_fold_wrap_state proc~ocean_fold_wrap_state->interface~fold_north_v_face proc~ocean_fold_wrap_stress ocean_fold_wrap_stress proc~ocean_fold_wrap_stress->interface~fold_north_v_face proc~ocean_fold_wrap_time_means ocean_fold_wrap_time_means proc~ocean_fold_wrap_time_means->interface~fold_north_v_face proc~ocean_fold_wrap_visc_rem ocean_fold_wrap_visc_rem proc~ocean_fold_wrap_visc_rem->interface~fold_north_v_face interface~ocean_fold_north_v_face ocean_fold_north_v_face interface~ocean_fold_north_v_face->proc~fold_v_2d interface~ocean_fold_north_v_face->proc~fold_v_3d proc~continuity_tracer_drain continuity_tracer_drain proc~continuity_tracer_drain->proc~drain_wrap_face_y proc~engine_setup engine_setup proc~engine_setup->proc~ocean_fold_wrap_state proc~configure_ocean_forcing configure_ocean_forcing proc~engine_setup->proc~configure_ocean_forcing proc~ocean_data_forcing_configure ocean_data_forcing_configure proc~engine_setup->proc~ocean_data_forcing_configure proc~ocean_seam_refresh_surface_stress ocean_seam_refresh_surface_stress proc~ocean_seam_refresh_surface_stress->proc~ocean_fold_wrap_stress proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->proc~ocean_fold_wrap_state proc~continuity_tracer_step_split continuity_tracer_step_split proc~run_continuity_chain->proc~continuity_tracer_step_split proc~run_gm_step run_gm_step proc~run_gm_step->proc~ocean_fold_wrap_state proc~continuity_gm_apply continuity_gm_apply proc~run_gm_step->proc~continuity_gm_apply proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_fold_wrap_state proc~run_stage_split->proc~ocean_fold_wrap_time_means proc~run_stage_split->proc~run_continuity_chain proc~visc_rem_precompute visc_rem_precompute proc~run_stage_split->proc~visc_rem_precompute proc~vmix_apply_in_stage vmix_apply_in_stage proc~run_stage_split->proc~vmix_apply_in_stage proc~visc_rem_halo_refresh visc_rem_halo_refresh proc~visc_rem_halo_refresh->proc~ocean_fold_wrap_visc_rem proc~barotropic_substep_nonlinear barotropic_substep_nonlinear proc~barotropic_substep_nonlinear->interface~ocean_fold_north_v_face proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~configure_ocean_forcing->proc~ocean_seam_refresh_surface_stress proc~continuity_gm_apply->interface~ocean_fold_north_v_face proc~continuity_tracer_step_split->interface~ocean_fold_north_v_face proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~ocean_dyn_flush_tracer_window ocean_dyn_flush_tracer_window proc~driver_run_ocean->proc~ocean_dyn_flush_tracer_window proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~ice_ocean_stress_flux ice_ocean_stress_flux proc~ice_ocean_stress_flux->proc~ocean_seam_refresh_surface_stress proc~ocean_data_forcing_apply ocean_data_forcing_apply proc~ocean_data_forcing_apply->proc~ocean_seam_refresh_surface_stress proc~ocean_data_forcing_configure->proc~ocean_seam_refresh_surface_stress proc~ocean_dyn_flush_tracer_window->proc~continuity_tracer_drain proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~continuity_tracer_drain proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~continuity_tracer_drain proc~ocean_dyn_step_split->proc~run_gm_step proc~ocean_dyn_step_split->proc~run_stage_split proc~visc_rem_precompute->proc~visc_rem_halo_refresh proc~vmix_apply_in_stage->proc~visc_rem_halo_refresh proc~vmix_apply_in_stage->proc~visc_rem_precompute proc~barotropic_substep_nonlinear_interior barotropic_substep_nonlinear_interior proc~barotropic_substep_nonlinear_interior->proc~barotropic_substep_nonlinear proc~bt_wide_substep bt_wide_substep proc~bt_wide_substep->proc~barotropic_substep_nonlinear proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~engine_step engine_step proc~engine_step->proc~ocean_data_forcing_apply proc~engine_step->proc~ocean_dyn_step proc~engine_step->proc~ocean_dyn_step_split proc~engine_step_ice engine_step_ice proc~engine_step_ice->proc~ice_ocean_stress_flux proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create proc~rdb_ocean_set_tracer rdb_ocean_set_tracer proc~rdb_ocean_set_tracer->proc~ocean_dyn_flush_tracer_window proc~run_stage run_stage proc~run_stage->proc~continuity_tracer_step_split proc~run_stage->proc~vmix_apply_in_stage

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: i_lo
integer, private :: isum
integer, private :: j
integer, private :: j_fold
integer, private :: jsum
logical, private :: negate_l
integer, private :: p
integer, private :: pm
real(kind=wp), private :: sgn

Source Code

   pure subroutine fold_north_v_face_2d(v, nx_total, ny_face, &
                                        nx_phys, ny_phys, nghost, negate)
      !! 2D y-face (Cv) fold: north-halo fill + on-line antisymmetric
      !! projection at the fold row.  Used for the barotropic `bt_vbt`
      !! field in the BT fast loop.  `negate` (default `.true.`, see the
      !! u-face twin) selects true-vector (sign flip + self-conjugate
      !! zero) vs. scalar (copy + self-conjugate left unchanged, matching
      !! `fold_north_corner_2d`'s scalar contract) — a scalar on a v-face
      !! (e.g. `visc_rem_v`) is the SAME physical attribute of the SAME
      !! face seen from both sides of the seam, so the duplicated DOF at
      !! the fold line must agree, not cancel.
      integer, intent(in) :: nx_total, ny_face, nx_phys, ny_phys, nghost
      real(wp), intent(inout) :: v(nx_total, ny_face)
         !! y-face 2D field, shape (nx_total, ny_total+1).
      logical, intent(in), optional :: negate
         !! `.true.` (default) = true-vector component; `.false.` = scalar.

      integer :: i, j, isum, jsum, j_fold, i_lo, p, pm
      real(wp) :: sgn
      logical :: negate_l

      negate_l = .true.
      if (present(negate)) negate_l = negate
      sgn = merge(-1.0_wp, 1.0_wp, negate_l)
      isum = 2*nghost + nx_phys + 1
      jsum = 2*nghost + 2*ny_phys + 2   ! v is SOUTH-face: y = j-1
      j_fold = nghost + ny_phys + 1     ! north face of the last T-row
      i_lo = nghost + 1

      ! (1) Halo rows strictly beyond the fold row.
      do concurrent(j=j_fold + 1:ny_face, i=1:nx_total)
         v(i, j) = sgn*v(isum - i, jsum - j)
      end do

      ! (2) On-line projection at j = j_fold, over EVERY storage column
      !     (periodic ghosts included, so the row stays periodic-consistent
      !     without a second wrap): a column whose physical index p lies in
      !     the west half takes sgn*(the east mirror p' = ni+1-p); the east
      !     half is the (read-only) source.  Self-conjugate column: zeroed
      !     for a vector (v = -v ⇒ 0), left as is for a scalar.
      do concurrent(i=1:nx_total) local(p, pm)
         p = modulo(i - i_lo, nx_phys) + 1
         pm = nx_phys + 1 - p
         if (p < pm) then
            v(i, j_fold) = sgn*v(nghost + pm, j_fold)
         else if (p == pm .and. negate_l) then
            v(i, j_fold) = 0.0_wp
         end if
      end do
   end subroutine fold_north_v_face_2d