subroutine snow_process(j, jea, ida, mstruc, precip, tmn, tx)
use output, only: output_store_hydrotope_value
integer, intent(in) :: ida
integer, dimension(:, :, :), intent(in) :: mstruc
real(dp), intent(in) :: precip
real(dp), dimension(:), intent(in) :: tmn
real(dp), dimension(:), intent(in) :: tx
integer, intent(in) :: j, jea
real(dp) :: elevh
smle = 0.
snowVal = 0.
gmle = 0.
elevh = mstruc(j, jea, 5) ! hydrotope elevation
vsn = 0.
! elevation-based correction of precipitation and air temperature
if (precip > 0.) then
precipe = precip * (1. + xgrad1 * (elevh - elev0(j)))
else
precipe = 0.
end if
precipe = max(0.0_dp, precipe)
precip_elev_cor = precipe
tmit = tx(j) + tgrad1 * (elevh - elev0(j))
tmax = tmx(j) + tgrad1 * (elevh - elev0(j))
tmin = tmn(j) + tgrad1 * (elevh - elev0(j))
! rsn = snow water density in HYDROTOPE, (g/cm3)
! snoa = snow water content, mm
if (rsn(j, jea) > 0. ) then
hsn0 = snoa(j, jea) * .1 / rsn(j, jea) ! hsn0 = snow depth, cm
else
hsn0 = 0.
end if
if (tmit <= tsnfall(j) ) then
snoa(j, jea) = snoa(j, jea) + precipe * prcor! snow ! add precipitation to snow water content, mm
snowVal = precipe * prcor ! actual snow fall, mm
precipe = 0.
end if
if (snoa(j, jea) > 0. ) then
call snow_melting(j, jea, ida)
else
if (gla(j, jea) > 0. ) call snow_glacier_melt(j, jea)
end if
if (ida == gla_day_out) &
call output_store_hydrotope_value(glacier_weq_output_id, j, jea, gla(j, jea))
end subroutine snow_process