update_reservoir_zonal_west Subroutine

private pure subroutine update_reservoir_zonal_west(hTr, h_layer, mass_flux_x, tres_w, T_data, nx_total, ny_total, nz, i_w, j0, j1, L_out, L_in, dt, it, n_tr)

Update reservoir for the west open edge. Wall-face/interior cell = i_w. Outward normal = -x: u_n = -mass_flux_x(i_w,j,k)/max(h,hmin).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: hTr(nx_total,ny_total,nz)
real(kind=wp), intent(in) :: h_layer(nx_total,ny_total,nz)
real(kind=wp), intent(in) :: mass_flux_x(nx_total+1,ny_total,nz)
real(kind=wp), intent(inout) :: tres_w(ny_total,nz,n_tr)
real(kind=wp), intent(in) :: T_data
integer, intent(in) :: nx_total
integer, intent(in) :: ny_total
integer, intent(in) :: nz
integer, intent(in) :: i_w
integer, intent(in) :: j0
integer, intent(in) :: j1
real(kind=wp), intent(in) :: L_out
real(kind=wp), intent(in) :: L_in
real(kind=wp), intent(in) :: dt
integer, intent(in) :: it
integer, intent(in) :: n_tr

Calls

proc~~update_reservoir_zonal_west~~CallsGraph proc~update_reservoir_zonal_west update_reservoir_zonal_west local local proc~update_reservoir_zonal_west->local

Called by

proc~~update_reservoir_zonal_west~~CalledByGraph proc~update_reservoir_zonal_west update_reservoir_zonal_west proc~ocean_obc_update_reservoirs ocean_obc_update_reservoirs proc~ocean_obc_update_reservoirs->proc~update_reservoir_zonal_west proc~run_continuity_chain run_continuity_chain proc~run_continuity_chain->proc~ocean_obc_update_reservoirs proc~run_stage_split run_stage_split proc~run_stage_split->proc~run_continuity_chain proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: T_int
real(kind=wp), private :: c_in
real(kind=wp), private :: c_out
real(kind=wp), private :: denom
real(kind=wp), private :: h_int
integer, private :: j
integer, private :: k
real(kind=wp), private :: tres_old
real(kind=wp), private :: u_n

Source Code

   pure subroutine update_reservoir_zonal_west(hTr, h_layer, mass_flux_x, &
                                               tres_w, T_data, &
                                               nx_total, ny_total, nz, &
                                               i_w, j0, j1, &
                                               L_out, L_in, dt, it, n_tr)
      !! Update reservoir for the west open edge.  Wall-face/interior cell = i_w.
      !! Outward normal = -x: u_n = -mass_flux_x(i_w,j,k)/max(h,hmin).
      integer, intent(in) :: nx_total, ny_total, nz, n_tr, it
      integer, intent(in) :: i_w, j0, j1
      real(wp), intent(in) :: hTr(nx_total, ny_total, nz)
      real(wp), intent(in) :: h_layer(nx_total, ny_total, nz)
      real(wp), intent(in) :: mass_flux_x(nx_total + 1, ny_total, nz)
      real(wp), intent(inout) :: tres_w(ny_total, nz, n_tr)
      real(wp), intent(in) :: T_data
      real(wp), intent(in) :: L_out, L_in, dt

      integer :: j, k
      real(wp) :: h_int, T_int, u_n, c_out, c_in, tres_old, denom

      do concurrent(j=j0:j1, k=1:nz) local(h_int, T_int, u_n, c_out, c_in, tres_old, denom)
         h_int = max(h_layer(i_w, j, k), RES_H_MIN)
         T_int = hTr(i_w, j, k)/h_int
         ! mass_flux_x(i_w,...) > 0 = eastward into domain (inflow at west).
         u_n = -mass_flux_x(i_w, j, k)/h_int
         tres_old = tres_w(j, k, it)
         ! Degenerate limits: L_out==0 & u_n>0 ⇒ T_int; L_in==0 & u_n<0 ⇒ T_data
         ! instantly.  Both L zero ⇒ implicit form is a no-op (tres unchanged).
         if (L_out == 0.0_wp .and. u_n > 0.0_wp) then
            tres_w(j, k, it) = T_int
         else if (L_in == 0.0_wp .and. u_n < 0.0_wp) then
            tres_w(j, k, it) = T_data
         else
            c_out = merge(max(0.0_wp, u_n)*dt/L_out, 0.0_wp, L_out > 0.0_wp)
            c_in = merge(max(0.0_wp, -u_n)*dt/L_in, 0.0_wp, L_in > 0.0_wp)
            denom = 1.0_wp + c_out + c_in
            tres_w(j, k, it) = (tres_old + c_out*T_int + c_in*T_data)/denom
         end if
      end do
   end subroutine update_reservoir_zonal_west