coriolis_adv_set_beta_plane Subroutine

private subroutine coriolis_adv_set_beta_plane(this, grid, f_0, beta, y_ref)

Populate f_corner with a beta-plane profile f(y) = f_0 + beta * (y - y_ref)

The C-grid SW corner of cell (i, j) sits at physical position y = (j - 1 - nghost) * dy under our convention (j=1+nghost is the first interior corner row). Caller picks y_ref — typically the centre of the physical domain.

Also records f_0 and beta on the type for diagnostics. Must be called after init (so f_corner is allocated) and before enter_data if running on GPU (or follow with a host→device update if already mapped).

Type Bound

coriolis_adv_t

Arguments

Type IntentOptional Attributes Name
class(coriolis_adv_t), intent(inout) :: this
type(hgrid_t), intent(in) :: grid
real(kind=wp), intent(in) :: f_0
real(kind=wp), intent(in) :: beta
real(kind=wp), intent(in) :: y_ref

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
integer, private :: nx
integer, private :: ny
real(kind=wp), private :: y

Source Code

   subroutine coriolis_adv_set_beta_plane(this, grid, f_0, beta, y_ref)
      !! Populate `f_corner` with a beta-plane profile
      !!   f(y) = f_0 + beta * (y - y_ref)
      !!
      !! The C-grid SW corner of cell (i, j) sits at physical position
      !! `y = (j - 1 - nghost) * dy` under our convention (j=1+nghost
      !! is the first interior corner row).  Caller picks `y_ref` —
      !! typically the centre of the physical domain.
      !!
      !! Also records `f_0` and `beta` on the type for diagnostics.
      !! Must be called *after* `init` (so `f_corner` is allocated)
      !! and *before* `enter_data` if running on GPU (or follow with
      !! a host→device update if already mapped).
      class(coriolis_adv_t), intent(inout) :: this
      type(hgrid_t), intent(in) :: grid
      real(wp), intent(in) :: f_0, beta, y_ref

      integer :: i, j, nx, ny
      real(wp) :: y

      nx = grid%nx_total
      ny = grid%ny_total
      this%f_0 = f_0
      this%beta = beta

      do j = 1, ny + 1
         y = real(j - 1 - grid%nghost, wp)*grid%dy
         do i = 1, nx + 1
            this%f_corner(i, j) = f_0 + beta*(y - y_ref)
         end do
      end do
   end subroutine coriolis_adv_set_beta_plane