ice_top_melt_peel Subroutine

public pure subroutine ice_top_melt_peel(nk, m_lay, enthalpy, salin, tmelt, heat_to_ocn, h2o_ice_to_ocn)

Top melt peel (SIS2_ice_thm.F90:1217-1242; prototype sis2_resize.py:48-80). Peels mass from k=0 (snow) upward through k=nk until tmelt is spent; a massless layer is skipped; the partial layer takes m_melt = melt_left/(enth_fr - enthalpy); any leftover melt energy (all layers exhausted) drains to heat_to_ocn. Snow/pond-free path — tmelt is assumed already >= 0 on entry (the caller folds any negative top-melt into bmelt upstream, SIS2:1159-1163).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nk

Number of ice layers (declared first — decl-order).

real(kind=wp), intent(inout) :: m_lay(0:nk)

Layer masses (kg/m²), 0 = snow, 1..nk = ice.

real(kind=wp), intent(inout) :: enthalpy(0:nk)

Layer specific enthalpies (J/kg).

real(kind=wp), intent(in) :: salin(0:nk)

Layer bulk salinities (PSU) — index 0 (snow) unused.

real(kind=wp), intent(in) :: tmelt

Accumulated top melting energy (J/m²), assumed >= 0.

real(kind=wp), intent(inout) :: heat_to_ocn

Leftover melt energy after all layers exhausted (J/m²) — accumulator, caller zeroes once per step.

real(kind=wp), intent(inout) :: h2o_ice_to_ocn

Meltwater mass flux to the ocean (kg/m²) — accumulator.


Calls

proc~~ice_top_melt_peel~~CallsGraph proc~ice_top_melt_peel ice_top_melt_peel proc~ice_enthalpy_liquid_freeze ice_enthalpy_liquid_freeze proc~ice_top_melt_peel->proc~ice_enthalpy_liquid_freeze

Called by

proc~~ice_top_melt_peel~~CalledByGraph proc~ice_top_melt_peel ice_top_melt_peel proc~ice_column_step ice_column_step proc~ice_column_step->proc~ice_top_melt_peel proc~ice_thermo_columns ice_thermo_columns proc~ice_thermo_columns->proc~ice_column_step proc~ice_thermo_driver_step ice_thermo_driver_step proc~ice_thermo_driver_step->proc~ice_thermo_columns proc~engine_step_ice engine_step_ice proc~engine_step_ice->proc~ice_thermo_driver_step 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

Variables

Type Visibility Attributes Name Initial
real(kind=wp), private :: avail
real(kind=wp), private :: enth_fr(0:ICE_NK_MAX)
integer, private :: k
real(kind=wp), private :: m_melt
real(kind=wp), private :: melt_left

Source Code

   pure subroutine ice_top_melt_peel(nk, m_lay, enthalpy, salin, tmelt, &
                                     heat_to_ocn, h2o_ice_to_ocn)
      !! Top melt peel (SIS2_ice_thm.F90:1217-1242; prototype
      !! sis2_resize.py:48-80). Peels mass from k=0 (snow) upward
      !! through k=nk until `tmelt` is spent; a massless layer is
      !! skipped; the partial layer takes `m_melt = melt_left/(enth_fr
      !! - enthalpy)`; any leftover melt energy (all layers exhausted)
      !! drains to `heat_to_ocn`. Snow/pond-free path — `tmelt` is
      !! assumed already >= 0 on entry (the caller folds any negative
      !! top-melt into `bmelt` upstream, SIS2:1159-1163).
      !$acc routine seq
      integer, intent(in) :: nk
         !! Number of ice layers (declared first — decl-order).
      real(wp), intent(inout) :: m_lay(0:nk)
         !! Layer masses (kg/m²), 0 = snow, 1..nk = ice.
      real(wp), intent(inout) :: enthalpy(0:nk)
         !! Layer specific enthalpies (J/kg).
      real(wp), intent(in) :: salin(0:nk)
         !! Layer bulk salinities (PSU) — index 0 (snow) unused.
      real(wp), intent(in) :: tmelt
         !! Accumulated top melting energy (J/m²), assumed >= 0.
      real(wp), intent(inout) :: heat_to_ocn
         !! Leftover melt energy after all layers exhausted (J/m²) —
         !! accumulator, caller zeroes once per step.
      real(wp), intent(inout) :: h2o_ice_to_ocn
         !! Meltwater mass flux to the ocean (kg/m²) — accumulator.

      real(wp) :: enth_fr(0:ICE_NK_MAX)
      real(wp) :: melt_left, avail, m_melt
      integer :: k

      enth_fr(0) = ice_enthalpy_liquid_freeze(0.0_wp)
      do k = 1, nk
         enth_fr(k) = ice_enthalpy_liquid_freeze(salin(k))
      end do

      melt_left = tmelt
      if (melt_left > 0.0_wp) then
         do k = 0, nk
            if (m_lay(k) <= 0.0_wp) cycle
            avail = m_lay(k)*(enth_fr(k) - enthalpy(k))
            if (melt_left < avail) then
               m_melt = melt_left/(enth_fr(k) - enthalpy(k))
               melt_left = 0.0_wp
            else
               m_melt = m_lay(k)
               melt_left = melt_left - avail
            end if
            m_lay(k) = m_lay(k) - m_melt
            h2o_ice_to_ocn = h2o_ice_to_ocn + m_melt
            if (melt_left <= 0.0_wp) exit
         end do
         heat_to_ocn = heat_to_ocn + melt_left
      end if
   end subroutine ice_top_melt_peel