LCOV - code coverage report
Current view: top level - mHM - mo_snow_accum_melt.f90 (source / functions) Hit Total Coverage
Test: mHM coverage Lines: 24 24 100.0 %
Date: 2024-04-30 08:53:32 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !> \file mo_snow_accum_melt.f90
       2             : !> \brief \copybrief mo_snow_accum_melt
       3             : !> \details \copydetails mo_snow_accum_melt
       4             : 
       5             : !> \brief Snow melting and accumulation.
       6             : !> \details This module calculates snow melting and accumulation.
       7             : !> \authors Vladyslav Prykhodko
       8             : !> \date Dec 2012
       9             : !> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
      10             : !! mHM is released under the LGPLv3+ license \license_note
      11             : !> \ingroup f_mhm
      12             : MODULE mo_snow_accum_melt
      13             : 
      14             :   USE mo_kind, ONLY : dp
      15             : 
      16             :   IMPLICIT NONE
      17             : 
      18             :   PRIVATE
      19             : 
      20             :   PUBLIC :: snow_accum_melt
      21             : 
      22             :   ! ------------------------------------------------------------------
      23             : 
      24             : CONTAINS
      25             : 
      26             :   ! ------------------------------------------------------------------
      27             : 
      28             :   !    NAME
      29             :   !        snow_accum_melt
      30             : 
      31             :   !    PURPOSE
      32             :   !>       \brief Snow melting and accumulation.
      33             : 
      34             :   !>       \details Separates throughfall into rain and snow by comparing the temperature with the treshhold.
      35             :   !>       by comparing the temperature with the treshhold.
      36             :   !>       Calculates degree daily factor.
      37             :   !>       Calculates snow melting rates.
      38             :   !>       Calculates snow, rain and effective precipitation depth
      39             :   !>       and snow pack.
      40             : 
      41             :   !    INTENT(IN)
      42             :   !>       \param[in] "REAL(dp) :: deg_day_incr"       Increase of the Degree-day factor per mm of increasein
      43             :   !>       precipitation [s-1 degreeC-1]
      44             :   !>       \param[in] "REAL(dp) :: deg_day_max"        Maximum Degree-day factor [m-1 degreeC-1]
      45             :   !>       \param[in] "REAL(dp) :: deg_day_noprec"     Degree-day factor with no precipitation [m-1 degreeC-1]
      46             :   !>       \param[in] "REAL(dp) :: prec"               Daily mean precipitation [m]
      47             :   !>       \param[in] "REAL(dp) :: temperature"        Daily mean temperature [degreeC]
      48             :   !>       \param[in] "REAL(dp) :: temperature_thresh" Threshold temperature for snow/rain [degreeC]
      49             :   !>       \param[in] "REAL(dp) :: thrfall"            Throughfall [m TS-1]
      50             : 
      51             :   !    INTENT(INOUT)
      52             :   !>       \param[inout] "REAL(dp) :: snow_pack" Snow pack [m]
      53             : 
      54             :   !    INTENT(OUT)
      55             :   !>       \param[out] "REAL(dp) :: deg_day"     Degree-day factor  [m s-1 degreeC-1]
      56             :   !>       \param[out] "REAL(dp) :: melt"        Melting snow depth [m TS-1]
      57             :   !>       \param[out] "REAL(dp) :: prec_effect" Effective precipitation depth (snow melt + rain) [m]
      58             :   !>       \param[out] "REAL(dp) :: rain"        Rain precipitation depth [m]
      59             :   !>       \param[out] "REAL(dp) :: snow"        Snow precipitation depth [m]
      60             : 
      61             :   !    HISTORY
      62             :   !>       \authors Vladyslav Prykhodko
      63             : 
      64             :   !>       \date Dec 2012
      65             : 
      66             :   ! Modifications:
      67             :   ! JM Aug 2013 - ordering of arguments changed
      68             :   ! Robert Schweppe Jun 2018 - refactoring and reformatting
      69             : 
      70    76647048 :   SUBROUTINE snow_accum_melt(deg_day_incr, deg_day_max, deg_day_noprec, prec, temperature, temperature_thresh, thrfall, &
      71             :                             snow_pack, deg_day, melt, prec_effect, rain, snow)
      72             :     implicit none
      73             : 
      74             :     ! Increase of the Degree-day factor per mm of increasein precipitation [s-1 degreeC-1]
      75             :     REAL(dp), INTENT(IN) :: deg_day_incr
      76             : 
      77             :     ! Maximum Degree-day factor [m-1 degreeC-1]
      78             :     REAL(dp), INTENT(IN) :: deg_day_max
      79             : 
      80             :     ! Degree-day factor with no precipitation [m-1 degreeC-1]
      81             :     REAL(dp), INTENT(IN) :: deg_day_noprec
      82             : 
      83             :     ! Daily mean precipitation [m]
      84             :     REAL(dp), INTENT(IN) :: prec
      85             : 
      86             :     ! Daily mean temperature [degreeC]
      87             :     REAL(dp), INTENT(IN) :: temperature
      88             : 
      89             :     ! Threshold temperature for snow/rain [degreeC]
      90             :     REAL(dp), INTENT(IN) :: temperature_thresh
      91             : 
      92             :     ! Throughfall [m TS-1]
      93             :     REAL(dp), INTENT(IN) :: thrfall
      94             : 
      95             :     ! Snow pack [m]
      96             :     REAL(dp), INTENT(INOUT) :: snow_pack
      97             : 
      98             :     ! Degree-day factor  [m s-1 degreeC-1]
      99             :     REAL(dp), INTENT(OUT) :: deg_day
     100             : 
     101             :     ! Melting snow depth [m TS-1]
     102             :     REAL(dp), INTENT(OUT) :: melt
     103             : 
     104             :     ! Effective precipitation depth (snow melt + rain) [m]
     105             :     REAL(dp), INTENT(OUT) :: prec_effect
     106             : 
     107             :     ! Rain precipitation depth [m]
     108             :     REAL(dp), INTENT(OUT) :: rain
     109             : 
     110             :     ! Snow precipitation depth [m]
     111             :     REAL(dp), INTENT(OUT) :: snow
     112             : 
     113             :     ! Auxiliary helping variable [-]
     114    76647048 :     REAL(dp) :: aux_help
     115             : 
     116             : 
     117             :     !separate throughfall into rain and snow
     118    76647048 :     if(temperature >  temperature_thresh) then
     119    67289328 :       snow = 0.0_dp
     120    67289328 :       rain = thrfall
     121             :     else
     122     9357720 :       snow = thrfall
     123     9357720 :       rain = 0.0_dp
     124             :     end if
     125             : 
     126             :     ! calculate degree daily factor
     127    76647048 :     if (prec <= (deg_day_max - deg_day_noprec) / deg_day_incr) then
     128    67486416 :       deg_day = deg_day_noprec + deg_day_incr * prec
     129             :     else
     130     9160632 :       deg_day = deg_day_max
     131             :     end if
     132             : 
     133             :     ! melting/snow accumulation
     134    76647048 :     if (temperature > temperature_thresh) then
     135             :       ! melting
     136    67289328 :       if (snow_pack > 0.0_dp) then
     137     1997478 :         aux_help = deg_day * (temperature - temperature_thresh)
     138     1997478 :         if (aux_help > snow_pack) then
     139       76551 :           melt = snow_pack
     140       76551 :           snow_pack = 0.0_dp
     141             :         else
     142     1920927 :           melt = aux_help
     143     1920927 :           snow_pack = snow_pack - aux_help
     144             :         end if
     145             :       else
     146    65291850 :         melt = 0.0_dp
     147    65291850 :         snow_pack = 0.0_dp
     148             :       end if
     149             :     else
     150             :       ! snow accumulation
     151     9357720 :       melt = 0.0_dp
     152     9357720 :       snow_pack = snow_pack + snow
     153             :     end if
     154             : 
     155             :     ! effective precipitation
     156    76647048 :     prec_effect = melt + rain
     157             : 
     158    76647048 :   END SUBROUTINE snow_accum_melt
     159             : 
     160             : END MODULE mo_snow_accum_melt

Generated by: LCOV version 1.16