ocean_bc_state_set_topology Subroutine

public subroutine ocean_bc_state_set_topology(this, periodic_x, periodic_y, ierr)

Pre-create GRID TOPOLOGY injection (Python runtime API plan, P2.5): force per-dimension periodicity the Oceananigans way (docs/ocean_python_api_plan.md S5b) — “the grid owns periodicity”, not the per-edge &ocean_bc_nml tags. Sets periodic_x/periodic_y directly and back-fills the edge tags on every axis the caller marks periodic (both edges together, so a west/east — or south/north — mismatch is structurally unrepresentable through this entry point, unlike the namelist path which needs ocean_bc_validate_periodic to catch one). An axis the caller does NOT mark periodic is left untouched: its edge tags keep whatever physical BC configure_ocean_bc already derived from &ocean_bc_nml — periodicity is a GRID property, but the wall/open/clamped/… physics for a Bounded dimension stays the namelist’s job.

Call AFTER configure_ocean_bc (whose namelist-derived tags this may override) and BEFORE anything that reads periodic_x/_y — the init-time periodic ghost wrap, ocean_halo_init, configure_ocean_land_mask (engine_setup’s ordering).

Arguments

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

Non-zero (OCEAN_STATUS_ERR_SETUP) when a requested periodic axis violates the nghost >= 3 PPM/biharmonic stencil-depth requirement (ocean_bc_validate_periodic’s rule (c), mirrored here since this entry point bypasses that routine) when present; absent behaves as today (error stop).


Calls

proc~~ocean_bc_state_set_topology~~CallsGraph proc~ocean_bc_state_set_topology ocean_bc_state_set_topology error error proc~ocean_bc_state_set_topology->error

Called by

proc~~ocean_bc_state_set_topology~~CalledByGraph proc~ocean_bc_state_set_topology ocean_bc_state_set_topology proc~engine_setup engine_setup proc~engine_setup->proc~ocean_bc_state_set_topology 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

Source Code

   subroutine ocean_bc_state_set_topology(this, periodic_x, periodic_y, ierr)
      !! Pre-create GRID TOPOLOGY injection (Python runtime API plan,
      !! P2.5): force per-dimension periodicity the Oceananigans way
      !! (`docs/ocean_python_api_plan.md` S5b) — "the grid owns
      !! periodicity", not the per-edge `&ocean_bc_nml` tags. Sets
      !! `periodic_x`/`periodic_y` directly and back-fills the edge tags
      !! on every axis the caller marks periodic (both edges together, so
      !! a west/east — or south/north — mismatch is structurally
      !! unrepresentable through this entry point, unlike the namelist
      !! path which needs `ocean_bc_validate_periodic` to catch one). An
      !! axis the caller does NOT mark periodic is left untouched: its
      !! edge tags keep whatever physical BC `configure_ocean_bc` already
      !! derived from `&ocean_bc_nml` — periodicity is a GRID property,
      !! but the wall/open/clamped/... physics for a Bounded dimension
      !! stays the namelist's job.
      !!
      !! Call AFTER `configure_ocean_bc` (whose namelist-derived tags this
      !! may override) and BEFORE anything that reads `periodic_x`/`_y` —
      !! the init-time periodic ghost wrap, `ocean_halo_init`,
      !! `configure_ocean_land_mask` (`engine_setup`'s ordering).
      type(ocean_bc_state_t), intent(inout) :: this
      logical, intent(in) :: periodic_x
      logical, intent(in) :: periodic_y
      integer, intent(out), optional :: ierr
         !! Non-zero (`OCEAN_STATUS_ERR_SETUP`) when a requested periodic
         !! axis violates the `nghost >= 3` PPM/biharmonic stencil-depth
         !! requirement (`ocean_bc_validate_periodic`'s rule (c), mirrored
         !! here since this entry point bypasses that routine) when
         !! present; absent behaves as today (`error stop`).

      if ((periodic_x .or. periodic_y) .and. this%nghost < 3) then
         call logger%error("ocean_bc_state_set_topology: periodic topology requires "// &
                           "nghost >= 3 (PPM + biharmonic stencil depth)")
         if (present(ierr)) then
            ierr = OCEAN_STATUS_ERR_SETUP
            return
         end if
         error stop "ocean_bc_state_set_topology: periodic topology requires nghost >= 3"
      end if

      this%periodic_x = periodic_x
      this%periodic_y = periodic_y
      if (periodic_x) then
         this%west%bc_type = OBC_PERIODIC
         this%east%bc_type = OBC_PERIODIC
      end if
      if (periodic_y) then
         this%south%bc_type = OBC_PERIODIC
         this%north%bc_type = OBC_PERIODIC
      end if
      if (present(ierr)) ierr = OCEAN_STATUS_OK
   end subroutine ocean_bc_state_set_topology