ocean_bc_state_init Subroutine

public subroutine ocean_bc_state_init(this, grid, nz_ml, n_tracers)

Cache grid extents and derive periodic flags. Data buffers stay unallocated until a data source asks for them. Call ocean_bc_validate_periodic after setting per-edge tags if any edge is OBC_PERIODIC; init itself only derives the convenience flags.

Arguments

Type IntentOptional Attributes Name
type(ocean_bc_state_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
integer, intent(in) :: nz_ml
integer, intent(in), optional :: n_tracers

Called by

proc~~ocean_bc_state_init~~CalledByGraph proc~ocean_bc_state_init ocean_bc_state_init proc~ocean_state_init ocean_state_t%ocean_state_init proc~ocean_state_init->proc~ocean_bc_state_init proc~ocean_state_init_from_config ocean_state_t%ocean_state_init_from_config proc~ocean_state_init_from_config->proc~ocean_state_init proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_init_from_config 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_init(this, grid, nz_ml, n_tracers)
      !! Cache grid extents and derive periodic flags. Data buffers stay
      !! unallocated until a data source asks for them. Call
      !! `ocean_bc_validate_periodic` after setting per-edge tags if any edge
      !! is OBC_PERIODIC; init itself only derives the convenience flags.
      type(ocean_bc_state_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      integer, intent(in) :: nz_ml
      integer, intent(in), optional :: n_tracers

      this%nx_total = grid%nx_total
      this%ny_total = grid%ny_total
      this%nx_phys = grid%nx_phys
      this%ny_phys = grid%ny_phys
      this%nghost = grid%nghost
      this%nz_ml = nz_ml
      this%n_tracers = 0
      if (present(n_tracers)) this%n_tracers = n_tracers
      ! Reset edge tags to WALL so re-init after destroy doesn't inherit
      ! stale tags.
      this%west%bc_type = OBC_WALL
      this%east%bc_type = OBC_WALL
      this%south%bc_type = OBC_WALL
      this%north%bc_type = OBC_WALL
      ! Pre-allocate per-edge clamped_tracer arrays (zero) so callers can set
      ! Dirichlet values without allocating; only consulted on OBC_CLAMPED.
      if (this%n_tracers > 0) then
         allocate (this%west%clamped_tracer(this%n_tracers), source=0.0_wp)
         allocate (this%east%clamped_tracer(this%n_tracers), source=0.0_wp)
         allocate (this%south%clamped_tracer(this%n_tracers), source=0.0_wp)
         allocate (this%north%clamped_tracer(this%n_tracers), source=0.0_wp)
      end if
      ! Derive convenience periodic flags.  Tags may still be at the
      ! default OBC_WALL here if the caller sets them after init — the
      ! caller must call ocean_bc_validate_periodic after finalising tags.
      this%periodic_x = (this%west%bc_type == OBC_PERIODIC .and. &
                         this%east%bc_type == OBC_PERIODIC)
      this%periodic_y = (this%south%bc_type == OBC_PERIODIC .and. &
                         this%north%bc_type == OBC_PERIODIC)
      this%north_fold = (this%north%bc_type == OBC_TRIPOLAR_FOLD)
      this%is_init = .true.
   end subroutine ocean_bc_state_init