Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 4156)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 4159)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Surface classification revised and adjusted to changes in init_grid
+! 
+! 4156 2019-08-14 09:18:14Z schwenkel
 ! Bugfix in case of cloud microphysics morrison
 ! 
@@ -939,4 +942,6 @@
        LOGICAL ::  building                       !< flag indicating building grid point
        LOGICAL ::  terrain                        !< flag indicating natural terrain grid point
+       LOGICAL ::  unresolved_building            !< flag indicating a grid point where actually a building is 
+                                                  !< defined but not resolved by the vertical grid 
 
        num_def_h = 0
@@ -966,5 +971,6 @@
                    IF ( .NOT. BTEST( wall_flags_0(k-1,j,i), 0 ) )  THEN
 !
-!--                   Determine flags indicating terrain or building. 
+!--                   Determine flags indicating a terrain surface, a building
+!--                   surface, 
                       terrain  = BTEST( wall_flags_0(k-1,j,i), 5 )  .OR.       &
                                  topo_no_distinct
@@ -972,6 +978,13 @@
                                  topo_no_distinct
 !
+!--                   unresolved_building indicates a surface with equal height 
+!--                   as terrain but with a non-grid resolved building on top.
+!--                   These surfaces will be flagged as urban surfaces.
+                      unresolved_building = BTEST( wall_flags_0(k-1,j,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k-1,j,i), 6 )
+!
 !--                   Land-surface type
-                      IF ( land_surface  .AND.  terrain )  THEN
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
                          num_lsm_h    = num_lsm_h    + 1 
 !
@@ -1027,5 +1040,10 @@
                       building = BTEST( wall_flags_0(k,j-1,i), 6 )   .OR.      &
                                  topo_no_distinct
-                      IF (  land_surface  .AND.  terrain )  THEN
+
+                      unresolved_building = BTEST( wall_flags_0(k,j-1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j-1,i), 6 )
+                                     
+                      IF (  land_surface  .AND.  terrain  .AND.                &
+                           .NOT. unresolved_building )  THEN
                          num_lsm_v(0) = num_lsm_v(0) + 1 
                       ELSEIF ( urban_surface  .AND.  building )  THEN
@@ -1056,5 +1074,10 @@
                       building = BTEST( wall_flags_0(k,j+1,i), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF (  land_surface  .AND.  terrain )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j+1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j+1,i), 6 ) 
+                                
+                      IF (  land_surface  .AND.  terrain  .AND.                &
+                           .NOT. unresolved_building )  THEN
                          num_lsm_v(1) = num_lsm_v(1) + 1 
                       ELSEIF ( urban_surface  .AND.  building )  THEN
@@ -1085,5 +1108,10 @@
                       building = BTEST( wall_flags_0(k,j,i-1), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF (  land_surface  .AND.  terrain )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j,i-1), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j,i-1), 6 )
+                                     
+                      IF (  land_surface  .AND.  terrain  .AND.                &
+                           .NOT. unresolved_building )  THEN
                          num_lsm_v(2) = num_lsm_v(2) + 1 
                       ELSEIF ( urban_surface  .AND.  building )  THEN
@@ -1114,5 +1142,10 @@
                       building = BTEST( wall_flags_0(k,j,i+1), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF (  land_surface  .AND.  terrain )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j,i+1), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j,i+1), 6 )
+                                 
+                      IF (  land_surface  .AND.  terrain  .AND.                &
+                           .NOT. unresolved_building )  THEN
                          num_lsm_v(3) = num_lsm_v(3) + 1 
                       ELSEIF ( urban_surface  .AND.  building )  THEN
@@ -2217,7 +2250,7 @@
        INTEGER(iwp), DIMENSION(0:3) ::  start_index_usm_v !< dummy to determing local start index in surface type for given (j,i), for vertical urban surfaces
 
-       LOGICAL ::  building     !< flag indicating building grid point
-       LOGICAL ::  terrain      !< flag indicating natural terrain grid point
-
+       LOGICAL ::  building            !< flag indicating building grid point
+       LOGICAL ::  terrain             !< flag indicating natural terrain grid point
+       LOGICAL ::  unresolved_building !< flag indicating a grid point where actually a building is defined but not resolved by the vertical grid 
 !
 !--    Set offset indices, i.e. index difference between surface element and 
@@ -2322,7 +2355,15 @@
                       building = BTEST( wall_flags_0(k-1,j,i), 6 )  .OR.       &
                                  topo_no_distinct
+                                 
+!
+!--                   unresolved_building indicates a surface with equal height 
+!--                   as terrain but with a non-grid resolved building on top.
+!--                   These surfaces will be flagged as urban surfaces.
+                      unresolved_building = BTEST( wall_flags_0(k-1,j,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k-1,j,i), 6 )
 !
 !--                   Natural surface type          
-                      IF ( land_surface  .AND.  terrain )  THEN
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
                          CALL initialize_horizontal_surfaces( k, j, i,         &
                                                               surf_lsm_h,      &
@@ -2375,5 +2416,17 @@
                       building = BTEST( wall_flags_0(k,j-1,i), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF ( urban_surface  .AND.  building )  THEN
+
+                      unresolved_building = BTEST( wall_flags_0(k,j-1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j-1,i), 6 )
+                                     
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
+                         CALL initialize_vertical_surfaces( k, j, i,           &
+                                                            surf_lsm_v(0),     &
+                                                            num_lsm_v(0),      &
+                                                            num_lsm_v_kji(0),  &
+                                                            .FALSE., .FALSE.,  &             
+                                                            .FALSE., .TRUE. )
+                      ELSEIF ( urban_surface  .AND.  building )  THEN
                          CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(0),     &
@@ -2381,12 +2434,5 @@
                                                             num_usm_v_kji(0),  &
                                                             .FALSE., .FALSE.,  &             
-                                                            .FALSE., .TRUE. ) 
-                      ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( k, j, i,           &
-                                                            surf_lsm_v(0),     &
-                                                            num_lsm_v(0),      &
-                                                            num_lsm_v_kji(0),  &
-                                                            .FALSE., .FALSE.,  &             
-                                                            .FALSE., .TRUE. ) 
+                                                            .FALSE., .TRUE. )
                       ELSE
                          CALL initialize_vertical_surfaces( k, j, i,           &
@@ -2407,5 +2453,17 @@
                       building = BTEST( wall_flags_0(k,j+1,i), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF ( urban_surface  .AND.  building )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j+1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j+1,i), 6 )
+                                     
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
+                         CALL initialize_vertical_surfaces( k, j, i,           &
+                                                            surf_lsm_v(1),     &
+                                                            num_lsm_v(1),      &
+                                                            num_lsm_v_kji(1),  &
+                                                            .FALSE., .FALSE.,  &
+                                                            .TRUE., .FALSE. )
+                      ELSEIF ( urban_surface  .AND.  building )  THEN
                          CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(1),     &
@@ -2414,11 +2472,4 @@
                                                             .FALSE., .FALSE.,  &
                                                             .TRUE., .FALSE. )
-                      ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( k, j, i,           &
-                                                            surf_lsm_v(1),     &
-                                                            num_lsm_v(1),      &
-                                                            num_lsm_v_kji(1),  &
-                                                            .FALSE., .FALSE.,  &
-                                                            .TRUE., .FALSE. )  
                       ELSE
                          CALL initialize_vertical_surfaces( k, j, i,           &
@@ -2439,5 +2490,17 @@
                       building = BTEST( wall_flags_0(k,j,i-1), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF ( urban_surface  .AND.  building )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j,i-1), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j,i-1), 6 )
+                                 
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
+                         CALL initialize_vertical_surfaces( k, j, i,           &
+                                                            surf_lsm_v(2),     &
+                                                            num_lsm_v(2),      &
+                                                            num_lsm_v_kji(2),  &
+                                                            .TRUE., .FALSE.,   &
+                                                            .FALSE., .FALSE. )
+                      ELSEIF ( urban_surface  .AND.  building )  THEN
                          CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(2),     &
@@ -2445,12 +2508,5 @@
                                                             num_usm_v_kji(2),  &
                                                             .TRUE., .FALSE.,   &
-                                                            .FALSE., .FALSE. ) 
-                      ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( k, j, i,           &
-                                                            surf_lsm_v(2),     &
-                                                            num_lsm_v(2),      &
-                                                            num_lsm_v_kji(2),  &
-                                                            .TRUE., .FALSE.,   &
-                                                            .FALSE., .FALSE. ) 
+                                                            .FALSE., .FALSE. )
                       ELSE
                          CALL initialize_vertical_surfaces( k, j, i,           &
@@ -2471,5 +2527,17 @@
                       building = BTEST( wall_flags_0(k,j,i+1), 6 )  .OR.       &
                                  topo_no_distinct
-                      IF ( urban_surface  .AND.  building )  THEN
+                                 
+                      unresolved_building = BTEST( wall_flags_0(k,j,i+1), 5 )  &
+                                     .AND.  BTEST( wall_flags_0(k,j,i+1), 6 )
+                                  
+                      IF ( land_surface  .AND.  terrain  .AND.                 &
+                           .NOT. unresolved_building )  THEN
+                         CALL initialize_vertical_surfaces( k, j, i,           &
+                                                            surf_lsm_v(3),     &
+                                                            num_lsm_v(3),      &
+                                                            num_lsm_v_kji(3),  &
+                                                           .FALSE., .TRUE.,    &
+                                                           .FALSE., .FALSE. )
+                      ELSEIF ( urban_surface  .AND.  building )  THEN
                          CALL initialize_vertical_surfaces( k, j, i,           &
                                                             surf_usm_v(3),     &
@@ -2477,12 +2545,5 @@
                                                             num_usm_v_kji(3),  &
                                                            .FALSE., .TRUE.,    &
-                                                           .FALSE., .FALSE. ) 
-                      ELSEIF ( land_surface  .AND.  terrain )  THEN
-                         CALL initialize_vertical_surfaces( k, j, i,           &
-                                                            surf_lsm_v(3),     &
-                                                            num_lsm_v(3),      &
-                                                            num_lsm_v_kji(3),  &
-                                                           .FALSE., .TRUE.,    &
-                                                           .FALSE., .FALSE. ) 
+                                                           .FALSE., .FALSE. )
                       ELSE
                          CALL initialize_vertical_surfaces( k, j, i,           &
