Index: /palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- /palm/trunk/SOURCE/advec_ws.f90	(revision 4345)
+++ /palm/trunk/SOURCE/advec_ws.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4340 2019-12-16 08:17:03Z Giersch
 ! Topography closed channel flow with symmetric boundaries implemented 
 ! 
@@ -196,5 +200,5 @@
                nzb_max,                                                        &
                nzt,                                                            &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE grid_variables,                                                        &
@@ -418,5 +422,5 @@
 !--             u component - x-direction
 !--             WS1 (0), WS3 (1), WS5 (2)
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j,i+1),1)  .OR.         &
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j,i+1),1)  .OR.          &
                          ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
                            .AND. i <= nxlu  )    .OR.                          &
@@ -425,7 +429,7 @@
                 THEN                                                           
                     advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 0 )      
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i+2),1)  .AND.  &
-                                 BTEST(wall_flags_static_0(k,j,i+1),1)  .OR.   &
-                           .NOT. BTEST(wall_flags_static_0(k,j,i-1),1) )       &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i+2),1)  .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i+1),1)  .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k,j,i-1),1) )        &
                                                      .OR.                      &
                          ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
@@ -438,7 +442,7 @@
 !--                Clear flag for WS1                                          
                    advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 0 )       
-                ELSEIF ( BTEST(wall_flags_static_0(k,j,i+1),1)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i+2),1)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i-1),1) )               &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j,i+1),1)  .AND.          &
+                         BTEST(wall_flags_total_0(k,j,i+2),1)  .AND.          &
+                         BTEST(wall_flags_total_0(k,j,i-1),1) )               &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 2 )       
@@ -449,6 +453,6 @@
 !                                                                              
 !--             u component - y-direction                                      
-!--             WS1 (3), WS3 (4), WS5 (5)                                      
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j+1,i),1)   .OR.        &
+!--             WS1 (3), WS3 (4), WS5 (5)                                       
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j+1,i),1)   .OR.         &
                          ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
                            .AND. j == nys   )    .OR.                          &
@@ -457,7 +461,7 @@
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 3 )       
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j+2,i),1)  .AND.  &
-                                 BTEST(wall_flags_static_0(k,j+1,i),1)  .OR.   &
-                           .NOT. BTEST(wall_flags_static_0(k,j-1,i),1) )       &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j+2,i),1)  .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+1,i),1)  .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k,j-1,i),1) )        &
                                                      .OR.                      &
                          ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
@@ -470,7 +474,7 @@
 !--                Clear flag for WS1                                          
                    advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 3 )       
-                ELSEIF ( BTEST(wall_flags_static_0(k,j+1,i),1)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j+2,i),1)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j-1,i),1) )               &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j+1,i),1)  .AND.          &
+                         BTEST(wall_flags_total_0(k,j+2,i),1)  .AND.          &
+                         BTEST(wall_flags_total_0(k,j-1,i),1) )               &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 5 )       
@@ -500,32 +504,32 @@
                                                                                
                 flag_set = .FALSE.                                             
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),1)       .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),1)         .AND.     &
-                             BTEST(wall_flags_static_0(k+1,j,i),1) )     .OR.      &
-                     ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),1)      .AND.     &                              
-                             BTEST(wall_flags_static_0(k+1,j,i),1)       .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),1) )       .OR.      &
-                     ( k == nzt .AND. symmetry_flag == 0 ) )                       &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k-1,j,i),1)       .AND.     &
+                             BTEST(wall_flags_total_0(k,j,i),1)         .AND.     &
+                             BTEST(wall_flags_total_0(k+1,j,i),1) )     .OR.      &
+                     ( .NOT. BTEST(wall_flags_total_0(k_pp,j,i),1)      .AND.     &                              
+                             BTEST(wall_flags_total_0(k+1,j,i),1)       .AND.     &
+                             BTEST(wall_flags_total_0(k,j,i),1) )       .OR.      &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                      &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 6 )       
                    flag_set = .TRUE.                                           
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k_mm,j,i),1)    .OR.    &
-                           .NOT. BTEST(wall_flags_static_0(k_ppp,j,i),1) ) .AND.   & 
-                                 BTEST(wall_flags_static_0(k-1,j,i),1)     .AND.   &
-                                 BTEST(wall_flags_static_0(k,j,i),1)       .AND.   &
-                                 BTEST(wall_flags_static_0(k+1,j,i),1)     .AND.   &
-                                 BTEST(wall_flags_static_0(k_pp,j,i),1)    .AND.   &
-                           .NOT. flag_set                                  .OR.    & 
-                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )               &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k_mm,j,i),1)    .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k_ppp,j,i),1) ) .AND.   & 
+                                 BTEST(wall_flags_total_0(k-1,j,i),1)     .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i),1)       .AND.   &
+                                 BTEST(wall_flags_total_0(k+1,j,i),1)     .AND.   &
+                                 BTEST(wall_flags_total_0(k_pp,j,i),1)    .AND.   &
+                           .NOT. flag_set                                  .OR.   & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )              &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 7 )       
                    flag_set = .TRUE.                                           
-                ELSEIF ( BTEST(wall_flags_static_0(k_mm,j,i),1)            .AND.   &
-                         BTEST(wall_flags_static_0(k-1,j,i),1)             .AND.   &
-                         BTEST(wall_flags_static_0(k,j,i),1)               .AND.   &
-                         BTEST(wall_flags_static_0(k+1,j,i),1)             .AND.   &
-                         BTEST(wall_flags_static_0(k_pp,j,i),1)            .AND.   &
-                         BTEST(wall_flags_static_0(k_ppp,j,i),1)           .AND.   &
-                         .NOT. flag_set )                                          &
+                ELSEIF ( BTEST(wall_flags_total_0(k_mm,j,i),1)            .AND.   &
+                         BTEST(wall_flags_total_0(k-1,j,i),1)             .AND.   &
+                         BTEST(wall_flags_total_0(k,j,i),1)               .AND.   &
+                         BTEST(wall_flags_total_0(k+1,j,i),1)             .AND.   &
+                         BTEST(wall_flags_total_0(k_pp,j,i),1)            .AND.   &
+                         BTEST(wall_flags_total_0(k_ppp,j,i),1)           .AND.   &
+                         .NOT. flag_set )                                         &
                 THEN
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 8 )
@@ -549,5 +553,5 @@
 !--             v component - x-direction
 !--             WS1 (9), WS3 (10), WS5 (11)
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j,i+1),2)  .OR.         &
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j,i+1),2)  .OR.          &
                          ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
                            .AND. i == nxl   )    .OR.                          &
@@ -558,7 +562,7 @@
 !                                                                              
 !--             WS3                                                            
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i+2),2)   .AND. &
-                                 BTEST(wall_flags_static_0(k,j,i+1),2) ) .OR.  &
-                           .NOT. BTEST(wall_flags_static_0(k,j,i-1),2)         &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i+2),2)   .AND.  &
+                                 BTEST(wall_flags_total_0(k,j,i+1),2) ) .OR.   &
+                           .NOT. BTEST(wall_flags_total_0(k,j,i-1),2)          &
                                                  .OR.                          &
                          ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
@@ -571,7 +575,7 @@
 !--                Clear flag for WS1                                          
                    advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 9 )     
-                ELSEIF ( BTEST(wall_flags_static_0(k,j,i+1),2)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i+2),2)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i-1),2) )               &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j,i+1),2)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j,i+2),2)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j,i-1),2) )                &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 11 )      
@@ -583,5 +587,5 @@
 !--             v component - y-direction                                      
 !--             WS1 (12), WS3 (13), WS5 (14)                                   
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j+1,i),2) .OR.          &
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j+1,i),2) .OR.           &
                          ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
                            .AND. j <= nysv  )    .OR.                          &
@@ -590,7 +594,7 @@
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 12 )      
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j+2,i),2)  .AND.  &
-                                 BTEST(wall_flags_static_0(k,j+1,i),2)  .OR.   &
-                           .NOT. BTEST(wall_flags_static_0(k,j-1,i),2) )       &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j+2,i),2)  .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+1,i),2)  .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k,j-1,i),2) )        &
                                                      .OR.                      &
                          ( (  bc_dirichlet_s .OR. bc_radiation_s )             &
@@ -603,8 +607,8 @@
 !--                Clear flag for WS1                                          
                    advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 12 )      
-                ELSEIF ( BTEST(wall_flags_static_0(k,j+1,i),2)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j+2,i),2)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j-1,i),2) )               & 
-                THEN
+                ELSEIF ( BTEST(wall_flags_total_0(k,j+1,i),2)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j+2,i),2)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j-1,i),2) )                & 
+                THEN                                                          
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 14 )
 !
@@ -633,32 +637,32 @@
                 
                 flag_set = .FALSE.
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),2)          .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),2)            .AND.     &
-                             BTEST(wall_flags_static_0(k+1,j,i),2) )        .OR.      &
-                     ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),2)         .AND.     &                              
-                             BTEST(wall_flags_static_0(k+1,j,i),2)          .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),2) )          .OR.      &
-                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k-1,j,i),2)          .AND.   &
+                             BTEST(wall_flags_total_0(k,j,i),2)            .AND.   &
+                             BTEST(wall_flags_total_0(k+1,j,i),2) )        .OR.    &
+                     ( .NOT. BTEST(wall_flags_total_0(k_pp,j,i),2)         .AND.   &                              
+                             BTEST(wall_flags_total_0(k+1,j,i),2)          .AND.   &
+                             BTEST(wall_flags_total_0(k,j,i),2) )          .OR.    &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                       &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 15 )      
                    flag_set = .TRUE.                                           
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k_mm,j,i),2)    .OR.       &
-                           .NOT. BTEST(wall_flags_static_0(k_ppp,j,i),2) ) .AND.      & 
-                                 BTEST(wall_flags_static_0(k-1,j,i),2)     .AND.      &
-                                 BTEST(wall_flags_static_0(k,j,i),2)       .AND.      &
-                                 BTEST(wall_flags_static_0(k+1,j,i),2)     .AND.      &
-                                 BTEST(wall_flags_static_0(k_pp,j,i),2)    .AND.      &
-                           .NOT. flag_set                                  .OR.       & 
-                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k_mm,j,i),2)    .OR.     &
+                           .NOT. BTEST(wall_flags_total_0(k_ppp,j,i),2) ) .AND.    & 
+                                 BTEST(wall_flags_total_0(k-1,j,i),2)     .AND.    &
+                                 BTEST(wall_flags_total_0(k,j,i),2)       .AND.    &
+                                 BTEST(wall_flags_total_0(k+1,j,i),2)     .AND.    &
+                                 BTEST(wall_flags_total_0(k_pp,j,i),2)    .AND.    &
+                           .NOT. flag_set                                  .OR.    & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )               &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 16 )      
                    flag_set = .TRUE.                                           
-                ELSEIF ( BTEST(wall_flags_static_0(k_mm,j,i),2)             .AND.     &
-                         BTEST(wall_flags_static_0(k-1,j,i),2)              .AND.     &
-                         BTEST(wall_flags_static_0(k,j,i),2)                .AND.     &
-                         BTEST(wall_flags_static_0(k+1,j,i),2)              .AND.     &
-                         BTEST(wall_flags_static_0(k_pp,j,i),2)             .AND.     &
-                         BTEST(wall_flags_static_0(k_ppp,j,i),2)            .AND.     &
-                         .NOT. flag_set )                                             &
+                ELSEIF ( BTEST(wall_flags_total_0(k_mm,j,i),2)             .AND.   &
+                         BTEST(wall_flags_total_0(k-1,j,i),2)              .AND.   &
+                         BTEST(wall_flags_total_0(k,j,i),2)                .AND.   &
+                         BTEST(wall_flags_total_0(k+1,j,i),2)              .AND.   &
+                         BTEST(wall_flags_total_0(k_pp,j,i),2)             .AND.   &
+                         BTEST(wall_flags_total_0(k_ppp,j,i),2)            .AND.   &
+                         .NOT. flag_set )                                          &
                 THEN
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 17 )
@@ -682,5 +686,5 @@
 !--             w component - x-direction
 !--             WS1 (18), WS3 (19), WS5 (20)
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j,i+1),3) .OR.          &
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j,i+1),3) .OR.           &
                          ( (  bc_dirichlet_l .OR. bc_radiation_l )             &
                            .AND. i == nxl   )    .OR.                          &
@@ -689,7 +693,7 @@
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 18 )     
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i+2),3)  .AND.  &
-                                 BTEST(wall_flags_static_0(k,j,i+1),3)  .OR.   &
-                           .NOT. BTEST(wall_flags_static_0(k,j,i-1),3) )       &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i+2),3)  .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i+1),3)  .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k,j,i-1),3) )        &
                                                      .OR.                      &
                          ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
@@ -702,7 +706,7 @@
 !--                Clear flag for WS1                                          
                    advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 18 )      
-                ELSEIF ( BTEST(wall_flags_static_0(k,j,i+1),3)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i+2),3)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j,i-1),3) )               &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j,i+1),3)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j,i+2),3)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j,i-1),3) )                &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i),20 )       
@@ -714,5 +718,5 @@
 !--             w component - y-direction                                      
 !--             WS1 (21), WS3 (22), WS5 (23)                                   
-                IF ( .NOT. BTEST(wall_flags_static_0(k,j+1,i),3) .OR.          &
+                IF ( .NOT. BTEST(wall_flags_total_0(k,j+1,i),3) .OR.           &
                          ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
                            .AND. j == nys   )    .OR.                          &
@@ -721,7 +725,7 @@
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 21 )     
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j+2,i),3)  .AND.  &
-                                 BTEST(wall_flags_static_0(k,j+1,i),3)  .OR.   &
-                           .NOT. BTEST(wall_flags_static_0(k,j-1,i),3) )       &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j+2,i),3)  .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+1,i),3)  .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k,j-1,i),3) )        &
                                                      .OR.                      &
                          ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
@@ -733,8 +737,8 @@
 !                                                                              
 !--                Clear flag for WS1                                          
-                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 21 )      
-                ELSEIF ( BTEST(wall_flags_static_0(k,j+1,i),3)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j+2,i),3)  .AND.          &
-                         BTEST(wall_flags_static_0(k,j-1,i),3) )               &
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 21 )       
+                ELSEIF ( BTEST(wall_flags_total_0(k,j+1,i),3)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j+2,i),3)  .AND.           &
+                         BTEST(wall_flags_total_0(k,j-1,i),3) )                &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 23 )
@@ -765,9 +769,9 @@
                 
                 flag_set = .FALSE.                                        
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i),3)          .AND.     &
-                             BTEST(wall_flags_static_0(k+1,j,i),3) )      .OR.      &
-                     ( .NOT. BTEST(wall_flags_static_0(k+1,j,i),3)        .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),3) )        .OR.      &        
-                     k == nzt -1 )                                                  &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i),3)          .AND.   &
+                             BTEST(wall_flags_total_0(k+1,j,i),3) )      .OR.    &
+                     ( .NOT. BTEST(wall_flags_total_0(k+1,j,i),3)        .AND.   &
+                             BTEST(wall_flags_total_0(k,j,i),3) )        .OR.    &        
+                     k == nzt -1 )                                               &
                 THEN
 !
@@ -779,22 +783,22 @@
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 24 )
                    flag_set = .TRUE.
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),3)    .AND.     &
-                                 BTEST(wall_flags_static_0(k,j,i),3)      .AND.     &
-                                 BTEST(wall_flags_static_0(k+1,j,i),3)    .AND.     &
-                                 BTEST(wall_flags_static_0(k_pp,j,i),3) ) .OR.      &
-                         ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),3)   .AND.     &
-                                 BTEST(wall_flags_static_0(k+1,j,i),3)    .AND.     &
-                                 BTEST(wall_flags_static_0(k,j,i),3)      .AND.     &
-                                 BTEST(wall_flags_static_0(k-1,j,i),3) )  .AND.     &
-                           .NOT. flag_set                          .OR.             & 
-                         k == nzt - 2 )                                             &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k-1,j,i),3)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i),3)      .AND.   &
+                                 BTEST(wall_flags_total_0(k+1,j,i),3)    .AND.   &
+                                 BTEST(wall_flags_total_0(k_pp,j,i),3) ) .OR.    &
+                         ( .NOT. BTEST(wall_flags_total_0(k_pp,j,i),3)   .AND.   &
+                                 BTEST(wall_flags_total_0(k+1,j,i),3)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i),3)      .AND.   &
+                                 BTEST(wall_flags_total_0(k-1,j,i),3) )  .AND.   &
+                           .NOT. flag_set                          .OR.          & 
+                         k == nzt - 2 )                                          &
                 THEN                                                           
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 25 )      
                    flag_set = .TRUE.                                           
-                ELSEIF ( BTEST(wall_flags_static_0(k-1,j,i),3)            .AND.     &
-                         BTEST(wall_flags_static_0(k,j,i),3)              .AND.     &
-                         BTEST(wall_flags_static_0(k+1,j,i),3)            .AND.     &
-                         BTEST(wall_flags_static_0(k_pp,j,i),3)           .AND.     &
-                         .NOT. flag_set )                                           &
+                ELSEIF ( BTEST(wall_flags_total_0(k-1,j,i),3)            .AND.   &
+                         BTEST(wall_flags_total_0(k,j,i),3)              .AND.   &
+                         BTEST(wall_flags_total_0(k+1,j,i),3)            .AND.   &
+                         BTEST(wall_flags_total_0(k_pp,j,i),3)           .AND.   &
+                         .NOT. flag_set )                                        &
                 THEN                                                                
                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 26 )
@@ -867,33 +871,33 @@
           DO  j = nys, nyn
              DO  k = nzb+1, nzt
-                IF ( .NOT.  BTEST(wall_flags_static_0(k,j,i),0) )  CYCLE
+                IF ( .NOT.  BTEST(wall_flags_total_0(k,j,i),0) )  CYCLE
 !
 !--             scalar - x-direction
 !--             WS1 (0), WS3 (1), WS5 (2)
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i+1),0)      .OR.          &
-                       .NOT. BTEST(wall_flags_static_0(k,j,i+2),0)      .OR.          &   
-                       .NOT. BTEST(wall_flags_static_0(k,j,i-1),0) )    .OR.          &
-                       ( non_cyclic_l  .AND.  i == 0  )                 .OR.          &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i+1),0)      .OR.      &
+                       .NOT. BTEST(wall_flags_total_0(k,j,i+2),0)      .OR.      &   
+                       .NOT. BTEST(wall_flags_total_0(k,j,i-1),0) )    .OR.      &
+                       ( non_cyclic_l  .AND.  i == 0  )                .OR.      &
                        ( non_cyclic_r  .AND.  i == nx ) )  THEN           
                  advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 0 )             
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j,i+3),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i+1),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i+2),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i-1),0)                &
-                         )                       .OR.                                 &
-                         ( .NOT. BTEST(wall_flags_static_0(k,j,i-2),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i+1),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i+2),0)  .AND.         &
-                                 BTEST(wall_flags_static_0(k,j,i-1),0)                &
-                         )                                                            &
-                                                 .OR.                                 &
-                         ( non_cyclic_r  .AND.  i == nx-1 )  .OR.                     &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j,i+3),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i+1),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i+2),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i-1),0)            &
+                         )                       .OR.                            &
+                         ( .NOT. BTEST(wall_flags_total_0(k,j,i-2),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i+1),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i+2),0)  .AND.     &
+                                 BTEST(wall_flags_total_0(k,j,i-1),0)            &
+                         )                                                       &
+                                                 .OR.                            &
+                         ( non_cyclic_r  .AND.  i == nx-1 )  .OR.                &
                          ( non_cyclic_l  .AND.  i == 1    ) )  THEN           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 1 )             
-                ELSEIF ( BTEST(wall_flags_static_0(k,j,i+1),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j,i+2),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j,i+3),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j,i-1),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j,i-2),0) )                      &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j,i+1),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j,i+2),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j,i+3),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j,i-1),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j,i-2),0) )                  &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 2 )             
@@ -902,33 +906,33 @@
 !--             scalar - y-direction                                           
 !--             WS1 (3), WS3 (4), WS5 (5)                                      
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k,j+1,i),0)        .OR.        &
-                       .NOT. BTEST(wall_flags_static_0(k,j+2,i),0)        .OR.        &   
-                       .NOT. BTEST(wall_flags_static_0(k,j-1,i),0))       .OR.        &
-                     ( non_cyclic_s  .AND.  j == 0  )                     .OR.        &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k,j+1,i),0)        .OR.    &
+                       .NOT. BTEST(wall_flags_total_0(k,j+2,i),0)        .OR.    &   
+                       .NOT. BTEST(wall_flags_total_0(k,j-1,i),0))       .OR.    &
+                     ( non_cyclic_s  .AND.  j == 0  )                    .OR.    &
                      ( non_cyclic_n  .AND.  j == ny ) )  THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 3 )             
 !                                                                              
 !--             WS3                                                            
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k,j+3,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j+1,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j+2,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j-1,i),0)                &
-                         )                       .OR.                                 &
-                         ( .NOT. BTEST(wall_flags_static_0(k,j-2,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j+1,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j+2,i),0)    .AND.       &
-                                 BTEST(wall_flags_static_0(k,j-1,i),0)                &
-                         )                                                            &
-                                                 .OR.                                 &
-                         ( non_cyclic_s  .AND.  j == 1    )  .OR.                     &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k,j+3,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+1,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+2,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j-1,i),0)            &
+                         )                       .OR.                            &
+                         ( .NOT. BTEST(wall_flags_total_0(k,j-2,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+1,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j+2,i),0)    .AND.   &
+                                 BTEST(wall_flags_total_0(k,j-1,i),0)            &
+                         )                                                       &
+                                                 .OR.                            &
+                         ( non_cyclic_s  .AND.  j == 1    )  .OR.                &
                          ( non_cyclic_n  .AND.  j == ny-1 ) )  THEN           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 4 )             
 !                                                                              
 !--             WS5                                                            
-                ELSEIF ( BTEST(wall_flags_static_0(k,j+1,i),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j+2,i),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j+3,i),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j-1,i),0)           .AND.        &
-                         BTEST(wall_flags_static_0(k,j-2,i),0) )                      &
+                ELSEIF ( BTEST(wall_flags_total_0(k,j+1,i),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j+2,i),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j+3,i),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j-1,i),0)           .AND.    &
+                         BTEST(wall_flags_total_0(k,j-2,i),0) )                  &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 5 )             
@@ -938,5 +942,5 @@
 !--             for passive scalars, even if only one direction may be 
 !--             blocked by topography. These locations will be identified
-!--             by wall_flags_static_0 bit 31. Note, since several modules define 
+!--             by wall_flags_total_0 bit 31. Note, since several modules define 
 !--             advection flags but may apply different scalar boundary 
 !--             conditions, bit 31 is temporarily stored on advc_flags. 
@@ -1025,5 +1029,5 @@
 !--                them again. 
 !--                x-direction
-                   IF ( ( non_cyclic_l  .AND.  i == 0  )  .OR.                 &
+                   IF ( ( non_cyclic_l  .AND.  i == 0  )  .OR.             &
                         ( non_cyclic_r  .AND.  i == nx ) )  THEN
                       advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 0 )
@@ -1034,5 +1038,5 @@
                    ENDIF
                    
-                   IF ( ( non_cyclic_l  .AND.  i == 1    )  .OR.               &
+                   IF ( ( non_cyclic_l  .AND.  i == 1    )  .OR.           &
                         ( non_cyclic_r  .AND.  i == nx-1 ) )  THEN
                       advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 0 )
@@ -1044,5 +1048,5 @@
 !
 !--                y-direction
-                   IF ( ( non_cyclic_n  .AND.  j == 0  )  .OR.                 &
+                   IF ( ( non_cyclic_n  .AND.  j == 0  )  .OR.             &
                         ( non_cyclic_s  .AND.  j == ny ) )  THEN
                       advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 3 )
@@ -1053,5 +1057,5 @@
                    ENDIF
                    
-                   IF ( ( non_cyclic_n  .AND.  j == 1    )  .OR.               &
+                   IF ( ( non_cyclic_n  .AND.  j == 1    )  .OR.           &
                         ( non_cyclic_s  .AND.  j == ny-1 ) )  THEN
                       advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 3 )
@@ -1086,32 +1090,32 @@
                                                                                
                 flag_set = .FALSE.                                             
-                IF ( ( .NOT. BTEST(wall_flags_static_0(k-1,j,i),0)          .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),0)            .AND.     &
-                             BTEST(wall_flags_static_0(k+1,j,i),0) )        .OR.      &
-                     ( .NOT. BTEST(wall_flags_static_0(k_pp,j,i),0)         .AND.     &                              
-                             BTEST(wall_flags_static_0(k+1,j,i),0)          .AND.     &
-                             BTEST(wall_flags_static_0(k,j,i),0) )          .OR.      &
-                     ( k == nzt .AND. symmetry_flag == 0 ) )                          &
+                IF ( ( .NOT. BTEST(wall_flags_total_0(k-1,j,i),0)          .AND.  &
+                             BTEST(wall_flags_total_0(k,j,i),0)            .AND.  &
+                             BTEST(wall_flags_total_0(k+1,j,i),0) )        .OR.   &
+                     ( .NOT. BTEST(wall_flags_total_0(k_pp,j,i),0)         .AND.  &                              
+                             BTEST(wall_flags_total_0(k+1,j,i),0)          .AND.  &
+                             BTEST(wall_flags_total_0(k,j,i),0) )          .OR.   &
+                     ( k == nzt .AND. symmetry_flag == 0 ) )                      &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 6 )             
                    flag_set = .TRUE.                                           
-                ELSEIF ( ( .NOT. BTEST(wall_flags_static_0(k_mm,j,i),0)    .OR.       &
-                           .NOT. BTEST(wall_flags_static_0(k_ppp,j,i),0) ) .AND.      & 
-                                 BTEST(wall_flags_static_0(k-1,j,i),0)     .AND.      &
-                                 BTEST(wall_flags_static_0(k,j,i),0)       .AND.      &
-                                 BTEST(wall_flags_static_0(k+1,j,i),0)     .AND.      &
-                                 BTEST(wall_flags_static_0(k_pp,j,i),0)    .AND.      &
-                           .NOT. flag_set                                  .OR.       & 
-                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )                  &
+                ELSEIF ( ( .NOT. BTEST(wall_flags_total_0(k_mm,j,i),0)    .OR.    &
+                           .NOT. BTEST(wall_flags_total_0(k_ppp,j,i),0) ) .AND.   & 
+                                 BTEST(wall_flags_total_0(k-1,j,i),0)     .AND.   &
+                                 BTEST(wall_flags_total_0(k,j,i),0)       .AND.   &
+                                 BTEST(wall_flags_total_0(k+1,j,i),0)     .AND.   &
+                                 BTEST(wall_flags_total_0(k_pp,j,i),0)    .AND.   &
+                           .NOT. flag_set                                  .OR.   & 
+                         ( k == nzt - 1 .AND. symmetry_flag == 0 ) )              &
                 THEN                                                           
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 7 )             
                    flag_set = .TRUE.                                           
-                ELSEIF ( BTEST(wall_flags_static_0(k_mm,j,i),0)  .AND.                &
-                         BTEST(wall_flags_static_0(k-1,j,i),0)   .AND.                &
-                         BTEST(wall_flags_static_0(k,j,i),0)     .AND.                &
-                         BTEST(wall_flags_static_0(k+1,j,i),0)   .AND.                &
-                         BTEST(wall_flags_static_0(k_pp,j,i),0)  .AND.                &
-                         BTEST(wall_flags_static_0(k_ppp,j,i),0) .AND.                &
-                        .NOT. flag_set )                                       &
+                ELSEIF ( BTEST(wall_flags_total_0(k_mm,j,i),0)            .AND.   &
+                         BTEST(wall_flags_total_0(k-1,j,i),0)             .AND.   &
+                         BTEST(wall_flags_total_0(k,j,i),0)               .AND.   &
+                         BTEST(wall_flags_total_0(k+1,j,i),0)             .AND.   &
+                         BTEST(wall_flags_total_0(k_pp,j,i),0)            .AND.   &
+                         BTEST(wall_flags_total_0(k_ppp,j,i),0)           .AND.   &
+                        .NOT. flag_set )                                          &
                 THEN
                    advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 8 )
Index: /palm/trunk/SOURCE/bulk_cloud_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -144,5 +148,5 @@
                nbgp, nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt,     &
                topo_top_ind,                                                   &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -152,5 +156,6 @@
 
     USE statistics,                                                            &
-        ONLY:  weight_pres, weight_substep, sums_wsncs_ws_l, sums_wsnrs_ws_l, sums_wsqcs_ws_l, sums_wsqrs_ws_l
+        ONLY:  weight_pres, weight_substep, sums_wsncs_ws_l, sums_wsnrs_ws_l,  &
+               sums_wsqcs_ws_l, sums_wsqrs_ws_l
 
     USE surface_mod,                                                           &
@@ -1399,5 +1404,5 @@
                                              )                                 &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                    IF ( qc_p(k,j,i) < 0.0_wp )  qc_p(k,j,i) = 0.0_wp
@@ -1489,5 +1494,5 @@
                                              )                                 &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                    IF ( nc_p(k,j,i) < 0.0_wp )  nc_p(k,j,i) = 0.0_wp
@@ -1586,5 +1591,5 @@
                                              )                                 &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                    IF ( qr_p(k,j,i) < 0.0_wp )  qr_p(k,j,i) = 0.0_wp
@@ -1676,5 +1681,5 @@
                                              )                                 &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                    IF ( nr_p(k,j,i) < 0.0_wp )  nr_p(k,j,i) = 0.0_wp
@@ -1773,5 +1778,5 @@
                                        )                                 &
                                  * MERGE( 1.0_wp, 0.0_wp,                &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                    BTEST( wall_flags_total_0(k,j,i), 0 )&
                                         )
              IF ( qc_p(k,j,i) < 0.0_wp )  qc_p(k,j,i) = 0.0_wp
@@ -1832,5 +1837,5 @@
                                        )                                 &
                                  * MERGE( 1.0_wp, 0.0_wp,                &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                    BTEST( wall_flags_total_0(k,j,i), 0 )&
                                         )
              IF ( nc_p(k,j,i) < 0.0_wp )  nc_p(k,j,i) = 0.0_wp
@@ -1897,5 +1902,5 @@
                                        )                                 &
                                  * MERGE( 1.0_wp, 0.0_wp,                &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                    BTEST( wall_flags_total_0(k,j,i), 0 )&
                                         )
              IF ( qr_p(k,j,i) < 0.0_wp )  qr_p(k,j,i) = 0.0_wp
@@ -1956,5 +1961,5 @@
                                        )                                 &
                                  * MERGE( 1.0_wp, 0.0_wp,                &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                    BTEST( wall_flags_total_0(k,j,i), 0 )&
                                         )
              IF ( nr_p(k,j,i) < 0.0_wp )  nr_p(k,j,i) = 0.0_wp
@@ -2502,7 +2507,7 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( &
-                                     to_be_resorted(k,j,i),                    &
-                                     REAL( fill_value, KIND = wp ),            &
-                                     BTEST( wall_flags_static_0(k,j,i), flag_nr )     &
+                                     to_be_resorted(k,j,i),                      &
+                                     REAL( fill_value, KIND = wp ),              &
+                                     BTEST( wall_flags_total_0(k,j,i), flag_nr ) &
                                   )
              ENDDO
@@ -2643,8 +2648,8 @@
           DO  j = nys, nyn
              DO  k = nzb_do, nzt_do
-                local_pf(i,j,k) = MERGE(                                       &
-                                     to_be_resorted(k,j,i),                    &
-                                     REAL( fill_value, KIND = wp ),            &
-                                     BTEST( wall_flags_static_0(k,j,i), flag_nr )     &
+                local_pf(i,j,k) = MERGE(                                         &
+                                     to_be_resorted(k,j,i),                      &
+                                     REAL( fill_value, KIND = wp ),              &
+                                     BTEST( wall_flags_total_0(k,j,i), flag_nr ) &
                                   )
              ENDDO
@@ -3046,5 +3051,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( qr(k,j,i) <= eps_sb )  THEN
@@ -3100,5 +3105,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( qr(k,j,i) <= eps_sb )  THEN
@@ -3168,5 +3173,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
 !
@@ -3269,5 +3274,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--       Call calculation of supersaturation
@@ -3369,5 +3374,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--             Call calculation of supersaturation 
@@ -3456,5 +3461,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--       Call calculation of supersaturation
@@ -3545,5 +3550,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( microphysics_morrison ) THEN
@@ -3671,5 +3676,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( microphysics_morrison ) THEN
              nc_auto = nc(k,j,i)
@@ -3782,5 +3787,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( qc(k,j,i) > ql_crit )  THEN
@@ -3829,5 +3834,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( qc(k,j,i) > ql_crit )  THEN
@@ -3880,5 +3885,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( microphysics_morrison ) THEN
@@ -3961,5 +3966,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( microphysics_morrison ) THEN
              nc_accr = nc(k,j,i)
@@ -4041,5 +4046,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4096,5 +4101,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4158,5 +4163,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4280,5 +4285,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4394,5 +4399,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( microphysics_morrison ) THEN
@@ -4488,5 +4493,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( microphysics_morrison ) THEN
              nc_sedi = nc(k,j,i)
@@ -4594,5 +4599,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4659,5 +4664,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 c_nr(k) = 0.25_wp * ( w_nr(k-1) +                              &
@@ -4675,5 +4680,5 @@
 !
 !--                Predetermine flag to mask topography
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                    d_mean = 0.5_wp * ( qr(k+1,j,i) - qr(k-1,j,i) )
@@ -4709,5 +4714,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--             Sum up all rain drop number densities which contribute to the flux
@@ -4836,5 +4841,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( qr(k,j,i) > eps_sb )  THEN
@@ -4896,5 +4901,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           c_nr(k) = 0.25_wp * ( w_nr(k-1) + 2.0_wp * w_nr(k) + w_nr(k+1) ) *   &
@@ -4910,5 +4915,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              d_mean = 0.5_wp * ( qr(k+1,j,i) - qr(k-1,j,i) )
@@ -4943,5 +4948,5 @@
 !
 !--       Predetermine flag to mask topography
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--       Sum up all rain drop number densities which contribute to the flux
@@ -5153,5 +5158,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
 !
Index: /palm/trunk/SOURCE/calc_mean_profile.f90
===================================================================
--- /palm/trunk/SOURCE/calc_mean_profile.f90	(revision 4345)
+++ /palm/trunk/SOURCE/calc_mean_profile.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -66,5 +70,5 @@
        USE indices,                                                            &
            ONLY:  ngp_2dh_s_inner, nxl, nxr, nyn, nys, nzb, nzb, nzt,          &
-                  wall_flags_static_0
+                  wall_flags_total_0
 
        USE kinds
@@ -110,5 +114,5 @@
                    sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)              &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                          BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 ENDDO
              ENDDO
Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4346)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -249,5 +253,6 @@
     USE indices,                                                                                   &
          ONLY:  advc_flags_s,                                                                      &
-                nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, nzb, nzt, wall_flags_static_0
+                nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, nzb, nzt,            &
+                wall_flags_total_0
 
     USE pegrid,                                                                                    &
@@ -920,5 +925,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       cs_3d(k,j,i) = cs_pr_init(k) * flag
                    ENDDO
@@ -945,5 +950,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       cs_3d(k,j,i) = cs_3d(k,j,copied) * flag
                    ENDDO
@@ -982,5 +987,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       cs_3d(k,j,i) = cs_pr_init(k) * flag
                    ENDDO
@@ -1008,5 +1013,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       cs_3d(k,j,i) = cs_3d(k,copied,i) * flag
                    ENDDO
@@ -1331,5 +1336,5 @@
                                               chem_species(lsp)%conc(k,j,i),                       &
                                               REAL( fill_value, KIND = wp ),                       &
-                                              BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                              BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -1343,5 +1348,5 @@
                                               chem_species(lsp)%conc_av(k,j,i),                    &
                                               REAL( fill_value, KIND = wp ),                       &
-                                              BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                              BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -1439,5 +1444,5 @@
                                              chem_species(lsp)%conc(k,j,i),   &
                                              REAL( fill_value, KIND = wp ),   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                             BTEST( wall_flags_total_0(k,j,i), 0 ) )
                      ENDDO
                   ENDDO
@@ -1452,5 +1457,5 @@
                                              chem_species(lsp)%conc_av(k,j,i),&
                                              REAL( fill_value, KIND = wp ),   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                             BTEST( wall_flags_total_0(k,j,i), 0 ) )
                      ENDDO
                   ENDDO
@@ -1532,9 +1537,9 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -1568,9 +1573,9 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -1895,5 +1900,5 @@
        ALLOCATE( cs_advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 !
-!--    In case of decyling, set Neumann boundary conditions for wall_flags_static_0 
+!--    In case of decyling, set Neumann boundary conditions for wall_flags_total_0 
 !--    bit 31 instead of cyclic boundary conditions.
 !--    Bit 31 is used to identify extended degradation zones (please see
@@ -1901,5 +1906,5 @@
 !--    Note, since several also other modules like Salsa or other future 
 !--    one may access this bit but may have other boundary conditions, the 
-!--    original value of wall_flags_static_0 bit 31 must not be modified. Hence, 
+!--    original value of wall_flags_total_0 bit 31 must not be modified. Hence, 
 !--    store the boundary conditions directly on cs_advc_flags_s. 
 !--    cs_advc_flags_s will be later overwritten in ws_init_flags_scalar and
@@ -1908,5 +1913,5 @@
        cs_advc_flags_s = 0
        cs_advc_flags_s = MERGE( IBSET( cs_advc_flags_s, 31 ), 0,               &
-                                BTEST( wall_flags_static_0, 31 ) )
+                                BTEST( wall_flags_total_0, 31 ) )
 
        IF ( decycle_chem_ns )  THEN
@@ -2748,5 +2753,5 @@
                      * ( chem_species(ilsp)%conc(k,j,i) - chem_species(ilsp)%conc_pr_init(k) )     &
                      )                                                                             &
-                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 IF ( chem_species(ilsp)%conc_p(k,j,i) < 0.0_wp )  THEN
@@ -2858,5 +2863,5 @@
                )                                                                                   &
                * MERGE( 1.0_wp, 0.0_wp,                                                            &
-               BTEST( wall_flags_static_0(k,j,i), 0 )                                                     &
+               BTEST( wall_flags_total_0(k,j,i), 0 )                                               &
                )
 
@@ -3000,5 +3005,5 @@
                         rmask(j,i,sr)  *                                   &
                         MERGE( 1.0_wp, 0.0_wp,                             &
-                        BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                        BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 ENDDO
              ENDDO
Index: /palm/trunk/SOURCE/coriolis.f90
===================================================================
--- /palm/trunk/SOURCE/coriolis.f90	(revision 4345)
+++ /palm/trunk/SOURCE/coriolis.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -79,5 +83,6 @@
            
        USE indices,                                                            &
-           ONLY:  nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt, wall_flags_static_0
+           ONLY:  nxl, nxlu, nxr, nyn, nys, nysv, nzb, nzt,                    &
+                  wall_flags_total_0
                    
        USE kinds
@@ -107,5 +112,5 @@
           CASE ( 1 )
              !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
-             !$ACC PRESENT(wall_flags_static_0) &
+             !$ACC PRESENT(wall_flags_total_0) &
              !$ACC PRESENT(v, w, vg) &
              !$ACC PRESENT(tend)
@@ -115,5 +120,5 @@
 !
 !--                   Predetermine flag to mask topography
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
 
                       tend(k,j,i) = tend(k,j,i) + flag *                                           &
@@ -132,5 +137,5 @@
           CASE ( 2 )
              !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
-             !$ACC PRESENT(wall_flags_static_0) &
+             !$ACC PRESENT(wall_flags_total_0) &
              !$ACC PRESENT(u, w, ug) &
              !$ACC PRESENT(tend)
@@ -140,5 +145,5 @@
 !
 !--                   Predetermine flag to mask topography
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
 
                       tend(k,j,i) = tend(k,j,i) - flag *                                           &
@@ -157,5 +162,5 @@
           CASE ( 3 )
              !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
-             !$ACC PRESENT(wall_flags_static_0) &
+             !$ACC PRESENT(wall_flags_total_0) &
              !$ACC PRESENT(u, v) &
              !$ACC PRESENT(tend)
@@ -165,5 +170,5 @@
 !
 !--                   Predetermine flag to mask topography
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
 
                       tend(k,j,i) = tend(k,j,i)                                                 &
@@ -205,5 +210,5 @@
            
        USE indices,                                                            &
-           ONLY:  nzb, nzt, wall_flags_static_0
+           ONLY:  nzb, nzt, wall_flags_total_0
            
        USE kinds
@@ -235,5 +240,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
 
                 tend(k,j,i) = tend(k,j,i) + flag *                                                 &
@@ -252,5 +257,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
 
                 tend(k,j,i) = tend(k,j,i) - flag *                                                 &
@@ -269,5 +274,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
 
                 tend(k,j,i) = tend(k,j,i)                                                 &
Index: /palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_2d.f90	(revision 4345)
+++ /palm/trunk/SOURCE/data_output_2d.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4331 2019-12-10 18:25:02Z suehring
 ! Move 2-m potential temperature output to diagnostic_output_quantities
 ! 
@@ -103,5 +107,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg,       &
-               nzb, nzt, wall_flags_static_0
+               nzb, nzt, wall_flags_total_0
 
     USE kinds
@@ -1154,7 +1158,7 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),          &
-                                               REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i),     &
-                                                      flag_nr ) ) 
+                                           REAL( fill_value, KIND = wp ),      &
+                                           BTEST( wall_flags_total_0(k,j,i),   &
+                                                  flag_nr ) ) 
                    ENDDO
                 ENDDO
Index: /palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_3d.f90	(revision 4345)
+++ /palm/trunk/SOURCE/data_output_3d.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -98,9 +102,9 @@
     USE indices,                                                               &
         ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,     &
-               wall_flags_static_0
+               wall_flags_total_0
 #else
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb,  &
-               nzt, wall_flags_static_0
+               nzt, wall_flags_total_0
 #endif
 
@@ -623,5 +627,5 @@
                                       to_be_resorted(k,j,i),                   &
                                       REAL( fill_value, KIND = wp ),           &
-                                      BTEST( wall_flags_static_0(k,j,i), flag_nr ) )
+                                      BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
                 ENDDO
              ENDDO
Index: /palm/trunk/SOURCE/data_output_mask.f90
===================================================================
--- /palm/trunk/SOURCE/data_output_mask.f90	(revision 4345)
+++ /palm/trunk/SOURCE/data_output_mask.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4331 2019-12-10 18:25:02Z suehring
 ! Formatting adjustment
 ! 
@@ -97,5 +101,5 @@
 
     USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_static_0
+        ONLY:  nbgp, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
 
     USE kinds
@@ -267,10 +271,10 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )),&
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )),&
                                        DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -336,9 +340,10 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                         DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -379,9 +384,10 @@
                             im = mask_i(mid,i)
                             jm = mask_j(mid,j)
-                            ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                            ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                             DIM = 1 ) - 1
                             DO  k = 1, mask_size_l(mid,3)
                                kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                            Set value if not in building
-                               IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                               IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                   local_pf(i,j,k) = fill_value
                                ELSE
@@ -473,9 +479,10 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                          DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -512,9 +519,10 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                          DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -654,9 +662,10 @@
                    im = mask_i(mid,i)
                    jm = mask_j(mid,j)
-                   ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                   ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                    DIM = 1 ) - 1
                    DO  k = 1, mask_size_l(mid,3)
                       kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                   Set value if not in building
-                      IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                      IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                          local_pf(i,j,k) = fill_value
                       ELSE
Index: /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90
===================================================================
--- /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4331 2019-12-10 18:25:02Z suehring
 ! - Modularize 2-m potential temperature output
 ! - New output for 10-m wind speed
@@ -114,5 +118,5 @@
                nzb,                                                            &
                nzt,                                                            &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -704,6 +708,6 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-                                         REAL( fill_value, KIND = wp ),        &
-                                         BTEST( wall_flags_static_0(k,j,i), flag_nr ) ) 
+                                     REAL( fill_value, KIND = wp ),            &
+                                     BTEST( wall_flags_total_0(k,j,i), flag_nr ) ) 
              ENDDO
           ENDDO
@@ -807,6 +811,6 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-                                         REAL( fill_value, KIND = wp ),        &
-                                         BTEST( wall_flags_static_0(k,j,i), flag_nr ) ) 
+                                     REAL( fill_value, KIND = wp ),            &
+                                     BTEST( wall_flags_total_0(k,j,i), flag_nr ) ) 
              ENDDO
           ENDDO
@@ -924,5 +928,5 @@
                 im = mask_i(mid,i)
                 jm = mask_j(mid,j)
-                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), &
+                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
                               DIM = 1 ) - 1
                 DO  k = 1, mask_size_l(mid,3)
@@ -930,5 +934,5 @@
 !
 !--                Set value if not in building
-                   IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                       local_pf(i,j,k) = fill_value
                    ELSE
@@ -1071,5 +1075,5 @@
                           - (   u(k,j+1,i) + u(k,j+1,i+1)                      &
                               - u(k,j-1,i) - u(k,j-1,i+1) ) * ddy     )**2  )  &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0) )
                    ENDDO
                 ENDDO
@@ -1082,5 +1086,5 @@
                    DO  k = nzb+1, nzt
                       uu(k,j,i) = u(k,j,i) * u(k,j,i)                          &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1) )
                    ENDDO
                 ENDDO
@@ -1093,5 +1097,5 @@
                    DO  k = nzb+1, nzt
                       vv(k,j,i) = v(k,j,i) * v(k,j,i)                          &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2) )
                    ENDDO
                 ENDDO
@@ -1104,5 +1108,5 @@
                    DO  k = nzb+1, nzt-1
                       ww(k,j,i) = w(k,j,i) * w(k,j,i)                          &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3) )
                    ENDDO
                 ENDDO
Index: /palm/trunk/SOURCE/diffusion_s.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_s.f90	(revision 4345)
+++ /palm/trunk/SOURCE/diffusion_s.f90	(revision 4346)
@@ -25,5 +25,9 @@
 ! -----------------
 ! $Id$
-! Renamed wall_flags_0 to wall_flags_static_0
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
+! Renamed wall_flags_0 to wall_flags_total_0
 ! 
 ! 4182 2019-08-22 15:20:23Z scharf
@@ -86,5 +90,6 @@
        
        USE indices,                                                            &
-           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt, wall_flags_static_0
+           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,        &
+                  wall_flags_total_0
        
        USE kinds
@@ -135,5 +140,5 @@
        !$ACC PRIVATE(surf_e, surf_s, flag, mask_top, mask_bottom) &
        !$ACC PRIVATE(mask_north, mask_south, mask_west, mask_east) &
-       !$ACC PRESENT(wall_flags_static_0, kh) &
+       !$ACC PRESENT(wall_flags_total_0, kh) &
        !$ACC PRESENT(s) &
        !$ACC PRESENT(ddzu, ddzw, drho_air, rho_air_zw) &
@@ -159,12 +164,12 @@
 !
 !--             Predetermine flag to mask topography and wall-bounded grid points
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
 !
 !--             Predetermine flag to mask wall-bounded grid points, equivalent to
 !--             former s_outer array
-                mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i-1), 0 ) )
-                mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i+1), 0 ) )
-                mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j-1,i), 0 ) )
-                mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j+1,i), 0 ) )
+                mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 0 ) )
+                mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 0 ) )
+                mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 0 ) )
+                mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 0 ) )
 
                 tend(k,j,i) = tend(k,j,i)                                      &
@@ -300,11 +305,11 @@
 !--             flux at model top. 
                 mask_bottom = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                                 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
                 mask_top    = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 8 ) ) *     &
+                                 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) *   &
                               MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 9 ) ) 
+                                 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 
                 flag        = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                 BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 tend(k,j,i) = tend(k,j,i)                                      &
@@ -415,5 +420,5 @@
        
        USE indices,                                                            &
-           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_static_0
+           ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt, wall_flags_total_0
        
        USE kinds
@@ -465,12 +470,12 @@
 !
 !--       Predetermine flag to mask topography and wall-bounded grid points
-          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+          flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
 !
 !--       Predetermine flag to mask wall-bounded grid points, equivalent to
 !--       former s_outer array
-          mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i-1), 0 ) )
-          mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i+1), 0 ) )
-          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j-1,i), 0 ) )
-          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j+1,i), 0 ) )
+          mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 0 ) )
+          mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 0 ) )
+          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 0 ) )
+          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 0 ) )
 !
 !--       Finally, determine flag to mask both topography itself as well
@@ -610,11 +615,11 @@
 !--       flux at model top.   
           mask_bottom = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                               BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
           mask_top    = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 8 ) )  *          &
+                               BTEST( wall_flags_total_0(k+1,j,i), 8 ) )  *    &
                         MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 9 ) )
+                               BTEST( wall_flags_total_0(k+1,j,i), 9 ) )
           flag        = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           tend(k,j,i) = tend(k,j,i)                                            &
Index: /palm/trunk/SOURCE/diffusion_u.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_u.f90	(revision 4345)
+++ /palm/trunk/SOURCE/diffusion_u.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -75,5 +79,5 @@
        
        USE indices,                                                            &
-           ONLY:  nxlu, nxr, nyn, nys, nzb, nzt, wall_flags_static_0
+           ONLY:  nxlu, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
      
        USE kinds
@@ -108,5 +112,5 @@
        !$ACC PRIVATE(surf_e, surf_s, flag, kmym, kmyp, kmzm, kmzp) &
        !$ACC PRIVATE(mask_bottom, mask_north, mask_south, mask_top) &
-       !$ACC PRESENT(wall_flags_static_0, km) &
+       !$ACC PRESENT(wall_flags_total_0, km) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(ddzu, ddzw, drho_air, rho_air_zw) &
@@ -124,7 +128,7 @@
 !--             It is sufficient to masked only north- and south-facing surfaces, which
 !--             need special treatment for the u-component. 
-                flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i),   1 ) ) 
-                mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j-1,i), 1 ) )
-                mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j+1,i), 1 ) )
+                flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i),   1 ) ) 
+                mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 1 ) )
+                mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 1 ) )
 !
 !--             Interpolate eddy diffusivities on staggered gridpoints
@@ -199,11 +203,11 @@
 !--             momentum flux at model top.  
                 mask_bottom = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                                 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
                 mask_top    = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 8 ) ) *     &
+                                 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) *   &
                               MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 9 ) ) 
+                                 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 
                 flag        = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k,j,i), 1 ) ) 
+                                 BTEST( wall_flags_total_0(k,j,i), 1 ) ) 
 !
 !--             Interpolate eddy diffusivities on staggered gridpoints
@@ -322,5 +326,5 @@
        
        USE indices,                                                            &
-           ONLY:  nzb, nzt, wall_flags_static_0
+           ONLY:  nzb, nzt, wall_flags_total_0
       
        USE kinds
@@ -356,7 +360,7 @@
 !--       It is sufficient to masked only north- and south-facing surfaces, which
 !--       need special treatment for the u-component. 
-          flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i),   1 ) ) 
-          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j-1,i), 1 ) )
-          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j+1,i), 1 ) )
+          flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i),   1 ) ) 
+          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 1 ) )
+          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 1 ) )
 !
 !--       Interpolate eddy diffusivities on staggered gridpoints
@@ -425,11 +429,11 @@
 !--       momentum flux at model top. 
           mask_bottom = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                               BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
           mask_top    = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 8 ) ) *           &
+                               BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) *     &
                         MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 9 ) )
+                               BTEST( wall_flags_total_0(k+1,j,i), 9 ) )
           flag        = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k,j,i), 1 ) ) 
+                               BTEST( wall_flags_total_0(k,j,i), 1 ) ) 
 !
 !--       Interpolate eddy diffusivities on staggered gridpoints
Index: /palm/trunk/SOURCE/diffusion_v.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_v.f90	(revision 4345)
+++ /palm/trunk/SOURCE/diffusion_v.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -73,5 +77,5 @@
        
        USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nysv, nzb, nzt, wall_flags_static_0
+           ONLY:  nxl, nxr, nyn, nysv, nzb, nzt, wall_flags_total_0
        
        USE kinds
@@ -104,5 +108,5 @@
        !$ACC PRIVATE(surf_e, surf_s, flag, kmxm, kmxp, kmzm, kmzp) &
        !$ACC PRIVATE(mask_bottom, mask_east, mask_west, mask_top) &
-       !$ACC PRESENT(wall_flags_static_0, km) &
+       !$ACC PRESENT(wall_flags_total_0, km) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(ddzu, ddzw, drho_air, rho_air_zw) &
@@ -121,7 +125,7 @@
 !--             It is sufficient to masked only east- and west-facing surfaces, which
 !--             need special treatment for the v-component. 
-                flag      = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i),   2 ) ) 
-                mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i+1), 2 ) )
-                mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i-1), 2 ) )
+                flag      = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i),   2 ) ) 
+                mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 2 ) )
+                mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 2 ) )
 !
 !--             Interpolate eddy diffusivities on staggered gridpoints
@@ -195,11 +199,11 @@
 !--             momentum flux at model top.  
                 mask_bottom = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                                 BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
                 mask_top    = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 8 ) ) *     &
+                                 BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) *   &
                               MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k+1,j,i), 9 ) ) 
+                                 BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 
                 flag        = MERGE( 1.0_wp, 0.0_wp,                           &
-                                     BTEST( wall_flags_static_0(k,j,i), 2 ) ) 
+                                 BTEST( wall_flags_total_0(k,j,i), 2 ) ) 
 !
 !--             Interpolate eddy diffusivities on staggered gridpoints
@@ -313,5 +317,5 @@
        
        USE indices,                                                            &
-           ONLY:  nzb, nzt, wall_flags_static_0
+           ONLY:  nzb, nzt, wall_flags_total_0
        
        USE kinds
@@ -349,7 +353,7 @@
 !--       It is sufficient to masked only east- and west-facing surfaces, which
 !--       need special treatment for the v-component. 
-          flag      = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i),   2 ) ) 
-          mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i+1), 2 ) )
-          mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i-1), 2 ) )
+          flag      = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i),   2 ) ) 
+          mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 2 ) )
+          mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 2 ) )
 !
 !--       Interpolate eddy diffusivities on staggered gridpoints
@@ -419,11 +423,11 @@
 !--       momentum flux at model top.  
           mask_bottom = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k-1,j,i), 8 ) ) 
+                               BTEST( wall_flags_total_0(k-1,j,i), 8 ) ) 
           mask_top    = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 8 ) ) *           &
+                               BTEST( wall_flags_total_0(k+1,j,i), 8 ) ) *     &
                         MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k+1,j,i), 9 ) ) 
+                               BTEST( wall_flags_total_0(k+1,j,i), 9 ) ) 
           flag        = MERGE( 1.0_wp, 0.0_wp,                                 &
-                               BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                               BTEST( wall_flags_total_0(k,j,i), 2 ) )
 !
 !--       Interpolate eddy diffusivities on staggered gridpoints
Index: /palm/trunk/SOURCE/diffusion_w.f90
===================================================================
--- /palm/trunk/SOURCE/diffusion_w.f90	(revision 4345)
+++ /palm/trunk/SOURCE/diffusion_w.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -69,5 +73,5 @@
            
        USE indices,                                                            &            
-           ONLY :  nxl, nxr, nyn, nys, nzb, nzt, wall_flags_static_0
+           ONLY :  nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
            
        USE kinds
@@ -101,5 +105,5 @@
        !$ACC PRIVATE(surf_e, surf_s, flag, kmxm, kmxp, kmym, kmyp) &
        !$ACC PRIVATE(mask_west, mask_east, mask_south, mask_north) &
-       !$ACC PRESENT(wall_flags_static_0, km) &
+       !$ACC PRESENT(wall_flags_total_0, km) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(ddzu, ddzw, rho_air, drho_air_zw) &
@@ -114,13 +118,13 @@
 !--             Predetermine flag to mask topography and wall-bounded grid points. 
                 flag       = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,i),   3 ) ) 
+                                    BTEST( wall_flags_total_0(k,j,i),   3 ) ) 
                 mask_east  = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,i+1), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j,i+1), 3 ) )
                 mask_west  = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,i-1), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j,i-1), 3 ) )
                 mask_south = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j-1,i), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j-1,i), 3 ) )
                 mask_north = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j+1,i), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j+1,i), 3 ) )
 !
 !--             Interpolate eddy diffusivities on staggered gridpoints
@@ -254,5 +258,5 @@
            
        USE indices,                                                            &            
-           ONLY :  nzb, nzt, wall_flags_static_0
+           ONLY :  nzb, nzt, wall_flags_total_0
            
        USE kinds
@@ -286,9 +290,9 @@
 !
 !--       Predetermine flag to mask topography and wall-bounded grid points. 
-          flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i),   3 ) ) 
-          mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i+1), 3 ) )
-          mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i-1), 3 ) )
-          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j-1,i), 3 ) )
-          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j+1,i), 3 ) )
+          flag       = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i),   3 ) ) 
+          mask_east  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i+1), 3 ) )
+          mask_west  = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i-1), 3 ) )
+          mask_south = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j-1,i), 3 ) )
+          mask_north = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j+1,i), 3 ) )
 !
 !--       Interpolate eddy diffusivities on staggered gridpoints
Index: /palm/trunk/SOURCE/disturb_field.f90
===================================================================
--- /palm/trunk/SOURCE/disturb_field.f90	(revision 4345)
+++ /palm/trunk/SOURCE/disturb_field.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -62,5 +66,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_max, &
-               nzt, wall_flags_static_0
+               nzt, wall_flags_total_0
         
     USE kinds
@@ -217,5 +221,5 @@
              DO  k = nzb, nzb_max
                 dist1(k,j,i) = MERGE( dist1(k,j,i), 0.0_wp,                    &
-                                      BTEST( wall_flags_static_0(k,j,i), flag_nr )    &
+                                  BTEST( wall_flags_total_0(k,j,i), flag_nr )  &
                                     )
              ENDDO
Index: /palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/flow_statistics.f90	(revision 4345)
+++ /palm/trunk/SOURCE/flow_statistics.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -95,5 +99,5 @@
         ONLY:   ngp_2dh, ngp_2dh_s_inner, ngp_3d, ngp_3d_inner, ngp_sums,      &
                 ngp_sums_ls, nxl, nxr, nyn, nys, nzb, nzt, topo_min_level,     &
-                wall_flags_static_0
+                wall_flags_total_0
         
     USE kinds
@@ -257,9 +261,9 @@
        !$OMP DO
        !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) &
-       !$ACC PRESENT(wall_flags_static_0, u, v, pt, rmask, sums_l)
+       !$ACC PRESENT(wall_flags_total_0, u, v, pt, rmask, sums_l)
        DO  i = nxl, nxr
           DO  j =  nys, nyn
              DO  k = nzb, nzt+1
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 !$ACC ATOMIC
                 sums_l(k,1,tn)  = sums_l(k,1,tn)  + u(k,j,i)  * rmask(j,i,sr)  &
@@ -286,5 +290,5 @@
                                     * rmask(j,i,sr)                            &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                             BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 ENDDO
              ENDDO
@@ -301,5 +305,5 @@
              DO  j =  nys, nyn
                 DO  k = nzb, nzt+1
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
                    sums_l(k,44,tn)  = sums_l(k,44,tn) +                        &
                                       vpt(k,j,i) * rmask(j,i,sr) * flag
@@ -314,5 +318,5 @@
                 DO  j =  nys, nyn
                    DO  k = nzb, nzt+1
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       sums_l(k,42,tn) = sums_l(k,42,tn) +                      &
                                       ( q(k,j,i) - ql(k,j,i) ) * rmask(j,i,sr) &
@@ -338,5 +342,5 @@
                                     * rmask(j,i,sr)                            &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                             BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 ENDDO
              ENDDO
@@ -479,5 +483,5 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k, m) &
        !$ACC PRIVATE(sums_l_etot, flag) &
-       !$ACC PRESENT(wall_flags_static_0, rmask, momentumflux_output_conversion) &
+       !$ACC PRESENT(wall_flags_total_0, rmask, momentumflux_output_conversion) &
        !$ACC PRESENT(hom(:,1,4,sr)) &
        !$ACC PRESENT(e, u, v, w, km, kh, p, pt) &
@@ -488,5 +492,5 @@
              sums_l_etot = 0.0_wp
              DO  k = nzb, nzt+1
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
 !
 !--             Prognostic and diagnostic variables
@@ -656,5 +660,5 @@
              DO  j =  nys, nyn
                 DO  k = nzb, nzt+1
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
 
                    u2   = u(k,j,i)**2
@@ -688,10 +692,10 @@
        !$OMP DO
        !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag, w2, ust2, vst2) &
-       !$ACC PRESENT(wall_flags_static_0, u, v, w, rmask, hom(:,1,1:2,sr)) &
+       !$ACC PRESENT(wall_flags_total_0, u, v, w, rmask, hom(:,1,1:2,sr)) &
        !$ACC PRESENT(sums_l)
        DO  i = nxl, nxr
           DO  j =  nys, nyn
              DO  k = nzb, nzt+1
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
 
                 w2   = w(k,j,i)**2
@@ -717,5 +721,5 @@
        !$ACC PRIVATE(ki, flag, ust, vst, pts) &
        !$ACC PRESENT(kh, km, u, v, w, pt) &
-       !$ACC PRESENT(wall_flags_static_0, rmask, ddzu, rho_air_zw, hom(:,1,1:4,sr)) &
+       !$ACC PRESENT(wall_flags_total_0, rmask, ddzu, rho_air_zw, hom(:,1,1:4,sr)) &
        !$ACC PRESENT(heatflux_output_conversion, momentumflux_output_conversion) &
        !$ACC PRESENT(surf_def_h(0:2), surf_lsm_h, surf_usm_h) &
@@ -735,7 +739,7 @@
              DO  k = nzb, nzt
                 flag = MERGE( 1.0_wp, 0.0_wp,                                  &
-                              BTEST( wall_flags_static_0(k,j,i), 23 ) ) *             &
+                              BTEST( wall_flags_total_0(k,j,i), 23 ) ) *       &
                        MERGE( 1.0_wp, 0.0_wp,                                  &
-                              BTEST( wall_flags_static_0(k,j,i), 9  ) )
+                              BTEST( wall_flags_total_0(k,j,i), 9  ) )
 !
 !--             Momentum flux w"u"
@@ -1209,5 +1213,5 @@
 !--                rearranged according to the staggered grid.
              DO  k = nzb, nzt
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) )
                 ust = 0.5_wp * ( u(k,j,i)   - hom(k,1,1,sr) +                  &
                                  u(k+1,j,i) - hom(k+1,1,1,sr) )
@@ -1398,7 +1402,7 @@
 !--                fluxes, which are added further below. 
                    flag = MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(k,j,i), 23 ) ) *          &
+                                 BTEST( wall_flags_total_0(k,j,i), 23 ) ) *    &
                           MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(k,j,i), 9  ) )
+                                 BTEST( wall_flags_total_0(k,j,i), 9  ) )
 
                    ust = 0.5_wp * ( u(k,j,i)   - hom(k,1,1,sr) +               &
@@ -1433,7 +1437,7 @@
                 DO  k = nzb, nzt
                    flag = MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(k,j,i), 23 ) ) *          &
+                                 BTEST( wall_flags_total_0(k,j,i), 23 ) ) *    &
                           MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(k,j,i), 9  ) )
+                                 BTEST( wall_flags_total_0(k,j,i), 9  ) )
 !
 !--                Vertical heat flux
@@ -1484,5 +1488,5 @@
              DO  j = nys, nyn
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                    sums_ll(k,1) = sums_ll(k,1) + 0.5_wp * w(k,j,i) * (         &
@@ -1526,5 +1530,5 @@
                 DO  k = nzb+1, nzt
 
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                    sums_l(k,57,tn) = sums_l(k,57,tn) - 0.5_wp * (              &
@@ -1555,5 +1559,5 @@
              DO  j = nys, nyn
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--                Subgrid horizontal heat fluxes u"pt", v"pt"
@@ -1653,5 +1657,5 @@
              DO  j =  nys, nyn
                 DO  k = nzb+1, nzt+1
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                    sums_l(k,100,tn)  = sums_l(k,100,tn)  + rad_lw_in(k,j,i)    &
Index: /palm/trunk/SOURCE/indoor_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/indoor_model_mod.f90	(revision 4346)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -481,5 +485,5 @@
 
     USE indices,                                                               &
-        ONLY:  nxl, nxr, nyn, nys, nzb, nzt, wall_flags_static_0
+        ONLY:  nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
 
     USE grid_variables,                                                        &
@@ -671,5 +675,5 @@
 !
 !--             Check if grid point belongs to a building. 
-                IF ( BTEST( wall_flags_static_0(k,j,i), 6 ) )  THEN
+                IF ( BTEST( wall_flags_total_0(k,j,i), 6 ) )  THEN
                    k_min_l(nb) = MIN( k_min_l(nb), k )
                    k_max_l(nb) = MAX( k_max_l(nb), k )
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 4345)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -777,7 +781,7 @@
 !--       Set velocity components at non-atmospheric / oceanic grid points to 
 !--       zero. 
-          u = MERGE( u, 0.0_wp, BTEST( wall_flags_static_0, 1 ) )
-          v = MERGE( v, 0.0_wp, BTEST( wall_flags_static_0, 2 ) )
-          w = MERGE( w, 0.0_wp, BTEST( wall_flags_static_0, 3 ) )
+          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
+          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
+          w = MERGE( w, 0.0_wp, BTEST( wall_flags_total_0, 3 ) )
 !
 !--       Initialize surface variables, e.g. friction velocity, momentum 
@@ -827,6 +831,6 @@
 !
 !--       Set velocities back to zero
-          u = MERGE( u, 0.0_wp, BTEST( wall_flags_static_0, 1 ) )
-          v = MERGE( v, 0.0_wp, BTEST( wall_flags_static_0, 2 ) )         
+          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
+          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )         
 !
 !--       WARNING: The extra boundary conditions set after running the
@@ -871,6 +875,6 @@
 !
 !--       Mask topography
-          u = MERGE( u, 0.0_wp, BTEST( wall_flags_static_0, 1 ) )
-          v = MERGE( v, 0.0_wp, BTEST( wall_flags_static_0, 2 ) )
+          u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
+          v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
 !
 !--       Set initial horizontal velocities at the lowest computational grid 
@@ -887,7 +891,7 @@
                    DO  k = nzb, nzt
                       u(k,j,i) = MERGE( u(k,j,i), 0.0_wp,                      &
-                                        BTEST( wall_flags_static_0(k,j,i), 20 ) )
+                                     BTEST( wall_flags_total_0(k,j,i), 20 ) )
                       v(k,j,i) = MERGE( v(k,j,i), 0.0_wp,                      &
-                                        BTEST( wall_flags_static_0(k,j,i), 21 ) )
+                                     BTEST( wall_flags_total_0(k,j,i), 21 ) )
                    ENDDO
                 ENDDO
@@ -1313,9 +1317,9 @@
                 DO  k = nzb, nzt
                    u(k,j,i)     = MERGE( u(k,j,i), 0.0_wp,                     &
-                                         BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                      BTEST( wall_flags_total_0(k,j,i), 1 ) )
                    v(k,j,i)     = MERGE( v(k,j,i), 0.0_wp,                     &
-                                         BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                      BTEST( wall_flags_total_0(k,j,i), 2 ) )
                    w(k,j,i)     = MERGE( w(k,j,i), 0.0_wp,                     &
-                                         BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                      BTEST( wall_flags_total_0(k,j,i), 3 ) )
                 ENDDO
              ENDDO
@@ -1395,13 +1399,13 @@
              DO  j = nys, nyn
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
-                                              u_init(k) * dzw(k)               &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nxr), 1 )&
+                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +         &
+                                              u_init(k) * dzw(k)                 &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nxr), 1 )&
                                             )
 
-                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nxr), 1 )&
+                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)     &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nxr), 1 )&
                                             )
                 ENDDO
@@ -1412,12 +1416,12 @@
              DO  i = nxl, nxr
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
-                                              v_init(k) * dzw(k)               &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,nyn,i), 2 )&
+                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +         &
+                                              v_init(k) * dzw(k)                 &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,nyn,i), 2 )&
                                             )
-                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,nyn,i), 2 )&
+                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)     &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,nyn,i), 2 )&
                                             )
                 ENDDO
@@ -1444,12 +1448,12 @@
              DO  j = nys, nyn
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
-                                              hom_sum(k,1,0) * dzw(k)          &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nx), 1 ) &
+                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +         &
+                                              hom_sum(k,1,0) * dzw(k)            &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nx), 1 ) &
                                             )
-                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nx), 1 ) &
+                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)     &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nx), 1 ) &
                                             )
                 ENDDO
@@ -1460,12 +1464,12 @@
              DO  i = nxl, nxr
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
-                                              hom_sum(k,2,0) * dzw(k)          &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,ny,i), 2 ) &
+                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +         &
+                                              hom_sum(k,2,0) * dzw(k)            &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,ny,i), 2 ) &
                                             )
-                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,ny,i), 2 ) &
+                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)     &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,ny,i), 2 ) &
                                             )
                 ENDDO
@@ -1492,12 +1496,12 @@
              DO  j = nys, nyn
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +       &
-                                              u(k,j,nx) * dzw(k)               &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nx), 1 ) &
+                   volume_flow_initial_l(1) = volume_flow_initial_l(1) +         &
+                                              u(k,j,nx) * dzw(k)                 &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nx), 1 ) &
                                             )
-                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)   &
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nx), 1 ) &
+                   volume_flow_area_l(1)    = volume_flow_area_l(1) + dzw(k)     &
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,j,nx), 1 ) &
                                             )
                 ENDDO
@@ -1508,12 +1512,12 @@
              DO  i = nxl, nxr
                 DO  k = nzb+1, nzt
-                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +       &
-                                              v(k,ny,i) * dzw(k)               &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,ny,i), 2 ) &
+                   volume_flow_initial_l(2) = volume_flow_initial_l(2) +         &
+                                              v(k,ny,i) * dzw(k)                 &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,ny,i), 2 ) &
                                             )
-                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)   &        
-                                     * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,ny,i), 2 ) &
+                   volume_flow_area_l(2)    = volume_flow_area_l(2) + dzw(k)     &        
+                                     * MERGE( 1.0_wp, 0.0_wp,                    &
+                                          BTEST( wall_flags_total_0(k,ny,i), 2 ) &
                                             )
                 ENDDO
@@ -1696,8 +1700,8 @@
 !--                xy-grid points above topography
                    ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr)     +         &
-                                  MERGE( 1, 0, BTEST( wall_flags_static_0(k,j,i), 24 ) )
+                             MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 24 ) )
 
                    ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) +         &
-                                  MERGE( 1, 0, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                             MERGE( 1, 0, BTEST( wall_flags_total_0(k,j,i), 22 ) )
 
                 ENDDO
@@ -1795,5 +1799,5 @@
 !$ACC COPYIN(rho_air(nzb:nzt+1), rho_air_zw(nzb:nzt+1)) &
 !$ACC COPYIN(ddzu(1:nzt+1), ddzw(1:nzt+1)) &
-!$ACC COPYIN(wall_flags_static_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
+!$ACC COPYIN(wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
 !$ACC COPYIN(bc_h(0:1)) &
 !$ACC COPYIN(bc_h(0)%i(1:bc_h(0)%ns)) &
Index: /palm/trunk/SOURCE/init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/init_grid.f90	(revision 4345)
+++ /palm/trunk/SOURCE/init_grid.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4340 2019-12-16 08:17:03Z Giersch
 ! Topography closed channel flow with symmetric boundaries implemented
 ! 
@@ -2353,5 +2357,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb,  &
-               nzt, topo_top_ind, wall_flags_static_0
+               nzt, topo_top_ind, wall_flags_static_0, wall_flags_total_0
 
     USE kinds
@@ -2407,20 +2411,35 @@
 
     CALL exchange_horiz_int( wall_flags_static_0, nys, nyn, nxl, nxr, nzt, nbgp )
+
 !
 !-- Set outer array for scalars to mask near-surface grid points. Note, on 
 !-- basis of flag 24 futher flags will be derived which are used to control
 !-- production of subgrid TKE production near walls. 
+    
+    ALLOCATE( wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+    wall_flags_total_0 = 0
+                                    
     DO i = nxl, nxr
        DO j = nys, nyn
           DO k = nzb, nzt+1
-             IF ( BTEST( wall_flags_static_0(k,j-1,i), 0 )    .AND.                   &
-                  BTEST( wall_flags_static_0(k,j+1,i), 0 )    .AND.                   &
-                  BTEST( wall_flags_static_0(k,j,i-1), 0 )    .AND.                   &
-                  BTEST( wall_flags_static_0(k,j,i+1), 0 )    .AND.                   &
-                  BTEST( wall_flags_static_0(k,j-1,i-1), 0 )  .AND.                   &
-                  BTEST( wall_flags_static_0(k,j+1,i-1), 0 )  .AND.                   &
-                  BTEST( wall_flags_static_0(k,j-1,i+1), 0 )  .AND.                   &
-                  BTEST( wall_flags_static_0(k,j+1,i+1), 0 ) )                        &
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 24 )
+             wall_flags_total_0(k,j,i) = IOR( wall_flags_total_0(k,j,i), wall_flags_static_0(k,j,i) )
+          ENDDO
+       ENDDO
+    ENDDO
+    
+    CALL exchange_horiz_int( wall_flags_total_0, nys, nyn, nxl, nxr, nzt, nbgp )
+    
+    DO i = nxl, nxr
+       DO j = nys, nyn
+          DO k = nzb, nzt+1
+             IF ( BTEST( wall_flags_total_0(k,j-1,i), 0 )    .AND.                   &
+                  BTEST( wall_flags_total_0(k,j+1,i), 0 )    .AND.                   &
+                  BTEST( wall_flags_total_0(k,j,i-1), 0 )    .AND.                   &
+                  BTEST( wall_flags_total_0(k,j,i+1), 0 )    .AND.                   &
+                  BTEST( wall_flags_total_0(k,j-1,i-1), 0 )  .AND.                   &
+                  BTEST( wall_flags_total_0(k,j+1,i-1), 0 )  .AND.                   &
+                  BTEST( wall_flags_total_0(k,j-1,i+1), 0 )  .AND.                   &
+                  BTEST( wall_flags_total_0(k,j+1,i+1), 0 ) )                        &
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 24 )
           ENDDO
        ENDDO
@@ -2446,8 +2465,8 @@
 !--          effect on the flow is negligible. 
              IF ( constant_flux_layer  .OR.  use_surface_fluxes )  THEN
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )                         &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 8 )
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )                         &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 8 )
              ELSE
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 8 )
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 8 )
              ENDIF
 
@@ -2456,7 +2475,7 @@
 !--       Special flag to control vertical diffusion at model top - former 
 !--       nzt_diff
-          wall_flags_static_0(:,j,i) = IBSET( wall_flags_static_0(:,j,i), 9 )
+          wall_flags_total_0(:,j,i) = IBSET( wall_flags_total_0(:,j,i), 9 )
           IF ( use_top_fluxes )                                                &
-             wall_flags_static_0(nzt+1,j,i) = IBCLR( wall_flags_static_0(nzt+1,j,i), 9 )
+             wall_flags_total_0(nzt+1,j,i) = IBCLR( wall_flags_total_0(nzt+1,j,i), 9 )
 
 
@@ -2467,8 +2486,8 @@
 !--          topography, as well as initialize u with zero one grid point outside
 !--          of topography.
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 1 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k,j,i),   1 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k+1,j,i), 1 ) )                          &
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 20 )
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 1 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k,j,i),   1 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k+1,j,i), 1 ) )                          &
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 20 )
 !
 !--          Special flag on v grid, former nzb_v_inner + 1, required   
@@ -2476,26 +2495,26 @@
 !--          topography, as well as initialize v with zero one grid point outside
 !--          of topography.
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 2 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k,j,i),   2 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k+1,j,i), 2 ) )                          &
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 21 )
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 2 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k,j,i),   2 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k+1,j,i), 2 ) )                          &
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 21 )
 !
 !--          Special flag on scalar grid, former nzb_s_inner+1. Used for 
 !--          lpm_sgs_tke
-             IF ( BTEST( wall_flags_static_0(k,j,i),   0 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k-1,j,i), 0 )  .AND.                     &
-                  BTEST( wall_flags_static_0(k+1,j,i), 0 ) )                          &
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 25 )
+             IF ( BTEST( wall_flags_total_0(k,j,i),   0 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k-1,j,i), 0 )  .AND.                     &
+                  BTEST( wall_flags_total_0(k+1,j,i), 0 ) )                          &
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 25 )
 !
 !--          Special flag on scalar grid, nzb_diff_s_outer - 1, required in 
 !--          in production_e
              IF ( constant_flux_layer  .OR.  use_surface_fluxes )  THEN
-                IF ( BTEST( wall_flags_static_0(k,j,i),   24 )  .AND.                 &
-                     BTEST( wall_flags_static_0(k-1,j,i), 24 )  .AND.                 &
-                     BTEST( wall_flags_static_0(k+1,j,i), 0 ) )                       &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 29 )
+                IF ( BTEST( wall_flags_total_0(k,j,i),   24 )  .AND.                 &
+                     BTEST( wall_flags_total_0(k-1,j,i), 24 )  .AND.                 &
+                     BTEST( wall_flags_total_0(k+1,j,i), 0 ) )                       &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 29 )
              ELSE
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )                         &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 29 )
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )                         &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 29 )
              ENDIF
 !
@@ -2503,11 +2522,11 @@
 !--          in production_e
              IF ( constant_flux_layer  .OR.  use_surface_fluxes )  THEN
-                IF ( BTEST( wall_flags_static_0(k,j,i),   0 )  .AND.                  &
-                     BTEST( wall_flags_static_0(k-1,j,i), 0 )  .AND.                  &
-                     BTEST( wall_flags_static_0(k+1,j,i), 0 ) )                       &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 30 )
+                IF ( BTEST( wall_flags_total_0(k,j,i),   0 )  .AND.                  &
+                     BTEST( wall_flags_total_0(k-1,j,i), 0 )  .AND.                  &
+                     BTEST( wall_flags_total_0(k+1,j,i), 0 ) )                       &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 30 )
              ELSE
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )                         &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 30 )
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )                         &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 30 )
              ENDIF
           ENDDO
@@ -2517,22 +2536,22 @@
 !
 !--          Scalar grid
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 0 )  .AND.                     &
-            .NOT. BTEST( wall_flags_static_0(k,j,i), 0   ) )                          & 
-                 wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 13 ) 
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 0 )  .AND.                     &
+            .NOT. BTEST( wall_flags_total_0(k,j,i), 0   ) )                          & 
+                 wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 13 ) 
 !
 !--          Downward facing wall on u grid
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 1 )  .AND.                     &
-            .NOT. BTEST( wall_flags_static_0(k,j,i), 1   ) )                          & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 15 )
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 1 )  .AND.                     &
+            .NOT. BTEST( wall_flags_total_0(k,j,i), 1   ) )                          & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 15 )
 !
 !--          Downward facing wall on v grid
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 2 )  .AND.                     &
-            .NOT. BTEST( wall_flags_static_0(k,j,i), 2   ) )                          & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 17 )
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 2 )  .AND.                     &
+            .NOT. BTEST( wall_flags_total_0(k,j,i), 2   ) )                          & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 17 )
 !
 !--          Downward facing wall on w grid
-             IF ( BTEST( wall_flags_static_0(k-1,j,i), 3 )  .AND.                     &
-            .NOT. BTEST( wall_flags_static_0(k,j,i), 3 ) )                            & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 19 )
+             IF ( BTEST( wall_flags_total_0(k-1,j,i), 3 )  .AND.                     &
+            .NOT. BTEST( wall_flags_total_0(k,j,i), 3 ) )                            & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 19 )
           ENDDO
 !
@@ -2541,46 +2560,46 @@
 !
 !--          Upward facing wall on scalar grid
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i),   0 )  .AND.               &
-                        BTEST( wall_flags_static_0(k+1,j,i), 0 ) )                    & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 12 )
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i),   0 )  .AND.               &
+                        BTEST( wall_flags_total_0(k+1,j,i), 0 ) )                    & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 12 )
 !
 !--          Upward facing wall on u grid
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i),   1 )  .AND.               &
-                        BTEST( wall_flags_static_0(k+1,j,i), 1 ) )                    & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 14 )
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i),   1 )  .AND.               &
+                        BTEST( wall_flags_total_0(k+1,j,i), 1 ) )                    & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 14 )
 
 !   
 !--          Upward facing wall on v grid
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i),   2 )  .AND.               &
-                        BTEST( wall_flags_static_0(k+1,j,i), 2 ) )                    & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 16 )
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i),   2 )  .AND.               &
+                        BTEST( wall_flags_total_0(k+1,j,i), 2 ) )                    & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 16 )
    
 !
 !--          Upward facing wall on w grid
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i),   3 )  .AND.               &
-                        BTEST( wall_flags_static_0(k+1,j,i), 3 ) )                    & 
-                wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 18 )
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i),   3 )  .AND.               &
+                        BTEST( wall_flags_total_0(k+1,j,i), 3 ) )                    & 
+                wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 18 )
 !
 !--          Special flag on scalar grid, former nzb_s_inner
-             IF ( BTEST( wall_flags_static_0(k,j,i), 0 )  .OR.                        &
-                  BTEST( wall_flags_static_0(k,j,i), 12 ) .OR.                        &
-                  BTEST( wall_flags_static_0(k,j,i), 13 ) )                           &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 22 )
+             IF ( BTEST( wall_flags_total_0(k,j,i), 0 )  .OR.                        &
+                  BTEST( wall_flags_total_0(k,j,i), 12 ) .OR.                        &
+                  BTEST( wall_flags_total_0(k,j,i), 13 ) )                           &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 22 )
 !
 !--          Special flag on scalar grid, nzb_diff_s_inner - 1, required for 
 !--          flow_statistics
              IF ( constant_flux_layer  .OR.  use_surface_fluxes )  THEN
-                IF ( BTEST( wall_flags_static_0(k,j,i),   0 )  .AND.                  &
-                     BTEST( wall_flags_static_0(k+1,j,i), 0 ) )                       &
-                  wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 23 )
+                IF ( BTEST( wall_flags_total_0(k,j,i),   0 )  .AND.                  &
+                     BTEST( wall_flags_total_0(k+1,j,i), 0 ) )                       &
+                  wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 23 )
              ELSE
-                IF ( BTEST( wall_flags_static_0(k,j,i), 22 ) )                        &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 23 )
+                IF ( BTEST( wall_flags_total_0(k,j,i), 22 ) )                        &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 23 )
              ENDIF
    
 
           ENDDO
-          wall_flags_static_0(nzt+1,j,i) = IBSET( wall_flags_static_0(nzt+1,j,i), 22 )
-          wall_flags_static_0(nzt+1,j,i) = IBSET( wall_flags_static_0(nzt+1,j,i), 23 )
+          wall_flags_total_0(nzt+1,j,i) = IBSET( wall_flags_total_0(nzt+1,j,i), 22 )
+          wall_flags_total_0(nzt+1,j,i) = IBSET( wall_flags_total_0(nzt+1,j,i), 23 )
 !
 !--       Set flags indicating that topography is close by in horizontal 
@@ -2593,19 +2612,19 @@
           IF ( scalar_advec == 'ws-scheme' )  THEN
              DO k = nzb, nzt
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 )  .AND. (                   &
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i-1), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i-2), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i-3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i+1), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i+2), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3:j+3,i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-1,i-3:i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-2,i-3:i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j-3,i-3:i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j+1,i-3:i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j+2,i-3:i+3), 0 ) )  .OR.&
-                     ANY( .NOT. BTEST( wall_flags_static_0(k,j+3,i-3:i+3), 0 ) )      &
-                                                            ) )                &
-                   wall_flags_static_0(k,j,i) = IBSET( wall_flags_static_0(k,j,i), 31 )
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 )  .AND. (                  &
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i-1), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i-2), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i-3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i+1), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i+2), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3:j+3,i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-1,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-2,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j-3,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j+1,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j+2,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_total_0(k,j+3,i-3:i+3), 0 ) )      &
+                                                            ) )                      &
+                   wall_flags_total_0(k,j,i) = IBSET( wall_flags_total_0(k,j,i), 31 )
                      
              ENDDO
@@ -2656,7 +2675,17 @@
        ENDDO
     ENDDO
+    
+    CALL exchange_horiz_int( wall_flags_static_0, nys, nyn, nxl, nxr, nzt, nbgp )
+    
+    DO i = nxl, nxr
+       DO j = nys, nyn
+          DO k = nzb, nzt+1
+             wall_flags_total_0(k,j,i) = IOR( wall_flags_total_0(k,j,i), wall_flags_static_0(k,j,i) )
+          ENDDO
+       ENDDO
+    ENDDO
 !
 !-- Exchange ghost points for wall flags
-    CALL exchange_horiz_int( wall_flags_static_0, nys, nyn, nxl, nxr, nzt, nbgp )
+    CALL exchange_horiz_int( wall_flags_total_0, nys, nyn, nxl, nxr, nzt, nbgp )
 !
 !-- Set boundary conditions also for flags. Can be interpreted as Neumann
@@ -2665,10 +2694,10 @@
        IF ( nys == 0  )  THEN
           DO  i = 1, nbgp     
-             wall_flags_static_0(:,nys-i,:)   = wall_flags_static_0(:,nys,:)
+             wall_flags_total_0(:,nys-i,:)   = wall_flags_total_0(:,nys,:)
           ENDDO
        ENDIF
        IF ( nyn == ny )  THEN
           DO  i = 1, nbgp  
-             wall_flags_static_0(:,nyn+i,:) = wall_flags_static_0(:,nyn,:)
+             wall_flags_total_0(:,nyn+i,:) = wall_flags_total_0(:,nyn,:)
           ENDDO
        ENDIF
@@ -2677,10 +2706,10 @@
        IF ( nxl == 0  )  THEN
           DO  i = 1, nbgp   
-             wall_flags_static_0(:,:,nxl-i)   = wall_flags_static_0(:,:,nxl)
+             wall_flags_total_0(:,:,nxl-i)   = wall_flags_total_0(:,:,nxl)
           ENDDO
        ENDIF
        IF ( nxr == nx )  THEN 
           DO  i = 1, nbgp   
-             wall_flags_static_0(:,:,nxr+i) = wall_flags_static_0(:,:,nxr)     
+             wall_flags_total_0(:,:,nxr+i) = wall_flags_total_0(:,:,nxr)     
           ENDDO
        ENDIF      
@@ -2695,5 +2724,5 @@
     topo_top_ind(:,:,0) = MAXLOC(                                              &
                                   MERGE( 1, 0,                                 &
-                                          BTEST( wall_flags_static_0(:,:,:), ibit )   &
+                                    BTEST( wall_flags_total_0(:,:,:), ibit )   &
                                        ), DIM = 1                              &
                                 ) - 1 
@@ -2703,5 +2732,5 @@
     topo_top_ind(:,:,1) = MAXLOC(                                              &
                                   MERGE( 1, 0,                                 &
-                                          BTEST( wall_flags_static_0(:,:,:), ibit )   &
+                                    BTEST( wall_flags_total_0(:,:,:), ibit )   &
                                        ), DIM = 1                              &
                                 ) - 1 
@@ -2711,5 +2740,5 @@
     topo_top_ind(:,:,2) = MAXLOC(                                              &
                                   MERGE( 1, 0,                                 &
-                                          BTEST( wall_flags_static_0(:,:,:), ibit )   &
+                                    BTEST( wall_flags_total_0(:,:,:), ibit )   &
                                        ), DIM = 1                              &
                                 ) - 1 
@@ -2719,5 +2748,5 @@
     topo_top_ind(:,:,3) = MAXLOC(                                              &
                                   MERGE( 1, 0,                                 &
-                                          BTEST( wall_flags_static_0(:,:,:), ibit )   &
+                                    BTEST( wall_flags_total_0(:,:,:), ibit )   &
                                        ), DIM = 1                              &
                                 ) - 1 
@@ -2727,8 +2756,8 @@
     topo_top_ind(:,:,4) = MAXLOC(                                              &
                                   MERGE( 1, 0,                                 &
-                                          BTEST( wall_flags_static_0(:,:,:), ibit )   &
+                                    BTEST( wall_flags_total_0(:,:,:), ibit )   &
                                        ), DIM = 1                              &
                                 ) - 1                            
-
+        
  END SUBROUTINE set_topo_flags
 
Index: /palm/trunk/SOURCE/init_pt_anomaly.f90
===================================================================
--- /palm/trunk/SOURCE/init_pt_anomaly.f90	(revision 4345)
+++ /palm/trunk/SOURCE/init_pt_anomaly.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -53,5 +57,5 @@
 
     USE indices,                                                               &
-        ONLY:  nbgp, nx, nxl, nxr, ny, nyn, nys, nzb, nzt, wall_flags_static_0
+        ONLY:  nbgp, nx, nxl, nxr, ny, nyn, nys, nzb, nzt, wall_flags_total_0
 
     USE kinds
@@ -96,5 +100,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 x = ( i - ic ) * dx
@@ -129,5 +133,5 @@
 !
 !--             Predetermine flag to mask topography
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 pt(k,j,i) = pt(k,j,i) +                                        &
Index: /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4336 2019-12-13 10:12:05Z raasch
 ! bugfix: wrong header output of particle group features (density ratio) in case
 ! of restarts corrected
@@ -152,5 +156,5 @@
                nzb_max, nzt,nbgp, ngp_2dh_outer,                               &
                topo_top_ind,                                                   &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -1354,5 +1358,5 @@
 !--                               of overhanging structures.
                                   IF ( kp > nzt  .OR.                          &
-                                 .NOT. BTEST( wall_flags_static_0(kp,jp,ip), 0 ) )  THEN
+                                 .NOT. BTEST( wall_flags_total_0(kp,jp,ip), 0 ) )  THEN
                                      pos_x = pos_x + pdx(i)
                                      CYCLE xloop
@@ -1364,5 +1368,5 @@
                                ELSEIF ( .NOT. seed_follows_topography .AND.    &
                                          tmp_particle%z <= zw(k_surf)  .OR.    &
-                                        .NOT. BTEST( wall_flags_static_0(kp,jp,ip), 0 ) )&
+                                        .NOT. BTEST( wall_flags_total_0(kp,jp,ip), 0 ) )&
                                THEN
                                   pos_x = pos_x + pdx(i)
@@ -1520,5 +1524,5 @@
 !
 !--                Check if particle is within topography
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
                       particles(n)%particle_mask = .FALSE.
                       deleted_particles = deleted_particles + 1
@@ -1763,22 +1767,22 @@
           DO  k = nzb, nzt+1
 
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 0 )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i+1), 0 ) )                    &
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 0 )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i+1), 0 ) )              &
              THEN
                 de_dx(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i+1) - e(k,j,i) ) * ddx
-             ELSEIF ( BTEST( wall_flags_static_0(k,j,i-1), 0 )  .AND.                 &
-                      BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.                 &
-                .NOT. BTEST( wall_flags_static_0(k,j,i+1), 0 ) )                      &
+             ELSEIF ( BTEST( wall_flags_total_0(k,j,i-1), 0 )  .AND.           &
+                      BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.           &
+                .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )                &
              THEN
                 de_dx(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i) - e(k,j,i-1) ) * ddx
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 22   )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i+1), 22 ) )               &   
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 22   )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i+1), 22 ) )         &   
              THEN
                 de_dx(k,j,i) = 0.0_wp
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 22 )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i), 22   ) )               &
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 22 )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i), 22   ) )         &
              THEN
                 de_dx(k,j,i) = 0.0_wp
@@ -1787,22 +1791,22 @@
              ENDIF
 
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 0 )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j+1,i), 0 ) )                    &
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 0 )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j+1,i), 0 ) )              &
              THEN
                 de_dy(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j+1,i) - e(k,j,i) ) * ddy
-             ELSEIF ( BTEST( wall_flags_static_0(k,j-1,i), 0 )  .AND.                 &
-                      BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.                 &
-                .NOT. BTEST( wall_flags_static_0(k,j+1,i), 0 ) )                      &
+             ELSEIF ( BTEST( wall_flags_total_0(k,j-1,i), 0 )  .AND.           &
+                      BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.           &
+                .NOT. BTEST( wall_flags_total_0(k,j+1,i), 0 ) )                &
              THEN
                 de_dy(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i) - e(k,j-1,i) ) * ddy
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 22   )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j+1,i), 22 ) )               &   
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 22   )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j+1,i), 22 ) )         &   
              THEN
                 de_dy(k,j,i) = 0.0_wp
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 22 )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i), 22   ) )               &
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 22 )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i), 22   ) )         &
              THEN
                 de_dy(k,j,i) = 0.0_wp
@@ -1822,5 +1826,5 @@
 !
 !--          Flag to mask topography
-             flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0  ) )
+             flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0  ) )
 
              de_dz(k,j,i) = 2.0_wp * sgs_wf_part *                             &
@@ -1897,5 +1901,5 @@
 !
 !--             Flag indicating vicinity of wall
-                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 24 ) )
+                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 24 ) )
 
                 sums_l(k,1,0)  = sums_l(k,1,0)  + u(k,j,i) * flag1
@@ -1937,5 +1941,5 @@
 !
 !--             Flag indicating vicinity of wall
-                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 24 ) )
+                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 24 ) )
 
                 sums_l(k,8,0)  = sums_l(k,8,0)  + e(k,j,i)                       * flag1
@@ -3645,5 +3649,5 @@
                                ( gg-dd ) * w(k+1,j+1,i+1) &
                              ) / ( 3.0_wp * gg )
-                   w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) *               &
+                   w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) *            &
                               ( w_int_u - w_int_l )
                 ENDIF
@@ -3668,7 +3672,7 @@
              j = jp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 1 ) )
              k = kp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 0 ) )
-             IF ( .NOT. BTEST(wall_flags_static_0(k,  jp, ip), 0) .OR.                &
-                  .NOT. BTEST(wall_flags_static_0(kp, j,  ip), 0) .OR.                &
-                  .NOT. BTEST(wall_flags_static_0(kp, jp, i ), 0) )                   &
+             IF ( .NOT. BTEST(wall_flags_total_0(k,  jp, ip), 0) .OR.             &
+                  .NOT. BTEST(wall_flags_total_0(kp, j,  ip), 0) .OR.             &
+                  .NOT. BTEST(wall_flags_total_0(kp, jp, i ), 0) )                &
              THEN
                 subbox_at_wall = .TRUE.
@@ -4765,5 +4769,5 @@
                 IF ( reach_x(t_index)                      .AND.               & 
                      ABS( pos_x - xwall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_x )  THEN
 ! 
@@ -4805,5 +4809,5 @@
                 IF ( reach_y(t_index)                      .AND.               & 
                      ABS( pos_y - ywall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_y )  THEN
 ! 
@@ -4845,5 +4849,5 @@
                 IF ( reach_z(t_index)                      .AND.               & 
                      ABS( pos_z - zwall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_z )  THEN
 ! 
@@ -5203,5 +5207,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              q(k,j,i)  = q_p(k,j,i)  - ql_c(k,j,i) * flag
@@ -5233,5 +5237,5 @@
 !
 !--    Predetermine flag to mask topography
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
        q(k,j,i)  = q(k,j,i)  - ql_c(k,j,i) * flag
Index: /palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90
===================================================================
--- /palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/large_scale_forcing_nudging_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -74,5 +78,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, ngp_sums_ls, nx, nxl, nxlg, nxlu, nxr, nxrg, ny, nys,     &
-               nysv, nysg, nyn, nyng, nzb, nz, nzt, wall_flags_static_0
+               nysv, nysg, nyn, nyng, nzb, nz, nzt, wall_flags_total_0
 
     USE kinds
@@ -802,5 +806,5 @@
                                     ( td_lsa_lpt(k,nt+1) - td_lsa_lpt(k,nt) ) *&
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -815,5 +819,5 @@
                                     ( td_lsa_q(k,nt+1) - td_lsa_q(k,nt) ) *    &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -836,5 +840,5 @@
                                      ( td_sub_lpt(k,nt+1) - td_sub_lpt(k,nt) )*&
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -849,5 +853,5 @@
                                        ( td_sub_q(k,nt+1) - td_sub_q(k,nt) ) * &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -902,5 +906,5 @@
                              + fac * ( td_lsa_lpt(k,nt+1) - td_lsa_lpt(k,nt) )*&
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
              ENDDO
 
@@ -911,5 +915,5 @@
                               + fac * ( td_lsa_q(k,nt+1) - td_lsa_q(k,nt) ) *  &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
              ENDDO
 
@@ -928,5 +932,5 @@
                                  ( td_sub_lpt(k,nt+1) - td_sub_lpt(k,nt) ) *   &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ENDDO
   
@@ -937,5 +941,5 @@
                                  ( td_sub_q(k,nt+1) - td_sub_q(k,nt) ) *       &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ENDDO
 
@@ -1181,5 +1185,5 @@
                       tend(k,j,i) = tend(k,j,i) + tmp_tend *                   &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 1 ) )
 
                       sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend *             &
@@ -1204,5 +1208,5 @@
                       tend(k,j,i) = tend(k,j,i) + tmp_tend *                   &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 2 ) )
 
                       sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend *             &
@@ -1227,5 +1231,5 @@
                       tend(k,j,i) = tend(k,j,i) + tmp_tend *                   &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                       sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend *             &
@@ -1250,5 +1254,5 @@
                       tend(k,j,i) = tend(k,j,i) + tmp_tend *                   &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                       sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend *             &
@@ -1316,5 +1320,5 @@
                 tend(k,j,i) = tend(k,j,i) + tmp_tend *                         &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 1 ) )
 
                 sums_ls_l(k,6) = sums_ls_l(k,6) + tmp_tend                     &
@@ -1333,5 +1337,5 @@
                 tend(k,j,i) = tend(k,j,i) + tmp_tend *                         &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 2 ) )
 
                 sums_ls_l(k,7) = sums_ls_l(k,7) + tmp_tend                     &
@@ -1350,5 +1354,5 @@
                 tend(k,j,i) = tend(k,j,i) + tmp_tend *                         &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 sums_ls_l(k,4) = sums_ls_l(k,4) + tmp_tend                     &
@@ -1368,5 +1372,5 @@
                 tend(k,j,i) = tend(k,j,i) + tmp_tend *                         &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 sums_ls_l(k,5) = sums_ls_l(k,5) + tmp_tend                     &
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 4345)
+++ /palm/trunk/SOURCE/modules.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4340 2019-12-16 08:17:03Z Giersch
 ! Flag for topography closed channel flow with symmetric boundaries introduced
 ! 
@@ -1118,5 +1122,6 @@
     INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_s            !< flags used to degrade order of advection scheme for scalar quantities
     INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  topo_top_ind            !< precalculated topography top indices
-    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  wall_flags_static_0            !< flags to mask topography and surface-bounded grid points
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  wall_flags_static_0     !< flags to mask topography and surface-bounded grid points
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  wall_flags_total_0      !< merged array, which contains the static and dynamic flags
 
     SAVE
Index: /palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Removed wall_flags_static_0 from USE statements as it's not used within
+! the module
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -90,7 +94,6 @@
     USE indices,                                                               &
         ONLY:  nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb,        &
-               topo_top_ind,                                                   &
-               wall_flags_static_0
-
+               topo_top_ind
+               
     USE random_function_mod,                                                   &
         ONLY:  random_function
Index: /palm/trunk/SOURCE/nesting_offl_mod.f90
===================================================================
--- /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -191,5 +195,5 @@
                nysv, nysg, nyn, nyng, nzb, nz, nzt,                            &
                topo_top_ind,                                                   &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -866,5 +870,5 @@
                 volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzw(k) * dy   &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                       BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDDO
@@ -876,5 +880,5 @@
                 volume_flow_l(1) = volume_flow_l(1) - u(k,j,i) * dzw(k) * dy   &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                       BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDDO
@@ -886,5 +890,5 @@
                 volume_flow_l(2) = volume_flow_l(2) + v(k,j,i) * dzw(k) * dx   &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                       BTEST( wall_flags_total_0(k,j,i), 2 ) )
              ENDDO
           ENDDO
@@ -896,5 +900,5 @@
                 volume_flow_l(2) = volume_flow_l(2) - v(k,j,i) * dzw(k) * dx   &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                       BTEST( wall_flags_total_0(k,j,i), 2 ) )
              ENDDO
           ENDDO
@@ -1001,5 +1005,5 @@
                                                 fac_dt ) *                     &
                              MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,0), 1 ) )
+                                    BTEST( wall_flags_total_0(k,j,0), 1 ) )
                 u(k,j,-1) = u(k,j,0)
              ENDDO
@@ -1013,5 +1017,5 @@
                                                  fac_dt ) *                    &
                             MERGE( 1.0_wp, 0.0_wp,                             &
-                                   BTEST( wall_flags_static_0(k,j,-1), 3 ) )
+                                   BTEST( wall_flags_total_0(k,j,-1), 3 ) )
              ENDDO
              w(nzt,j,-1) = w(nzt-1,j,-1)
@@ -1024,5 +1028,5 @@
                                                  fac_dt ) *                    &
                                MERGE( 1.0_wp, 0.0_wp,                          &
-                                      BTEST( wall_flags_static_0(k,j,-1), 2 ) )
+                                      BTEST( wall_flags_total_0(k,j,-1), 2 ) )
              ENDDO
              v_ref_l(nzb+1:nzt) = v_ref_l(nzb+1:nzt) + v(nzb+1:nzt,j,-1)
@@ -1080,5 +1084,5 @@
                                                     fac_dt ) *                 &
                              MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,nxr+1), 1 ) )
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 1 ) )
              ENDDO
              u_ref_l(nzb+1:nzt) = u_ref_l(nzb+1:nzt) + u(nzb+1:nzt,j,nxr+1)
@@ -1090,5 +1094,5 @@
                                                     fac_dt ) *                 &
                              MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,nxr+1), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 3 ) )
              ENDDO
              w(nzt,j,nxr+1) = w(nzt-1,j,nxr+1)
@@ -1101,5 +1105,5 @@
                                                     fac_dt ) *                 &
                              MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(k,j,nxr+1), 2 ) )
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 2 ) )
              ENDDO
              v_ref_l(nzb+1:nzt) = v_ref_l(nzb+1:nzt) + v(nzb+1:nzt,j,nxr+1)
@@ -1158,5 +1162,5 @@
                                                 fac_dt ) *                     &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(k,0,i), 2 ) )
+                                  BTEST( wall_flags_total_0(k,0,i), 2 ) )
                 v(k,-1,i) = v(k,0,i) 
              ENDDO
@@ -1170,5 +1174,5 @@
                                                  fac_dt ) *                    &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(k,-1,i), 3 ) )
+                                  BTEST( wall_flags_total_0(k,-1,i), 3 ) )
              ENDDO
              w(nzt,-1,i) = w(nzt-1,-1,i)
@@ -1181,5 +1185,5 @@
                                                  fac_dt ) *                    &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(k,-1,i), 1 ) )
+                                  BTEST( wall_flags_total_0(k,-1,i), 1 ) )
              ENDDO
              u_ref_l(nzb+1:nzt) = u_ref_l(nzb+1:nzt) + u(nzb+1:nzt,-1,i)
@@ -1239,5 +1243,5 @@
                                                     fac_dt ) *                 &
                                MERGE( 1.0_wp, 0.0_wp,                          &
-                                      BTEST( wall_flags_static_0(k,nyn+1,i), 2 ) )
+                                    BTEST( wall_flags_total_0(k,nyn+1,i), 2 ) )
              ENDDO
              v_ref_l(nzb+1:nzt) = v_ref_l(nzb+1:nzt) + v(nzb+1:nzt,nyn+1,i)
@@ -1249,5 +1253,5 @@
                                                     fac_dt ) *                 &
                                MERGE( 1.0_wp, 0.0_wp,                          &
-                                      BTEST( wall_flags_static_0(k,nyn+1,i), 3 ) )
+                                    BTEST( wall_flags_total_0(k,nyn+1,i), 3 ) )
              ENDDO
              w(nzt,nyn+1,i) = w(nzt-1,nyn+1,i)
@@ -1260,5 +1264,5 @@
                                                     fac_dt ) *                 &
                                MERGE( 1.0_wp, 0.0_wp,                          &
-                                      BTEST( wall_flags_static_0(k,nyn+1,i), 1 ) )
+                                    BTEST( wall_flags_total_0(k,nyn+1,i), 1 ) )
 
              ENDDO
@@ -1318,5 +1322,5 @@
                                                  fac_dt ) *                    &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzt+1,j,i), 1 ) )
+                                  BTEST( wall_flags_total_0(nzt+1,j,i), 1 ) )
              u_ref_l(nzt+1) = u_ref_l(nzt+1) + u(nzt+1,j,i)
           ENDDO
@@ -1334,5 +1338,5 @@
                                                  fac_dt ) *                    &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzt+1,j,i), 2 ) )
+                                  BTEST( wall_flags_total_0(nzt+1,j,i), 2 ) )
              v_ref_l(nzt+1) = v_ref_l(nzt+1) + v(nzt+1,j,i)
           ENDDO
@@ -1350,5 +1354,5 @@
                                                fac_dt ) *                      &
                            MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzt,j,i), 3 ) )
+                                  BTEST( wall_flags_total_0(nzt,j,i), 3 ) )
              w(nzt+1,j,i) = w(nzt,j,i)
           ENDDO
@@ -2133,7 +2137,7 @@
 !--    After boundary data is initialized, mask topography at the 
 !--    boundaries for the velocity components.
-       u = MERGE( u, 0.0_wp, BTEST( wall_flags_static_0, 1 ) )
-       v = MERGE( v, 0.0_wp, BTEST( wall_flags_static_0, 2 ) )
-       w = MERGE( w, 0.0_wp, BTEST( wall_flags_static_0, 3 ) )
+       u = MERGE( u, 0.0_wp, BTEST( wall_flags_total_0, 1 ) )
+       v = MERGE( v, 0.0_wp, BTEST( wall_flags_total_0, 2 ) )
+       w = MERGE( w, 0.0_wp, BTEST( wall_flags_total_0, 3 ) )
 !
 !--    Initial calculation of the boundary layer depth from the prescribed 
Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -3404,5 +3408,5 @@
 
        USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys, wall_flags_static_0
+           ONLY:  nxl, nxr, nyn, nys, wall_flags_total_0
 
        IMPLICIT NONE
@@ -3870,11 +3874,11 @@
 !--          Check if building_type is set at each building and vice versa. 
 !--          Please note, buildings are already processed and filtered.
-!--          For this reason, consistency checks are based on wall_flags_static_0 
+!--          For this reason, consistency checks are based on wall_flags_total_0 
 !--          rather than buildings_f (buildings are represented by bit 6 in 
-!--          wall_flags_static_0). 
+!--          wall_flags_total_0). 
              IF ( building_type_f%from_file  .AND.  buildings_f%from_file )  THEN
-                IF ( ANY( BTEST ( wall_flags_static_0(:,j,i), 6 ) )  .AND.            &
+                IF ( ANY( BTEST ( wall_flags_total_0(:,j,i), 6 ) )  .AND.      &
                      building_type_f%var(j,i) == building_type_f%fill  .OR.    &
-               .NOT. ANY( BTEST ( wall_flags_static_0(:,j,i), 6 ) )  .AND.            &
+               .NOT. ANY( BTEST ( wall_flags_total_0(:,j,i), 6 ) )  .AND.      &
                      building_type_f%var(j,i) /= building_type_f%fill )  THEN
                    WRITE( message_string, * ) 'Each location where a ' //      &
@@ -3891,7 +3895,7 @@
 !--          is set and vice versa.
              IF ( buildings_f%from_file )  THEN
-                IF ( ANY( BTEST ( wall_flags_static_0(:,j,i), 6 ) )  .AND.           &
+                IF ( ANY( BTEST ( wall_flags_total_0(:,j,i), 6 ) )  .AND.     &
                      building_id_f%var(j,i) == building_id_f%fill  .OR.       &
-               .NOT. ANY( BTEST ( wall_flags_static_0(:,j,i), 6 ) )  .AND.           &
+               .NOT. ANY( BTEST ( wall_flags_total_0(:,j,i), 6 ) )  .AND.     &
                      building_id_f%var(j,i) /= building_id_f%fill )  THEN
                    WRITE( message_string, * ) 'Each location where a ' //     &
@@ -3905,5 +3909,5 @@
 !--          Check if building ID is set where a bulding is defined.
              IF ( buildings_f%from_file )  THEN
-                IF ( ANY( BTEST ( wall_flags_static_0(:,j,i), 6 ) )  .AND.           &
+                IF ( ANY( BTEST ( wall_flags_total_0(:,j,i), 6 ) )  .AND.     &
                      building_id_f%var(j,i) == building_id_f%fill )  THEN
                    WRITE( message_string, * ) 'Each building grid point '//   &
Index: /palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- /palm/trunk/SOURCE/ocean_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/ocean_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -89,5 +93,5 @@
 
     USE indices,                                                               &
-        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_static_0
+        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
 
     USE surface_mod,                                                           &
@@ -971,5 +975,5 @@
     USE indices,                                                               &
         ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,            &
-              wall_flags_static_0
+              wall_flags_total_0
 
     IMPLICIT NONE
@@ -1039,6 +1043,6 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-                                         REAL( fill_value, KIND = wp ),        &
-                                         BTEST( wall_flags_static_0(k,j,i), flag_nr ) )
+                                   REAL( fill_value, KIND = wp ),              &
+                                   BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
              ENDDO
           ENDDO
@@ -1066,5 +1070,5 @@
     USE indices,                                                               &
         ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,           &
-               wall_flags_static_0
+               wall_flags_total_0
 
     IMPLICIT NONE
@@ -1131,6 +1135,6 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-                                         REAL( fill_value, KIND = wp ),        &
-                                         BTEST( wall_flags_static_0(k,j,i), flag_nr ) )
+                                   REAL( fill_value, KIND = wp ),              &
+                                   BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
              ENDDO
           ENDDO
@@ -1676,11 +1680,11 @@
           DO  j = nys, nyn
              DO  k = nzb+1, nzt
-                sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +      &
-                                                      tsc(3) * tsa_m(k,j,i) )  &
-                                                  - tsc(5) * rdf_sc(k) *       &
-                                                    ( sa(k,j,i) - sa_init(k) ) &
-                                          )                                    &
-                                            * MERGE( 1.0_wp, 0.0_wp,           &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) &
+                sa_p(k,j,i) = sa(k,j,i) + ( dt_3d * ( sbt * tend(k,j,i) +            &
+                                                      tsc(3) * tsa_m(k,j,i) )        &
+                                                  - tsc(5) * rdf_sc(k) *             &
+                                                    ( sa(k,j,i) - sa_init(k) )       &
+                                          )                                          &
+                                            * MERGE( 1.0_wp, 0.0_wp,                 &
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) &
                                                    )
                 IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
@@ -1829,5 +1833,5 @@
                                              * ( sa(k,j,i) - sa_init(k) )      &
                                     ) * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                         BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
           IF ( sa_p(k,j,i) < 0.0_wp )  sa_p(k,j,i) = 0.1_wp * sa(k,j,i)
Index: /palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4346)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4342 2019-12-16 13:49:14Z Giersch
 ! Use statements moved to module level, ocean dependency removed, redundant
 ! variables removed
@@ -152,5 +156,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
-               nz, nzb, nzt, topo_top_ind, wall_flags_static_0
+               nz, nzb, nzt, topo_top_ind, wall_flags_total_0
 
     USE kinds
@@ -1060,6 +1064,6 @@
 !--                   an informative message is given.
                       IF ( ANY( lad_s(:,j,i) /= 0.0_wp )  .AND.                &
-                           ANY( BTEST( wall_flags_static_0(:,j,i), 6 ) ) .AND.        &
-                           ANY( BTEST( wall_flags_static_0(:,j,i), 4 ) ) )  THEN
+                           ANY( BTEST( wall_flags_total_0(:,j,i), 6 ) ) .AND.  &
+                           ANY( BTEST( wall_flags_total_0(:,j,i), 4 ) ) )  THEN
                          lad_s(:,j,i) = 0.0_wp
                          WRITE( message_string, * )                            &
@@ -1493,8 +1497,8 @@
 !--                of the potential rooftop grid point, while building_edge_e is
 !--                is set from the perspective of the non-building grid point.
-                   building_edge_w = ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )&
-                        .AND.  .NOT. ANY( BTEST( wall_flags_static_0(:,j,i-1), 6 ) )
-                   building_edge_e = ANY( BTEST( wall_flags_static_0(:,j,i-1), 6 ) )&
-                        .AND.  .NOT. ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )
+                   building_edge_w = ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )&
+                        .AND.  .NOT. ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) )
+                   building_edge_e = ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) )&
+                        .AND.  .NOT. ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )
 !
 !--                Determine topography-top index on u-grid
@@ -1573,8 +1577,8 @@
 !--                of the potential rooftop grid point, while building_edge_n is
 !--                is set from the perspective of the non-building grid point.
-                   building_edge_s = ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )&
-                        .AND.  .NOT. ANY( BTEST( wall_flags_static_0(:,j-1,i), 6 ) )
-                   building_edge_n = ANY( BTEST( wall_flags_static_0(:,j-1,i), 6 ) )&
-                        .AND.  .NOT. ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )
+                   building_edge_s = ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )&
+                        .AND.  .NOT. ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) )
+                   building_edge_n = ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) )&
+                        .AND.  .NOT. ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )
 !
 !--                Determine topography-top index on v-grid
@@ -1881,8 +1885,8 @@
 !--          of the potential rooftop grid point, while building_edge_e is
 !--          is set from the perspective of the non-building grid point.
-             building_edge_w = ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )  .AND. &
-                         .NOT. ANY( BTEST( wall_flags_static_0(:,j,i-1), 6 ) )
-             building_edge_e = ANY( BTEST( wall_flags_static_0(:,j,i-1), 6 ) )  .AND. &
-                         .NOT. ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )
+             building_edge_w = ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )  .AND. &
+                         .NOT. ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) )
+             building_edge_e = ANY( BTEST( wall_flags_total_0(:,j,i-1), 6 ) )  .AND. &
+                         .NOT. ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )
 !
 !--          Determine topography-top index on u-grid
@@ -1960,8 +1964,8 @@
 !--          of the potential rooftop grid point, while building_edge_n is
 !--          is set from the perspective of the non-building grid point.
-             building_edge_s = ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )  .AND. &
-                         .NOT. ANY( BTEST( wall_flags_static_0(:,j-1,i), 6 ) )
-             building_edge_n = ANY( BTEST( wall_flags_static_0(:,j-1,i), 6 ) )  .AND. &
-                         .NOT. ANY( BTEST( wall_flags_static_0(:,j,i),   6 ) )
+             building_edge_s = ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )  .AND. &
+                         .NOT. ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) )
+             building_edge_n = ANY( BTEST( wall_flags_total_0(:,j-1,i), 6 ) )  .AND. &
+                         .NOT. ANY( BTEST( wall_flags_total_0(:,j,i),   6 ) )
 !
 !--          Determine topography-top index on v-grid
Index: /palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -208,5 +212,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxlu, nxr, nxrg, ny, nyn, nyng, nys, nysg, &
-               nysv, nz, nzb, nzt, topo_top_ind, wall_flags_static_0
+               nysv, nz, nzb, nzt, topo_top_ind, wall_flags_total_0
 
     USE bulk_cloud_model_mod,                                                  &
@@ -1529,14 +1533,14 @@
        INTEGER(iwp) ::  istart    !<
        INTEGER(iwp) ::  ir        !<
-       INTEGER(iwp) ::  iw        !< Child-grid index limited to -1 <= iw <= nx+1 for wall_flags_static_0
+       INTEGER(iwp) ::  iw        !< Child-grid index limited to -1 <= iw <= nx+1 for wall_flags_total_0
        INTEGER(iwp) ::  j         !< Child-grid index in the y-direction
        INTEGER(iwp) ::  jj        !< Parent-grid index in the y-direction
        INTEGER(iwp) ::  jstart    !<
        INTEGER(iwp) ::  jr        !<
-       INTEGER(iwp) ::  jw        !< Child-grid index limited to -1 <= jw <= ny+1 for wall_flags_static_0
+       INTEGER(iwp) ::  jw        !< Child-grid index limited to -1 <= jw <= ny+1 for wall_flags_total_0
        INTEGER(iwp) ::  k         !< Child-grid index in the z-direction
        INTEGER(iwp) ::  kk        !< Parent-grid index in the z-direction
        INTEGER(iwp) ::  kstart    !<
-       INTEGER(iwp) ::  kw        !< Child-grid index limited to kw <= nzt+1 for wall_flags_static_0
+       INTEGER(iwp) ::  kw        !< Child-grid index limited to kw <= nzt+1 for wall_flags_total_0
 
        REAL(wp)     ::  tolex     !< Tolerance for grid-line matching in x-direction    
@@ -1779,5 +1783,5 @@
 !--    Note that ii, jj, and kk are parent-grid indices. 
 !--    This information is needed in the anterpolation. 
-!--    The indices for wall_flags_static_0 (kw,jw,iw) must be limited to the range 
+!--    The indices for wall_flags_total_0 (kw,jw,iw) must be limited to the range 
 !--    [-1,...,nx/ny/nzt+1] in order to avoid zero values on the outer ghost nodes.
        DO  ii = ipla, ipra
@@ -1793,5 +1797,5 @@
                          kw = MIN( k, nzt+1 )                
                          ijkfc_u(kk,jj,ii) = ijkfc_u(kk,jj,ii)                                      &
-                              + MERGE( 1, 0, BTEST( wall_flags_static_0(kw,jw,iw), 1 ) )
+                              + MERGE( 1, 0, BTEST( wall_flags_total_0(kw,jw,iw), 1 ) )
                       ENDDO
                    ENDDO
@@ -1806,5 +1810,5 @@
                          kw = MIN( k, nzt+1 )                                        
                          ijkfc_v(kk,jj,ii) = ijkfc_v(kk,jj,ii)                                      &
-                              + MERGE( 1, 0, BTEST( wall_flags_static_0(kw,jw,iw), 2 ) )
+                              + MERGE( 1, 0, BTEST( wall_flags_total_0(kw,jw,iw), 2 ) )
                       ENDDO
                    ENDDO
@@ -1819,5 +1823,5 @@
                          kw = MIN( k, nzt+1 )
                          ijkfc_s(kk,jj,ii) = ijkfc_s(kk,jj,ii)                                      &
-                              + MERGE( 1, 0, BTEST( wall_flags_static_0(kw,jw,iw), 0 ) )
+                              + MERGE( 1, 0, BTEST( wall_flags_total_0(kw,jw,iw), 0 ) )
                       ENDDO
                    ENDDO
@@ -1832,5 +1836,5 @@
                          kw = MIN( k, nzt+1 )
                          ijkfc_w(kk,jj,ii) = ijkfc_w(kk,jj,ii)                                      &
-                              + MERGE( 1, 0, BTEST( wall_flags_static_0(kw,jw,iw), 3 ) )
+                              + MERGE( 1, 0, BTEST( wall_flags_total_0(kw,jw,iw), 3 ) )
                       ENDDO
                    ENDDO
@@ -2753,10 +2757,10 @@
              DO  jc = nysg, nyng
                 DO  kc = nzb, nzt
-                   u(kc,jc,ic)   = MERGE( u(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 1 ) )
-                   v(kc,jc,ic)   = MERGE( v(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 2 ) )
-                   w(kc,jc,ic)   = MERGE( w(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 3 ) )
-                   u_p(kc,jc,ic) = MERGE( u_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 1 ) )
-                   v_p(kc,jc,ic) = MERGE( v_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 2 ) )
-                   w_p(kc,jc,ic) = MERGE( w_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_static_0(kc,jc,ic), 3 ) )
+                   u(kc,jc,ic)   = MERGE( u(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 1 ) )
+                   v(kc,jc,ic)   = MERGE( v(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 2 ) )
+                   w(kc,jc,ic)   = MERGE( w(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 3 ) )
+                   u_p(kc,jc,ic) = MERGE( u_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 1 ) )
+                   v_p(kc,jc,ic) = MERGE( v_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 2 ) )
+                   w_p(kc,jc,ic) = MERGE( w_p(kc,jc,ic), 0.0_wp, BTEST( wall_flags_total_0(kc,jc,ic), 3 ) )
                 ENDDO
              ENDDO
@@ -3271,7 +3275,7 @@
                 DO   j = nysg, nyng
                    DO  k = nzb, nzt+1
-                      u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
-                      v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
-                      w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                      u(k,j,i) = MERGE( u(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
+                      v(k,j,i) = MERGE( v(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
+                      w(k,j,i) = MERGE( w(k,j,i), 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
 !
 !--                 TO_DO: zero setting of temperature within topography creates
@@ -4633,5 +4637,5 @@
                      DO  kc = kfl(kp), kfu(kp)
                         cellsum = cellsum + MERGE( child_array(kc,jc,ic), 0.0_wp,                   &
-                             BTEST( wall_flags_static_0(kc,jc,ic), var_flag ) )
+                             BTEST( wall_flags_total_0(kc,jc,ic), var_flag ) )
                      ENDDO
                   ENDDO
@@ -4924,5 +4928,5 @@
           DO   k = nzb+1, nzt
              sub_sum = sub_sum + innor * u(k,j,i) * dzw(k)                                          &
-                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
           ENDDO
           volume_flux_local = volume_flux_local + sub_sum
@@ -4947,5 +4951,5 @@
           DO   k = nzb+1, nzt
              sub_sum = sub_sum + innor * u(k,j,i) * dzw(k)                                          &
-                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
           ENDDO
           volume_flux_local = volume_flux_local + sub_sum
@@ -4970,5 +4974,5 @@
           DO   k = nzb+1, nzt
              sub_sum = sub_sum + innor * v(k,j,i) * dzw(k)                                          &
-                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
           ENDDO
           volume_flux_local = volume_flux_local + sub_sum
@@ -4993,5 +4997,5 @@
           DO  k = nzb+1, nzt
              sub_sum = sub_sum + innor * v(k,j,i) * dzw(k)                                          &
-                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                               * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
           ENDDO
           volume_flux_local = volume_flux_local + sub_sum
@@ -5063,5 +5067,5 @@
              DO  k = nzb + 1, nzt
                 u(k,j,i) = u(k,j,i) + u_corr_left                              &
-                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDDO
@@ -5075,5 +5079,5 @@
              DO  k = nzb + 1, nzt
                 u(k,j,i) = u(k,j,i) + u_corr_right                              &
-                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDDO
@@ -5087,5 +5091,5 @@
              DO  k = nzb + 1, nzt
                 v(k,j,i) = v(k,j,i) + v_corr_south                              &
-                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
              ENDDO
           ENDDO
@@ -5099,5 +5103,5 @@
              DO  k = nzb + 1, nzt
                 v(k,j,i) = v(k,j,i) + v_corr_north                              &
-                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 2 ) )
              ENDDO
           ENDDO
Index: /palm/trunk/SOURCE/poismg_noopt_mod.f90
===================================================================
--- /palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/poismg_noopt_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -1655,5 +1659,5 @@
        USE indices,                                                            &
            ONLY:  flags, nxl_mg, nxr_mg, nyn_mg, nys_mg, nzb, nzt_mg,          &
-                  wall_flags_static_0, wall_flags_1,                                  &
+                  wall_flags_total_0, wall_flags_1,                            &
                   wall_flags_10, wall_flags_2, wall_flags_3,  wall_flags_4,    &
                   wall_flags_5, wall_flags_6, wall_flags_7, wall_flags_8,      &
@@ -1739,5 +1743,5 @@
                 DO  j = nys_l, nyn_l
                    DO  k = nzb, nzt_l
-                      topo_tmp(k,j,i) = wall_flags_static_0(k*inc,j*inc,i*inc)
+                      topo_tmp(k,j,i) = wall_flags_total_0(k*inc,j*inc,i*inc)
                    ENDDO
                 ENDDO
Index: /palm/trunk/SOURCE/pres.f90
===================================================================
--- /palm/trunk/SOURCE/pres.f90	(revision 4345)
+++ /palm/trunk/SOURCE/pres.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -72,5 +76,5 @@
         ONLY:  nbgp, ngp_2dh_outer, nx, nxl, nxlg, nxl_mg, nxr, nxrg, nxr_mg,  &
                ny, nys, nysg, nys_mg, nyn, nyng, nyn_mg, nzb, nzt, nzt_mg,     &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -190,5 +194,5 @@
              volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzw(k)           &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                             )
           ENDDO
@@ -209,5 +213,5 @@
              u(k,j,i) = u(k,j,i) + volume_flow_offset(1)                       &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                             )
           ENDDO
@@ -235,5 +239,5 @@
              volume_flow_l(2) = volume_flow_l(2) + v(k,j,i) * dzw(k)           &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                             )
           ENDDO
@@ -254,5 +258,5 @@
              v(k,j,i) = v(k,j,i) + volume_flow_offset(2)                       &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                             )
           ENDDO
@@ -283,5 +287,5 @@
              DO  k = nzb+1, nzt
                 w_l_l(k) = w_l_l(k) + w(k,j,i)                                                     &
-                                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
              ENDDO
           ENDDO
@@ -300,5 +304,5 @@
              DO  k = nzb+1, nzt
                 w(k,j,i) = w(k,j,i) - w_l(k)                                                       &
-                                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                     * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 3 ) )
              ENDDO
           ENDDO
@@ -347,5 +351,5 @@
                         ) * ddt_3d * d_weight_pres                             &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,i), 0 )    &
+                                      BTEST( wall_flags_total_0(k,j,i), 0 )    &
                                           )
           ENDDO
@@ -355,5 +359,5 @@
              threadsum = threadsum + ABS( d(k,j,i) )                           &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,i), 0 )    &
+                                      BTEST( wall_flags_total_0(k,j,i), 0 )    &
                                           )
           ENDDO
@@ -372,5 +376,5 @@
     !$OMP DO SCHEDULE( STATIC )
     !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-    !$ACC PRESENT(u, v, w, rho_air, rho_air_zw, ddzw, wall_flags_static_0) &
+    !$ACC PRESENT(u, v, w, rho_air, rho_air_zw, ddzw, wall_flags_total_0) &
     !$ACC PRESENT(d)
     DO  i = nxl, nxr
@@ -383,5 +387,5 @@
                         ) * ddt_3d * d_weight_pres                             &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,i), 0 )    &
+                                      BTEST( wall_flags_total_0(k,j,i), 0 )    &
                                           )     
           ENDDO
@@ -633,5 +637,5 @@
     !$OMP DO
     !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k) &
-    !$ACC PRESENT(u, v, w, tend, ddzu, wall_flags_static_0)
+    !$ACC PRESENT(u, v, w, tend, ddzu, wall_flags_total_0)
     DO  i = nxl, nxr   
        DO  j = nys, nyn
@@ -642,5 +646,5 @@
                                      * weight_pres_l                           &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 3 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 3 )  &
                                             )
           ENDDO
@@ -651,5 +655,5 @@
                                      * weight_pres_l                           &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                             )
           ENDDO
@@ -660,5 +664,5 @@
                                      * weight_pres_l                           &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                             )
           ENDDO                                                         
@@ -691,5 +695,5 @@
              volume_flow_l(1) = volume_flow_l(1) + u(k,j,nxr) * dzw(k)         &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,nxr), 1 )&
+                                        BTEST( wall_flags_total_0(k,j,nxr), 1 )&
                                             )
           ENDDO
@@ -710,5 +714,5 @@
              volume_flow_l(2) = volume_flow_l(2) + v(k,nyn,i) * dzw(k)         &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,nyn,i), 2 )&
+                                        BTEST( wall_flags_total_0(k,nyn,i), 2 )&
                                             )
            ENDDO
@@ -741,5 +745,5 @@
                 u(k,j,i) = u(k,j,i) + volume_flow_offset(1)                    &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                             )
              ENDDO
@@ -747,5 +751,5 @@
                 v(k,j,i) = v(k,j,i) + volume_flow_offset(2)                    &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                        BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                             )
              ENDDO
@@ -791,5 +795,5 @@
                             w(k-1,j,i) * rho_air_zw(k-1) ) * ddzw(k)           &
                         ) * MERGE( 1.0_wp, 0.0_wp,                             &
-                                   BTEST( wall_flags_static_0(k,j,i), 0 )             &
+                             BTEST( wall_flags_total_0(k,j,i), 0 )             &
                                  )
              ENDDO
@@ -802,5 +806,5 @@
        !$OMP DO SCHEDULE( STATIC )
        !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-       !$ACC PRESENT(u, v, w, rho_air, rho_air_zw, ddzw, wall_flags_static_0) &
+       !$ACC PRESENT(u, v, w, rho_air, rho_air_zw, ddzw, wall_flags_total_0) &
        !$ACC PRESENT(d)
        DO  i = nxl, nxr
@@ -812,5 +816,5 @@
                                w(k-1,j,i) * rho_air_zw(k-1) ) * ddzw(k)        &
                            ) * MERGE( 1.0_wp, 0.0_wp,                          &
-                                   BTEST( wall_flags_static_0(k,j,i), 0 )             &
+                             BTEST( wall_flags_total_0(k,j,i), 0 )             &
                                     )
              ENDDO
Index: /palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4345)
+++ /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -206,5 +210,5 @@
         ONLY:  advc_flags_s,                                                   &
                nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
-               nzb, nzt, wall_flags_static_0
+               nzb, nzt, wall_flags_total_0
 
     USE kinds
@@ -376,5 +380,5 @@
                                                      * ( u(k,j,i) - u_init(k) ) &
                                         ) * MERGE( 1.0_wp, 0.0_wp,              &
-                                                   BTEST( wall_flags_static_0(k,j,i), 1 )&
+                                           BTEST( wall_flags_total_0(k,j,i), 1 )&
                                                  )
              ENDDO
@@ -454,5 +458,5 @@
                                                      * ( v(k,j,i) - v_init(k) )&
                                         ) * MERGE( 1.0_wp, 0.0_wp,             &
-                                                   BTEST( wall_flags_static_0(k,j,i), 2 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 2 )&
                                                  )
              ENDDO
@@ -528,5 +532,5 @@
                                              - tsc(5) * rdf(k) * w(k,j,i)      &
                                      ) * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 3 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 3 )&
                                               )
           ENDDO
@@ -626,5 +630,5 @@
                                           )                                    &
                                        * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
                                               )
              ENDDO
@@ -716,5 +720,5 @@
                                         )                                      &
                                        * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
                                               )                
                 IF ( q_p(k,j,i) < 0.0_wp )  q_p(k,j,i) = 0.1_wp * q(k,j,i)
@@ -814,5 +818,5 @@
                                         )                                      &
                                        * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
                                               )
                 IF ( s_p(k,j,i) < 0.0_wp )  s_p(k,j,i) = 0.1_wp * s(k,j,i)
@@ -927,5 +931,5 @@
 !-- Prognostic equation for u-velocity component
     !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-    !$ACC PRESENT(u, tend, tu_m, u_init, rdf, wall_flags_static_0) &
+    !$ACC PRESENT(u, tend, tu_m, u_init, rdf, wall_flags_total_0) &
     !$ACC PRESENT(tsc(2:5)) &
     !$ACC PRESENT(u_p)
@@ -938,5 +942,5 @@
                                                         ( u(k,j,i) - u_init(k) ) &
                                      ) * MERGE( 1.0_wp, 0.0_wp,                  &
-                                                 BTEST( wall_flags_static_0(k,j,i), 1 ) &
+                                           BTEST( wall_flags_total_0(k,j,i), 1 ) &
                                               )
           ENDDO
@@ -1030,5 +1034,5 @@
 !-- Prognostic equation for v-velocity component
     !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-    !$ACC PRESENT(v, tend, tv_m, v_init, rdf, wall_flags_static_0) &
+    !$ACC PRESENT(v, tend, tv_m, v_init, rdf, wall_flags_total_0) &
     !$ACC PRESENT(tsc(2:5)) &
     !$ACC PRESENT(v_p)
@@ -1041,5 +1045,5 @@
                                                       ( v(k,j,i) - v_init(k) ) &
                                      ) * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 2 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 2 )&
                                               )
           ENDDO
@@ -1129,5 +1133,5 @@
 !-- Prognostic equation for w-velocity component
     !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-    !$ACC PRESENT(w, tend, tw_m, v_init, rdf, wall_flags_static_0) &
+    !$ACC PRESENT(w, tend, tw_m, v_init, rdf, wall_flags_total_0) &
     !$ACC PRESENT(tsc(2:5)) &
     !$ACC PRESENT(w_p)
@@ -1139,5 +1143,5 @@
                                                - tsc(5) * rdf(k) * w(k,j,i)    &
                                      ) * MERGE( 1.0_wp, 0.0_wp,                &
-                                                BTEST( wall_flags_static_0(k,j,i), 3 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 3 )&
                                               )
           ENDDO
@@ -1267,5 +1271,5 @@
 !--    Prognostic equation for potential temperature
        !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-       !$ACC PRESENT(pt, tend, tpt_m, wall_flags_static_0) &
+       !$ACC PRESENT(pt, tend, tpt_m, wall_flags_total_0) &
        !$ACC PRESENT(pt_init, rdf_sc, ptdf_x, ptdf_y) &
        !$ACC PRESENT(tsc(3:5)) &
@@ -1281,5 +1285,5 @@
                                           )                                    &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
              ENDDO
@@ -1402,5 +1406,5 @@
                                                       ( q(k,j,i) - q_init(k) ) &
                                         ) * MERGE( 1.0_wp, 0.0_wp,             &
-                                                   BTEST( wall_flags_static_0(k,j,i), 0 ) &
+                                         BTEST( wall_flags_total_0(k,j,i), 0 ) &
                                                  )
                 IF ( q_p(k,j,i) < 0.0_wp )  q_p(k,j,i) = 0.1_wp * q(k,j,i)
@@ -1523,5 +1527,5 @@
                                         )                                      &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                 IF ( s_p(k,j,i) < 0.0_wp )  s_p(k,j,i) = 0.1_wp * s(k,j,i)
Index: /palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- /palm/trunk/SOURCE/salsa_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/salsa_mod.f90	(revision 4346)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4342 2019-12-16 13:49:14Z Giersch
 ! cdc replaced by canopy_drag_coeff
 ! 
@@ -259,5 +263,6 @@
 
     USE indices,                                                                                   &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, nz, nzt, wall_flags_static_0
+        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, nz, nzt,             &
+               wall_flags_total_0
 
     USE kinds
@@ -1655,8 +1660,8 @@
        ALLOCATE( salsa_advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 !
-!--    In case of decycling, set Neuman boundary conditions for wall_flags_static_0 bit 31 instead of
+!--    In case of decycling, set Neuman boundary conditions for wall_flags_total_0 bit 31 instead of
 !--    cyclic boundary conditions. Bit 31 is used to identify extended degradation zones (please see
 !--    the following comment). Note, since several also other modules may access this bit but may
-!--    have other boundary conditions, the original value of wall_flags_static_0 bit 31 must not be
+!--    have other boundary conditions, the original value of wall_flags_total_0 bit 31 must not be
 !--    modified. Hence, store the boundary conditions directly on salsa_advc_flags_s.
 !--    salsa_advc_flags_s will be later overwritten in ws_init_flags_scalar and bit 31 won't be used
@@ -1664,5 +1669,5 @@
 !--    Initialize with flag 31 only.
        salsa_advc_flags_s = 0
-       salsa_advc_flags_s = MERGE( IBSET( salsa_advc_flags_s, 31 ), 0, BTEST( wall_flags_static_0, 31 ) )
+       salsa_advc_flags_s = MERGE( IBSET( salsa_advc_flags_s, 31 ), 0, BTEST( wall_flags_total_0, 31 ) )
 
        IF ( decycle_salsa_ns )  THEN
@@ -1784,5 +1789,6 @@
        DO  j = nys, nyn
 
-          k_topo_top(j,i) = MAXLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,j,i), 12 ) ), DIM = 1 ) - 1
+          k_topo_top(j,i) = MAXLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,j,i), 12 ) ), &
+                                       DIM = 1 ) - 1
 
           CALL salsa_driver( i, j, 1 )
@@ -2310,5 +2316,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--          a) Number concentrations
@@ -2521,5 +2527,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
 !
 !--          Regime 2a:
@@ -3068,5 +3074,5 @@
 !
 !--    Predetermine flag to mask topography
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--    Wind velocity for dry depositon on vegetation
@@ -7443,5 +7449,5 @@
 !
 !-- Predetermine flag to mask topography
-    flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(:,j,i), 0 ) )
+    flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(:,j,i), 0 ) )
 
     DO  ib = 1, nbins_aerosol   ! aerosol size bins
@@ -7859,5 +7865,5 @@
 
     USE indices,                                                                                   &
-        ONLY:  wall_flags_static_0
+        ONLY:  wall_flags_total_0
 
     USE surface_mod,                                                                               &
@@ -7951,8 +7957,8 @@
           tend(k,j,i) = tend(k,j,i) - MAX( 0.0_wp, ( rs(k+1,j,i) * sedim_vd(k+1,j,i,ib) -          &
                                                      rs(k,j,i) * sedim_vd(k,j,i,ib) ) * ddzu(k) )  &
-                                    * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k-1,j,i), 0 ) )
+                                    * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 0 ) )
           rs_p(k,j,i) = rs(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )     &
                                       - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) ) )          &
-                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
        ENDDO
@@ -7964,5 +7970,5 @@
           rs_p(k,j,i) = rs(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )     &
                                                 - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) ) )&
-                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
        ENDDO
@@ -8003,5 +8009,5 @@
         ONLY:  diffusion_s
     USE indices,                                                                                   &
-        ONLY:  wall_flags_static_0
+        ONLY:  wall_flags_total_0
     USE surface_mod,                                                                               &
         ONLY :  surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v
@@ -8088,10 +8094,10 @@
                                    sedim_vd(nzb+2:nzt+1,j,i,ib) - rs(nzb+1:nzt,j,i) *              &
                                    sedim_vd(nzb+1:nzt,j,i,ib) ) * ddzu(nzb+1:nzt) ) *              &
-                                   MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(nzb:nzt-1,j,i), 0 ) )
+                                   MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(nzb:nzt-1,j,i), 0 ) )
           ENDIF
           DO  k = nzb+1, nzt
              rs_p(k,j,i) = rs(k,j,i) +  ( dt_3d  * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )&
                                                   - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) )&
-                                        ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
              IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
           ENDDO
@@ -8424,5 +8430,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq_init(k) * flag
                    ENDDO
@@ -8449,5 +8455,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq(k,j,copied) * flag
                    ENDDO
@@ -8485,5 +8491,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq_init(k) * flag
                    ENDDO
@@ -8510,5 +8516,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq(k,copied,i) * flag
                    ENDDO
@@ -10006,5 +10012,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10021,5 +10028,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10035,5 +10043,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10053,5 +10062,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10071,5 +10081,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10089,5 +10100,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10704,5 +10716,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( aerosol_number(ib)%conc(k,j,i), REAL( fill_value,   &
-                                               KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10713,5 +10725,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( nbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10736,5 +10748,5 @@
                       ENDDO
                       local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),            &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10745,5 +10757,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( mbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10770,5 +10782,5 @@
                          local_pf(i,j,k) = MERGE( salsa_gas(found_index)%conc(k,j,i),              &
                                                   REAL( fill_value,  KIND = wp ),                  &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10784,5 +10796,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10814,5 +10826,5 @@
 
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10823,5 +10835,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ldsa_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10844,5 +10856,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10853,5 +10865,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( nufp_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10872,5 +10884,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10881,5 +10893,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ntot_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10903,5 +10915,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10912,5 +10924,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm01_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10934,5 +10946,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10943,5 +10955,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm25_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10965,5 +10977,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin,  REAL( fill_value, KIND = wp ),        &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10974,5 +10986,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm10_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10995,5 +11007,5 @@
                             ENDDO
                             local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),      &
-                                                     BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11011,5 +11023,5 @@
                          DO  k = nzb_do, nzt_do
                             local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,      &
-                                                     KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11033,5 +11045,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11043,5 +11055,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                              KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11114,5 +11126,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( aerosol_number(ib)%conc(k,j,i), REAL( fill_value,   &
-                                               KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -11123,5 +11135,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( nbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                    ENDDO
                 ENDDO
@@ -11144,5 +11156,5 @@
                       ENDDO
                       local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),            &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -11153,5 +11165,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( mbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                    ENDDO
                 ENDDO
@@ -11176,5 +11188,5 @@
                          local_pf(i,j,k) = MERGE( salsa_gas(found_index)%conc(k,j,i),              &
                                                   REAL( fill_value, KIND = wp ),                   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11192,5 +11204,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11219,5 +11231,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11228,5 +11240,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ldsa_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11246,5 +11258,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11255,5 +11267,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( nufp_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11271,5 +11283,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11280,5 +11292,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ntot_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11300,5 +11312,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11309,5 +11321,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm01_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11329,5 +11341,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11338,5 +11350,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm25_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11358,5 +11370,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11367,5 +11379,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm10_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11385,5 +11397,5 @@
                             ENDDO
                             local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),      &
-                                                     BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                          ENDDO
                       ENDDO
@@ -11403,5 +11415,5 @@
                          DO  k = nzb_do, nzt_do
                             local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,      &
-                                                     KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                     KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11421,5 +11433,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11431,5 +11443,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11521,10 +11533,11 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                    DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -11575,10 +11588,11 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                    DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -11654,10 +11668,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11703,10 +11718,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11750,10 +11766,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11801,10 +11818,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11852,10 +11870,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11903,10 +11922,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11955,10 +11975,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -12011,10 +12032,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                          DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -12055,9 +12077,10 @@
                 im = mask_i(mid,i)
                 jm = mask_j(mid,j)
-                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                 DIM = 1 ) - 1
                 DO  k = 1, mask_size_l(mid,3)
                    kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                Set value if not in building
-                   IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                       local_pf(i,j,k) = fill_value
                    ELSE
Index: /palm/trunk/SOURCE/subsidence_mod.f90
===================================================================
--- /palm/trunk/SOURCE/subsidence_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/subsidence_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -155,5 +159,5 @@
        USE indices,                                                            &
            ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,        &
-                  wall_flags_static_0
+                  wall_flags_total_0
 
        USE kinds
@@ -189,10 +193,10 @@
                               ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) *      &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ELSE                               ! large-scale ascent
                    tmp_tend = - w_subs(k) *                                    &
                               ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) *        &
                                         MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ENDIF
 
@@ -203,5 +207,5 @@
                                  * weight_substep(intermediate_timestep_count) &
                                  * MERGE( 1.0_wp, 0.0_wp,                      &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                   BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ENDIF
              ENDDO
@@ -269,5 +273,6 @@
 
        USE indices,                                                            &
-           ONLY:  nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt, wall_flags_static_0
+           ONLY:  nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt,                  &
+                  wall_flags_total_0
 
        USE kinds
@@ -300,9 +305,9 @@
                                     * ddzu(k+1)                                &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                      BTEST( wall_flags_total_0(k,j,i), 0 ) )
           ELSE                                 ! large-scale ascent
              tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k)  &
                                     * MERGE( 1.0_wp, 0.0_wp,                   &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                      BTEST( wall_flags_total_0(k,j,i), 0 ) )
           ENDIF
 
@@ -313,5 +318,5 @@
                                   * weight_substep(intermediate_timestep_count)&
                                   * MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                    BTEST( wall_flags_total_0(k,j,i), 0 ) )
           ENDIF
        ENDDO
Index: /palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/surface_mod.f90	(revision 4346)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4331 2019-12-10 18:25:02Z suehring
 ! -pt_2m - array is moved to diagnostic_output_quantities
 ! 
@@ -114,5 +118,6 @@
 
     USE indices,                                                               &
-        ONLY:  nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt, wall_flags_static_0
+        ONLY:  nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt,           &
+               wall_flags_total_0
 
     USE grid_variables,                                                        &
@@ -590,6 +595,6 @@
 !         
 !--                Check if current gridpoint belongs to the atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+bc_h(l)%koff,           &
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_h(l)%koff,     &
                                                      j+bc_h(l)%joff,           &
                                                      i+bc_h(l)%ioff), 0 ) )    &
@@ -621,8 +626,8 @@
 !         
 !--                Check if current gridpoint belongs to the atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !         
 !--                   Upward-facing
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+bc_h(l)%koff,           &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_h(l)%koff,     &
                                                      j+bc_h(l)%joff,           &
                                                      i+bc_h(l)%ioff), 0 )      &
@@ -657,6 +662,6 @@
 !         
 !--                Check if current gridpoint belongs to the atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+bc_v(l)%koff,           &
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_v(l)%koff,     &
                                                      j+bc_v(l)%joff,           &
                                                      i+bc_v(l)%ioff), 0 ) )    &
@@ -690,8 +695,8 @@
 !         
 !--                Check if current gridpoint belongs to the atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !         
 !--                   Upward-facing
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+bc_v(l)%koff,           &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+bc_v(l)%koff,     &
                                                      j+bc_v(l)%joff,           &
                                                      i+bc_v(l)%ioff), 0 )      &
@@ -770,16 +775,16 @@
 !
 !--             Check if current gridpoint belongs to the atmosphere
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !
 !--                Check if grid point adjoins to any upward-facing horizontal
 !--                surface, e.g. the Earth surface, plane roofs, or ceilings.
 
-                   IF ( .NOT. BTEST( wall_flags_static_0(k-1,j,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i), 0 ) )  THEN
 !
 !--                   Determine flags indicating a terrain surface, a building
 !--                   surface, 
-                      terrain  = BTEST( wall_flags_static_0(k-1,j,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k-1,j,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k-1,j,i), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k-1,j,i), 6 )  .OR.       &
                                  topo_no_distinct
 !
@@ -787,6 +792,6 @@
 !--                   as terrain but with a non-grid resolved building on top.
 !--                   These surfaces will be flagged as urban surfaces.
-                      unresolved_building = BTEST( wall_flags_static_0(k-1,j,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k-1,j,i), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k-1,j,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k-1,j,i), 6 )
 !
 !--                   Land-surface type
@@ -822,5 +827,5 @@
 !--                Check for any other downward-facing surface. So far only for 
 !--                default surface type.
-                   ELSEIF ( .NOT. BTEST( wall_flags_static_0(k+1,j,i), 0 ) )  THEN
+                   ELSEIF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i), 0 ) )  THEN
                       num_def_h(1) = num_def_h(1) + 1
                    ENDIF 
@@ -835,18 +840,18 @@
           DO  j = nys, nyn
              DO  k = nzb+1, nzt
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !
 !--                Northward-facing
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
 
-                      terrain  = BTEST( wall_flags_static_0(k,j-1,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j-1,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j-1,i), 6 )   .OR.      &
+                      building = BTEST( wall_flags_total_0(k,j-1,i), 6 )   .OR.      &
                                  topo_no_distinct
 
-                      unresolved_building = BTEST( wall_flags_static_0(k,j-1,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j-1,i), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j-1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j-1,i), 6 )
                                      
                       IF (  land_surface  .AND.  terrain  .AND.                &
@@ -873,14 +878,14 @@
 !
 !--                Southward-facing
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j+1,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j+1,i), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j+1,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j+1,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j+1,i), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j+1,i), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j+1,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j+1,i), 6 ) 
+                      unresolved_building = BTEST( wall_flags_total_0(k,j+1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j+1,i), 6 ) 
                                 
                       IF (  land_surface  .AND.  terrain  .AND.                &
@@ -907,14 +912,14 @@
 !
 !--                Eastward-facing
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j,i-1), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j,i-1), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j,i-1), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j,i-1), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j,i-1), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j,i-1), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j,i-1), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j,i-1), 6 )
                                      
                       IF (  land_surface  .AND.  terrain  .AND.                &
@@ -941,14 +946,14 @@
 !
 !--                Westward-facing
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i+1), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j,i+1), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j,i+1), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j,i+1), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j,i+1), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j,i+1), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j,i+1), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j,i+1), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j,i+1), 6 )
                                  
                       IF (  land_surface  .AND.  terrain  .AND.                &
@@ -2139,15 +2144,15 @@
 !
 !--             Check if current gridpoint belongs to the atmosphere
-                IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !
 !--                Upward-facing surface. Distinguish between differet surface types.
 !--                To do, think about method to flag natural and non-natural 
 !--                surfaces. 
-                   IF ( .NOT. BTEST( wall_flags_static_0(k-1,j,i), 0 ) )  THEN 
+                   IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i), 0 ) )  THEN 
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k-1,j,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k-1,j,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k-1,j,i), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k-1,j,i), 6 )  .OR.       &
                                  topo_no_distinct
                                  
@@ -2156,6 +2161,6 @@
 !--                   as terrain but with a non-grid resolved building on top.
 !--                   These surfaces will be flagged as urban surfaces.
-                      unresolved_building = BTEST( wall_flags_static_0(k-1,j,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k-1,j,i), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k-1,j,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k-1,j,i), 6 )
 !
 !--                   Natural surface type          
@@ -2195,5 +2200,5 @@
 !--                Check for any other downward-facing surface. So far only for 
 !--                default surface type.
-                   ELSEIF ( .NOT. BTEST( wall_flags_static_0(k+1,j,i), 0 ) )  THEN
+                   ELSEIF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i), 0 ) )  THEN
                       CALL initialize_horizontal_surfaces( k, j, i,            &
                                                            surf_def_h(1),      &
@@ -2205,14 +2210,14 @@
 !--                Check for vertical walls and, if required, initialize it.
 !                  Start with northward-facing surface.
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j-1,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j-1,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j-1,i), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j-1,i), 6 )  .OR.       &
                                  topo_no_distinct
 
-                      unresolved_building = BTEST( wall_flags_static_0(k,j-1,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j-1,i), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j-1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j-1,i), 6 )
                                      
                       IF ( land_surface  .AND.  terrain  .AND.                 &
@@ -2242,14 +2247,14 @@
 !
 !--                southward-facing surface
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j+1,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j+1,i), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j+1,i), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j+1,i), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j+1,i), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j+1,i), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j+1,i), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j+1,i), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j+1,i), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j+1,i), 6 )
                                      
                       IF ( land_surface  .AND.  terrain  .AND.                 &
@@ -2279,14 +2284,14 @@
 !
 !--                eastward-facing surface
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j,i-1), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j,i-1), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j,i-1), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j,i-1), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j,i-1), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j,i-1), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j,i-1), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j,i-1), 6 )
                                  
                       IF ( land_surface  .AND.  terrain  .AND.                 &
@@ -2316,14 +2321,14 @@
 !   
 !--                westward-facing surface
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i+1), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )  THEN
 !
 !--                   Determine flags indicating terrain or building
-                      terrain  = BTEST( wall_flags_static_0(k,j,i+1), 5 )  .OR.       &
+                      terrain  = BTEST( wall_flags_total_0(k,j,i+1), 5 )  .OR.       &
                                  topo_no_distinct
-                      building = BTEST( wall_flags_static_0(k,j,i+1), 6 )  .OR.       &
+                      building = BTEST( wall_flags_total_0(k,j,i+1), 6 )  .OR.       &
                                  topo_no_distinct
                                  
-                      unresolved_building = BTEST( wall_flags_static_0(k,j,i+1), 5 )  &
-                                     .AND.  BTEST( wall_flags_static_0(k,j,i+1), 6 )
+                      unresolved_building = BTEST( wall_flags_total_0(k,j,i+1), 5 )  &
+                                     .AND.  BTEST( wall_flags_total_0(k,j,i+1), 6 )
                                   
                       IF ( land_surface  .AND.  terrain  .AND.                 &
Index: /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90
===================================================================
--- /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/synthetic_turbulence_generator_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4335 2019-12-12 16:39:05Z suehring
 ! Commentation of last commit
 ! 
@@ -204,5 +208,5 @@
                nyng,                                                           &
                nysg,                                                           &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -986,5 +990,5 @@
        nr_non_topo_yz_l(1) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,nys:nyn,i), 1 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,nys:nyn,i), 1 ) ) )
 !
 !--    Number of grid points where perturbations are imposed on v and w                                   
@@ -994,8 +998,8 @@
        nr_non_topo_yz_l(2) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,nysv:nyn,i), 2 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,nysv:nyn,i), 2 ) ) )
        nr_non_topo_yz_l(3) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,nys:nyn,i), 3 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,nys:nyn,i), 3 ) ) )
                                     
 #if defined( __parallel )
@@ -1015,5 +1019,5 @@
        nr_non_topo_xz_l(2) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,j,nxl:nxr), 2 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,j,nxl:nxr), 2 ) ) )
 !
 !--    Number of grid points where perturbations are imposed on u and w 
@@ -1023,8 +1027,8 @@
        nr_non_topo_xz_l(1) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,j,nxlu:nxr), 1 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,j,nxlu:nxr), 1 ) ) )
        nr_non_topo_xz_l(3) = SUM(                                              &
                           MERGE( 1, 0,                                         &
-                                 BTEST( wall_flags_static_0(nzb:nzt,j,nxl:nxr), 3 ) ) )
+                          BTEST( wall_flags_total_0(nzb:nzt,j,nxl:nxr), 3 ) ) )
                                     
 #if defined( __parallel )
@@ -1351,5 +1355,5 @@
                 dist_yz(k,j,1) = MIN( a11(k) * fu_yz(k,j), 3.0_wp ) *          &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                    BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDDO
@@ -1368,5 +1372,5 @@
                                          + a22(k) * fv_yz(k,j) ), 3.0_wp ) *   &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 2 ) )   
+                                        BTEST( wall_flags_total_0(k,j,i), 2 ) )   
                 dist_yz(k,j,3) = MIN( ( SQRT(a33(k) / MAXVAL(a33) )            &
                                       * 1.3_wp )                               &
@@ -1375,5 +1379,5 @@
                                         + a33(k) * fw_yz(k,j) ), 3.0_wp )  *   &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 3 ) )
              ENDDO
           ENDDO
@@ -1398,5 +1402,5 @@
           mc_factor_l(1) = SUM( dist_yz(nzb:nzt,nys:nyn,1)                     &
                          * MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzb:nzt,nys:nyn,i), 1 ) ) )
+                           BTEST( wall_flags_total_0(nzb:nzt,nys:nyn,i), 1 ) ) )
         
           IF ( myidx == id_stg_left  )  i = nxl-1
@@ -1405,8 +1409,8 @@
           mc_factor_l(2) = SUM( dist_yz(nzb:nzt,nysv:nyn,2)                    &
                           * MERGE( 1.0_wp, 0.0_wp,                             &
-                                   BTEST( wall_flags_static_0(nzb:nzt,nysv:nyn,i), 2 ) ) )
+                            BTEST( wall_flags_total_0(nzb:nzt,nysv:nyn,i), 2 ) ) )
           mc_factor_l(3) = SUM( dist_yz(nzb:nzt,nys:nyn,3)                     &
                           * MERGE( 1.0_wp, 0.0_wp,                             &
-                                   BTEST( wall_flags_static_0(nzb:nzt,nys:nyn,i), 3 ) ) )
+                            BTEST( wall_flags_total_0(nzb:nzt,nys:nyn,i), 3 ) ) )
           
 #if defined( __parallel )
@@ -1425,5 +1429,5 @@
           dist_yz(:,:,1) = ( dist_yz(:,:,1) - mc_factor(1) )                   &
                         * MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(:,:,i), 1 ) )             
+                          BTEST( wall_flags_total_0(:,:,i), 1 ) )             
                                                                                
                                                                                
@@ -1433,9 +1437,9 @@
           dist_yz(:,:,2) = ( dist_yz(:,:,2) - mc_factor(2) )                   &
                         * MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(:,:,i), 2 ) )             
+                          BTEST( wall_flags_total_0(:,:,i), 2 ) )             
                                                                                
           dist_yz(:,:,3) = ( dist_yz(:,:,3) - mc_factor(3) )                   &
                         * MERGE( 1.0_wp, 0.0_wp,                               &
-                                 BTEST( wall_flags_static_0(:,:,i), 3 ) )
+                          BTEST( wall_flags_total_0(:,:,i), 3 ) )
 !      
 !--       Add disturbances
@@ -1453,12 +1457,12 @@
                                            dist_yz(k,j,1)             )        &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,0), 1 ) )  
+                                     BTEST( wall_flags_total_0(k,j,0), 1 ) )  
                       v(k,j,-nbgp:-1)  = ( mean_inflow_profiles(k,2) +         &
                                            dist_yz(k,j,2)             )        &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,-1), 2 ) ) 
+                                     BTEST( wall_flags_total_0(k,j,-1), 2 ) ) 
                       w(k,j,-nbgp:-1)  =   dist_yz(k,j,3)                      &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                            BTEST( wall_flags_static_0(k,j,-1), 3 ) )
+                                     BTEST( wall_flags_total_0(k,j,-1), 3 ) )
                    ENDDO
                 ENDDO
@@ -1469,12 +1473,12 @@
                       u(k,j,0)   = ( u(k,j,0) + dist_yz(k,j,1) )               &
                                  * MERGE( 1.0_wp, 0.0_wp,                      &
-                                          BTEST( wall_flags_static_0(k,j,0), 1 ) )
+                                   BTEST( wall_flags_total_0(k,j,0), 1 ) )
                       u(k,j,-1)  = u(k,j,0)
                       v(k,j,-1)  = ( v(k,j,-1)  + dist_yz(k,j,2)  )            &
                                  * MERGE( 1.0_wp, 0.0_wp,                      &
-                                          BTEST( wall_flags_static_0(k,j,-1), 2 ) )
+                                   BTEST( wall_flags_total_0(k,j,-1), 2 ) )
                       w(k,j,-1)  = ( w(k,j,-1)  + dist_yz(k,j,3) )             &
                                  * MERGE( 1.0_wp, 0.0_wp,                      &
-                                          BTEST( wall_flags_static_0(k,j,-1), 3 ) )
+                                   BTEST( wall_flags_total_0(k,j,-1), 3 ) )
                    ENDDO
                 ENDDO
@@ -1486,11 +1490,11 @@
                    u(k,j,nxr+1) = ( u(k,j,nxr+1) + dist_yz(k,j,1) )            &
                                   * MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,nxr+1), 1 ) ) 
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 1 ) ) 
                    v(k,j,nxr+1) = ( v(k,j,nxr+1) + dist_yz(k,j,2) )            &
                                   * MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,nxr+1), 2 ) )
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 2 ) )
                    w(k,j,nxr+1) = ( w(k,j,nxr+1) + dist_yz(k,j,3) )            &
                                   * MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,nxr+1), 3 ) )
+                                    BTEST( wall_flags_total_0(k,j,nxr+1), 3 ) )
                 ENDDO
              ENDDO
@@ -1551,5 +1555,5 @@
                                          + a22(k) * fv_xz(k,i) ), 3.0_wp ) *   &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                    BTEST( wall_flags_total_0(k,j,i), 2 ) )
              ENDDO
           ENDDO
@@ -1564,5 +1568,5 @@
                 dist_xz(k,i,1) = MIN( a11(k) * fu_xz(k,i), 3.0_wp ) *          &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 1 ) )   
+                                    BTEST( wall_flags_total_0(k,j,i), 1 ) )   
           
                 dist_xz(k,i,3) = MIN( ( SQRT(a33(k) / MAXVAL(a33) )            &
@@ -1572,5 +1576,5 @@
                                         + a33(k) * fw_xz(k,i) ), 3.0_wp )  *   &
                                     MERGE( 1.0_wp, 0.0_wp,                     &
-                                           BTEST( wall_flags_static_0(k,j,i), 3 ) ) 
+                                    BTEST( wall_flags_total_0(k,j,i), 3 ) ) 
              ENDDO
           ENDDO
@@ -1593,5 +1597,5 @@
           mc_factor_l(2) = SUM( dist_xz(nzb:nzt,nxl:nxr,2)                     &
                          * MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzb:nzt,j,nxl:nxr), 2 ) ) )
+                           BTEST( wall_flags_total_0(nzb:nzt,j,nxl:nxr), 2 ) ) )
           
           IF ( myidy == id_stg_south  ) j = nys-1
@@ -1600,8 +1604,8 @@
           mc_factor_l(1) = SUM( dist_xz(nzb:nzt,nxlu:nxr,1)                    &
                          * MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzb:nzt,j,nxlu:nxr), 1 ) ) )
+                           BTEST( wall_flags_total_0(nzb:nzt,j,nxlu:nxr), 1 ) ) )
           mc_factor_l(3) = SUM( dist_xz(nzb:nzt,nxl:nxr,3)                     &
                          * MERGE( 1.0_wp, 0.0_wp,                              &
-                                  BTEST( wall_flags_static_0(nzb:nzt,j,nxl:nxr), 3 ) ) )
+                           BTEST( wall_flags_total_0(nzb:nzt,j,nxl:nxr), 3 ) ) )
           
 #if defined( __parallel )
@@ -1619,5 +1623,5 @@
           dist_xz(:,:,2)   = ( dist_xz(:,:,2) - mc_factor(2) )                 &
                            * MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(:,j,:), 2 ) )          
+                             BTEST( wall_flags_total_0(:,j,:), 2 ) )          
                                                                                
                                                                                
@@ -1627,9 +1631,9 @@
           dist_xz(:,:,1)   = ( dist_xz(:,:,1) - mc_factor(1) )                 &
                            * MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(:,j,:), 1 ) )          
+                             BTEST( wall_flags_total_0(:,j,:), 1 ) )          
                                                                                
           dist_xz(:,:,3)   = ( dist_xz(:,:,3) - mc_factor(3) )                 &
                            * MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_static_0(:,j,:), 3 ) )      
+                             BTEST( wall_flags_total_0(:,j,:), 3 ) )      
 !         
 !--       Add disturbances
@@ -1639,12 +1643,12 @@
                    u(k,-1,i) = ( u(k,-1,i) + dist_xz(k,i,1) )                  &
                                         * MERGE( 1.0_wp, 0.0_wp,               &
-                                                 BTEST( wall_flags_static_0(k,-1,i), 1 ) )
+                                          BTEST( wall_flags_total_0(k,-1,i), 1 ) )
                    v(k,0,i)  = ( v(k,0,i)  + dist_xz(k,i,2)  )                 &
                                         * MERGE( 1.0_wp, 0.0_wp,               &
-                                                 BTEST( wall_flags_static_0(k,0,i), 2 ) )
+                                          BTEST( wall_flags_total_0(k,0,i), 2 ) )
                    v(k,-1,i) = v(k,0,i)
                    w(k,-1,i) = ( w(k,-1,i) + dist_xz(k,i,3)  )                 &
                                         * MERGE( 1.0_wp, 0.0_wp,               &
-                                                 BTEST( wall_flags_static_0(k,-1,i), 3 ) )
+                                          BTEST( wall_flags_total_0(k,-1,i), 3 ) )
                 ENDDO
              ENDDO
@@ -1656,11 +1660,11 @@
                    u(k,nyn+1,i) = ( u(k,nyn+1,i) + dist_xz(k,i,1) )            &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                             BTEST( wall_flags_static_0(k,nyn+1,i), 1 ) )
+                                       BTEST( wall_flags_total_0(k,nyn+1,i), 1 ) )
                    v(k,nyn+1,i) = ( v(k,nyn+1,i) + dist_xz(k,i,2) )            &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,nyn+1,i), 2 ) )
+                                       BTEST( wall_flags_total_0(k,nyn+1,i), 2 ) )
                    w(k,nyn+1,i) = ( w(k,nyn+1,i) + dist_xz(k,i,3) )            &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,nyn+1,i), 3 ) )
+                                       BTEST( wall_flags_total_0(k,nyn+1,i), 3 ) )
                 ENDDO
              ENDDO
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 4345)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -369,5 +373,5 @@
 
     USE indices,                                                                                   &
-        ONLY:  advc_flags_m, advc_flags_s, nyn, nyng, nys, nysg, nz, nzb_max, wall_flags_static_0
+        ONLY:  advc_flags_m, advc_flags_s, nyn, nyng, nys, nysg, nz, nzb_max, wall_flags_total_0
 
     USE statistics,                                                                                &
@@ -459,5 +463,5 @@
 !$ACC COPYIN(advc_flags_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
 !$ACC COPYIN(advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg)) &
-!$ACC COPYIN(wall_flags_static_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
+!$ACC COPYIN(wall_flags_total_0(nzb:nzt+1,nysg:nyng,nxlg:nxrg))
 
 !
@@ -599,6 +603,5 @@
 !--    Execute all other module actions routines
        CALL module_interface_actions( 'before_timestep' )
-
-!
+       
 !--    Start of intermediate step loop
        intermediate_timestep_count = 0
Index: /palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- /palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -140,5 +144,5 @@
                nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,    &
                topo_top_ind,                                                  &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -925,6 +929,6 @@
              DO  k = nzb_do, nzt_do
                 local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i),                &
-                                         REAL( fill_value, KIND = wp ),        &
-                                         BTEST( wall_flags_static_0(k,j,i), flag_nr ) )
+                                  REAL( fill_value, KIND = wp ),               &
+                                  BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
              ENDDO
           ENDDO
@@ -1022,5 +1026,5 @@
                                    to_be_resorted(k,j,i),                &
                                    REAL( fill_value, KIND = wp ),        &
-                                   BTEST( wall_flags_static_0(k,j,i), flag_nr ) )
+                                   BTEST( wall_flags_total_0(k,j,i), flag_nr ) )
              ENDDO
           ENDDO
@@ -1311,5 +1315,5 @@
                 DO  k = nzb, nzt
                    e(k,j,i)     = MERGE( e(k,j,i), 0.0_wp,                     &
-                                         BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                         BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 ENDDO
              ENDDO
@@ -1321,5 +1325,5 @@
                    DO  k = nzb, nzt
                       diss(k,j,i)    = MERGE( diss(k,j,i), 0.0_wp,             &
-                                              BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                         BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -1367,5 +1371,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb,  &
-               nzt, wall_flags_static_0
+               nzt, wall_flags_total_0
 
     USE kinds
@@ -1441,77 +1445,77 @@
 !
 !--                Check if current gridpoint belongs to the atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
 !
 !--                   Check for neighbouring grid-points.
 !--                   Vertical distance, down
-                      IF ( .NOT. BTEST( wall_flags_static_0(k-1,j,i), 0 ) )             &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i), 0 ) )             &
                          l_wall(k,j,i) = MIN( l_grid(k), zu(k) - zw(k-1) )
 !
 !--                   Vertical distance, up
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+1,j,i), 0 ) )             &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i), 0 ) )             &
                          l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k), zw(k) - zu(k) )
 !
 !--                   y-distance
-                      IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 0 )  .OR.         &
-                           .NOT. BTEST( wall_flags_static_0(k,j+1,i), 0 ) )             &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 0 )  .OR.         &
+                           .NOT. BTEST( wall_flags_total_0(k,j+1,i), 0 ) )             &
                          l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k), 0.5_wp * dy )
 !
 !--                   x-distance
-                      IF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 0 )  .OR.         &
-                           .NOT. BTEST( wall_flags_static_0(k,j,i+1), 0 ) )             &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 0 )  .OR.         &
+                           .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )             &
                          l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k), 0.5_wp * dx )
 !
 !--                   yz-distance (vertical edges, down)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k-1,j-1,i), 0 )  .OR.       &
-                           .NOT. BTEST( wall_flags_static_0(k-1,j+1,i), 0 )  )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),          &
-                                              SQRT( 0.25_wp * dy**2 +            &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k-1,j-1,i), 0 )  .OR.       &
+                           .NOT. BTEST( wall_flags_total_0(k-1,j+1,i), 0 )  )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                &
+                                              SQRT( 0.25_wp * dy**2 +                  &
                                              ( zu(k) - zw(k-1) )**2 ) )
 !
 !--                   yz-distance (vertical edges, up)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+1,j-1,i), 0 )  .OR.       &
-                           .NOT. BTEST( wall_flags_static_0(k+1,j+1,i), 0 )  )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),          &
-                                              SQRT( 0.25_wp * dy**2 +            &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+1,j-1,i), 0 )  .OR.       &
+                           .NOT. BTEST( wall_flags_total_0(k+1,j+1,i), 0 )  )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                &
+                                              SQRT( 0.25_wp * dy**2 +                  &
                                              ( zw(k) - zu(k) )**2 ) )
 !
 !--                   xz-distance (vertical edges, down)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k-1,j,i-1), 0 )  .OR.       &
-                           .NOT. BTEST( wall_flags_static_0(k-1,j,i+1), 0 )  )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),          &
-                                              SQRT( 0.25_wp * dx**2 +            &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k-1,j,i-1), 0 )  .OR.       &
+                           .NOT. BTEST( wall_flags_total_0(k-1,j,i+1), 0 )  )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                &
+                                              SQRT( 0.25_wp * dx**2 +                  &
                                              ( zu(k) - zw(k-1) )**2 ) )
 !
 !--                   xz-distance (vertical edges, up)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+1,j,i-1), 0 )  .OR.       &
-                           .NOT. BTEST( wall_flags_static_0(k+1,j,i+1), 0 )  )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),          &
-                                              SQRT( 0.25_wp * dx**2 +            &
-                                             ( zw(k) - zu(k) )**2 ) )
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+1,j,i-1), 0 )  .OR.       &
+                           .NOT. BTEST( wall_flags_total_0(k+1,j,i+1), 0 )  )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                &
+                                              SQRT( 0.25_wp * dx**2 +                  &
+                                             ( zw(k) - zu(k) )**2 ) )                 
 !
 !--                   xy-distance (horizontal edges)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i-1), 0 )  .OR.        &
-                           .NOT. BTEST( wall_flags_static_0(k,j+1,i-1), 0 )  .OR.        &
-                           .NOT. BTEST( wall_flags_static_0(k,j-1,i+1), 0 )  .OR.        &
-                           .NOT. BTEST( wall_flags_static_0(k,j+1,i+1), 0 ) )            &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),           &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i-1), 0 )  .OR.        &
+                           .NOT. BTEST( wall_flags_total_0(k,j+1,i-1), 0 )  .OR.        &
+                           .NOT. BTEST( wall_flags_total_0(k,j-1,i+1), 0 )  .OR.        &
+                           .NOT. BTEST( wall_flags_total_0(k,j+1,i+1), 0 ) )            &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                 &
                                               SQRT( 0.25_wp * ( dx**2 + dy**2 ) ) )
 !
 !--                   xyz distance (vertical and horizontal edges, down)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k-1,j-1,i-1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k-1,j+1,i-1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k-1,j-1,i+1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k-1,j+1,i+1), 0 ) )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),           &
-                                              SQRT( 0.25_wp * ( dx**2 + dy**2 )   &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k-1,j-1,i-1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k-1,j+1,i-1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k-1,j-1,i+1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k-1,j+1,i+1), 0 ) )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                 &
+                                              SQRT( 0.25_wp * ( dx**2 + dy**2 )         &
                                                     +  ( zu(k) - zw(k-1) )**2  ) )
 !
 !--                   xyz distance (vertical and horizontal edges, up)
-                      IF ( .NOT. BTEST( wall_flags_static_0(k+1,j-1,i-1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k+1,j+1,i-1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k+1,j-1,i+1), 0 )  .OR.      &
-                           .NOT. BTEST( wall_flags_static_0(k+1,j+1,i+1), 0 ) )          &
-                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),           &
-                                              SQRT( 0.25_wp * ( dx**2 + dy**2 )   &
+                      IF ( .NOT. BTEST( wall_flags_total_0(k+1,j-1,i-1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k+1,j+1,i-1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k+1,j-1,i+1), 0 )  .OR.      &
+                           .NOT. BTEST( wall_flags_total_0(k+1,j+1,i+1), 0 ) )          &
+                         l_wall(k,j,i) = MIN( l_wall(k,j,i), l_grid(k),                 &
+                                              SQRT( 0.25_wp * ( dx**2 + dy**2 )         &
                                                     +  ( zw(k) - zu(k) )**2  ) )
 
@@ -1553,5 +1557,5 @@
           DO  j = nysg, nyng
              DO  k = nzb+1, nzt-1
-                IF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 0 ) .AND.  &
+                IF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 0 ) .AND.  &
                      k > k_max_topo )  &
                    k_max_topo = k
@@ -1619,5 +1623,5 @@
 !
 !--                Start search only if (i/j/k) belongs to atmosphere
-                   IF ( BTEST( wall_flags_static_0(k,j,i), 0 )  )  THEN
+                   IF ( BTEST( wall_flags_total_0(k,j,i), 0 )  )  THEN
 !
 !--                   Reset topography within vicinity
@@ -1839,5 +1843,5 @@
 ! ------------
 !> Copy a subarray of size (kb:kt,js:jn,il:ir) centered around grid point
-!> (kp,jp,ip) containing the first bit of wall_flags_static_0 into the array
+!> (kp,jp,ip) containing the first bit of wall_flags_total_0 into the array
 !> 'vicinity'. Only copy first bit as this indicates the presence of topography.
 !------------------------------------------------------------------------------!
@@ -1864,5 +1868,5 @@
              DO  k = kb, kt
                 vicinity(k,j,i) = MERGE( 0, 1,               &
-                       BTEST( wall_flags_static_0(kp+k,jp+j,ip+i), 0 ) )
+                       BTEST( wall_flags_total_0(kp+k,jp+j,ip+i), 0 ) )
              ENDDO
           ENDDO
@@ -2263,5 +2267,5 @@
 !--    value is reduced by 90%.
        !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-       !$ACC PRESENT(e, tend, te_m, wall_flags_static_0) &
+       !$ACC PRESENT(e, tend, te_m, wall_flags_total_0) &
        !$ACC PRESENT(tsc(3:3)) &
        !$ACC PRESENT(e_p)
@@ -2273,5 +2277,5 @@
                                         )                                      &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                 IF ( e_p(k,j,i) < 0.0_wp )  e_p(k,j,i) = 0.1_wp * e(k,j,i)
@@ -2380,5 +2384,5 @@
                                         )                                      &
                                    * MERGE( 1.0_wp, 0.0_wp,                    &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                                       BTEST( wall_flags_total_0(k,j,i), 0 )   &
                                           )
                 IF ( diss_p(k,j,i) < 0.0_wp )                                  &
@@ -2495,5 +2499,5 @@
                                   )                                            &
                                  * MERGE( 1.0_wp, 0.0_wp,                      &
-                                          BTEST( wall_flags_static_0(k,j,i), 0 )      &
+                                    BTEST( wall_flags_total_0(k,j,i), 0 )      &
                                         )
           IF ( e_p(k,j,i) <= 0.0_wp )  e_p(k,j,i) = 0.1_wp * e(k,j,i)
@@ -2562,5 +2566,5 @@
                                         )                                      &
                                         * MERGE( 1.0_wp, 0.0_wp,               &
-                                                BTEST( wall_flags_static_0(k,j,i), 0 )&
+                                          BTEST( wall_flags_total_0(k,j,i), 0 )&
                                                )
        ENDDO
@@ -2657,5 +2661,5 @@
     !$ACC PRIVATE(surf_s, surf_e) &
     !$ACC PRIVATE(dudx(:), dudy(:), dudz(:), dvdx(:), dvdy(:), dvdz(:), dwdx(:), dwdy(:), dwdz(:)) &
-    !$ACC PRESENT(e, u, v, w, diss, dd2zu, ddzw, km, wall_flags_static_0) &
+    !$ACC PRESENT(e, u, v, w, diss, dd2zu, ddzw, km, wall_flags_total_0) &
     !$ACC PRESENT(tend) &
     !$ACC PRESENT(surf_def_h(0:1), surf_def_v(0:3)) &
@@ -2717,5 +2721,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
                    dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
                    dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -2736,5 +2740,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
                    dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
                    dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -2755,5 +2759,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
                    dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
                    dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -2776,5 +2780,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
                    dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
                    dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -2795,5 +2799,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
                    dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
                    dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -2814,5 +2818,5 @@
 !--                -1.0 for right-facing wall, 1.0 for left-facing wall
                    sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                                     BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                              BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
                    dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
                    dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -2889,5 +2893,5 @@
              IF ( def < 0.0_wp )  def = 0.0_wp
 
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),flag_nr) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),flag_nr) )
 
              IF ( .NOT. diss_production )  THEN
@@ -2953,5 +2957,5 @@
 !--                   Compute tendency for TKE-production from shear
                       DO  k = nzb+1, nzt
-                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                          tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                        MERGE( rho_reference, prho(k,j,i),       &
@@ -2963,5 +2967,5 @@
 !--                   RANS mode: Compute tendency for dissipation-rate-production from shear
                       DO  k = nzb+1, nzt
-                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                          tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                        MERGE( rho_reference, prho(k,j,i),       &
@@ -2981,5 +2985,5 @@
              !$ACC PRIVATE(surf_s, surf_e) &
              !$ACC PRIVATE(tmp_flux(nzb+1:nzt)) &
-             !$ACC PRESENT(e, diss, kh, pt, dd2zu, drho_air_zw, wall_flags_static_0) &
+             !$ACC PRESENT(e, diss, kh, pt, dd2zu, drho_air_zw, wall_flags_total_0) &
              !$ACC PRESENT(tend) &
              !$ACC PRESENT(surf_def_h(0:2)) &
@@ -3041,5 +3045,5 @@
                      !$ACC LOOP PRIVATE(k, flag)
                       DO  k = nzb+1, nzt
-                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                          tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                        MERGE( pt_reference, pt(k,j,i),          &
@@ -3051,5 +3055,5 @@
 !--                   RANS mode: Compute tendency for dissipation-rate-production from shear
                       DO  k = nzb+1, nzt
-                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                         flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                          tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                        MERGE( pt_reference, pt(k,j,i),          &
@@ -3256,5 +3260,5 @@
 !--                Compute tendency for TKE-production from shear
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                       tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                     MERGE( vpt_reference, vpt(k,j,i),          &
@@ -3266,5 +3270,5 @@
 !--                RANS mode: Compute tendency for dissipation-rate-production from shear
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                       tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g /   &
                                     MERGE( vpt_reference, vpt(k,j,i),          &
@@ -3401,5 +3405,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
              dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
              dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -3419,5 +3423,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
              dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
              dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -3437,5 +3441,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j-1,i), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j-1,i), flag_nr ) )
              dudy(k) = sign_dir * usvs / ( km_neutral + 1E-10_wp )
              dwdy(k) = sign_dir * wsvs / ( km_neutral + 1E-10_wp )
@@ -3457,5 +3461,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
              dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
              dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -3475,5 +3479,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
              dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
              dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -3493,5 +3497,5 @@
 !--          -1.0 for right-facing wall, 1.0 for left-facing wall
              sign_dir = MERGE( 1.0_wp, -1.0_wp,                          &
-                               BTEST( wall_flags_static_0(k,j,i-1), flag_nr ) )
+                        BTEST( wall_flags_total_0(k,j,i-1), flag_nr ) )
              dvdx(k) = sign_dir * vsus / ( km_neutral + 1E-10_wp )
              dwdx(k) = sign_dir * wsus / ( km_neutral + 1E-10_wp )
@@ -3561,5 +3565,5 @@
        IF ( def < 0.0_wp )  def = 0.0_wp
 
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),flag_nr) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),flag_nr) )
 
        IF ( .NOT. diss_production )  THEN
@@ -3618,5 +3622,5 @@
 !--             Compute tendency for TKE-production from shear
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                    tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                  MERGE( rho_reference, prho(k,j,i),       &
@@ -3628,5 +3632,5 @@
 !--             RANS mode: Compute tendency for dissipation-rate-production from shear
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                    tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                  MERGE( rho_reference, prho(k,j,i),       &
@@ -3687,5 +3691,5 @@
 !--             Compute tendency for TKE-production from shear
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                    tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                  MERGE( pt_reference, pt(k,j,i),          &
@@ -3697,5 +3701,5 @@
 !--             RANS mode: Compute tendency for dissipation-rate-production from shear
                 DO  k = nzb+1, nzt
-                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                   flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                    tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                                  MERGE( pt_reference, pt(k,j,i),          &
@@ -3896,5 +3900,5 @@
 !--          Compute tendency for TKE-production from shear
              DO  k = nzb+1, nzt
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                 tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g / &
                               MERGE( vpt_reference, vpt(k,j,i),          &
@@ -3906,5 +3910,5 @@
 !--          RANS mode: Compute tendency for dissipation-rate-production from shear
              DO  k = nzb+1, nzt
-                flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_static_0(k,j,i),0) )
+                flag = MERGE( 1.0_wp, 0.0_wp, BTEST(wall_flags_total_0(k,j,i),0) )
                 tend(k,j,i) = tend(k,j,i) + flag * tmp_flux(k) * ( g /   &
                               MERGE( vpt_reference, vpt(k,j,i),          &
@@ -3972,5 +3976,5 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j) &
        !$ACC PRIVATE(l, l_stable, dvar_dz) &
-       !$ACC PRESENT(diss, e, var, wall_flags_static_0) &
+       !$ACC PRESENT(diss, e, var, wall_flags_total_0) &
        !$ACC PRESENT(dd2zu, l_grid, l_wall)
        DO  i = nxl, nxr
@@ -4002,5 +4006,5 @@
                 diss(k,j,i) = ( 0.19_wp + 0.74_wp * l / l_wall(k,j,i) )                &
                               * e(k,j,i) * SQRT( e(k,j,i) ) / l                        &
-                              * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                              * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              ENDDO
@@ -4013,5 +4017,5 @@
       !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j) &
       !$ACC PRIVATE(l_stable, duv2_dz2, rif, dvar_dz) &
-      !$ACC PRESENT(diss, e, u, v, var, wall_flags_static_0) &
+      !$ACC PRESENT(diss, e, u, v, var, wall_flags_total_0) &
       !$ACC PRESENT(dd2zu, l_black, l_wall)
        DO  i = nxl, nxr
@@ -4060,5 +4064,5 @@
 
                 diss(k,j,i) = c_0**3 * e(k,j,i) * SQRT( e(k,j,i) ) / l_stable(k)     &
-                            * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                            * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              ENDDO
@@ -4072,5 +4076,5 @@
 
     !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k) &
-    !$ACC PRESENT(diss, e, km, tend, wall_flags_static_0) &
+    !$ACC PRESENT(diss, e, km, tend, wall_flags_total_0) &
     !$ACC PRESENT(ddzu, ddzw, rho_air_zw, drho_air)
     DO  i = nxl, nxr
@@ -4095,5 +4099,5 @@
                                          ) * dsig_e                                   &
                                            * MERGE( 1.0_wp, 0.0_wp,                   &
-                                                    BTEST( wall_flags_static_0(k,j,i), 0 ) ) &
+                                             BTEST( wall_flags_total_0(k,j,i), 0 ) )  &
                           - diss(k,j,i)
 
@@ -4201,5 +4205,5 @@
           diss(k,j,i) = ( 0.19_wp + 0.74_wp * l / l_wall(k,j,i) )              &
                         * e(k,j,i) * SQRT( e(k,j,i) ) / l                      &
-                        * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                        * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
        ENDDO
 
@@ -4245,5 +4249,5 @@
        DO  k = nzb+1, nzt
           diss(k,j,i) = c_0**3 * e(k,j,i) * SQRT( e(k,j,i) ) / l_stable(k)     &
-                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
        ENDDO
 
@@ -4274,5 +4278,5 @@
                                    ) * dsig_e                                  &
                                      * MERGE( 1.0_wp, 0.0_wp,                  &
-                                              BTEST( wall_flags_static_0(k,j,i), 0 ) )&
+                                        BTEST( wall_flags_total_0(k,j,i), 0 ) )&
                                  - diss(k,j,i)
 
@@ -4337,5 +4341,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              tend(k,j,i) = tend(k,j,i) +                                       &
@@ -4393,5 +4397,5 @@
 !
 !--    Predetermine flag to mask topography
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
 !
@@ -4454,5 +4458,5 @@
              DO  k = nzb+1, nzt
                 e(k,j,i) = MAX( e(k,j,i), e_min ) *                            &
-                        MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                        MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
              ENDDO
           ENDDO
@@ -4665,5 +4669,5 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j) &
        !$ACC PRIVATE(dvar_dz, l, l_stable, l_v) &
-       !$ACC PRESENT(wall_flags_static_0, var, dd2zu, e, l_wall, l_grid, rmask) &
+       !$ACC PRESENT(wall_flags_total_0, var, dd2zu, e, l_wall, l_grid, rmask) &
        !$ACC PRESENT(kh, km, sums_l_l)
        DO  i = nxlg, nxrg
@@ -4697,5 +4701,5 @@
 
                 l_v(k) = MIN( l_wall(k,j,i), l_stable(k) )                      &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 l = l_v(k)
 !
@@ -4722,5 +4726,5 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j) &
        !$ACC PRIVATE(dvar_dz, duv2_dz2, l_stable, l_v, rif) &
-       !$ACC PRESENT(wall_flags_static_0, var, dd2zu, e, u, v, l_wall, l_black, rmask) &
+       !$ACC PRESENT(wall_flags_total_0, var, dd2zu, e, u, v, l_wall, l_black, rmask) &
        !$ACC PRESENT(kh, km, sums_l_l)
        DO  i = nxlg, nxrg
@@ -4770,5 +4774,5 @@
              !DIR$ IVDEP
              DO  k = nzb+1, nzt
-                l_v(k)    = l_stable(k) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                l_v(k)    = l_stable(k) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                 km(k,j,i) = c_0 * l_v(k) * SQRT( e(k,j,i) )
                 kh(k,j,i) = km(k,j,i) / prandtl_number
@@ -4791,5 +4795,5 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j) &
        !$ACC PRIVATE(l_v) &
-       !$ACC PRESENT(wall_flags_static_0, e, diss, rmask) &
+       !$ACC PRESENT(wall_flags_total_0, e, diss, rmask) &
        !$ACC PRESENT(kh, km, sums_l_l)
        DO  i = nxlg, nxrg
@@ -4802,5 +4806,5 @@
 
                 l_v(k) = c_0**3 * e(k,j,i) * SQRT(e(k,j,i)) / ( diss(k,j,i) + 1.0E-30_wp ) &
-                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                       * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
                 km(k,j,i) = c_0 * SQRT( e(k,j,i) ) * l_v(k)
@@ -4939,5 +4943,5 @@
           DO  k = nzb+1, nzt
 
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
 !
Index: /palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/urban_surface_mod.f90	(revision 4346)
@@ -28,4 +28,8 @@
 ! -----------------
 ! $Id$
+! Removed wall_flags_static_0 from USE statements as it's not used within
+! the module
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -261,5 +265,5 @@
     USE indices,                                                               &
         ONLY:  nx, ny, nnx, nny, nnz, nxl, nxlg, nxr, nxrg, nyn, nyng, nys,    &
-               nysg, nzb, nzt, nbgp, topo_top_ind, wall_flags_static_0
+               nysg, nzb, nzt, nbgp, topo_top_ind
 
     USE, INTRINSIC :: iso_c_binding 
Index: /palm/trunk/SOURCE/user_module.f90
===================================================================
--- /palm/trunk/SOURCE/user_module.f90	(revision 4345)
+++ /palm/trunk/SOURCE/user_module.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -1053,5 +1057,5 @@
 !                                     * rmask(j,i,sr)                          &
 !                                     * MERGE( 1.0_wp, 0.0_wp,                 &
-!                                              BTEST( wall_flags_static_0(k,j,i), 0 ) )
+!                                              BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !!
 !!--             Further profiles can be defined and calculated by increasing
Index: /palm/trunk/SOURCE/vdi_internal_controls.f90
===================================================================
--- /palm/trunk/SOURCE/vdi_internal_controls.f90	(revision 4345)
+++ /palm/trunk/SOURCE/vdi_internal_controls.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -83,5 +87,5 @@
                nzb,                         &
                nzt,                         &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -205,5 +209,5 @@
 !
 !--    If the grid point lies in a building, a new point is defined
-       DO WHILE ( .NOT. BTEST( wall_flags_static_0(cgp_k,cgp_j,cgp_i), 1 ) )
+       DO WHILE ( .NOT. BTEST( wall_flags_total_0(cgp_k,cgp_j,cgp_i), 1 ) )
           CALL RANDOM_NUMBER( random )
           cgp_k = cgp_k + FLOOR( ( nzt - cgp_k ) * random )   !< Random number upon cgp_k
@@ -454,5 +458,5 @@
        DO  j = nys, nyn
           DO  k = nzb+1, nzt+1
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), quant_type ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), quant_type ) )
              quant_av_k_l(k) = quant_av_k_l(k) + quant(k,j,i) * flag
              count_2d_l(k)   = count_2d_l(k) + INT( flag, KIND=iwp )
@@ -482,5 +486,5 @@
                                 + ( quant(k,j,i) - quant_av_k(k) )**2 &
                                 * MERGE( 1.0_wp, 0.0_wp,              &
-                                         BTEST( wall_flags_static_0(k,j,i), quant_type ) )
+                                         BTEST( wall_flags_total_0(k,j,i), quant_type ) )
           ENDDO
        ENDDO
@@ -722,5 +726,5 @@
       DO  j = nys, nyn
          DO  k = nzb, nzt+1
-            flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), quant_type ) )
+            flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), quant_type ) )
             quant_av_l = quant_av_l + quant(k,j,i) * flag
             average_count_l = average_count_l + INT( flag, KIND=iwp )
@@ -774,5 +778,5 @@
                               + u(k,j,i) * dzw(k) * dy                  &
                               * MERGE( 1.0_wp, 0.0_wp,                  &
-                                       BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                 BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                      )
           ENDDO
@@ -788,5 +792,5 @@
                               - u(k,j,i) * dzw(k) * dy                  &
                               * MERGE( 1.0_wp, 0.0_wp,                  &
-                                       BTEST( wall_flags_static_0(k,j,i), 1 )  &
+                                 BTEST( wall_flags_total_0(k,j,i), 1 )  &
                                      )
           ENDDO
@@ -803,5 +807,5 @@
                               + v(k,j,i) * dzw(k) * dx                  &
                               * MERGE( 1.0_wp, 0.0_wp,                  &
-                                       BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                 BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                      )
           ENDDO
@@ -817,5 +821,5 @@
                               - v(k,j,i) * dzw(k) * dx                  &
                               * MERGE( 1.0_wp, 0.0_wp,                  &
-                                       BTEST( wall_flags_static_0(k,j,i), 2 )  &
+                                 BTEST( wall_flags_total_0(k,j,i), 2 )  &
                                      )
           ENDDO
Index: /palm/trunk/SOURCE/virtual_measurement_mod.f90
===================================================================
--- /palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/virtual_measurement_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -124,5 +128,6 @@
 
     USE indices,                                                               &
-        ONLY:  nzb, nzt, nxl, nxr, nys, nyn, nx, ny, topo_top_ind, wall_flags_static_0
+        ONLY:  nzb, nzt, nxl, nxr, nys, nyn, nx, ny, topo_top_ind,             &
+               wall_flags_total_0
 
     USE kinds
@@ -783,8 +788,8 @@
                       DO  j = js-1, js+1
                          DO  k = kl, ku
-                            meas_flag(k,j,i) = MERGE(                          &
-                                             IBSET( meas_flag(k,j,i), 0 ),     &
-                                             0,                                &
-                                             BTEST( wall_flags_static_0(k,j,i), 0 )   &
+                            meas_flag(k,j,i) = MERGE(                              &
+                                             IBSET( meas_flag(k,j,i), 0 ),         &
+                                             0,                                    &
+                                             BTEST( wall_flags_total_0(k,j,i), 0 ) &
                                                     )
                          ENDDO
Index: /palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 4345)
+++ /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 4346)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4343 2019-12-17 12:26:12Z oliver.maas
 ! replaced <= by < in line 1464 to ensure that ialpha will not be 
 ! greater than dlen
@@ -118,5 +122,5 @@
     USE indices,                                                               &
         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz,   &
-               nzb, nzt, wall_flags_static_0
+               nzb, nzt, wall_flags_total_0
 
     USE kinds
@@ -2228,5 +2232,5 @@
 !
 !--                         Predetermine flag to mask topography
-                            flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                            flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 1 ) )
       
 !
@@ -2702,5 +2706,5 @@
                                   - tend_nac_x - tend_tow_x )                  &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 1 ) )
                    ENDDO
                 ENDDO
@@ -2722,5 +2726,5 @@
                                   - tend_nac_y - tend_tow_y )                  &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 2 ) )
                    ENDDO
                 ENDDO
@@ -2737,5 +2741,5 @@
                       tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i)            &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 3 ) )
                    ENDDO
                 ENDDO
@@ -2788,5 +2792,5 @@
                             - tend_nac_x - tend_tow_x )                        &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                            BTEST( wall_flags_static_0(k,j,i), 1 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 1 ) )
              ENDDO
           ENDIF
@@ -2804,5 +2808,5 @@
                             - tend_nac_y - tend_tow_y )                        &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 2 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 2 ) )
                 ENDDO
           ENDIF
@@ -2815,5 +2819,5 @@
                 tend(k,j,i) = tend(k,j,i) - rot_tend_z(k,j,i)                  &
                                       * MERGE( 1.0_wp, 0.0_wp,                 &
-                                               BTEST( wall_flags_static_0(k,j,i), 3 ) )
+                                        BTEST( wall_flags_total_0(k,j,i), 3 ) )
              ENDDO
           ENDIF
