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).
| Type | Intent | Optional | 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. |
| 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 |
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