Index: /palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4200)
+++ /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4201)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! - Limit soil moisture to its saturation moisture and give a respective 
+!   warning rather than an error.
+! - Perform checks for soil temperature only when there is no dynamic input
+!   file for the parent or possible child domains. 
+! 
+! 4194 2019-08-28 08:09:44Z suehring
 ! Apply more strict limitation of z0 over water surfaces in case it exceeds the 
 ! surface-layer height, in order to avoid instabilities. 
@@ -182,12 +188,22 @@
 
     USE netcdf_data_input_mod,                                                 &
-        ONLY :  building_type_f, init_3d,                                      &
+        ONLY :  building_type_f,                                               &
+                init_3d,                                                       &
+                input_file_dynamic,                                            &
                 input_pids_dynamic,                                            &
                 input_pids_static,                                             &
-                netcdf_data_input_interpolate, netcdf_data_input_init_lsm,     &
-                pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f,  &
-                root_area_density_lsm_f, soil_pars_f, soil_type_f,             &
-                surface_fraction_f, vegetation_pars_f, vegetation_type_f,      &
-                water_pars_f, water_type_f
+                netcdf_data_input_interpolate,                                 &
+                netcdf_data_input_init_lsm,                                    &
+                pavement_pars_f,                                               &
+                pavement_subsurface_pars_f,                                    &
+                pavement_type_f,                                               &
+                root_area_density_lsm_f,                                       &
+                soil_pars_f,                                                   &
+                soil_type_f,                                                   &
+                surface_fraction_f,                                            &
+                vegetation_pars_f,                                             &
+                vegetation_type_f,                                             &
+                water_pars_f,                                                  &
+                water_type_f
 
     USE kinds
@@ -992,4 +1008,6 @@
     INTEGER(iwp) ::  j        !< running index, y-dimension
     INTEGER(iwp) ::  k        !< running index, z-dimension
+    
+    LOGICAL      ::  dynamic_soil_input_parent !< flag indicating the presence of a dynamic input file for the parent
 
 !
@@ -1392,6 +1410,13 @@
 
 !
-!-- Check whether valid soil temperatures are prescribed
-    IF ( .NOT. input_pids_dynamic )  THEN
+!-- Check whether valid soil temperatures are prescribed. Only check this if 
+!-- no dynamic soil is not initialized with dynamic input.
+!-- In a nested case, check whether there is a dynamic input file for the 
+!-- child (input_pids_dynamic = .T.) or one for the parent (inquire without
+!-- coupling_char. 
+    INQUIRE( FILE = TRIM( input_file_dynamic ),                                &
+             EXIST = dynamic_soil_input_parent )
+
+    IF ( .NOT. input_pids_dynamic  .AND.  .NOT. dynamic_soil_input_parent )  THEN
        IF ( COUNT( soil_temperature /= 9999999.9_wp ) /= nzs )  THEN
           WRITE( message_string, * )                                           &
@@ -1412,12 +1437,14 @@
 !
 !-- Check whether the sum of all root fractions equals one
-    IF ( vegetation_type == 0 )  THEN
-       IF ( SUM( root_fraction(nzb_soil:nzt_soil) ) /= 1.0_wp )  THEN
-          message_string = 'vegetation_type = 0 (user_defined)'//              &
-                           'requires setting of root_fraction'//               &
-                           '/= 9999999.9 and SUM(root_fraction) = 1'
-          CALL message( 'lsm_check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
+    IF ( .NOT. vegetation_type_f%from_file )  THEN
+       IF ( vegetation_type == 0 )  THEN
+          IF ( SUM( root_fraction(nzb_soil:nzt_soil) ) /= 1.0_wp )  THEN
+             message_string = 'vegetation_type = 0 (user_defined)'//           &
+                              'requires setting of root_fraction'//            &
+                              '/= 9999999.9 and SUM(root_fraction) = 1'
+             CALL message( 'lsm_check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
+          ENDIF
        ENDIF
-    ENDIF     
+    ENDIF
 !
 !-- Calculate grid spacings. Temperature and moisture are defined at
@@ -4303,6 +4330,8 @@
 !
 !--       After soil moisture and temperature are finally initialized, check 
-!--       if soil moisture is higher than its saturation value. Else, this 
-!--       will produce floating point errors in the soil model parametrization.
+!--       if soil moisture is higher than its saturation value. If this would 
+!--       be the case, the soil model parametrization will produce floating 
+!--       point errors. Hence, limit the soil moisture to its saturation value
+!--       and give a warning. 
           DO  m = 1, surf_lsm_h%ns
              IF ( surf_lsm_h%vegetation_surface(m)  .OR.                       &
@@ -4310,8 +4339,10 @@
                 DO  k = nzb_soil, nzt_soil
                    IF ( m_soil_h%var_2d(k,m) > surf_lsm_h%m_sat(k,m) )  THEN
+                      m_soil_h%var_2d(k,m) = surf_lsm_h%m_sat(k,m)
                       WRITE( message_string, * ) 'soil moisture is higher '//  &
                             'than its saturation value at (k,j,i) ', k,        &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-                      CALL message( 'lsm_init', 'PA0458', 2, 2, myid, 6, 0 )
+                            surf_lsm_h%i(m), surf_lsm_h%j(m), ' and is ' //    &
+                            'thus limited to this value to maintain stability.'
+                      CALL message( 'lsm_init', 'PA0458', 0, 1, myid, 6, 0 )
                    ENDIF               
                 ENDDO
@@ -4325,9 +4356,12 @@
                       IF ( m_soil_v(l)%var_2d(k,m) > surf_lsm_v(l)%m_sat(k,m) )&
                       THEN
+                         m_soil_v(l)%var_2d(k,m) = surf_lsm_v(l)%m_sat(k,m)
                          WRITE( message_string, * )                            &
-                            'soil moisture is higher than ' //                 &
-                            'its saturation value at (k,j,i) ', k,             &
-                            surf_lsm_v(l)%i(m), surf_lsm_v(l)%j(m)
-                         CALL message( 'lsm_init', 'PA0458', 2, 2, myid, 6, 0 )                   
+                            'soil moisture is higher '//                       &
+                            'than its saturation value at (k,j,i) ', k,        &
+                            surf_lsm_v(l)%i(m), surf_lsm_v(l)%j(m),            &
+                            ' and is ' //                                      &
+                            'thus limited to this value to maintain stability.'
+                         CALL message( 'lsm_init', 'PA0458', 0, 1, myid, 6, 0 )                   
                       ENDIF
                    ENDDO
