Validate periodic pairing + ghost-width + sponge incompatibility.
Call after all per-edge tags are set and after ocean_bc_state_init.
Derives periodic_x / periodic_y from the final tags and
stops with a diagnostic message if any rule is violated.
Rules (design §1.3): (a) west periodic ⟺ east periodic (must be paired). (b) south periodic ⟺ north periodic (must be paired). (c) periodic requires nghost >= 3 (PPM 5-point + biharmonic). (d) a periodic edge cannot be paired with OBC_SPONGE on any edge in the same axis-pair.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(ocean_bc_state_t), | intent(inout) | :: | this | |||
| integer, | intent(out), | optional | :: | ierr |
Non-zero on a periodic-BC pairing/ghost-width violation when
present; absent behaves as today ( |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| logical, | private | :: | e_per | ||||
| logical, | private | :: | n_per | ||||
| logical, | private | :: | s_per | ||||
| logical, | private | :: | w_per |
subroutine ocean_bc_validate_periodic(this, ierr) !! Validate periodic pairing + ghost-width + sponge incompatibility. !! Call after all per-edge tags are set and after ocean_bc_state_init. !! Derives `periodic_x` / `periodic_y` from the final tags and !! stops with a diagnostic message if any rule is violated. !! !! Rules (design §1.3): !! (a) west periodic ⟺ east periodic (must be paired). !! (b) south periodic ⟺ north periodic (must be paired). !! (c) periodic requires nghost >= 3 (PPM 5-point + biharmonic). !! (d) a periodic edge cannot be paired with OBC_SPONGE on any !! edge in the same axis-pair. type(ocean_bc_state_t), intent(inout) :: this integer, intent(out), optional :: ierr !! Non-zero on a periodic-BC pairing/ghost-width violation when !! present; absent behaves as today (`error stop`). logical :: w_per, e_per, s_per, n_per w_per = (this%west%bc_type == OBC_PERIODIC) e_per = (this%east%bc_type == OBC_PERIODIC) s_per = (this%south%bc_type == OBC_PERIODIC) n_per = (this%north%bc_type == OBC_PERIODIC) ! Rule (a): zonal pairing if (w_per .neqv. e_per) then call logger%error("ocean_bc_validate_periodic: west periodic requires east "// & "periodic (must be paired)") if (present(ierr)) then ierr = OCEAN_STATUS_ERR_SETUP return end if error stop "ocean_bc_validate_periodic: west periodic requires east periodic (must be paired)" end if ! Rule (b): meridional pairing if (s_per .neqv. n_per) then call logger%error("ocean_bc_validate_periodic: south periodic requires north "// & "periodic (must be paired)") if (present(ierr)) then ierr = OCEAN_STATUS_ERR_SETUP return end if error stop "ocean_bc_validate_periodic: south periodic requires north periodic (must be paired)" end if ! Rule (c): ghost width if ((w_per .or. s_per) .and. this%nghost < 3) then call logger%error("ocean_bc_validate_periodic: periodic BC requires nghost "// & ">= 3 (PPM + biharmonic stencil depth)") if (present(ierr)) then ierr = OCEAN_STATUS_ERR_SETUP return end if error stop "ocean_bc_validate_periodic: periodic BC requires nghost >= 3 (PPM + biharmonic stencil depth)" end if ! Rule (d) "a periodic edge cannot be a sponge edge" is enforced ! structurally: each edge carries exactly one tag, and rules (a)/(b) ! force the partner edge of a periodic edge to be periodic too — so ! no edge on a periodic axis can carry OBC_SPONGE. Cross-axis ! combinations (e.g. periodic-x with sponge bands at the y-walls — ! the reentrant-channel configuration) are deliberately allowed. ! Update derived flags now that tags are finalised. this%periodic_x = w_per this%periodic_y = s_per if (present(ierr)) ierr = OCEAN_STATUS_OK end subroutine ocean_bc_validate_periodic