meke_baro_transport Subroutine

private pure subroutine meke_baro_transport(nx, ny, nz, rho0, have_rho, mflux_x, mflux_y, rho_layer, baro_hu, baro_hv)

Depth-integrated, mass-weighted barotropic transport through each C-grid face: baroHu(I,j) = Sum_k rho_face * mass_flux_x_layer, where mass_flux_*_layer is the per-layer VOLUME transport (m^3/s, = uh_facedy) and rho_face the two-cell average density. The result is a MASS transport (kg/s) so the advective divergence pairs exactly with IareaT*I_mass (1/(areamass)) ⇒ Sum Earea*mass is conserved. Array-edge faces carry zero transport (closed domain).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz
real(kind=wp), intent(in) :: rho0
logical, intent(in) :: have_rho
real(kind=wp), intent(in) :: mflux_x(nx+1,ny,nz)
real(kind=wp), intent(in) :: mflux_y(nx,ny+1,nz)
real(kind=wp), intent(in) :: rho_layer(nx,ny,nz)
real(kind=wp), intent(out) :: baro_hu(nx+1,ny)
real(kind=wp), intent(out) :: baro_hv(nx,ny+1)

Calls

proc~~meke_baro_transport~~CallsGraph proc~meke_baro_transport meke_baro_transport local local proc~meke_baro_transport->local

Called by

proc~~meke_baro_transport~~CalledByGraph proc~meke_baro_transport meke_baro_transport proc~meke_step meke_step proc~meke_step->proc~meke_baro_transport proc~run_meke_step run_meke_step proc~run_meke_step->proc~meke_step proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_meke_step proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step_split proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
integer, private :: k
real(kind=wp), private :: rho_face
real(kind=wp), private :: tsum

Source Code

   pure subroutine meke_baro_transport(nx, ny, nz, rho0, have_rho, &
                                       mflux_x, mflux_y, rho_layer, &
                                       baro_hu, baro_hv)
      !! Depth-integrated, mass-weighted barotropic transport through each
      !! C-grid face: `baroHu(I,j) = Sum_k rho_face * mass_flux_x_layer`,
      !! where `mass_flux_*_layer` is the per-layer VOLUME transport (m^3/s,
      !! = u*h_face*dy) and `rho_face` the two-cell average density.  The
      !! result is a MASS transport (kg/s) so the advective divergence pairs
      !! exactly with `IareaT*I_mass` (1/(area*mass)) ⇒ Sum E*area*mass is
      !! conserved.  Array-edge faces carry zero transport (closed domain).
      integer, intent(in) :: nx, ny, nz
      real(wp), intent(in) :: rho0
      logical, intent(in) :: have_rho
      real(wp), intent(in) :: mflux_x(nx + 1, ny, nz)
      real(wp), intent(in) :: mflux_y(nx, ny + 1, nz)
      real(wp), intent(in) :: rho_layer(nx, ny, nz)
      real(wp), intent(out) :: baro_hu(nx + 1, ny)
      real(wp), intent(out) :: baro_hv(nx, ny + 1)
      integer :: i, j, k
      real(wp) :: tsum, rho_face

      ! u-faces: interior I=2..nx between cells I-1 and I.
      do concurrent(j=1:ny, i=1:nx + 1) local(k, tsum, rho_face)
         tsum = 0.0_wp
         if (i >= 2 .and. i <= nx) then
            do k = 1, nz
               rho_face = rho0
               if (have_rho) rho_face = 0.5_wp*(rho_layer(i - 1, j, k) + rho_layer(i, j, k))
               tsum = tsum + rho_face*mflux_x(i, j, k)
            end do
         end if
         baro_hu(i, j) = tsum
      end do
      ! v-faces: interior J=2..ny between cells J-1 and J.
      do concurrent(j=1:ny + 1, i=1:nx) local(k, tsum, rho_face)
         tsum = 0.0_wp
         if (j >= 2 .and. j <= ny) then
            do k = 1, nz
               rho_face = rho0
               if (have_rho) rho_face = 0.5_wp*(rho_layer(i, j - 1, k) + rho_layer(i, j, k))
               tsum = tsum + rho_face*mflux_y(i, j, k)
            end do
         end if
         baro_hv(i, j) = tsum
      end do
   end subroutine meke_baro_transport