budget_total_mass Function

public pure function budget_total_mass(ms, mask, areaT) result(total)

Total mass: Σ over masked interior of h_layer·areaT·weight over k. Units: m³. Public only for the unit-test suite.

Arguments

Type IntentOptional Attributes Name
type(multilayer_state_t), intent(in) :: ms
type(diag_mask_t), intent(in) :: mask
real(kind=wp), intent(in) :: areaT(:,:)

Return Value real(kind=wp)


Called by

proc~~budget_total_mass~~CalledByGraph proc~budget_total_mass budget_total_mass proc~ocean_budgets_evaluate ocean_budgets_t%ocean_budgets_evaluate proc~ocean_budgets_evaluate->proc~budget_total_mass proc~ocean_budgets_init_snapshot ocean_budgets_t%ocean_budgets_init_snapshot proc~ocean_budgets_init_snapshot->proc~ocean_budgets_evaluate

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: col_sum
integer, private :: i
integer, private :: j
integer, private :: k
integer, private :: nx
integer, private :: ny
integer, private :: nz
real(kind=wp), private :: w_dA

Source Code

   pure function budget_total_mass(ms, mask, areaT) result(total)
      !! Total mass: Σ over masked interior of `h_layer·areaT·weight` over k.
      !! Units: m³.  Public only for the unit-test suite.
      type(multilayer_state_t), intent(in) :: ms
      type(diag_mask_t), intent(in) :: mask
      real(wp), intent(in) :: areaT(:, :)
      real(wp) :: total
      integer :: i, j, k, nx, ny, nz
      real(wp) :: w_dA, col_sum
      total = 0.0_wp
      nx = min(mask%nx, size(ms%h_layer, 1))
      ny = min(mask%ny, size(ms%h_layer, 2))
      nz = ms%nz_ml
      do j = 1, ny
         do i = 1, nx
            w_dA = mask%weight(i, j)*areaT(i, j)
            if (w_dA <= 0.0_wp) cycle
            col_sum = 0.0_wp
            do k = 1, nz
               col_sum = col_sum + ms%h_layer(i, j, k)
            end do
            total = total + w_dA*col_sum
         end do
      end do
   end function budget_total_mass