Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4360)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4381)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! - Bugfix in nested soil initialization in case no dynamic input file is 
+!   present
+! - In order to do not mess-up the job-protocoll, give error messages 503, 507 
+!   and 508 only once
+! 
+! 4360 2020-01-07 11:25:50Z suehring
 ! Fix wrong location string in message call
 ! 
@@ -2347,6 +2353,13 @@
 #if defined( __parallel )
        INTEGER(iwp) ::  nzs_root                !< number of soil layers in root domain (used in case soil data needs to be
-                                                !< transferred from root model to child models)   
-                                                
+                                                !< transferred from root model to child models)
+
+       LOGICAL      ::  init_msoil_from_driver_root !< flag indicating that msoil in root is initialized from dynamic file
+       LOGICAL      ::  init_tsoil_from_driver_root !< flag indicating that tsoil in root is initialized from dynamic file
+#endif
+       LOGICAL      ::  flag_exceed_z0              !< dummy flag to indicate whether roughness length is too high
+       LOGICAL      ::  flag_exceed_z0h             !< dummy flag to indicate whether roughness length for scalars is too high
+
+#if defined( __parallel )
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  m_soil_root    !< domain-averaged soil moisture profile in root domain 
        REAL(wp), DIMENSION(:), ALLOCATABLE ::  t_soil_root    !< domain-averaged soil temperature profile in root domain
@@ -4293,120 +4306,145 @@
 #if defined( __parallel )
 !
+!--          Check if soil moisture and temperature in the root model are 
+!--          initialized from dynamic input. This case, distribute these 
+!--          information to its child domain(s).
+             IF ( pmc_is_rootmodel() )  THEN
+                init_msoil_from_driver_root = init_3d%from_file_msoil 
+                init_tsoil_from_driver_root = init_3d%from_file_tsoil
+             ENDIF
+
+             CALL MPI_BCAST( init_msoil_from_driver_root, 1, MPI_LOGICAL,      &
+                             0, MPI_COMM_WORLD, ierr )
+             CALL MPI_BCAST( init_tsoil_from_driver_root, 1, MPI_LOGICAL,      &
+                             0, MPI_COMM_WORLD, ierr )
+!
 !--          In case of a nested run, first average the soil profiles in the 
 !--          root domain.
-             IF ( pmc_is_rootmodel() )  THEN
-!            
-!--             Child domains will be only initialized with horizontally 
-!--             averaged soil profiles in parent domain (for sake of simplicity). 
-!--             If required, average soil data on root parent domain before the 
-!--             soil profiles are distributed onto the child domains.
-!--             Start with soil moisture.
-                IF ( init_3d%from_file_msoil  .AND.  init_3d%lod_msoil == 2 )  &
-                THEN
-                   ALLOCATE( pr_soil_init(0:init_3d%nzs-1) )
-                   DO  k = 0, init_3d%nzs-1
-                      pr_soil_init(k) = SUM( init_3d%msoil_3d(k,nys:nyn,nxl:nxr)  )
-                   ENDDO
-!            
-!--                Allocate 1D array for soil-moisture profile (will not be 
-!--                allocated in lod==2 case). 
-                   ALLOCATE( init_3d%msoil_1d(0:init_3d%nzs-1) )
-                   init_3d%msoil_1d = 0.0_wp
-                   CALL MPI_ALLREDUCE( pr_soil_init(0), init_3d%msoil_1d(0),   &
-                                       SIZE(pr_soil_init),                     &
-                                       MPI_REAL, MPI_SUM, comm2d, ierr )
-             
-                   init_3d%msoil_1d = init_3d%msoil_1d /                       &
+             IF ( init_msoil_from_driver_root  .OR.                            &
+                  init_tsoil_from_driver_root )  THEN
+
+                IF ( pmc_is_rootmodel() )  THEN
+!
+!--                Child domains will be only initialized with horizontally 
+!--                averaged soil profiles in parent domain (for sake of simplicity). 
+!--                If required, average soil data on root parent domain before the 
+!--                soil profiles are distributed onto the child domains.
+!--                Start with soil moisture.
+                   IF ( init_3d%from_file_msoil  .AND.                         &
+                        init_3d%lod_msoil == 2 )  THEN
+                      ALLOCATE( pr_soil_init(0:init_3d%nzs-1) )
+                      DO  k = 0, init_3d%nzs-1
+                         pr_soil_init(k) = SUM( init_3d%msoil_3d(k,nys:nyn,nxl:nxr)  )
+                      ENDDO
+!               
+!--                   Allocate 1D array for soil-moisture profile (will not be 
+!--                   allocated in lod==2 case). 
+                      ALLOCATE( init_3d%msoil_1d(0:init_3d%nzs-1) )
+                      init_3d%msoil_1d = 0.0_wp
+                      CALL MPI_ALLREDUCE( pr_soil_init(0), init_3d%msoil_1d(0),&
+                                          SIZE(pr_soil_init),                  &
+                                          MPI_REAL, MPI_SUM, comm2d, ierr )
+                
+                      init_3d%msoil_1d = init_3d%msoil_1d /                    &
                                         REAL( ( nx + 1 ) * ( ny + 1), KIND=wp )
-                   DEALLOCATE( pr_soil_init )
-                ENDIF
-! 
-!--             Proceed with soil temperature.
-                IF ( init_3d%from_file_tsoil  .AND.  init_3d%lod_tsoil == 2 )  &
-                THEN
-                   ALLOCATE( pr_soil_init(0:init_3d%nzs-1) )
-             
-                   DO  k = 0, init_3d%nzs-1
-                      pr_soil_init(k) = SUM( init_3d%tsoil_3d(k,nys:nyn,nxl:nxr)  )
-                   ENDDO
-!            
-!--                Allocate 1D array for soil-temperature profile (will not be 
-!--                allocated in lod==2 case). 
-                   ALLOCATE( init_3d%tsoil_1d(0:init_3d%nzs-1) )
-                   init_3d%tsoil_1d = 0.0_wp
-                   CALL MPI_ALLREDUCE( pr_soil_init(0), init_3d%tsoil_1d(0),   &
-                                       SIZE(pr_soil_init),                     &
-                                       MPI_REAL, MPI_SUM, comm2d, ierr )
-                   init_3d%tsoil_1d = init_3d%tsoil_1d /                       &
+                      DEALLOCATE( pr_soil_init )
+                   ENDIF
+!               
+!--                Proceed with soil temperature.
+                   IF ( init_3d%from_file_tsoil  .AND.                         &
+                        init_3d%lod_tsoil == 2 )  THEN
+                      ALLOCATE( pr_soil_init(0:init_3d%nzs-1) )
+                
+                      DO  k = 0, init_3d%nzs-1
+                         pr_soil_init(k) = SUM( init_3d%tsoil_3d(k,nys:nyn,nxl:nxr)  )
+                      ENDDO
+!               
+!--                   Allocate 1D array for soil-temperature profile (will not be 
+!--                   allocated in lod==2 case). 
+                      ALLOCATE( init_3d%tsoil_1d(0:init_3d%nzs-1) )
+                      init_3d%tsoil_1d = 0.0_wp
+                      CALL MPI_ALLREDUCE( pr_soil_init(0), init_3d%tsoil_1d(0),&
+                                          SIZE(pr_soil_init),                  &
+                                          MPI_REAL, MPI_SUM, comm2d, ierr )
+                      init_3d%tsoil_1d = init_3d%tsoil_1d /                    &
                                         REAL( ( nx + 1 ) * ( ny + 1), KIND=wp )
-                   DEALLOCATE( pr_soil_init )
-             
-                ENDIF
-             ENDIF
-!
-!--          Broadcast number of soil layers in root model to all childs. 
-!--          Note, only process 0 in COMM_WORLD is sending. 
-             IF ( pmc_is_rootmodel() )  nzs_root = init_3d%nzs
-             
-             CALL MPI_BCAST( nzs_root, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
-!            
-!--          Allocate dummy arrays for soil moisture and temperature profiles 
-!--          on all domains.             
-             ALLOCATE( z_soil_root(1:nzs_root)   )
-             ALLOCATE( m_soil_root(0:nzs_root-1) )
-             ALLOCATE( t_soil_root(0:nzs_root-1) )
-!
-!--          Distribute the mean soil profiles to all child domains.
-             IF ( pmc_is_rootmodel() )  THEN
-                z_soil_root = init_3d%z_soil
-                m_soil_root = init_3d%msoil_1d
-                t_soil_root = init_3d%tsoil_1d
-             ENDIF
-             
-             CALL MPI_BCAST( z_soil_root, SIZE( z_soil_root ),                 &
-                             MPI_REAL, 0, MPI_COMM_WORLD, ierr )               
-             CALL MPI_BCAST( m_soil_root, SIZE( m_soil_root ),                 &
-                             MPI_REAL, 0, MPI_COMM_WORLD, ierr )               
-             CALL MPI_BCAST( t_soil_root, SIZE( t_soil_root ),                 &
-                             MPI_REAL, 0, MPI_COMM_WORLD, ierr )
-!
-!--          In the following, the child domains decide whether they take
-!--          the information from the root domain or not. 
-             IF ( .NOT. pmc_is_rootmodel() )  THEN
-!
-!--             If soil moisture or temperature isn't in dynamic input file for
-!--             the child, take the information provided from the root model. 
-!--             Start with z-dimension
-                IF ( .NOT. init_3d%from_file_msoil  .OR.                       &
-                     .NOT. init_3d%from_file_msoil    )  THEN
-                   init_3d%nzs = nzs_root
-                   ALLOCATE( init_3d%z_soil(1:init_3d%nzs) )
-                   init_3d%z_soil(1:init_3d%nzs) = z_soil_root
+                      DEALLOCATE( pr_soil_init )
+                
+                   ENDIF
                 ENDIF
 !               
-!--             Take soil moisture. Note, control flags from_file... and LoD 
-!--             need to be set. 
-                IF ( .NOT. init_3d%from_file_msoil )  THEN
-                   ALLOCATE( init_3d%msoil_1d(0:init_3d%nzs-1) )
-                   init_3d%lod_msoil = 1
-                   init_3d%from_file_msoil = .TRUE.
-                   
-                   init_3d%msoil_1d = m_soil_root             
+!--             Broadcast number of soil layers in root model to all childs. 
+!--             Note, only process 0 in COMM_WORLD is sending. 
+                IF ( pmc_is_rootmodel() )  nzs_root = init_3d%nzs
+                
+                CALL MPI_BCAST( nzs_root, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr )
+!               
+!--             Allocate dummy arrays for soil moisture and temperature profiles 
+!--             on all domains.             
+                ALLOCATE( z_soil_root(1:nzs_root)   )
+                IF ( init_msoil_from_driver_root )                             &
+                   ALLOCATE( m_soil_root(0:nzs_root-1) )
+                IF ( init_tsoil_from_driver_root )                             &
+                   ALLOCATE( t_soil_root(0:nzs_root-1) )
+!
+!--             Distribute the mean soil profiles to all child domains.
+                IF ( pmc_is_rootmodel() )  THEN
+                   z_soil_root = init_3d%z_soil
+                   IF ( init_msoil_from_driver_root )                          &
+                      m_soil_root = init_3d%msoil_1d
+                   IF ( init_tsoil_from_driver_root )                          &
+                      t_soil_root = init_3d%tsoil_1d
                 ENDIF
+
+                CALL MPI_BCAST( z_soil_root, SIZE( z_soil_root ),              &
+                                MPI_REAL, 0, MPI_COMM_WORLD, ierr )
+
+                IF ( init_msoil_from_driver_root )                             &
+                   CALL MPI_BCAST( m_soil_root, SIZE( m_soil_root ),           &
+                                   MPI_REAL, 0, MPI_COMM_WORLD, ierr )
+
+                IF ( init_msoil_from_driver_root )                             &
+                   CALL MPI_BCAST( t_soil_root, SIZE( t_soil_root ),           &
+                                   MPI_REAL, 0, MPI_COMM_WORLD, ierr )
+!
+!--             In the following, the child domains decide whether they take
+!--             the information from the root domain or not. 
+                IF ( .NOT. pmc_is_rootmodel() )  THEN
 !               
-!--             Take soil temperature. Note, control flags from_file... and LoD 
-!--             need to be set. 
-                IF (  .NOT. init_3d%from_file_tsoil )  THEN
-                   ALLOCATE( init_3d%tsoil_1d(0:init_3d%nzs-1) )
-                   init_3d%lod_tsoil = 1
-                   init_3d%from_file_tsoil = .TRUE.
-                   
-                   init_3d%tsoil_1d = t_soil_root  
+!--                If soil moisture or temperature isn't in dynamic input file for
+!--                the child, take the information provided from the root model. 
+!--                Start with z-dimension
+                   IF ( .NOT. init_3d%from_file_msoil  .OR.                    &
+                        .NOT. init_3d%from_file_msoil    )  THEN
+                      init_3d%nzs = nzs_root
+                      ALLOCATE( init_3d%z_soil(1:init_3d%nzs) )
+                      init_3d%z_soil(1:init_3d%nzs) = z_soil_root
+                   ENDIF
+!                  
+!--                Take soil moisture. Note, control flags from_file... and LoD 
+!--                need to be set. 
+                   IF ( .NOT. init_3d%from_file_msoil )  THEN
+                      ALLOCATE( init_3d%msoil_1d(0:init_3d%nzs-1) )
+                      init_3d%lod_msoil = 1
+                      init_3d%from_file_msoil = .TRUE.
+                      
+                      init_3d%msoil_1d = m_soil_root             
+                   ENDIF
+!                  
+!--                Take soil temperature. Note, control flags from_file... and LoD 
+!--                need to be set. 
+                   IF (  .NOT. init_3d%from_file_tsoil )  THEN
+                      ALLOCATE( init_3d%tsoil_1d(0:init_3d%nzs-1) )
+                      init_3d%lod_tsoil = 1
+                      init_3d%from_file_tsoil = .TRUE.
+                      
+                      init_3d%tsoil_1d = t_soil_root  
+                   ENDIF
                 ENDIF
+                
+                DEALLOCATE( z_soil_root )
+                DEALLOCATE( m_soil_root )
+                DEALLOCATE( t_soil_root )
              ENDIF
-             
-             DEALLOCATE( z_soil_root )
-             DEALLOCATE( m_soil_root )
-             DEALLOCATE( t_soil_root )
           ENDIF
 #endif
@@ -4878,60 +4916,75 @@
 !--    Check if roughness length for momentum, heat, or moisture exceed 
 !--    surface-layer height and decrease local roughness length where 
-!--    necessary. 
+!--    necessary. This case, give an informative message. Note, to avoid
+!--    that the job-protocoll is messed-up, this message is only given once.
+       flag_exceed_z0  = .FALSE.
+       flag_exceed_z0h = .FALSE.
        DO  m = 1, surf_lsm_h%ns
           IF ( surf_lsm_h%z0(m) > 0.5_wp * surf_lsm_h%z_mo(m) )  THEN
-          
              surf_lsm_h%z0(m) = 0.5_wp * surf_lsm_h%z_mo(m)
-             
-             WRITE( message_string, * ) 'z0 exceeds surface-layer height ' //  &
-                            'at horizontal natural surface and is ' //         &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-             CALL message( 'land_surface_model_mod', 'PA0503',                 &
-                            0, 0, myid, 6, 0 )
+             flag_exceed_z0   = .TRUE.
           ENDIF
           IF ( surf_lsm_h%z0h(m) > 0.5_wp * surf_lsm_h%z_mo(m) )  THEN
-          
              surf_lsm_h%z0h(m) = 0.5_wp * surf_lsm_h%z_mo(m)
              surf_lsm_h%z0q(m) = 0.5_wp * surf_lsm_h%z_mo(m)
-             
-             WRITE( message_string, * ) 'z0h exceeds surface-layer height ' // &
-                            'at horizontal natural surface and is ' //         &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-             CALL message( 'land_surface_model_mod', 'PA0507',                 &
-                            0, 0, myid, 6, 0 )
+             flag_exceed_z0h   = .TRUE.
           ENDIF
        ENDDO
-       
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0, 1, MPI_LOGICAL,       &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0 )  THEN
+          WRITE( message_string, * ) 'z0 exceeds surface-layer height ' //     &
+                                     'at horizontal natural surface(s) and '// &
+                                     'is decreased appropriately'
+          CALL message( 'land_surface_model_mod', 'PA0503', 0, 0, 0, 6, 0 )
+       ENDIF
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0h, 1, MPI_LOGICAL,      &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0h )  THEN
+          WRITE( message_string, * ) 'z0h exceeds surface-layer height ' //    &
+                                     'at horizontal natural surface(s) and '// &
+                                     'is decreased appropriately.'
+          CALL message( 'land_surface_model_mod', 'PA0507', 0, 0, 0, 6, 0 )
+       ENDIF
+
+       flag_exceed_z0  = .FALSE.
+       flag_exceed_z0h = .FALSE.
        DO  l = 0, 3
           DO  m = 1, surf_lsm_v(l)%ns
              IF ( surf_lsm_v(l)%z0(m) > 0.5_wp * surf_lsm_v(l)%z_mo(m) )  THEN
-          
                 surf_lsm_v(l)%z0(m) = 0.5_wp * surf_lsm_v(l)%z_mo(m)
-             
-                WRITE( message_string, * ) 'z0 exceeds surface-layer height '//&
-                            'at vertical natural surface and is ' //           &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_v(l)%i(m)+surf_lsm_v(l)%ioff,             &
-                            surf_lsm_v(l)%j(m)+surf_lsm_v(l)%joff
-                CALL message( 'land_surface_model_mod', 'PA0503',              &
-                            0, 0, myid, 6, 0 )
+                flag_exceed_z0      = .TRUE.
              ENDIF
              IF ( surf_lsm_v(l)%z0h(m) > 0.5_wp * surf_lsm_v(l)%z_mo(m) )  THEN
-          
                 surf_lsm_v(l)%z0h(m) = 0.5_wp * surf_lsm_v(l)%z_mo(m)
                 surf_lsm_v(l)%z0q(m) = 0.5_wp * surf_lsm_v(l)%z_mo(m)
-             
-                WRITE( message_string, * ) 'z0h exceeds surface-layer height '//&
-                            'at vertical natural surface and is ' //           &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_v(l)%i(m)+surf_lsm_v(l)%ioff,             &
-                            surf_lsm_v(l)%j(m)+surf_lsm_v(l)%joff
-                CALL message( 'land_surface_model_mod', 'PA0507',              &
-                            0, 0, myid, 6, 0 )
+                flag_exceed_z0h      = .TRUE.
              ENDIF
           ENDDO
        ENDDO
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0, 1, MPI_LOGICAL,       &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0 )  THEN
+          WRITE( message_string, * ) 'z0 exceeds surface-layer height ' //     &
+                                     'at vertical natural surface(s) and '//   &
+                                     'is decreased appropriately'
+          CALL message( 'land_surface_model_mod', 'PA0503', 0, 0, 0, 6, 0 )
+       ENDIF
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0h, 1, MPI_LOGICAL,      &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0h )  THEN
+          WRITE( message_string, * ) 'z0h exceeds surface-layer height ' //    &
+                                     'at vertical natural surface(s) and '//   &
+                                     'is decreased appropriately.'
+          CALL message( 'land_surface_model_mod', 'PA0507', 0, 0, 0, 6, 0 )
+       ENDIF
 
        IF ( debug_output )  CALL debug_message( 'lsm_init', 'end' )
@@ -7201,11 +7254,13 @@
 
        USE control_parameters,                                                 &
-           ONLY: message_string, molecular_viscosity
-
-       IMPLICIT NONE
+           ONLY:  message_string,                                              &
+                  molecular_viscosity
 
        INTEGER(iwp) ::  i       !< running index
        INTEGER(iwp) ::  j       !< running index
        INTEGER(iwp) ::  m       !< running index
+       
+       LOGICAL      ::  flag_exceed_z0  = .FALSE. !< dummy flag to indicate whether roughness length is too high
+       LOGICAL      ::  flag_exceed_z0h = .FALSE. !< dummy flag to indicate whether roughness length for scalars is too high
 
        REAL(wp), PARAMETER :: alpha_ch  = 0.018_wp !< Charnock constant (0.01-0.11). Use 0.01 for FLake and 0.018 for ECMWF
@@ -7255,39 +7310,18 @@
                                  ( surf_lsm_h%us(m) + 1E-8_wp )
 
-  
+
              IF ( surf_lsm_h%z0(m) > 0.1_wp * surf_lsm_h%z_mo(m) )  THEN
-  
                 surf_lsm_h%z0(m) = 0.1_wp * surf_lsm_h%z_mo(m)
-             
-                WRITE( message_string, * ) 'z0 exceeds surface-layer height' //&
-                            ' at horizontal sea surface and is ' //            &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-                CALL message( 'land_surface_model_mod', 'PA0508',              &
-                              0, 0, myid, 6, 0 )
+                flag_exceed_z0   = .TRUE.
              ENDIF
-  
+
              IF ( surf_lsm_h%z0h(m) >= 0.1_wp * surf_lsm_h%z_mo(m) )  THEN
-  
                 surf_lsm_h%z0h(m) = 0.1_wp * surf_lsm_h%z_mo(m)
-             
-                WRITE( message_string, * ) 'z0h exceeds surface-layer height'//&
-                            ' at horizontal sea surface and is ' //            &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-                CALL message( 'land_surface_model_mod', 'PA0508',              &
-                              0, 0, myid, 6, 0 )
+                flag_exceed_z0h   = .TRUE.
              ENDIF
-             
+
              IF ( surf_lsm_h%z0q(m) >= 0.1_wp * surf_lsm_h%z_mo(m) )  THEN
-  
                 surf_lsm_h%z0q(m) = 0.1_wp * surf_lsm_h%z_mo(m)
-             
-                WRITE( message_string, * ) 'z0q exceeds surface-layer height'//&
-                            ' at horizontal sea surface and is ' //            &
-                            'decreased appropriately at grid point (i,j) = ',  &
-                            surf_lsm_h%i(m), surf_lsm_h%j(m)
-                CALL message( 'land_surface_model_mod', 'PA0508',              &
-                              0, 0, myid, 6, 0 )
+                flag_exceed_z0h   = .TRUE.
              ENDIF
   
@@ -7295,4 +7329,24 @@
           ENDIF
        ENDDO
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0, 1, MPI_LOGICAL,       &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0 )  THEN
+          WRITE( message_string, * ) 'z0 exceeds surface-layer height ' //     &
+                                     'at horizontal sea surface(s) and ' //    &
+                                     'is decreased appropriately'
+          CALL message( 'land_surface_model_mod', 'PA0508', 0, 0, 0, 6, 0 )
+       ENDIF
+#if defined( __parallel )
+       CALL MPI_ALLREDUCE( MPI_IN_PLACE, flag_exceed_z0h, 1, MPI_LOGICAL,      &
+                           MPI_LOR, comm2d, ierr)
+#endif
+       IF ( flag_exceed_z0h )  THEN
+          WRITE( message_string, * ) 'z0h/q exceeds surface-layer height ' //  &
+                                     'at horizontal sea surface(s) and ' //    &
+                                     'is decreased appropriately'
+          CALL message( 'land_surface_model_mod', 'PA0508', 0, 0, 0, 6, 0 )
+       ENDIF
 
     END SUBROUTINE calc_z0_water_surface
