meke_mass Subroutine

private pure subroutine meke_mass(nx, ny, nz, rho0, have_rho, h_layer, rho_layer, i_mass, depth_tot, mass_ws)

Column mass mass = Sum_k rho*max(h,H_VANISHED) (kg/m^2), its inverse i_mass (0 where mass<=0), depth_tot = Sum_k h (m), and mass_ws = mass (the harmonic-mass input for the lateral flux).

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) :: h_layer(nx,ny,nz)
real(kind=wp), intent(in) :: rho_layer(nx,ny,nz)
real(kind=wp), intent(out) :: i_mass(nx,ny)
real(kind=wp), intent(out) :: depth_tot(nx,ny)
real(kind=wp), intent(out) :: mass_ws(nx,ny)

Calls

proc~~meke_mass~~CallsGraph proc~meke_mass meke_mass local local proc~meke_mass->local

Called by

proc~~meke_mass~~CalledByGraph proc~meke_mass meke_mass proc~meke_step meke_step proc~meke_step->proc~meke_mass 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
real(kind=wp), private :: dsum
real(kind=wp), private :: hk
integer, private :: i
integer, private :: j
integer, private :: k
real(kind=wp), private :: mass
real(kind=wp), private :: rhok

Source Code

   pure subroutine meke_mass(nx, ny, nz, rho0, have_rho, h_layer, rho_layer, &
                             i_mass, depth_tot, mass_ws)
      !! Column mass `mass = Sum_k rho*max(h,H_VANISHED)` (kg/m^2), its
      !! inverse `i_mass` (0 where mass<=0), `depth_tot = Sum_k h` (m), and
      !! `mass_ws = mass` (the harmonic-mass input for the lateral flux).
      integer, intent(in) :: nx, ny, nz
      real(wp), intent(in) :: rho0
      logical, intent(in) :: have_rho
      real(wp), intent(in) :: h_layer(nx, ny, nz)
      real(wp), intent(in) :: rho_layer(nx, ny, nz)
      real(wp), intent(out) :: i_mass(nx, ny)
      real(wp), intent(out) :: depth_tot(nx, ny)
      real(wp), intent(out) :: mass_ws(nx, ny)
      integer :: i, j, k
      real(wp) :: mass, dsum, hk, rhok

      do concurrent(j=1:ny, i=1:nx) local(k, mass, dsum, hk, rhok)
         mass = 0.0_wp
         dsum = 0.0_wp
         do k = 1, nz
            hk = max(h_layer(i, j, k), H_VANISHED)
            rhok = rho0
            if (have_rho) rhok = rho_layer(i, j, k)
            mass = mass + rhok*hk
            dsum = dsum + h_layer(i, j, k)
         end do
         depth_tot(i, j) = dsum
         mass_ws(i, j) = mass
         if (mass > 0.0_wp) then
            i_mass(i, j) = 1.0_wp/mass
         else
            i_mass(i, j) = 0.0_wp
         end if
      end do
   end subroutine meke_mass