ocean_bc_validate_fold Subroutine

public subroutine ocean_bc_validate_fold(this, ierr)

Validate the tripolar north-fold tag. Call after all per-edge tags are set and after ocean_bc_state_init. Refreshes north_fold and stops with a diagnostic if any rule fails.

Rules (design Appendix A): (a) OBC_TRIPOLAR_FOLD is accepted ONLY on the NORTH edge — west/east/south carrying it is a config error. (b) the fold requires periodic west AND east (the fold reads already-cyclically-wrapped corner columns). (c) the fold requires nghost >= 3 (PPM + biharmonic stencil depth — same as periodic). The reverse rule (tripolar grid REQUIRES the fold tag) is checked at the configure-metrics site, which knows grid_config.

Arguments

Type IntentOptional Attributes Name
type(ocean_bc_state_t), intent(inout) :: this
integer, intent(out), optional :: ierr

Non-zero on a tripolar-fold configuration violation when present; absent behaves as today (error stop).


Calls

proc~~ocean_bc_validate_fold~~CallsGraph proc~ocean_bc_validate_fold ocean_bc_validate_fold error error proc~ocean_bc_validate_fold->error

Called by

proc~~ocean_bc_validate_fold~~CalledByGraph proc~ocean_bc_validate_fold ocean_bc_validate_fold proc~configure_ocean_bc configure_ocean_bc proc~configure_ocean_bc->proc~ocean_bc_validate_fold 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 :: n_fold

Source Code

   subroutine ocean_bc_validate_fold(this, ierr)
      !! Validate the tripolar north-fold tag.  Call after all per-edge
      !! tags are set and after `ocean_bc_state_init`.  Refreshes
      !! `north_fold` and stops with a diagnostic if any rule fails.
      !!
      !! Rules (design Appendix A):
      !!   (a) OBC_TRIPOLAR_FOLD is accepted ONLY on the NORTH edge —
      !!       west/east/south carrying it is a config error.
      !!   (b) the fold requires periodic west AND east (the fold reads
      !!       already-cyclically-wrapped corner columns).
      !!   (c) the fold requires nghost >= 3 (PPM + biharmonic stencil
      !!       depth — same as periodic).
      !! The reverse rule (tripolar grid REQUIRES the fold tag) is
      !! checked at the configure-metrics site, which knows grid_config.
      type(ocean_bc_state_t), intent(inout) :: this
      integer, intent(out), optional :: ierr
         !! Non-zero on a tripolar-fold configuration violation when
         !! present; absent behaves as today (`error stop`).

      logical :: n_fold

      n_fold = (this%north%bc_type == OBC_TRIPOLAR_FOLD)

      ! Rule (a): only the north edge may carry the fold tag.
      if (this%west%bc_type == OBC_TRIPOLAR_FOLD .or. &
          this%east%bc_type == OBC_TRIPOLAR_FOLD .or. &
          this%south%bc_type == OBC_TRIPOLAR_FOLD) then
         call logger%error("ocean_bc_validate_fold: tripolar_fold is accepted "// &
                           "only on the north edge")
         if (present(ierr)) then
            ierr = OCEAN_STATUS_ERR_SETUP
            return
         end if

         error stop "ocean_bc_validate_fold: tripolar_fold is accepted only on the north edge"
      end if

      if (n_fold) then
         ! Rule (b): periodic west+east mandatory.
         if (this%west%bc_type /= OBC_PERIODIC .or. &
             this%east%bc_type /= OBC_PERIODIC) then
            call logger%error("ocean_bc_validate_fold: north='tripolar_fold' "// &
                              "requires periodic west+east edges")
            if (present(ierr)) then
               ierr = OCEAN_STATUS_ERR_SETUP
               return
            end if

            error stop "ocean_bc_validate_fold: north='tripolar_fold' requires periodic west+east edges"
         end if
         ! Rule (c): ghost width.
         if (this%nghost < 3) then
            call logger%error("ocean_bc_validate_fold: tripolar_fold requires "// &
                              "nghost >= 3 (PPM + biharmonic stencil depth)")
            if (present(ierr)) then
               ierr = OCEAN_STATUS_ERR_SETUP
               return
            end if

            error stop "ocean_bc_validate_fold: tripolar_fold requires nghost >= 3 (PPM + biharmonic stencil depth)"
         end if
      end if

      ! Rank-local: only the rank that owns the physical north edge folds.
      this%north_fold = n_fold .and. this%has_north
      if (present(ierr)) ierr = OCEAN_STATUS_OK
   end subroutine ocean_bc_validate_fold