ice_cell_concentration_impl Subroutine

public pure subroutine ice_cell_concentration_impl(wet_T, part_size, m_ice, m_snow, mis, mice, ci, ncat, nx, ny)

Two-mode per-cell concentration/mass gather (module docstring convention), shared by rdb_ice_evp (ice_evp_step) and rdb_ice_ocean_coupler (ice_ocean_stress_flux) so neither module depends on the other.

ncat > 1 (ITD live): mis = Σ_c part_size(c)*(m_ice(c)+ m_snow(c)), mice = Σ_c part_size(c)*m_ice(c), ci = min(1, Σ_{c>=1} part_size(c)). ncat == 1 (legacy lumped; per-CELL masses, D5 — SIS2 has no lumped mode): mis = m_ice(1)+m_snow(1), mice = m_ice(1), ci = merge(1, 0, m_ice(1) > 0). All × wet_T (land ⇒ 0). Decl-order: integer dims before the explicit-shape arrays that use them.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: wet_T(nx,ny)
real(kind=wp), intent(in) :: part_size(nx,ny,0:ncat)
real(kind=wp), intent(in) :: m_ice(nx,ny,ncat)
real(kind=wp), intent(in) :: m_snow(nx,ny,ncat)
real(kind=wp), intent(out) :: mis(nx,ny)
real(kind=wp), intent(out) :: mice(nx,ny)
real(kind=wp), intent(out) :: ci(nx,ny)
integer, intent(in) :: ncat
integer, intent(in) :: nx
integer, intent(in) :: ny

Calls

proc~~ice_cell_concentration_impl~~CallsGraph proc~ice_cell_concentration_impl ice_cell_concentration_impl local local proc~ice_cell_concentration_impl->local

Called by

proc~~ice_cell_concentration_impl~~CalledByGraph proc~ice_cell_concentration_impl ice_cell_concentration_impl proc~ice_evp_step ice_evp_step proc~ice_evp_step->proc~ice_cell_concentration_impl proc~ice_ocean_stress_flux ice_ocean_stress_flux proc~ice_ocean_stress_flux->proc~ice_cell_concentration_impl proc~engine_step_ice engine_step_ice proc~engine_step_ice->proc~ice_evp_step proc~engine_step_ice->proc~ice_ocean_stress_flux proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_step_ice proc~rdb_ocean_step rdb_ocean_step proc~rdb_ocean_step->proc~engine_step_ice proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: c
real(kind=wp), private :: ci_sum
integer, private :: i
integer, private :: j
real(kind=wp), private :: mice_sum
real(kind=wp), private :: mis_sum

Source Code

   pure subroutine ice_cell_concentration_impl(wet_T, part_size, m_ice, m_snow, &
                                               mis, mice, ci, ncat, nx, ny)
      !! Two-mode per-cell concentration/mass gather (module docstring
      !! convention), shared by `rdb_ice_evp` (`ice_evp_step`) and
      !! `rdb_ice_ocean_coupler` (`ice_ocean_stress_flux`) so neither
      !! module depends on the other.
      !!
      !! `ncat > 1` (ITD live): `mis = Σ_c part_size(c)*(m_ice(c)+
      !! m_snow(c))`, `mice = Σ_c part_size(c)*m_ice(c)`,
      !! `ci = min(1, Σ_{c>=1} part_size(c))`.
      !! `ncat == 1` (legacy lumped; per-CELL masses, D5 — SIS2 has no
      !! lumped mode): `mis = m_ice(1)+m_snow(1)`, `mice = m_ice(1)`,
      !! `ci = merge(1, 0, m_ice(1) > 0)`.
      !! All × `wet_T` (land ⇒ 0).  Decl-order: integer dims before the
      !! explicit-shape arrays that use them.
      integer, intent(in) :: ncat, nx, ny
      real(wp), intent(in) :: wet_T(nx, ny)
      real(wp), intent(in) :: part_size(nx, ny, 0:ncat)
      real(wp), intent(in) :: m_ice(nx, ny, ncat)
      real(wp), intent(in) :: m_snow(nx, ny, ncat)
      real(wp), intent(out) :: mis(nx, ny)
      real(wp), intent(out) :: mice(nx, ny)
      real(wp), intent(out) :: ci(nx, ny)
      integer :: i, j, c
      real(wp) :: mis_sum, mice_sum, ci_sum

      if (ncat == 1) then
         do concurrent(j=1:ny, i=1:nx)
            if (wet_T(i, j) > 0.5_wp .and. m_ice(i, j, 1) > 0.0_wp) then
               mis(i, j) = m_ice(i, j, 1) + m_snow(i, j, 1)
               mice(i, j) = m_ice(i, j, 1)
               ci(i, j) = 1.0_wp
            else
               mis(i, j) = 0.0_wp
               mice(i, j) = 0.0_wp
               ci(i, j) = 0.0_wp
            end if
         end do
      else
         do concurrent(j=1:ny, i=1:nx) local(c, mis_sum, mice_sum, ci_sum)
            if (wet_T(i, j) > 0.5_wp) then
               mis_sum = 0.0_wp
               mice_sum = 0.0_wp
               ci_sum = 0.0_wp
               do c = 1, ncat
                  mis_sum = mis_sum + part_size(i, j, c)*(m_ice(i, j, c) + m_snow(i, j, c))
                  mice_sum = mice_sum + part_size(i, j, c)*m_ice(i, j, c)
                  ci_sum = ci_sum + part_size(i, j, c)
               end do
               mis(i, j) = mis_sum
               mice(i, j) = mice_sum
               ci(i, j) = min(1.0_wp, ci_sum)
            else
               mis(i, j) = 0.0_wp
               mice(i, j) = 0.0_wp
               ci(i, j) = 0.0_wp
            end if
         end do
      end if
   end subroutine ice_cell_concentration_impl