ocean_bc_validate_periodic Subroutine

public 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.

Arguments

Type IntentOptional 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 (error stop).


Calls

proc~~ocean_bc_validate_periodic~~CallsGraph proc~ocean_bc_validate_periodic ocean_bc_validate_periodic error error proc~ocean_bc_validate_periodic->error

Called by

proc~~ocean_bc_validate_periodic~~CalledByGraph proc~ocean_bc_validate_periodic ocean_bc_validate_periodic proc~configure_ocean_bc configure_ocean_bc proc~configure_ocean_bc->proc~ocean_bc_validate_periodic proc~engine_setup engine_setup proc~engine_setup->proc~configure_ocean_bc proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup 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~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 :: e_per
logical, private :: n_per
logical, private :: s_per
logical, private :: w_per

Source Code

   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