metrics_fold_periodic_ghosts Subroutine

public subroutine metrics_fold_periodic_ghosts(this, grid, periodic_x, north_fold)

Tripolar ghost-metric fill (M4c): periodic-x wrap of the east/west ghost columns + north-fold of the north ghost rows, for EVERY metric + geography array. Replaces the constant extrapolation the supergrid assembler left on those edges. The ONE routine both the analytic tripolar generator and the MOM6 mosaic reader (metrics_fill_from_supergrid) use.

Composition (Appendix A): periodic-x FIRST so the fold reads the cyclically-wrapped corner columns. All arrays fold as scalars (negate=.false.) — lengths/areas are reflection-invariant and geography reads the conjugate point’s stored lat/lon — except the grid rotation angle_dx, which gains pi across the fold (the conjugate cell’s +i axis points the other way).

Arguments

Type IntentOptional Attributes Name
type(ocean_metrics_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
logical, intent(in), optional :: periodic_x

Wrap the east/west ghost columns. Absent ⇒ .true..

logical, intent(in), optional :: north_fold

Fold the north ghost rows. Absent ⇒ .true..


Calls

proc~~metrics_fold_periodic_ghosts~~CallsGraph proc~metrics_fold_periodic_ghosts metrics_fold_periodic_ghosts interface~fold_north_centre fold_north_centre proc~metrics_fold_periodic_ghosts->interface~fold_north_centre proc~metrics_fold_north_faces metrics_fold_north_faces proc~metrics_fold_periodic_ghosts->proc~metrics_fold_north_faces proc~metrics_periodic_x_all metrics_periodic_x_all proc~metrics_fold_periodic_ghosts->proc~metrics_periodic_x_all 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 interface~fold_north_corner fold_north_corner proc~metrics_fold_north_faces->interface~fold_north_corner proc~metrics_fold_north_cu_scalar metrics_fold_north_cu_scalar proc~metrics_fold_north_faces->proc~metrics_fold_north_cu_scalar proc~metrics_fold_north_cv_scalar metrics_fold_north_cv_scalar proc~metrics_fold_north_faces->proc~metrics_fold_north_cv_scalar proc~metrics_periodic_x_2d metrics_periodic_x_2d proc~metrics_periodic_x_all->proc~metrics_periodic_x_2d proc~metrics_periodic_x_bu metrics_periodic_x_bu proc~metrics_periodic_x_all->proc~metrics_periodic_x_bu proc~metrics_periodic_x_cu metrics_periodic_x_cu proc~metrics_periodic_x_all->proc~metrics_periodic_x_cu proc~metrics_periodic_x_cv metrics_periodic_x_cv proc~metrics_periodic_x_all->proc~metrics_periodic_x_cv proc~fold_north_corner_2d fold_north_corner_2d interface~fold_north_corner->proc~fold_north_corner_2d local local proc~fold_north_corner_2d->local

Called by

proc~~metrics_fold_periodic_ghosts~~CalledByGraph proc~metrics_fold_periodic_ghosts metrics_fold_periodic_ghosts proc~engine_setup engine_setup proc~engine_setup->proc~metrics_fold_periodic_ghosts proc~configure_ocean_metrics configure_ocean_metrics proc~engine_setup->proc~configure_ocean_metrics proc~metrics_fill_from_supergrid metrics_fill_from_supergrid proc~metrics_fill_from_supergrid->proc~metrics_fold_periodic_ghosts proc~metrics_fill_tripolar_whole metrics_fill_tripolar_whole proc~metrics_fill_tripolar_whole->proc~metrics_fold_periodic_ghosts proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~configure_ocean_metrics->proc~metrics_fill_from_supergrid proc~metrics_fill_tripolar metrics_fill_tripolar proc~configure_ocean_metrics->proc~metrics_fill_tripolar proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~metrics_fill_tripolar->proc~metrics_fill_tripolar_whole proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean 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

Variables

Type Visibility Attributes Name Initial
logical, private :: do_fold
logical, private :: do_x
integer, private :: i
integer, private :: j
integer, private :: ng
integer, private :: ni
integer, private :: nj

Source Code

   subroutine metrics_fold_periodic_ghosts(this, grid, periodic_x, north_fold)
      !! Tripolar ghost-metric fill (M4c): periodic-x wrap of the
      !! east/west ghost columns + north-fold of the north ghost rows,
      !! for EVERY metric + geography array.  Replaces the constant
      !! extrapolation the supergrid assembler left on those edges.  The
      !! ONE routine both the analytic tripolar generator and the MOM6
      !! mosaic reader (`metrics_fill_from_supergrid`) use.
      !!
      !! Composition (Appendix A): periodic-x FIRST so the fold reads the
      !! cyclically-wrapped corner columns.  All arrays fold as scalars
      !! (negate=.false.) — lengths/areas are reflection-invariant and
      !! geography reads the conjugate point's stored lat/lon — except the
      !! grid rotation `angle_dx`, which gains `pi` across the fold (the
      !! conjugate cell's +i axis points the other way).
      type(ocean_metrics_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      logical, intent(in), optional :: periodic_x
         !! Wrap the east/west ghost columns.  Absent ⇒ `.true.`.
      logical, intent(in), optional :: north_fold
         !! Fold the north ghost rows.  Absent ⇒ `.true.`.
      integer :: ng, ni, nj, i, j
      logical :: do_x, do_fold

      ng = grid%nghost
      ni = grid%nx_phys
      nj = grid%ny_phys
      do_x = .true.
      if (present(periodic_x)) do_x = periodic_x
      do_fold = .true.
      if (present(north_fold)) do_fold = north_fold

      ! ---- (1) Periodic-x wrap of east/west ghost columns ----
      if (do_x) call metrics_periodic_x_all(this, grid)

      ! ---- (2) North fold of the north ghost rows (scalars: negate=.false.) ----
      if (.not. do_fold) return
      ! T-stagger (centre).
      call fold_north_centre(this%dxT, grid%nx_total, grid%ny_total, ni, nj, ng)
      call fold_north_centre(this%dyT, grid%nx_total, grid%ny_total, ni, nj, ng)
      call fold_north_centre(this%areaT, grid%nx_total, grid%ny_total, ni, nj, ng)
      call fold_north_centre(this%geolatT, grid%nx_total, grid%ny_total, ni, nj, ng)
      call fold_north_centre(this%geolonT, grid%nx_total, grid%ny_total, ni, nj, ng)
      ! Grid rotation: the conjugate's +i axis is reversed => angle + pi,
      ! folded back into (-pi, pi].
      call fold_north_centre(this%angle_dx, grid%nx_total, grid%ny_total, ni, nj, ng)
      do j = ng + nj + 1, grid%ny_total
         do i = 1, grid%nx_total
            this%angle_dx(i, j) = this%angle_dx(i, j) + PI_WP
            if (this%angle_dx(i, j) > PI_WP) this%angle_dx(i, j) = this%angle_dx(i, j) - 2.0_wp*PI_WP
         end do
      end do
      call metrics_fold_north_faces(this, grid)
   end subroutine metrics_fold_periodic_ghosts