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 | Intent | Optional | 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 ⇒ |
|
| logical, | intent(in), | optional | :: | north_fold |
Fold the north ghost rows. Absent ⇒ |
| 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 |
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