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 | Intent | Optional | 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 |
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