fill_bathymetry_ghosts_array Subroutine

public subroutine fill_bathymetry_ghosts_array(b, grid)

Fill ghost cell bathymetry by constant extrapolation from the nearest interior cell. This ensures boundary flux computations see a consistent bottom elevation across the ghost-interior interface. Works on a target 2D array directly so both the coastal and ocean barotropic slots can reuse it.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: b(:,:)
type(hgrid_t), intent(in) :: grid

Called by

proc~~fill_bathymetry_ghosts_array~~CalledByGraph proc~fill_bathymetry_ghosts_array fill_bathymetry_ghosts_array proc~load_bathymetry_into_array load_bathymetry_into_array proc~load_bathymetry_into_array->proc~fill_bathymetry_ghosts_array proc~ocean_state_seed_from_cfg ocean_state_seed_from_cfg proc~ocean_state_seed_from_cfg->proc~load_bathymetry_into_array proc~engine_setup engine_setup proc~engine_setup->proc~ocean_state_seed_from_cfg 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
integer, private :: i
integer, private :: j
integer, private :: ng
integer, private :: nx
integer, private :: ny

Source Code

   subroutine fill_bathymetry_ghosts_array(b, grid)
      !! Fill ghost cell bathymetry by constant extrapolation from the
      !! nearest interior cell.  This ensures boundary flux computations
      !! see a consistent bottom elevation across the ghost-interior
      !! interface.  Works on a target 2D array directly so both the
      !! coastal and ocean barotropic slots can reuse it.
      real(wp), intent(inout) :: b(:, :)
      type(hgrid_t), intent(in) :: grid

      integer :: ng, i, j, nx, ny

      ng = grid%nghost
      nx = grid%nx_phys
      ny = grid%ny_phys

      ! West and east ghost columns
      do j = 1, grid%ny_total
         do i = 1, ng
            b(i, j) = b(ng + 1, j)                  ! west
            b(ng + nx + i, j) = b(ng + nx, j)       ! east
         end do
      end do

      ! South and north ghost rows (corners already filled above)
      do j = 1, ng
         do i = 1, grid%nx_total
            b(i, j) = b(i, ng + 1)                  ! south
            b(i, ng + ny + j) = b(i, ng + ny)       ! north
         end do
      end do

   end subroutine fill_bathymetry_ghosts_array