Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3963)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 3964)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! In a nested child domain, distinguish between soil moisture and temperature 
+! initialization from parent via dynamic input file. Further, initialize soil
+! moisture/temperature from dynamic input file only when initialization via
+! 'inifor' is desired.
+! 
+! 3943 2019-05-02 09:50:41Z maronga
 ! Removed extra blank character
 ! 
@@ -2636,5 +2642,6 @@
        IMPLICIT NONE
 
-       LOGICAL      ::  init_soil_from_parent   !< flag controlling initialization of soil in child domains
+       LOGICAL      ::  init_msoil_from_parent   !< flag controlling initialization of soil moisture in nested child domains
+       LOGICAL      ::  init_tsoil_from_parent   !< flag controlling initialization of soil temperature in nested child domains
 
        INTEGER(iwp) ::  i                       !< running index
@@ -4356,6 +4363,7 @@
        IF (  TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
 !
-!--       Read soil properties from dynamic input file
-          CALL netcdf_data_input_init_lsm
+!--       Read soil properties from dynamic input file. 
+          IF ( INDEX( initializing_actions, 'inifor' ) /= 0 )                  &
+             CALL netcdf_data_input_init_lsm
 !
 !--       In case no dynamic input is available for a child domain but root 
@@ -4363,11 +4371,15 @@
 !--       properties can lead to significant discrepancies in the atmospheric 
 !--       surface forcing. For this reason, the child domain
-!--       is initialized with mean soil profiles from the root domain.          
-          init_soil_from_parent = .FALSE. 
+!--       is initialized with mean soil profiles from the root domain, even if
+!--       no initialization with inifor is set. 
+          init_tsoil_from_parent = .FALSE. 
+          init_msoil_from_parent = .FALSE. 
           IF ( nested_run )  THEN
 #if defined( __parallel )
-             CALL MPI_ALLREDUCE( init_3d%from_file_tsoil  .OR.                 &
-                                 init_3d%from_file_msoil,                      &
-                                 init_soil_from_parent,                        &
+             CALL MPI_ALLREDUCE( init_3d%from_file_tsoil,                      &
+                                 init_tsoil_from_parent,                       &
+                                 1, MPI_LOGICAL, MPI_LOR, MPI_COMM_WORLD, ierr )
+             CALL MPI_ALLREDUCE( init_3d%from_file_msoil,                      &
+                                 init_msoil_from_parent,                       &
                                  1, MPI_LOGICAL, MPI_LOR, MPI_COMM_WORLD, ierr )
 #endif
@@ -4407,5 +4419,5 @@
 !--       transfer soil mean profiles from the root-parent domain onto all 
 !--       child domains.
-          IF ( init_soil_from_parent )  THEN
+          IF ( init_msoil_from_parent )  THEN
 !
 !--          Child domains will be only initialized with horizontally 
@@ -4434,4 +4446,6 @@
                 DEALLOCATE( pr_soil_init )
              ENDIF
+          ENDIF
+          IF ( init_tsoil_from_parent )  THEN
              IF ( init_3d%from_file_tsoil  .AND.  init_3d%lod_tsoil == 2 )  THEN
                 ALLOCATE( pr_soil_init(0:init_3d%nzs-1) )
@@ -4455,24 +4469,28 @@
 
              ENDIF
-
-#if defined( __parallel )
+          ENDIF
+          IF ( init_msoil_from_parent  .OR.  init_tsoil_from_parent )  THEN
 !
 !--          Distribute soil grid information on file from root to all childs.
 !--          Only process with rank 0 sends the information. 
+#if defined( __parallel )
              CALL MPI_BCAST( init_3d%nzs,    1,                                &
                              MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
+#endif
 
              IF ( .NOT.  ALLOCATED( init_3d%z_soil ) )                         &
                 ALLOCATE( init_3d%z_soil(1:init_3d%nzs) )
-
+#if defined( __parallel )
              CALL MPI_BCAST( init_3d%z_soil, SIZE(init_3d%z_soil),             &
                              MPI_REAL, 0, MPI_COMM_WORLD, ierr )
 #endif
-!
-!--          ALLOCATE arrays on child domains and set control attributes.
-!--          Note, 1d soil profiles are allocated even though soil information
-!--          is already read from dynamic file in one child domain. 
-!--          This case, however, data is not used for further initialization 
-!--          since the LoD=2. 
+          ENDIF
+!
+!--       ALLOCATE arrays on child domains and set control attributes.
+!--       Note, 1d soil profiles are allocated even though soil information
+!--       is already read from dynamic file in one child domain. 
+!--       This case, however, data is not used for further initialization 
+!--       since the LoD=2. 
+          IF ( init_msoil_from_parent )  THEN
              IF ( .NOT. ALLOCATED( init_3d%msoil_1d ) )  THEN
                 ALLOCATE( init_3d%msoil_1d(0:init_3d%nzs-1) )
@@ -4480,4 +4498,6 @@
                 init_3d%from_file_msoil = .TRUE.
              ENDIF
+          ENDIF
+          IF ( init_tsoil_from_parent )  THEN
              IF ( .NOT. ALLOCATED( init_3d%tsoil_1d ) )  THEN
                 ALLOCATE( init_3d%tsoil_1d(0:init_3d%nzs-1) )
@@ -4485,15 +4505,19 @@
                 init_3d%from_file_tsoil = .TRUE.
              ENDIF
-
-
+          ENDIF
+!
+!--       Distribute soil profiles from root to all childs
+          IF ( init_msoil_from_parent )  THEN
 #if defined( __parallel )
-!
-!--          Distribute soil profiles from root to all childs
              CALL MPI_BCAST( init_3d%msoil_1d, SIZE(init_3d%msoil_1d),         &
                              MPI_REAL, 0, MPI_COMM_WORLD, ierr )
+#endif
+                    
+          ENDIF
+          IF ( init_tsoil_from_parent )  THEN
+#if defined( __parallel )
              CALL MPI_BCAST( init_3d%tsoil_1d, SIZE(init_3d%tsoil_1d),         &
                              MPI_REAL, 0, MPI_COMM_WORLD, ierr )
 #endif
-
           ENDIF
 !
Index: palm/trunk/SOURCE/nesting_offl_mod.f90
===================================================================
--- palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 3963)
+++ palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 3964)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Ensure that veloctiy term in calculation of bulk Richardson number does not
+! become zero
+! 
+! 3937 2019-04-29 15:09:07Z suehring
 ! Set boundary conditon on upper-left and upper-south grid point for the u- and
 ! v-component, respectively.
@@ -900,4 +904,8 @@
 !--          Note, no interpolation of u- and v-component is made, as both 
 !--          are mainly mean inflow profiles with very small spatial variation. 
+!--          Add a safety factor in case the velocity term becomes zero. This
+!--          may happen if overhanging 3D structures are directly located at
+!--          the boundary, where velocity inside the building is zero 
+!--          (k_surface is the index of the lowest upward-facing surface).
              zi_local = 0.0_wp
              DO  k = k_surface+1, nzt
@@ -906,5 +914,5 @@
                 ri_bulk = zu(k) * g / vpt_surface *                            &
                           ( vpt_col(k) - vpt_surface ) /                       &
-                          ( u_comp * u_comp + v_comp * v_comp ) 
+                          ( u_comp * u_comp + v_comp * v_comp + 1E-5_wp ) 
                        
                 IF ( zi_local == 0.0_wp  .AND.  ri_bulk > ri_bulk_crit )       &
@@ -943,5 +951,5 @@
                 ri_bulk = zu(k) * g / vpt_surface *                            &
                        ( vpt_col(k) - vpt_surface ) /                          &
-                       ( u_comp * u_comp + v_comp * v_comp ) 
+                       ( u_comp * u_comp + v_comp * v_comp + 1E-5_wp ) 
                        
                 IF ( zi_local == 0.0_wp  .AND.  ri_bulk > 0.25_wp )            &
Index: palm/trunk/SOURCE/pmc_child_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_child_mod.f90	(revision 3963)
+++ palm/trunk/SOURCE/pmc_child_mod.f90	(revision 3964)
@@ -21,9 +21,12 @@
 ! Current revisions:
 ! ------------------
-! Remove unused variable
+! 
 ! 
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Remove unused variable
+! 
+! 3963 2019-05-08 20:09:11Z suehring
 ! Bugfixes in initial settings of child and parent communication patterns. 
 !
