MODULE melt_exchange !----------------------------------------------------------------------- ! NAME ! melt_exchange ! ! DESCRIPTION ! Account for perennial glacier melt as a conservative ice-to-liquid ! transfer outside the atmospheric water closure. ! ! NOTES ! Fully glacier-covered continental source cells have zero soil capacity ! in the PCM, so their melt reaches lakes and runoff immediately. !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use numerics, only: dp, qp use geometry, only: ngrid, nslope use mass_balance, only: mass_surf ! DECLARATION ! ----------- implicit none (type, external) ! VARIABLES ! --------- real(dp), allocatable :: glacier_melt_rate(:,:) ! Prescribed glacier melt [kg/m2/y] real(dp), allocatable :: ice_atmospheric_tendency(:,:) ! Net ice gain from the remaining exchanges [kg/m2/y] ! VISIBILITY ! ---------- private public :: initialize_melt_exchange, balance_h2o_fluxes contains !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !======================================================================= SUBROUTINE initialize_melt_exchange(d_h2oice_ini,d_precip_ini,d_runoff_ini,glacier_melt,glacier_melt_lake) !----------------------------------------------------------------------- ! NAME ! initialize_melt_exchange ! ! DESCRIPTION ! Separate glacier melt from the PCM ice and hydrology reference ! tendencies before the PEM evolution begins. ! ! NOTES ! The PCM fractions and melt accumulations have already been loaded by ! the standard restart and XIOS readers. !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use hydrology, only: do_hydrology, h2o_liq_density, peren_h2o_liq_frac_PCM use surf_ice, only: peren_h2o_ice_frac_PCM use stoppage, only: stop_clean ! DECLARATION ! ----------- implicit none ! ARGUMENTS ! --------- real(dp), intent(in) :: d_h2oice_ini(:,:) real(dp), intent(inout) :: d_precip_ini(:,:), d_runoff_ini(:,:) real(dp), intent(in) :: glacier_melt(:), glacier_melt_lake(:) ! Annual totals per grid-cell area [kg/m2/y] ! LOCAL VARIABLES ! --------------- real(dp) :: lake_melt_input_rate(ngrid), runoff_melt_input_rate(ngrid) ! CODE ! ---- allocate(glacier_melt_rate(ngrid,nslope),ice_atmospheric_tendency(ngrid,nslope)) glacier_melt_rate = 0._dp ice_atmospheric_tendency = d_h2oice_ini ! Without hydrology retain the existing ice-only atmospheric closure. if (.not. do_hydrology) return if (nslope /= 1) call stop_clean(__FILE__,__LINE__,'Glacier melt transfer requires one slope.',1) glacier_melt_rate(:,1) = max(glacier_melt,0._dp) ! Partially covered glaciers can retain melt in the PCM soil bucket. if (any(glacier_melt_rate(:,1) > 0._dp .and. peren_h2o_ice_frac_PCM < 1._dp-1.e-12_dp)) & call stop_clean(__FILE__,__LINE__,'Glacier melt transfer requires fully glacier-covered source cells (no soil storage).',1) ! Direct-to-lake melt is part of the total; the remainder enters runoff. ! Remove both contributions before injecting the actual melt explicitly. lake_melt_input_rate = 0._dp runoff_melt_input_rate = 0._dp where (peren_h2o_liq_frac_PCM > 1.e-12_dp) & lake_melt_input_rate = glacier_melt_lake/peren_h2o_liq_frac_PCM/h2o_liq_density where (peren_h2o_liq_frac_PCM < 1._dp-1.e-12_dp) & runoff_melt_input_rate = (glacier_melt_rate(:,1)-glacier_melt_lake)/(1._dp-peren_h2o_liq_frac_PCM)/h2o_liq_density if (any(d_precip_ini(:,1)-lake_melt_input_rate < -1.e-9_dp) .or. & any(d_runoff_ini(:,1)-runoff_melt_input_rate < -1.e-9_dp)) & call stop_clean(__FILE__,__LINE__,'Glacier melt exceeds the PCM receiving flux; storage/routing assumptions fail.',1) d_precip_ini(:,1) = max(d_precip_ini(:,1)-lake_melt_input_rate,0._dp) d_runoff_ini(:,1) = max(d_runoff_ini(:,1)-runoff_melt_input_rate,0._dp) ! The residual retains the annual-minimum convention of the original ice trend. ! With beta=1 and plentiful ice, atmosphere minus melt reproduces that trend. ice_atmospheric_tendency = d_h2oice_ini + glacier_melt_rate END SUBROUTINE initialize_melt_exchange !======================================================================= !======================================================================= SUBROUTINE balance_h2o_fluxes(h2o_ice,dt_yr,m_evap,m_precip,m_runoff,beta,stopcrit,d_h2oice,d_melt) !----------------------------------------------------------------------- ! NAME ! balance_h2o_fluxes ! ! DESCRIPTION ! Balance atmospheric water exchanges and limit sublimation and glacier ! melt to the available ice. ! ! NOTES ! Sublimation and melt share a limited ice supply. The closure factor ! applies to deposition; the actual melt is transferred unscaled. !----------------------------------------------------------------------- ! DEPENDENCIES ! ------------ use water_balance, only: balance_h2o_atm_fluxes use stopping_crit_core, only: stopFlags ! DECLARATION ! ----------- implicit none ! ARGUMENTS ! --------- real(dp), intent(in) :: h2o_ice(:,:),dt_yr real(qp), intent(in) :: m_evap,m_precip,m_runoff real(qp), intent(out) :: beta class(stopFlags), intent(inout) :: stopcrit real(dp), intent(out) :: d_h2oice(:,:), d_melt(:,:) ! LOCAL VARIABLES ! --------------- real(qp) :: m_subl,m_cond real(dp) :: deposition_rate(ngrid,nslope), sublimation_rate(ngrid,nslope) real(dp) :: total_ice_loss_rate(ngrid,nslope), ice_loss_fraction(ngrid,nslope) ! CODE ! ---- ! Sublimation and melt share the available ice in their prescribed proportions. ! ice_loss_fraction is the fraction of that demand the available ice can supply. sublimation_rate = max(-ice_atmospheric_tendency,0._dp) total_ice_loss_rate = sublimation_rate + glacier_melt_rate ice_loss_fraction = 1._dp where (ice_atmospheric_tendency < 0._dp .and. total_ice_loss_rate > 0._dp) & ice_loss_fraction = min(1._dp,(max(h2o_ice,0._dp)/dt_yr)/total_ice_loss_rate) m_subl = mass_surf(ice_loss_fraction*sublimation_rate*dt_yr) m_cond = mass_surf(max(ice_atmospheric_tendency,0._dp)*dt_yr) call balance_h2o_atm_fluxes(m_subl,m_evap,m_cond,m_precip,m_runoff,beta,stopcrit) deposition_rate = real(beta,dp)*max(ice_atmospheric_tendency,0._dp) ice_loss_fraction = 1._dp ! Deposition can also supply melt during this step; only deposition gets beta. where (total_ice_loss_rate > 0._dp) & ice_loss_fraction = min(1._dp,(max(h2o_ice,0._dp)/dt_yr+deposition_rate)/total_ice_loss_rate) d_melt = ice_loss_fraction*glacier_melt_rate d_h2oice = deposition_rate - ice_loss_fraction*sublimation_rate - d_melt ! Only roundoff can make the donor slightly negative after the proportional cap. d_h2oice = max(d_h2oice,-h2o_ice/dt_yr) END SUBROUTINE balance_h2o_fluxes !======================================================================= END MODULE melt_exchange