Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3485)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3486)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix for liquid water treatment on pavements
+! 
+! 3361 2018-10-16 20:39:37Z knoop
 ! Bugfix in initialization of soil properties from dynamic input file
 ! 
@@ -479,4 +482,5 @@
 !>       more levels are used this may cause an potential bug
 !> @todo Routine calc_q_surface required?
+!> @todo Allow for precipitation water to enter pavements that are semi-pervious
 !------------------------------------------------------------------------------!
  MODULE land_surface_model_mod
@@ -2057,5 +2061,5 @@
           f_qsws_soil = 0.0_wp
           f_qsws_liq  = rho_lv / surf%r_a(m)
-       ELSEIF ( surf%pavement_surface (m) )  THEN
+       ELSEIF ( surf%pavement_surface(m) )  THEN
           f_qsws_veg  = 0.0_wp
           f_qsws_soil = 0.0_wp
@@ -2222,24 +2226,35 @@
 !--          Add precipitation to liquid water reservoir, if possible.
 !--          Otherwise, add the water to soil. In case of
-!--          pavements, the exceeding water amount is implicitely removed 
-!--          as runoff as qsws_soil is then not used in the soil model
-             IF ( surf_m_liq%var_1d(m) /= m_liq_max )  THEN
-                surf%qsws_liq(m) = surf%qsws_liq(m)                            &
+!--          pavements, the exceeding water amount is explicitly removed 
+!--          (as fictive runoff by drainage systems)
+             IF ( surf%pavement_surface(m) )  THEN
+                IF ( surf_m_liq%var_1d(m) < m_liq_max )  THEN
+                   surf%qsws_liq(m) = surf%qsws_liq(m)                         &
+                                 + prr(k+k_off,j+j_off,i+i_off)                &
+                                 * hyrho(k+k_off)                              &
+                                 * 0.001_wp * rho_l * l_v
+                ENDIF         
+             ELSE
+                IF ( surf_m_liq%var_1d(m) < m_liq_max )  THEN
+                   surf%qsws_liq(m) = surf%qsws_liq(m)                         &
                                  + surf%c_veg(m) * prr(k+k_off,j+j_off,i+i_off)&
                                  * hyrho(k+k_off)                              &
                                  * 0.001_wp * rho_l * l_v
-             ELSE
-                surf%qsws_soil(m) = surf%qsws_soil(m)                          &
+                   surf%qsws_soil(m) = surf%qsws_soil(m) + ( 1.0_wp -          &
+                                 surf%c_veg(m) ) * prr(k+k_off,j+j_off,i+i_off)&
+                                 * hyrho(k+k_off)                              &
+                                 * 0.001_wp * rho_l * l_v                                 
+                ELSE
+
+!--                Add precipitation to bare soil according to the bare soil
+!--                coverage.
+                   surf%qsws_soil(m) = surf%qsws_soil(m)                       &
                                  + surf%c_veg(m) * prr(k+k_off,j+j_off,i+i_off)&
                                  * hyrho(k+k_off)                              &
                                  * 0.001_wp * rho_l * l_v
+
+                ENDIF
              ENDIF
 
-!--          Add precipitation to bare soil according to the bare soil
-!--          coverage.
-             surf%qsws_soil(m) = surf%qsws_soil(m) + ( 1.0_wp                  &
-                               - surf%c_veg(m) ) * prr(k+k_off,j+j_off,i+i_off)&
-                               * hyrho(k+k_off)                                &
-                               * 0.001_wp * rho_l * l_v
           ENDIF
 
@@ -2249,10 +2264,11 @@
 !
 !--          Check if reservoir is full (avoid values > m_liq_max)
-!--          In that case, qsws_liq goes to qsws_soil. In this 
-!--          case qsws_veg is zero anyway (because c_liq = 1),       
+!--          In that case, qsws_liq goes to qsws_soil for pervious surfaces. In
+!--          this case qsws_veg is zero anyway (because c_liq = 1),       
 !--          so that tend is zero and no further check is needed
              IF ( surf_m_liq%var_1d(m) == m_liq_max )  THEN
-                surf%qsws_soil(m) = surf%qsws_soil(m) + surf%qsws_liq(m)
-
+                IF ( .NOT. surf%pavement_surface(m))  THEN
+                   surf%qsws_soil(m) = surf%qsws_soil(m) + surf%qsws_liq(m)
+                ENDIF
                 surf%qsws_liq(m)  = 0.0_wp
              ENDIF
@@ -5400,7 +5416,9 @@
    
 !
-!--                Account for dry soils (find a better solution here!)
+!--                Account for dry and wet soils to keep solution stable
+!--                (mass conservation is violated here)
                    DO  k = nzb_soil, nzt_soil
-                      IF ( surf_m_soil_p%var_2d(k,m) < 0.0_wp )  surf_m_soil_p%var_2d(k,m) = 0.0_wp
+                      surf_m_soil_p%var_2d(k,m) = MIN( surf_m_soil_p%var_2d(k,m), surf_m_soil_p%var_2d(k,m) )
+                      surf_m_soil_p%var_2d(k,m) = MAX( surf_m_soil_p%var_2d(k,m), 0.0_wp )                      
                    ENDDO
   
