Index: /palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- /palm/trunk/SOURCE/advec_ws.f90	(revision 4108)
+++ /palm/trunk/SOURCE/advec_ws.f90	(revision 4109)
@@ -20,5 +20,21 @@
 ! Current revisions:
 ! ------------------
-! 
+! - Separate initialization of advection flags for momentum and scalars. In this
+!   context, resort the bits and do some minor formatting. 
+! - Make flag initialization for scalars more flexible, introduce an 
+!   arguemnt list to indicate non-cyclic boundaries (required for decycled 
+!   scalars such as chemical species or aerosols)
+! - Introduce extended 'degradation zones', where horizontal advection of 
+!   passive scalars is discretized by first-order scheme at all grid points 
+!   that in the vicinity of buildings (<= 3 grid points). Even though no 
+!   building is within the numerical stencil, first-order scheme is used. 
+!   At fourth and fifth grid point the order of the horizontal advection scheme
+!   is successively upgraded.
+!   These extended degradation zones are used to avoid stationary numerical 
+!   oscillations, which are responsible for high concentration maxima that may
+!   appear under shear-free stable conditions. 
+! - Change interface for scalar advection routine. 
+! - Bugfix, avoid uninitialized value sk_num in vector version of scalar
+!   advection
 ! 
 ! Former revisions:
@@ -106,5 +122,5 @@
 ! Change in file header (GPL part)
 ! Implement advection for TKE-dissipation in case of RANS-TKE-e closure (TG)
-! Allocate advc_flags_1/2 within ws_init_flags instead of init_grid
+! Allocate advc_flags_m/2 within ws_init_flags instead of init_grid
 ! Change argument list for exchange_horiz_2d_int (MS)
 ! 
@@ -120,8 +136,8 @@
 ! 
 ! 2232 2017-05-30 17:47:52Z suehring
-! Rename wall_flags_0 and wall_flags_00 into advc_flags_1 and advc_flags_2, 
+! Rename wall_flags_0 and wall_flags_00 into advc_flags_m and advc_flags_m, 
 ! respectively.
-! Set advc_flags_1/2 on basis of wall_flags_0/00 instead of nzb_s/u/v/w_inner.
-! Setting advc_flags_1/2 also for downward-facing walls
+! Set advc_flags_m/2 on basis of wall_flags_0/00 instead of nzb_s/u/v/w_inner.
+! Setting advc_flags_m/2 also for downward-facing walls
 ! 
 ! 2200 2017-04-11 11:37:51Z suehring
@@ -246,5 +262,5 @@
 ! vector version.
 ! Degradation of the applied order of scheme is now steered by multiplying with
-! Integer advc_flags_1. 2nd order scheme, WS3 and WS5 are calculated on each
+! Integer advc_flags_m. 2nd order scheme, WS3 and WS5 are calculated on each
 ! grid point and mulitplied with the appropriate flag.
 ! 2nd order numerical dissipation term changed. Now the appropriate 2nd order
@@ -267,4 +283,9 @@
 !
 ! 411 2009-12-11 12:31:43 Z suehring
+!
+!
+!
+! @author Matthias Suehring
+!
 !
 ! Description:
@@ -282,4 +303,6 @@
 !>
 !> @todo Implement monotonic flux limiter also for vector version.
+!> @todo Move 3d arrays advc_flag, advc_flags_m from modules to advec_ws
+!> @todo Move arrays flux_l_x from modules to advec_ws
 !------------------------------------------------------------------------------!
  MODULE advec_ws
@@ -299,15 +322,47 @@
 
     USE control_parameters,                                                    &
-        ONLY:  humidity, loop_optimization, passive_scalar,                    &
-               rans_tke_e, ws_scheme_mom, ws_scheme_sca,                       &
-               momentum_advec, scalar_advec,                                   &
-               bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
-               bc_dirichlet_s, bc_radiation_l, bc_radiation_n,                 &
-               bc_radiation_r, bc_radiation_s, intermediate_timestep_count,    &
-               u_gtrans, v_gtrans, dt_3d
+        ONLY:  air_chemistry,                                                  &
+               bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &
+               humidity,                                                       &
+               loop_optimization,                                              &
+               passive_scalar,                                                 &
+               rans_tke_e,                                                     &
+               momentum_advec,                                                 &
+               salsa,                                                          &
+               scalar_advec,                                                   &
+               intermediate_timestep_count,                                    &
+               u_gtrans,                                                       &
+               v_gtrans,                                                       &
+               ws_scheme_mom,                                                  &
+               ws_scheme_sca,                                                  &
+               dt_3d
 
     USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
-               nzb, nzb_max, nzt, advc_flags_1, advc_flags_2, wall_flags_0
+        ONLY:  advc_flags_m,                                                   &
+               advc_flags_s,                                                   &
+               nbgp,                                                           &
+               nx,                                                             &
+               nxl,                                                            &
+               nxlg,                                                           &
+               nxlu,                                                           &
+               nxr,                                                            & 
+               nxrg,                                                           & 
+               ny,                                                             &
+               nyn,                                                            & 
+               nyng,                                                           & 
+               nys,                                                            &
+               nysg,                                                           &
+               nysv,                                                           &
+               nzb,                                                            &
+               nzb_max,                                                        &
+               nzt,                                                            &
+               wall_flags_0
 
     USE grid_variables,                                                        &
@@ -338,13 +393,17 @@
     PRIVATE
     PUBLIC   advec_s_ws, advec_u_ws, advec_v_ws, advec_w_ws, ws_init,          &
-             ws_init_flags, ws_statistics
+             ws_init_flags_momentum, ws_init_flags_scalar, ws_statistics
 
     INTERFACE ws_init
        MODULE PROCEDURE ws_init
-    END INTERFACE ws_init
-
-    INTERFACE ws_init_flags
-       MODULE PROCEDURE ws_init_flags
-    END INTERFACE ws_init_flags
+    END INTERFACE ws_init         
+             
+    INTERFACE ws_init_flags_momentum
+       MODULE PROCEDURE ws_init_flags_momentum
+    END INTERFACE ws_init_flags_momentum
+    
+    INTERFACE ws_init_flags_scalar
+       MODULE PROCEDURE ws_init_flags_scalar
+    END INTERFACE ws_init_flags_scalar
 
     INTERFACE ws_statistics
@@ -490,8 +549,9 @@
 ! Description:
 ! ------------
-!> Initialization of flags for WS-scheme used to degrade the order of the scheme
-!> near walls.
+!> Initialization of flags to control the order of the advection scheme near
+!> solid walls and non-cyclic inflow boundaries, where the order is sucessively
+!> degraded. 
 !------------------------------------------------------------------------------!
-    SUBROUTINE ws_init_flags
+    SUBROUTINE ws_init_flags_momentum
 
 
@@ -505,583 +565,743 @@
        LOGICAL      ::  flag_set !< steering variable for advection flags
    
-       ALLOCATE( advc_flags_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                  &
-                 advc_flags_2(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-       advc_flags_1 = 0
-       advc_flags_2 = 0
-       IF ( scalar_advec == 'ws-scheme' )  THEN
-!
-!--       Set flags to steer the degradation of the advection scheme in advec_ws
-!--       near topography, inflow- and outflow boundaries as well as bottom and
-!--       top of model domain. advc_flags_1 remains zero for all non-prognostic
-!--       grid points.
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-!
-!--                scalar - x-direction
-!--                WS1 (0), WS3 (1), WS5 (2)
-                   IF ( ( .NOT. BTEST(wall_flags_0(k,j,i+1),0)                 &
-                    .OR.  .NOT. BTEST(wall_flags_0(k,j,i+2),0)                 &   
-                    .OR.  .NOT. BTEST(wall_flags_0(k,j,i-1),0) )               &
-                      .OR.  ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                            .AND.  i == nxl   )                                &
-                      .OR.  ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                            .AND.  i == nxr   ) )                              &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 0 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+3),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i+1),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i+2),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i-1),0)             &
-                            )                       .OR.                       &
-                            ( .NOT. BTEST(wall_flags_0(k,j,i-2),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i+1),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i+2),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j,i-1),0)             &
-                            )                                                  &
-                                                    .OR.                       &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr-1 )    .OR.                       &
-                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                              .AND. i == nxlu  ) )                             & ! why not nxl+1
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 1 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j,i+1),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j,i+2),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j,i+3),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j,i-1),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j,i-2),0) )                   &
-                   THEN 
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 2 )
-                   ENDIF
-!
-!--                scalar - y-direction
-!--                WS1 (3), WS3 (4), WS5 (5)
-                   IF ( ( .NOT. BTEST(wall_flags_0(k,j+1,i),0)                 &
-                    .OR.  .NOT. BTEST(wall_flags_0(k,j+2,i),0)                 &   
-                    .OR.  .NOT. BTEST(wall_flags_0(k,j-1,i),0))                &
-                      .OR.  ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                            .AND.  j == nys   )                                &
-                      .OR.  ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                            .AND.  j == nyn   ) )                              &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 3 )
-!
-!--                WS3
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+3,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j+1,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j+2,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j-1,i),0)             &
-                            )                       .OR.                       &
-                            ( .NOT. BTEST(wall_flags_0(k,j-2,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j+1,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j+2,i),0)             &
-                       .AND.        BTEST(wall_flags_0(k,j-1,i),0)             &
-                            )                                                  &
-                                                    .OR.                       &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j == nysv  )    .OR.                       & ! why not nys+1
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn-1 ) )                             &          
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 4 )
-!
-!--                WS5
-                   ELSEIF ( BTEST(wall_flags_0(k,j+1,i),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j+2,i),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j+3,i),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j-1,i),0)                     &
-                      .AND. BTEST(wall_flags_0(k,j-2,i),0) )                   &
-                   THEN 
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 5 )
-                   ENDIF
-! 
-!--                scalar - z-direction
-!--                WS1 (6), WS3 (7), WS5 (8)
-                   IF ( k == nzb+1 )  THEN
-                      k_mm = nzb
-                   ELSE 
-                      k_mm = k - 2
-                   ENDIF
-                   IF ( k > nzt-1 )  THEN
-                      k_pp = nzt+1
-                   ELSE 
-                      k_pp = k + 2
-                   ENDIF
-                   IF ( k > nzt-2 )  THEN
-                      k_ppp = nzt+1
-                   ELSE 
-                      k_ppp = k + 3
-                   ENDIF
-
-                   flag_set = .FALSE.
-                   IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),0)  .AND.            &
-                              BTEST(wall_flags_0(k,j,i),0)    .OR.             &
-                        .NOT. BTEST(wall_flags_0(k_pp,j,i),0) .AND.            &                              
-                              BTEST(wall_flags_0(k,j,i),0)    .OR.             &
-                        k == nzt )                                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 6 )
-                      flag_set = .TRUE.
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),0)    .OR.    &
-                              .NOT. BTEST(wall_flags_0(k_ppp,j,i),0) ) .AND.   & 
-                                  BTEST(wall_flags_0(k-1,j,i),0)  .AND.        &
-                                  BTEST(wall_flags_0(k,j,i),0)    .AND.        &
-                                  BTEST(wall_flags_0(k+1,j,i),0)  .AND.        &
-                                  BTEST(wall_flags_0(k_pp,j,i),0) .OR.         &    
-                            k == nzt - 1 )                                     &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 7 )
-                      flag_set = .TRUE.
-                   ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),0)                    &
-                     .AND.  BTEST(wall_flags_0(k-1,j,i),0)                     &
-                     .AND.  BTEST(wall_flags_0(k,j,i),0)                       &
-                     .AND.  BTEST(wall_flags_0(k+1,j,i),0)                     &
-                     .AND.  BTEST(wall_flags_0(k_pp,j,i),0)                    &
-                     .AND.  BTEST(wall_flags_0(k_ppp,j,i),0)                   &
-                     .AND. .NOT. flag_set )                                    &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 8 )
-                   ENDIF
-
-                ENDDO
+       advc_flags_m = 0
+
+!
+!--    Set advc_flags_m to steer the degradation of the advection scheme in advec_ws
+!--    near topography, inflow- and outflow boundaries as well as bottom and
+!--    top of model domain. advc_flags_m remains zero for all non-prognostic
+!--    grid points.
+!--    u-component
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt
+!  
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+!--             near vertical walls. 
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 0 )
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 3 )
+!
+!--             u component - x-direction
+!--             WS1 (0), WS3 (1), WS5 (2)
+                IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),1)  .OR.                &
+                         ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
+                           .AND. i <= nxlu  )    .OR.                          &
+                         ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
+                           .AND. i == nxr   ) )                                &
+                THEN                                                           
+                    advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 0 )      
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),1)  .AND.         &
+                                 BTEST(wall_flags_0(k,j,i+1),1)  .OR.          &
+                           .NOT. BTEST(wall_flags_0(k,j,i-1),1) )              &
+                                                     .OR.                      &
+                         ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
+                           .AND. i == nxr-1 )    .OR.                          &
+                         ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
+                           .AND. i == nxlu+1) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 1 )       
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 0 )       
+                ELSEIF ( BTEST(wall_flags_0(k,j,i+1),1)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i+2),1)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i-1),1) )                      &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 2 )       
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 0 )       
+                ENDIF                                                          
+!                                                                              
+!--             u component - y-direction                                      
+!--             WS1 (3), WS3 (4), WS5 (5)                                      
+                IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),1)   .OR.               &
+                         ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
+                           .AND. j == nys   )    .OR.                          &
+                         ( ( bc_dirichlet_n .OR. bc_radiation_n )              &
+                           .AND. j == nyn   ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 3 )       
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),1)  .AND.         &
+                                 BTEST(wall_flags_0(k,j+1,i),1)  .OR.          &
+                           .NOT. BTEST(wall_flags_0(k,j-1,i),1) )              &
+                                                     .OR.                      &
+                         ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
+                           .AND. j == nysv  )    .OR.                          &
+                         ( ( bc_dirichlet_n .OR. bc_radiation_n )              &
+                           .AND. j == nyn-1 ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 4 )       
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 3 )       
+                ELSEIF ( BTEST(wall_flags_0(k,j+1,i),1)  .AND.                 &
+                         BTEST(wall_flags_0(k,j+2,i),1)  .AND.                 &
+                         BTEST(wall_flags_0(k,j-1,i),1) )                      &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 5 )       
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 3 )       
+                ENDIF                                                          
+!                                                                              
+!--             u component - z-direction                                      
+!--             WS1 (6), WS3 (7), WS5 (8)                                      
+                IF ( k == nzb+1 )  THEN                                        
+                   k_mm = nzb                                                  
+                ELSE                                                           
+                   k_mm = k - 2                                                
+                ENDIF                                                          
+                IF ( k > nzt-1 )  THEN                                         
+                   k_pp = nzt+1                                                
+                ELSE                                                           
+                   k_pp = k + 2                                                
+                ENDIF                                                          
+                IF ( k > nzt-2 )  THEN                                         
+                   k_ppp = nzt+1                                               
+                ELSE                                                           
+                   k_ppp = k + 3                                               
+                ENDIF                                                          
+                                                                               
+                flag_set = .FALSE.                                             
+                IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),1)  .AND.               &
+                           BTEST(wall_flags_0(k,j,i),1)    .OR.                &
+                     .NOT. BTEST(wall_flags_0(k_pp,j,i),1) .AND.               &                              
+                           BTEST(wall_flags_0(k,j,i),1)    .OR.                &
+                     k == nzt )                                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 6 )       
+                   flag_set = .TRUE.                                           
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),1)    .OR.       &
+                           .NOT. BTEST(wall_flags_0(k_ppp,j,i),1) ) .AND.      & 
+                               BTEST(wall_flags_0(k-1,j,i),1)  .AND.           &
+                               BTEST(wall_flags_0(k,j,i),1)    .AND.           &
+                               BTEST(wall_flags_0(k+1,j,i),1)  .AND.           &
+                               BTEST(wall_flags_0(k_pp,j,i),1) .OR.            &
+                               k == nzt - 1 )                                  &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 7 )       
+                   flag_set = .TRUE.                                           
+                ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),1)  .AND.                &
+                         BTEST(wall_flags_0(k-1,j,i),1)   .AND.                &
+                         BTEST(wall_flags_0(k,j,i),1)     .AND.                &
+                         BTEST(wall_flags_0(k+1,j,i),1)   .AND.                &
+                         BTEST(wall_flags_0(k_pp,j,i),1)  .AND.                &
+                         BTEST(wall_flags_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 )
+                ENDIF
+
              ENDDO
           ENDDO
-       ENDIF
-
-       IF ( momentum_advec == 'ws-scheme' )  THEN
-!
-!--       Set advc_flags_1 to steer the degradation of the advection scheme in advec_ws
-!--       near topography, inflow- and outflow boundaries as well as bottom and
-!--       top of model domain. advc_flags_1 remains zero for all non-prognostic
-!--       grid points.
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-!  
-!--                At first, set flags to WS1. 
-!--                Since fluxes are swapped in advec_ws.f90, this is necessary to 
-!--                in order to handle the left/south flux.
-!--                near vertical walls. 
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 9 )
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 12 )
-!
-!--                u component - x-direction
-!--                WS1 (9), WS3 (10), WS5 (11)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),1)  .OR.             &
-                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                              .AND. i <= nxlu  )    .OR.                       &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr   ) )                             &
-                   THEN
-                       advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 9 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),1)  .AND.      &
-                                    BTEST(wall_flags_0(k,j,i+1),1)  .OR.       &
-                              .NOT. BTEST(wall_flags_0(k,j,i-1),1) )           &
-                                                        .OR.                   &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr-1 )    .OR.                       &
-                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                              .AND. i == nxlu+1) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 10 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 9 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j,i+1),1)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i+2),1)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i-1),1) )                   &
-                   THEN    
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 11 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 9 )
-                   ENDIF
-!
-!--                u component - y-direction
-!--                WS1 (12), WS3 (13), WS5 (14)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),1)   .OR.            &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j == nys   )    .OR.                       &
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn   ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 12 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),1)  .AND.      &
-                                    BTEST(wall_flags_0(k,j+1,i),1)  .OR.       &
-                              .NOT. BTEST(wall_flags_0(k,j-1,i),1) )           &
-                                                        .OR.                   &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j == nysv  )    .OR.                       &
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn-1 ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 13 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 12 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j+1,i),1)  .AND.              &
-                            BTEST(wall_flags_0(k,j+2,i),1)  .AND.              &
-                            BTEST(wall_flags_0(k,j-1,i),1) )                   &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 14 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 12 )
-                   ENDIF
-!
-!--                u component - z-direction
-!--                WS1 (15), WS3 (16), WS5 (17)
-                   IF ( k == nzb+1 )  THEN
-                      k_mm = nzb
-                   ELSE 
-                      k_mm = k - 2
-                   ENDIF
-                   IF ( k > nzt-1 )  THEN
-                      k_pp = nzt+1
-                   ELSE 
-                      k_pp = k + 2
-                   ENDIF
-                   IF ( k > nzt-2 )  THEN
-                      k_ppp = nzt+1
-                   ELSE 
-                      k_ppp = k + 3
-                   ENDIF                   
-
-                   flag_set = .FALSE.
-                   IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),1)  .AND.            &
-                              BTEST(wall_flags_0(k,j,i),1)    .OR.             &
-                        .NOT. BTEST(wall_flags_0(k_pp,j,i),1) .AND.            &                              
-                              BTEST(wall_flags_0(k,j,i),1)    .OR.             &
-                        k == nzt )                                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 15 )
-                      flag_set = .TRUE.                      
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),1)    .OR.    &
-                              .NOT. BTEST(wall_flags_0(k_ppp,j,i),1) ) .AND.   & 
-                                  BTEST(wall_flags_0(k-1,j,i),1)  .AND.        &
-                                  BTEST(wall_flags_0(k,j,i),1)    .AND.        &
-                                  BTEST(wall_flags_0(k+1,j,i),1)  .AND.        &
-                                  BTEST(wall_flags_0(k_pp,j,i),1) .OR.         &
-                                  k == nzt - 1 )                               &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 16 )
-                      flag_set = .TRUE.
-                   ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),1)  .AND.             &
-                            BTEST(wall_flags_0(k-1,j,i),1)   .AND.             &
-                            BTEST(wall_flags_0(k,j,i),1)     .AND.             &
-                            BTEST(wall_flags_0(k+1,j,i),1)   .AND.             &
-                            BTEST(wall_flags_0(k_pp,j,i),1)  .AND.             &
-                            BTEST(wall_flags_0(k_ppp,j,i),1) .AND.             &
-                            .NOT. flag_set )                                   &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 17 )
-                   ENDIF
-
-                ENDDO
+       ENDDO
+!
+!--    v-component
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt
+!
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 9  )
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 12 )
+!
+!--             v component - x-direction
+!--             WS1 (9), WS3 (10), WS5 (11)
+                IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),2)  .OR.                &
+                         ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
+                           .AND. i == nxl   )    .OR.                          &
+                         ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
+                           .AND. i == nxr   ) )                                &
+               THEN                                                            
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 9 )       
+!                                                                              
+!--             WS3                                                            
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),2)   .AND.        &
+                                 BTEST(wall_flags_0(k,j,i+1),2) ) .OR.         &
+                           .NOT. BTEST(wall_flags_0(k,j,i-1),2)                &
+                                                 .OR.                          &
+                         ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
+                           .AND. i == nxr-1 )    .OR.                          &
+                         ( ( bc_dirichlet_l .OR. bc_radiation_l )              &
+                           .AND. i == nxlu  ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 10 )      
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 9 )       
+                ELSEIF ( BTEST(wall_flags_0(k,j,i+1),2)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i+2),2)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i-1),2) )                      &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 11 )      
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 9 )       
+                ENDIF                                                          
+!                                                                              
+!--             v component - y-direction                                      
+!--             WS1 (12), WS3 (13), WS5 (14)                                   
+                IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),2) .OR.                 &
+                         ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
+                           .AND. j <= nysv  )    .OR.                          &
+                         ( ( bc_dirichlet_n .OR. bc_radiation_n )              &
+                           .AND. j == nyn   ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 12 )      
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),2)  .AND.         &
+                                 BTEST(wall_flags_0(k,j+1,i),2)  .OR.          &
+                           .NOT. BTEST(wall_flags_0(k,j-1,i),2) )              &
+                                                     .OR.                      &
+                         ( (  bc_dirichlet_s .OR. bc_radiation_s )             &
+                           .AND. j == nysv+1)    .OR.                          &
+                         ( (  bc_dirichlet_n .OR. bc_radiation_n )             &
+                           .AND. j == nyn-1 ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 13 )      
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 12 )      
+                ELSEIF ( BTEST(wall_flags_0(k,j+1,i),2)  .AND.                 &
+                         BTEST(wall_flags_0(k,j+2,i),2)  .AND.                 &
+                         BTEST(wall_flags_0(k,j-1,i),2) )                      & 
+                THEN
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 14 )
+!
+!--                Clear flag for WS1
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 12 )
+                ENDIF
+!
+!--             v component - z-direction
+!--             WS1 (15), WS3 (16), WS5 (17)
+                IF ( k == nzb+1 )  THEN
+                   k_mm = nzb
+                ELSE 
+                   k_mm = k - 2
+                ENDIF
+                IF ( k > nzt-1 )  THEN
+                   k_pp = nzt+1
+                ELSE 
+                   k_pp = k + 2
+                ENDIF
+                IF ( k > nzt-2 )  THEN
+                   k_ppp = nzt+1
+                ELSE 
+                   k_ppp = k + 3
+                ENDIF  
+                
+                flag_set = .FALSE.
+                IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),2)  .AND.               &
+                           BTEST(wall_flags_0(k,j,i),2)    .OR.                &
+                     .NOT. BTEST(wall_flags_0(k_pp,j,i),2) .AND.               &                              
+                           BTEST(wall_flags_0(k,j,i),2)    .OR.                &
+                     k == nzt )                                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 15 )      
+                   flag_set = .TRUE.                                           
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),2)    .OR.       &
+                           .NOT. BTEST(wall_flags_0(k_ppp,j,i),2) ) .AND.      & 
+                               BTEST(wall_flags_0(k-1,j,i),2)  .AND.           &
+                               BTEST(wall_flags_0(k,j,i),2)    .AND.           &
+                               BTEST(wall_flags_0(k+1,j,i),2)  .AND.           &
+                               BTEST(wall_flags_0(k_pp,j,i),2)  .OR.           &
+                               k == nzt - 1 )                                  &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 16 )      
+                   flag_set = .TRUE.                                           
+                ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),2)  .AND.                &
+                         BTEST(wall_flags_0(k-1,j,i),2)   .AND.                &
+                         BTEST(wall_flags_0(k,j,i),2)     .AND.                &
+                         BTEST(wall_flags_0(k+1,j,i),2)   .AND.                &
+                         BTEST(wall_flags_0(k_pp,j,i),2)  .AND.                &
+                         BTEST(wall_flags_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 )
+                ENDIF
+
              ENDDO
           ENDDO
-
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-!
-!--                At first, set flags to WS1. 
-!--                Since fluxes are swapped in advec_ws.f90, this is necessary to 
-!--                in order to handle the left/south flux.
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 18 )
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 21 )
-!
-!--                v component - x-direction
-!--                WS1 (18), WS3 (19), WS5 (20)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),2)  .OR.             &
-                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                              .AND. i == nxl   )    .OR.                       &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr   ) )                             &
-                  THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 18 )
-!
-!--                WS3
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),2)   .AND.     &
-                                    BTEST(wall_flags_0(k,j,i+1),2) ) .OR.      &
-                              .NOT. BTEST(wall_flags_0(k,j,i-1),2)             &
-                                                    .OR.                       &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr-1 )    .OR.                       &
-                            ( ( bc_dirichlet_l .OR. bc_radiation_l )           &
-                              .AND. i == nxlu  ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 19 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 18 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j,i+1),2)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i+2),2)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i-1),2) )                   &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 20 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 18 )
-                   ENDIF
-!
-!--                v component - y-direction
-!--                WS1 (21), WS3 (22), WS5 (23)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),2) .OR.              &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j <= nysv  )    .OR.                       &
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn   ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 21 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),2)  .AND.      &
-                                    BTEST(wall_flags_0(k,j+1,i),2)  .OR.       &
-                              .NOT. BTEST(wall_flags_0(k,j-1,i),2) )           &
-                                                        .OR.                   &
-                            ( (  bc_dirichlet_s .OR. bc_radiation_s )          &
-                              .AND. j == nysv+1)    .OR.                       &
-                            ( (  bc_dirichlet_n .OR. bc_radiation_n )          &
-                              .AND. j == nyn-1 ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 22 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 21 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j+1,i),2)  .AND.              &
-                            BTEST(wall_flags_0(k,j+2,i),2)  .AND.              &
-                            BTEST(wall_flags_0(k,j-1,i),2) )                   & 
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 23 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 21 )
-                   ENDIF
-!
-!--                v component - z-direction
-!--                WS1 (24), WS3 (25), WS5 (26)
-                   IF ( k == nzb+1 )  THEN
-                      k_mm = nzb
-                   ELSE 
-                      k_mm = k - 2
-                   ENDIF
-                   IF ( k > nzt-1 )  THEN
-                      k_pp = nzt+1
-                   ELSE 
-                      k_pp = k + 2
-                   ENDIF
-                   IF ( k > nzt-2 )  THEN
-                      k_ppp = nzt+1
-                   ELSE 
-                      k_ppp = k + 3
-                   ENDIF  
-                   
-                   flag_set = .FALSE.
-                   IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),2)  .AND.            &
-                              BTEST(wall_flags_0(k,j,i),2)    .OR.             &
-                        .NOT. BTEST(wall_flags_0(k_pp,j,i),2) .AND.            &                              
-                              BTEST(wall_flags_0(k,j,i),2)    .OR.             &
-                        k == nzt )                                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 24 )
-                      flag_set = .TRUE.
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),2)    .OR.    &
-                              .NOT. BTEST(wall_flags_0(k_ppp,j,i),2) ) .AND.   & 
-                                  BTEST(wall_flags_0(k-1,j,i),2)  .AND.        &
-                                  BTEST(wall_flags_0(k,j,i),2)    .AND.        &
-                                  BTEST(wall_flags_0(k+1,j,i),2)  .AND.        &
-                                  BTEST(wall_flags_0(k_pp,j,i),2)  .OR.        &
-                                  k == nzt - 1 )                               &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 25 )
-                      flag_set = .TRUE.
-                   ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),2)  .AND.             &
-                            BTEST(wall_flags_0(k-1,j,i),2)   .AND.             &
-                            BTEST(wall_flags_0(k,j,i),2)     .AND.             &
-                            BTEST(wall_flags_0(k+1,j,i),2)   .AND.             &
-                            BTEST(wall_flags_0(k_pp,j,i),2)  .AND.             &
-                            BTEST(wall_flags_0(k_ppp,j,i),2) .AND.             &
-                            .NOT. flag_set )                                   &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 26 )
-                   ENDIF
-
-                ENDDO
+       ENDDO
+!
+!--    w - component
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt
+!
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 18 )
+                advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 21 )
+!
+!--             w component - x-direction
+!--             WS1 (18), WS3 (19), WS5 (20)
+                IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),3) .OR.                 &
+                         ( (  bc_dirichlet_l .OR. bc_radiation_l )             &
+                           .AND. i == nxl   )    .OR.                          &
+                         ( (  bc_dirichlet_r .OR. bc_radiation_r )             &
+                           .AND. i == nxr   ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 18 )      
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),3)  .AND.         &
+                                 BTEST(wall_flags_0(k,j,i+1),3)  .OR.          &
+                           .NOT. BTEST(wall_flags_0(k,j,i-1),3) )              &
+                                                     .OR.                      &
+                         ( ( bc_dirichlet_r .OR. bc_radiation_r )              &
+                           .AND. i == nxr-1 )    .OR.                          &
+                         ( ( bc_dirichlet_l .OR.  bc_radiation_l )             &
+                           .AND. i == nxlu  ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 19 )      
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 18 )      
+                ELSEIF ( BTEST(wall_flags_0(k,j,i+1),3)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i+2),3)  .AND.                 &
+                         BTEST(wall_flags_0(k,j,i-1),3) )                      &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i),20 )       
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 18 )      
+                ENDIF                                                          
+!                                                                              
+!--             w component - y-direction                                      
+!--             WS1 (21), WS3 (22), WS5 (23)                                   
+                IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),3) .OR.                 &
+                         ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
+                           .AND. j == nys   )    .OR.                          &
+                         ( ( bc_dirichlet_n .OR. bc_radiation_n )              &
+                           .AND. j == nyn   ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 21 )      
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),3)  .AND.         &
+                                 BTEST(wall_flags_0(k,j+1,i),3)  .OR.          &
+                           .NOT. BTEST(wall_flags_0(k,j-1,i),3) )              &
+                                                     .OR.                      &
+                         ( ( bc_dirichlet_s .OR. bc_radiation_s )              &
+                           .AND. j == nysv  )    .OR.                          &
+                         ( ( bc_dirichlet_n .OR. bc_radiation_n )              &
+                           .AND. j == nyn-1 ) )                                &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 22 )      
+!                                                                              
+!--                Clear flag for WS1                                          
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 21 )      
+                ELSEIF ( BTEST(wall_flags_0(k,j+1,i),3)  .AND.                 &
+                         BTEST(wall_flags_0(k,j+2,i),3)  .AND.                 &
+                         BTEST(wall_flags_0(k,j-1,i),3) )                      &
+                THEN
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 23 )
+!
+!--                Clear flag for WS1
+                   advc_flags_m(k,j,i) = IBCLR( advc_flags_m(k,j,i), 21 )
+                ENDIF
+!
+!--             w component - z-direction
+!--             WS1 (24), WS3 (25), WS5 (26)
+                flag_set = .FALSE.
+                IF ( k == nzb+1 )  THEN
+                   k_mm = nzb
+                ELSE
+                   k_mm = k - 2
+                ENDIF
+                IF ( k > nzt-1 )  THEN
+                   k_pp = nzt+1
+                ELSE 
+                   k_pp = k + 2
+                ENDIF
+                IF ( k > nzt-2 )  THEN
+                   k_ppp = nzt+1
+                ELSE 
+                   k_ppp = k + 3
+                ENDIF  
+                
+                IF ( ( .NOT. BTEST(wall_flags_0(k-1,j,i),3)  .AND.             &
+                       .NOT. BTEST(wall_flags_0(k,j,i),3)    .AND.             &
+                             BTEST(wall_flags_0(k+1,j,i),3) )  .OR.            &
+                     ( .NOT. BTEST(wall_flags_0(k-1,j,i),3)  .AND.             &
+                             BTEST(wall_flags_0(k,j,i),3) )  .OR.              &
+                     ( .NOT. BTEST(wall_flags_0(k+1,j,i),3)  .AND.             &
+                             BTEST(wall_flags_0(k,j,i),3) )  .OR.              &        
+                     k == nzt )                                                &
+                THEN
+!
+!--                Please note, at k == nzb_w_inner(j,i) a flag is explictely
+!--                set, although this is not a prognostic level. However, 
+!--                contrary to the advection of u,v and s this is necessary
+!--                because flux_t(nzb_w_inner(j,i)) is used for the tendency
+!--                at k == nzb_w_inner(j,i)+1.
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 24 )
+                   flag_set = .TRUE.
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),3)     .OR.      &
+                           .NOT. BTEST(wall_flags_0(k_ppp,j,i),3) ) .AND.      &
+                                 BTEST(wall_flags_0(k-1,j,i),3)  .AND.         &
+                                 BTEST(wall_flags_0(k,j,i),3)    .AND.         &
+                                 BTEST(wall_flags_0(k+1,j,i),3)  .OR.          &
+                         k == nzt - 1 )                                        &
+                THEN                                                           
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 25 )      
+                   flag_set = .TRUE.                                           
+                ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),3)  .AND.                &
+                         BTEST(wall_flags_0(k-1,j,i),3)   .AND.                &
+                         BTEST(wall_flags_0(k,j,i),3)     .AND.                &
+                         BTEST(wall_flags_0(k+1,j,i),3)   .AND.                &
+                         BTEST(wall_flags_0(k_pp,j,i),3)  .AND.                &
+                         BTEST(wall_flags_0(k_ppp,j,i),3) .AND.                &
+                         .NOT. flag_set )                                      &
+                THEN
+                   advc_flags_m(k,j,i) = IBSET( advc_flags_m(k,j,i), 26 )
+                ENDIF
+
              ENDDO
           ENDDO
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb+1, nzt
-!
-!--                At first, set flags to WS1. 
-!--                Since fluxes are swapped in advec_ws.f90, this is necessary to 
-!--                in order to handle the left/south flux.
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 27 )
-                   advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 30 )
-!
-!--                w component - x-direction
-!--                WS1 (27), WS3 (28), WS5 (29)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j,i+1),3) .OR.              &
-                            ( (  bc_dirichlet_l .OR. bc_radiation_l )          &
-                              .AND. i == nxl   )    .OR.                       &
-                            ( (  bc_dirichlet_r .OR. bc_radiation_r )          &
-                              .AND. i == nxr   ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 27 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j,i+2),3)  .AND.      &
-                                    BTEST(wall_flags_0(k,j,i+1),3)  .OR.       &
-                              .NOT. BTEST(wall_flags_0(k,j,i-1),3) )           &
-                                                        .OR.                   &
-                            ( ( bc_dirichlet_r .OR. bc_radiation_r )           &
-                              .AND. i == nxr-1 )    .OR.                       &
-                            ( ( bc_dirichlet_l .OR.  bc_radiation_l )          &
-                              .AND. i == nxlu  ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 28 )
-!   
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 27 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j,i+1),3)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i+2),3)  .AND.              &
-                            BTEST(wall_flags_0(k,j,i-1),3) )                   &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i),29 )
-!   
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 27 )
+       ENDDO
+!
+!--    Exchange ghost points for advection flags
+       CALL exchange_horiz_int( advc_flags_m, nys, nyn, nxl, nxr, nzt, nbgp )
+!
+!--    Set boundary flags at inflow and outflow boundary in case of 
+!--    non-cyclic boundary conditions.
+       IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
+          advc_flags_m(:,:,nxl-1) = advc_flags_m(:,:,nxl)
+       ENDIF
+
+       IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
+         advc_flags_m(:,:,nxr+1) = advc_flags_m(:,:,nxr)
+       ENDIF
+
+       IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
+          advc_flags_m(:,nyn+1,:) = advc_flags_m(:,nyn,:)
+       ENDIF
+
+       IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
+          advc_flags_m(:,nys-1,:) = advc_flags_m(:,nys,:)
+       ENDIF
+
+    END SUBROUTINE ws_init_flags_momentum
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of flags to control the order of the advection scheme near
+!> solid walls and non-cyclic inflow boundaries, where the order is sucessively
+!> degraded. 
+!------------------------------------------------------------------------------!
+    SUBROUTINE ws_init_flags_scalar( non_cyclic_l, non_cyclic_n, non_cyclic_r, &
+                                     non_cyclic_s, advc_flag, extensive_degrad )
+
+
+       INTEGER(iwp) ::  i     !< index variable along x
+       INTEGER(iwp) ::  j     !< index variable along y
+       INTEGER(iwp) ::  k     !< index variable along z
+       INTEGER(iwp) ::  k_mm  !< dummy index along z
+       INTEGER(iwp) ::  k_pp  !< dummy index along z
+       INTEGER(iwp) ::  k_ppp !< dummy index along z
+       
+       INTEGER(iwp), INTENT(INOUT), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::&
+                                                  advc_flag !< flag array to control order of scalar advection
+       
+       LOGICAL ::  flag_set     !< steering variable for advection flags
+       LOGICAL ::  non_cyclic_l !< flag that indicates non-cyclic boundary on the left
+       LOGICAL ::  non_cyclic_n !< flag that indicates non-cyclic boundary on the north
+       LOGICAL ::  non_cyclic_r !< flag that indicates non-cyclic boundary on the right
+       LOGICAL ::  non_cyclic_s !< flag that indicates non-cyclic boundary on the south
+       
+       LOGICAL, OPTIONAL ::  extensive_degrad !< flag indicating that extensive degradation is required, e.g. for 
+                                              !< passive scalars nearby topography along the horizontal directions,
+                                              !< as no monotonic limiter can be applied there 
+!
+!--    Set flags to steer the degradation of the advection scheme in advec_ws
+!--    near topography, inflow- and outflow boundaries as well as bottom and
+!--    top of model domain. advc_flags_m remains zero for all non-prognostic
+!--    grid points.
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO  k = nzb+1, nzt
+                IF ( .NOT.  BTEST(wall_flags_0(k,j,i),0) )  CYCLE
+!
+!--             scalar - x-direction
+!--             WS1 (0), WS3 (1), WS5 (2)
+                IF ( ( .NOT. BTEST(wall_flags_0(k,j,i+1),0)                    &
+                 .OR.  .NOT. BTEST(wall_flags_0(k,j,i+2),0)                    &   
+                 .OR.  .NOT. BTEST(wall_flags_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_0(k,j,i+3),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j,i+1),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j,i+2),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j,i-1),0)                &
+                         )                       .OR.                          &
+                         ( .NOT. BTEST(wall_flags_0(k,j,i-2),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j,i+1),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j,i+2),0)                &
+                    .AND.        BTEST(wall_flags_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_0(k,j,i+1),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j,i+2),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j,i+3),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j,i-1),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j,i-2),0) )                      &
+                THEN                                                           
+                   advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 2 )             
+                ENDIF                                                          
+!                                                                              
+!--             scalar - y-direction                                           
+!--             WS1 (3), WS3 (4), WS5 (5)                                      
+                IF ( ( .NOT. BTEST(wall_flags_0(k,j+1,i),0)                    &
+                 .OR.  .NOT. BTEST(wall_flags_0(k,j+2,i),0)                    &   
+                 .OR.  .NOT. BTEST(wall_flags_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_0(k,j+3,i),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j+1,i),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j+2,i),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j-1,i),0)                &
+                         )                       .OR.                          &
+                         ( .NOT. BTEST(wall_flags_0(k,j-2,i),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j+1,i),0)                &
+                    .AND.        BTEST(wall_flags_0(k,j+2,i),0)                &
+                    .AND.        BTEST(wall_flags_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_0(k,j+1,i),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j+2,i),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j+3,i),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j-1,i),0)                        &
+                   .AND. BTEST(wall_flags_0(k,j-2,i),0) )                      &
+                THEN                                                           
+                   advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 5 )             
+                ENDIF
+!
+!--             Near topography, set horizontal advection scheme to 1st order 
+!--             for passive scalars, even if only one direction may be 
+!--             blocked by topography. These locations will be identified
+!--             by wall_flags_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. 
+!--             Moreover, note that this extended degradtion for passive 
+!--             scalars is not required for the vertical direction as there 
+!--             the monotonic limiter can be applied. 
+                IF ( PRESENT( extensive_degrad ) )  THEN
+                   IF ( extensive_degrad )  THEN
+!
+!--                   At all grid points that are within a three-grid point
+!--                   range to topography, set 1st-order scheme.
+                      IF( BTEST( advc_flag(k,j,i), 31 ) )  THEN
+!
+!--                      Clear flags that might indicate higher-order 
+!--                      advection along x- and y-direction.
+                         advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 1 )
+                         advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 2 )
+                         advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 4 )
+                         advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 5 )
+!
+!--                      Set flags that indicate 1st-order advection along
+!--                      x- and y-direction.
+                         advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 0 )
+                         advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 3 )  
+                      ENDIF
+!
+!--                   Adjacent to this extended degradation zone, successively
+!--                   upgrade the order of the scheme if this grid point isn't 
+!--                   flagged with bit 31 (indicating extended degradation 
+!--                   zone). 
+                      IF ( .NOT. BTEST( advc_flag(k,j,i), 31 ) )  THEN
+!
+!--                      x-direction. First, clear all previous settings, than
+!--                      set flag for 3rd-order scheme.
+                         IF ( BTEST( advc_flag(k,j,i-1), 31 )  .AND.        &
+                              BTEST( advc_flag(k,j,i+1), 31 ) )  THEN
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 0 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 1 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 2 )
+                            
+                            advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 1 )
+                         ENDIF
+!
+!--                      x-direction. First, clear all previous settings, than
+!--                      set flag for 5rd-order scheme.
+                         IF ( .NOT. BTEST( advc_flag(k,j,i-1), 31 )  .AND.  &
+                                    BTEST( advc_flag(k,j,i-2), 31 )  .AND.  &
+                              .NOT. BTEST( advc_flag(k,j,i+1), 31 )  .AND.  &
+                                    BTEST( advc_flag(k,j,i+2), 31 ) )  THEN
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 0 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 1 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 2 )
+                            
+                            advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 2 )
+                         ENDIF
+!
+!--                      y-direction. First, clear all previous settings, than
+!--                      set flag for 3rd-order scheme.
+                         IF ( BTEST( advc_flag(k,j-1,i), 31 )  .AND.        &
+                              BTEST( advc_flag(k,j+1,i), 31 ) )  THEN
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 3 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 4 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 5 )
+                            
+                            advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 4 )
+                         ENDIF
+!
+!--                      y-direction. First, clear all previous settings, than
+!--                      set flag for 5rd-order scheme.
+                         IF ( .NOT. BTEST( advc_flag(k,j-1,i), 31 )  .AND.  &
+                                    BTEST( advc_flag(k,j-2,i), 31 )  .AND.  &
+                              .NOT. BTEST( advc_flag(k,j+1,i), 31 )  .AND.  &
+                                    BTEST( advc_flag(k,j+2,i), 31 ) )  THEN
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 3 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 4 )
+                            advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 5 )
+                            
+                            advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 5 )
+                         ENDIF
+                      ENDIF
+                   
                    ENDIF
-!
-!--                w component - y-direction
-!--                WS1 (30), WS3 (31), WS5 (32)
-                   IF ( .NOT. BTEST(wall_flags_0(k,j+1,i),3) .OR.              &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j == nys   )    .OR.                       &
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn   ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 30 )
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k,j+2,i),3)  .AND.      &
-                                    BTEST(wall_flags_0(k,j+1,i),3)  .OR.       &
-                              .NOT. BTEST(wall_flags_0(k,j-1,i),3) )           &
-                                                        .OR.                   &
-                            ( ( bc_dirichlet_s .OR. bc_radiation_s )           &
-                              .AND. j == nysv  )    .OR.                       &
-                            ( ( bc_dirichlet_n .OR. bc_radiation_n )           &
-                              .AND. j == nyn-1 ) )                             &
-                   THEN
-                      advc_flags_1(k,j,i) = IBSET( advc_flags_1(k,j,i), 31 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 30 )
-                   ELSEIF ( BTEST(wall_flags_0(k,j+1,i),3)  .AND.              &
-                            BTEST(wall_flags_0(k,j+2,i),3)  .AND.              &
-                            BTEST(wall_flags_0(k,j-1,i),3) )                   &
-                   THEN
-                      advc_flags_2(k,j,i) = IBSET( advc_flags_2(k,j,i), 0 )
-!
-!--                   Clear flag for WS1
-                      advc_flags_1(k,j,i) = IBCLR( advc_flags_1(k,j,i), 30 )
+                   
+!
+!--                Near lateral boundary flags might be overwritten. Set
+!--                them again. 
+!--                x-direction
+                   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 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 1 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 2 )
+                         
+                      advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 0 )
                    ENDIF
-!
-!--                w component - z-direction
-!--                WS1 (33), WS3 (34), WS5 (35)
-                   flag_set = .FALSE.
-                   IF ( k == nzb+1 )  THEN
-                      k_mm = nzb
-                   ELSE
-                      k_mm = k - 2
+                   
+                   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 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 1 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 2 )
+                         
+                      advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 1 )
                    ENDIF
-                   IF ( k > nzt-1 )  THEN
-                      k_pp = nzt+1
-                   ELSE 
-                      k_pp = k + 2
+!
+!--                y-direction
+                   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 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 4 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 5 )
+                         
+                      advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 3 )
                    ENDIF
-                   IF ( k > nzt-2 )  THEN
-                      k_ppp = nzt+1
-                   ELSE 
-                      k_ppp = k + 3
-                   ENDIF  
                    
-                   IF ( ( .NOT. BTEST(wall_flags_0(k-1,j,i),3)  .AND.          &
-                          .NOT. BTEST(wall_flags_0(k,j,i),3)    .AND.          &
-                                BTEST(wall_flags_0(k+1,j,i),3) )  .OR.         &
-                        ( .NOT. BTEST(wall_flags_0(k-1,j,i),3)  .AND.          &
-                                BTEST(wall_flags_0(k,j,i),3) )  .OR.           &
-                        ( .NOT. BTEST(wall_flags_0(k+1,j,i),3)  .AND.          &
-                                BTEST(wall_flags_0(k,j,i),3) )  .OR.           &        
-                        k == nzt )                                             &
-                   THEN
-!
-!--                   Please note, at k == nzb_w_inner(j,i) a flag is explictely
-!--                   set, although this is not a prognostic level. However, 
-!--                   contrary to the advection of u,v and s this is necessary
-!--                   because flux_t(nzb_w_inner(j,i)) is used for the tendency
-!--                   at k == nzb_w_inner(j,i)+1.
-                      advc_flags_2(k,j,i) = IBSET( advc_flags_2(k,j,i), 1 )
-                      flag_set = .TRUE.
-                   ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),3)     .OR.   &
-                              .NOT. BTEST(wall_flags_0(k_ppp,j,i),3) ) .AND.   &
-                                    BTEST(wall_flags_0(k-1,j,i),3)  .AND.      &
-                                    BTEST(wall_flags_0(k,j,i),3)    .AND.      &
-                                    BTEST(wall_flags_0(k+1,j,i),3)  .OR.       &
-                            k == nzt - 1 )                                     &
-                   THEN
-                      advc_flags_2(k,j,i) = IBSET( advc_flags_2(k,j,i), 2 )
-                      flag_set = .TRUE.
-                   ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),3)  .AND.             &
-                            BTEST(wall_flags_0(k-1,j,i),3)   .AND.             &
-                            BTEST(wall_flags_0(k,j,i),3)     .AND.             &
-                            BTEST(wall_flags_0(k+1,j,i),3)   .AND.             &
-                            BTEST(wall_flags_0(k_pp,j,i),3)  .AND.             &
-                            BTEST(wall_flags_0(k_ppp,j,i),3) .AND.             &
-                            .NOT. flag_set )                                   &
-                   THEN
-                      advc_flags_2(k,j,i) = IBSET( advc_flags_2(k,j,i), 3 )
+                   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 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 4 )
+                      advc_flag(k,j,i) = IBCLR( advc_flag(k,j,i), 5 )
+                         
+                      advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 4 )
                    ENDIF
-
-                ENDDO
+                   
+                ENDIF
+                
+                
+!                                                                              
+!--             scalar - z-direction                                           
+!--             WS1 (6), WS3 (7), WS5 (8)                                      
+                IF ( k == nzb+1 )  THEN                                        
+                   k_mm = nzb                                                  
+                ELSE                                                           
+                   k_mm = k - 2                                                
+                ENDIF                                                          
+                IF ( k > nzt-1 )  THEN                                         
+                   k_pp = nzt+1                                                
+                ELSE                                                           
+                   k_pp = k + 2                                                
+                ENDIF                                                          
+                IF ( k > nzt-2 )  THEN                                         
+                   k_ppp = nzt+1                                               
+                ELSE                                                           
+                   k_ppp = k + 3                                               
+                ENDIF                                                          
+                                                                               
+                flag_set = .FALSE.                                             
+                IF ( .NOT. BTEST(wall_flags_0(k-1,j,i),0)  .AND.               &
+                           BTEST(wall_flags_0(k,j,i),0)    .OR.                &
+                     .NOT. BTEST(wall_flags_0(k_pp,j,i),0) .AND.               &                              
+                           BTEST(wall_flags_0(k,j,i),0)    .OR.                &
+                     k == nzt )                                                &
+                THEN                                                           
+                   advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 6 )             
+                   flag_set = .TRUE.                                           
+                ELSEIF ( ( .NOT. BTEST(wall_flags_0(k_mm,j,i),0)    .OR.       &
+                           .NOT. BTEST(wall_flags_0(k_ppp,j,i),0) ) .AND.      & 
+                               BTEST(wall_flags_0(k-1,j,i),0)  .AND.           &
+                               BTEST(wall_flags_0(k,j,i),0)    .AND.           &
+                               BTEST(wall_flags_0(k+1,j,i),0)  .AND.           &
+                               BTEST(wall_flags_0(k_pp,j,i),0) .OR.            &    
+                         k == nzt - 1 )                                        &
+                THEN                                                           
+                   advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 7 )             
+                   flag_set = .TRUE.                                           
+                ELSEIF ( BTEST(wall_flags_0(k_mm,j,i),0)                       &
+                  .AND.  BTEST(wall_flags_0(k-1,j,i),0)                        &
+                  .AND.  BTEST(wall_flags_0(k,j,i),0)                          &
+                  .AND.  BTEST(wall_flags_0(k+1,j,i),0)                        &
+                  .AND.  BTEST(wall_flags_0(k_pp,j,i),0)                       &
+                  .AND.  BTEST(wall_flags_0(k_ppp,j,i),0)                      &
+                  .AND. .NOT. flag_set )                                       &
+                THEN
+                   advc_flag(k,j,i) = IBSET( advc_flag(k,j,i), 8 )
+                ENDIF
+
              ENDDO
           ENDDO
-
+       ENDDO
+!
+!--    Exchange 3D integer wall_flags.
+!
+!--    Exchange ghost points for advection flags
+       CALL exchange_horiz_int( advc_flag, nys, nyn, nxl, nxr, nzt, nbgp )
+!
+!--    Set boundary flags at inflow and outflow boundary in case of 
+!--    non-cyclic boundary conditions.
+       IF ( non_cyclic_l )  THEN
+          advc_flag(:,:,nxl-1) = advc_flag(:,:,nxl)
        ENDIF
 
-
-!
-!--    Exchange 3D integer wall_flags.
-       IF ( momentum_advec == 'ws-scheme' .OR. scalar_advec == 'ws-scheme'     &
-          )  THEN  
-!
-!--       Exchange ghost points for advection flags
-          CALL exchange_horiz_int( advc_flags_1, nys, nyn, nxl, nxr, nzt, nbgp )
-          CALL exchange_horiz_int( advc_flags_2, nys, nyn, nxl, nxr, nzt, nbgp )
-!
-!--       Set boundary flags at inflow and outflow boundary in case of 
-!--       non-cyclic boundary conditions.
-          IF ( bc_dirichlet_l  .OR.  bc_radiation_l )  THEN
-             advc_flags_1(:,:,nxl-1) = advc_flags_1(:,:,nxl)
-             advc_flags_2(:,:,nxl-1) = advc_flags_2(:,:,nxl)
-          ENDIF
-
-          IF ( bc_dirichlet_r  .OR.  bc_radiation_r )  THEN
-            advc_flags_1(:,:,nxr+1) = advc_flags_1(:,:,nxr)
-            advc_flags_2(:,:,nxr+1) = advc_flags_2(:,:,nxr)
-          ENDIF
-
-          IF ( bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
-             advc_flags_1(:,nyn+1,:) = advc_flags_1(:,nyn,:)
-             advc_flags_2(:,nyn+1,:) = advc_flags_2(:,nyn,:)
-          ENDIF
-
-          IF ( bc_dirichlet_s  .OR.  bc_radiation_s )  THEN
-             advc_flags_1(:,nys-1,:) = advc_flags_1(:,nys,:)
-             advc_flags_2(:,nys-1,:) = advc_flags_2(:,nys,:)
-          ENDIF
+       IF ( non_cyclic_r )  THEN
+         advc_flag(:,:,nxr+1) = advc_flag(:,:,nxr)
+       ENDIF
+
+       IF ( non_cyclic_n )  THEN
+          advc_flag(:,nyn+1,:) = advc_flag(:,nyn,:)
+       ENDIF
+
+       IF ( non_cyclic_s )  THEN
+          advc_flag(:,nys-1,:) = advc_flag(:,nys,:)
+       ENDIF
   
-       ENDIF
-
-
-    END SUBROUTINE ws_init_flags
-
-
+
+
+    END SUBROUTINE ws_init_flags_scalar   
+    
 !------------------------------------------------------------------------------!
 ! Description:
@@ -1123,7 +1343,10 @@
 !> Scalar advection - Call for grid point i,j
 !------------------------------------------------------------------------------!
-    SUBROUTINE advec_s_ws_ij( i, j, sk, sk_char, swap_flux_y_local,            &
+    SUBROUTINE advec_s_ws_ij( advc_flag, i, j, sk, sk_char, swap_flux_y_local, &
                               swap_diss_y_local, swap_flux_x_local,            &
-                              swap_diss_x_local, i_omp, tn, flux_limitation )
+                              swap_diss_x_local, i_omp, tn,                    &
+                              non_cyclic_l, non_cyclic_n,                      &
+                              non_cyclic_r, non_cyclic_s,                      &
+                              flux_limitation )
 
 
@@ -1140,5 +1363,12 @@
        INTEGER(iwp) ::  nzb_max_l !< index indicating upper bound for order degradation of horizontal advection terms  
        INTEGER(iwp) ::  tn        !< number of OpenMP thread
-
+       
+       INTEGER(iwp), INTENT(IN), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::   &
+                                                  advc_flag !< flag array to control order of scalar advection
+
+       LOGICAL           ::  non_cyclic_l    !< flag that indicates non-cyclic boundary on the left
+       LOGICAL           ::  non_cyclic_n    !< flag that indicates non-cyclic boundary on the north
+       LOGICAL           ::  non_cyclic_r    !< flag that indicates non-cyclic boundary on the right
+       LOGICAL           ::  non_cyclic_s    !< flag that indicates non-cyclic boundary on the south                                           
        LOGICAL, OPTIONAL ::  flux_limitation !< flag indicating flux limitation of the vertical advection
        LOGICAL           ::  limiter         !< control flag indicating the application of flux limitation
@@ -1196,8 +1426,8 @@
 !--    instead of the entire subdomain. This should lead to better 
 !--    load balance between boundary and non-boundary PEs.
-       IF( ( bc_dirichlet_l  .OR.  bc_radiation_l )  .AND.  i <= nxl + 2  .OR. &
-           ( bc_dirichlet_r  .OR.  bc_radiation_r )  .AND.  i >= nxr - 2  .OR. &
-           ( bc_dirichlet_s  .OR.  bc_radiation_s )  .AND.  j <= nys + 2  .OR. &
-           ( bc_dirichlet_n  .OR.  bc_radiation_n )  .AND.  j >= nyn - 2 )  THEN
+       IF( non_cyclic_l  .AND.  i <= nxl + 2  .OR.                             &
+           non_cyclic_r  .AND.  i >= nxr - 2  .OR.                             &
+           non_cyclic_s  .AND.  j <= nys + 2  .OR.                             &
+           non_cyclic_n  .AND.  j >= nyn - 2 )  THEN
           nzb_max_l = nzt
        ELSE
@@ -1215,7 +1445,7 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit5 = REAL( IBITS(advc_flags_1(k,j-1,i),5,1), KIND = wp )
-             ibit4 = REAL( IBITS(advc_flags_1(k,j-1,i),4,1), KIND = wp )
-             ibit3 = REAL( IBITS(advc_flags_1(k,j-1,i),3,1), KIND = wp )
+             ibit5 = REAL( IBITS(advc_flag(k,j-1,i),5,1), KIND = wp )
+             ibit4 = REAL( IBITS(advc_flag(k,j-1,i),4,1), KIND = wp )
+             ibit3 = REAL( IBITS(advc_flag(k,j-1,i),3,1), KIND = wp )
 
              v_comp                  = v(k,j,i) - v_gtrans + v_stokes_zu(k)
@@ -1276,7 +1506,7 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit2 = REAL( IBITS(advc_flags_1(k,j,i-1),2,1), KIND = wp )
-             ibit1 = REAL( IBITS(advc_flags_1(k,j,i-1),1,1), KIND = wp )
-             ibit0 = REAL( IBITS(advc_flags_1(k,j,i-1),0,1), KIND = wp )
+             ibit2 = REAL( IBITS(advc_flag(k,j,i-1),2,1), KIND = wp )
+             ibit1 = REAL( IBITS(advc_flag(k,j,i-1),1,1), KIND = wp )
+             ibit0 = REAL( IBITS(advc_flag(k,j,i-1),0,1), KIND = wp )
 
              u_comp                     = u(k,j,i) - u_gtrans + u_stokes_zu(k)
@@ -1340,7 +1570,7 @@
 !--       flux at the end. 
 
-          ibit2 = REAL( IBITS(advc_flags_1(k,j,i),2,1), KIND = wp )
-          ibit1 = REAL( IBITS(advc_flags_1(k,j,i),1,1), KIND = wp )
-          ibit0 = REAL( IBITS(advc_flags_1(k,j,i),0,1), KIND = wp )
+          ibit2 = REAL( IBITS(advc_flag(k,j,i),2,1), KIND = wp )
+          ibit1 = REAL( IBITS(advc_flag(k,j,i),1,1), KIND = wp )
+          ibit0 = REAL( IBITS(advc_flag(k,j,i),0,1), KIND = wp )
 
           u_comp    = u(k,j,i+1) - u_gtrans + u_stokes_zu(k)
@@ -1375,7 +1605,7 @@
                                        )
 
-          ibit5 = REAL( IBITS(advc_flags_1(k,j,i),5,1), KIND = wp )
-          ibit4 = REAL( IBITS(advc_flags_1(k,j,i),4,1), KIND = wp )
-          ibit3 = REAL( IBITS(advc_flags_1(k,j,i),3,1), KIND = wp )
+          ibit5 = REAL( IBITS(advc_flag(k,j,i),5,1), KIND = wp )
+          ibit4 = REAL( IBITS(advc_flag(k,j,i),4,1), KIND = wp )
+          ibit3 = REAL( IBITS(advc_flag(k,j,i),3,1), KIND = wp )
 
           v_comp    = v(k,j+1,i) - v_gtrans + v_stokes_zu(k)
@@ -1445,11 +1675,11 @@
 !--    calculated explicetely for the tendency at
 !--    the first w-level. For topography wall this is done implicitely by
-!--    advc_flags_1.
+!--    advc_flag.
        flux_t(nzb) = 0.0_wp
        diss_t(nzb) = 0.0_wp
        DO  k = nzb+1, nzb+2
-          ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-          ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-          ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 !
 !--       k index has to be modified near bottom and top, else array
@@ -1491,7 +1721,7 @@
        
        DO  k = nzb+3, nzt-2
-          ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-          ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-          ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 
           flux_t(k) = w(k,j,i) * rho_air_zw(k) * (                            &
@@ -1526,7 +1756,7 @@
        
        DO  k = nzt-1, nzt
-          ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-          ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-          ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 !
 !--       k index has to be modified near bottom and top, else array
@@ -1675,15 +1905,15 @@
           diss_d    = diss_t(k-1)
           
-          ibit2 = REAL( IBITS(advc_flags_1(k,j,i),2,1), KIND = wp )
-          ibit1 = REAL( IBITS(advc_flags_1(k,j,i),1,1), KIND = wp )
-          ibit0 = REAL( IBITS(advc_flags_1(k,j,i),0,1), KIND = wp )
+          ibit2 = REAL( IBITS(advc_flag(k,j,i),2,1), KIND = wp )
+          ibit1 = REAL( IBITS(advc_flag(k,j,i),1,1), KIND = wp )
+          ibit0 = REAL( IBITS(advc_flag(k,j,i),0,1), KIND = wp )
           
-          ibit5 = REAL( IBITS(advc_flags_1(k,j,i),5,1), KIND = wp )
-          ibit4 = REAL( IBITS(advc_flags_1(k,j,i),4,1), KIND = wp )
-          ibit3 = REAL( IBITS(advc_flags_1(k,j,i),3,1), KIND = wp )
+          ibit5 = REAL( IBITS(advc_flag(k,j,i),5,1), KIND = wp )
+          ibit4 = REAL( IBITS(advc_flag(k,j,i),4,1), KIND = wp )
+          ibit3 = REAL( IBITS(advc_flag(k,j,i),3,1), KIND = wp )
           
-          ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-          ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-          ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 !
 !--       Calculate the divergence of the velocity field. A respective
@@ -1692,14 +1922,14 @@
           div         =   ( u(k,j,i+1) * ( ibit0 + ibit1 + ibit2 )            &
                           - u(k,j,i)   * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j,i-1),0,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),1,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),2,1), KIND = wp )   &
+                        REAL( IBITS(advc_flag(k,j,i-1),0,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k,j,i-1),1,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k,j,i-1),2,1), KIND = wp )      &
                                          )                                    &
                           ) * ddx                                             &
                         + ( v(k,j+1,i) * ( ibit3 + ibit4 + ibit5 )            &
                           - v(k,j,i)   * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j-1,i),3,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),4,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),5,1), KIND = wp )   &
+                        REAL( IBITS(advc_flag(k,j-1,i),3,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k,j-1,i),4,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k,j-1,i),5,1), KIND = wp )      &
                                          )                                    &
                           ) * ddy                                             &
@@ -1708,7 +1938,7 @@
                           - w(k-1,j,i) * rho_air_zw(k-1) *                    &
                                          (                                    &
-                        REAL( IBITS(advc_flags_1(k-1,j,i),6,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),7,1), KIND = wp )   &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),8,1), KIND = wp )   &
+                        REAL( IBITS(advc_flag(k-1,j,i),6,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k-1,j,i),7,1), KIND = wp )      &
+                      + REAL( IBITS(advc_flag(k-1,j,i),8,1), KIND = wp )      &
                                          )                                    &      
                           ) * drho_air(k) * ddzw(k)
@@ -1897,13 +2127,13 @@
        INTEGER(iwp) ::  tn        !< number of OpenMP thread
        
-       REAL(wp)    ::  ibit9    !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit10   !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit11   !< flag indicating 5th-order scheme along x-direction
-       REAL(wp)    ::  ibit12   !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit13   !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit14   !< flag indicating 5th-order scheme along y-direction
-       REAL(wp)    ::  ibit15   !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)    ::  ibit16   !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)    ::  ibit17   !< flag indicating 5th-order scheme along z-direction
+       REAL(wp)    ::  ibit0   !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit1   !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit2   !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit3   !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit4   !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit5   !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit6   !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)    ::  ibit7   !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)    ::  ibit8   !< flag indicating 5th-order scheme along z-direction
        REAL(wp)    ::  diss_d   !< artificial dissipation term at grid box bottom
        REAL(wp)    ::  div      !< diverence on u-grid
@@ -1944,37 +2174,37 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit14 = REAL( IBITS(advc_flags_1(k,j-1,i),14,1), KIND = wp )
-             ibit13 = REAL( IBITS(advc_flags_1(k,j-1,i),13,1), KIND = wp )
-             ibit12 = REAL( IBITS(advc_flags_1(k,j-1,i),12,1), KIND = wp )
+             ibit5 = REAL( IBITS(advc_flags_m(k,j-1,i),5,1), KIND = wp )
+             ibit4 = REAL( IBITS(advc_flags_m(k,j-1,i),4,1), KIND = wp )
+             ibit3 = REAL( IBITS(advc_flags_m(k,j-1,i),3,1), KIND = wp )
 
              v_comp(k)      = v(k,j,i) + v(k,j,i-1) - gv
-             flux_s_u(k,tn) = v_comp(k) * (                                   &
-                            ( 37.0_wp * ibit14 * adv_mom_5                    &
-                         +     7.0_wp * ibit13 * adv_mom_3                    &
-                         +              ibit12 * adv_mom_1                    &
-                            ) *                                               &
-                                        ( u(k,j,i)   + u(k,j-1,i) )           &
-                     -      (  8.0_wp * ibit14 * adv_mom_5                    &
-                         +              ibit13 * adv_mom_3                    &
-                            ) *                                               &
-                                        ( u(k,j+1,i) + u(k,j-2,i) )           &
-                     +      (           ibit14 * adv_mom_5                    &
-                            ) *                                               &
-                                        ( u(k,j+2,i) + u(k,j-3,i) )           &
+             flux_s_u(k,tn) = v_comp(k) * (                                    &
+                            ( 37.0_wp * ibit5 * adv_mom_5                      &
+                         +     7.0_wp * ibit4 * adv_mom_3                      &
+                         +              ibit3 * adv_mom_1                      &
+                            ) *                                                &
+                                        ( u(k,j,i)   + u(k,j-1,i) )            &
+                     -      (  8.0_wp * ibit5 * adv_mom_5                      &
+                         +              ibit4 * adv_mom_3                      &
+                            ) *                                                &
+                                        ( u(k,j+1,i) + u(k,j-2,i) )            &
+                     +      (           ibit5 * adv_mom_5                      &
+                            ) *                                                &
+                                        ( u(k,j+2,i) + u(k,j-3,i) )            &
                                           )
 
-             diss_s_u(k,tn) = - ABS ( v_comp(k) ) * (                         &
-                            ( 10.0_wp * ibit14 * adv_mom_5                    &
-                         +     3.0_wp * ibit13 * adv_mom_3                    &
-                         +              ibit12 * adv_mom_1                    &
-                            ) *                                               &
-                                        ( u(k,j,i)   - u(k,j-1,i) )           &
-                     -      (  5.0_wp * ibit14 * adv_mom_5                    &
-                         +              ibit13 * adv_mom_3                    &
-                            ) *                                               &
-                                        ( u(k,j+1,i) - u(k,j-2,i) )           &
-                     +      (           ibit14 * adv_mom_5                    &
-                            ) *                                               &
-                                        ( u(k,j+2,i) - u(k,j-3,i) )           &
+             diss_s_u(k,tn) = - ABS ( v_comp(k) ) * (                          &
+                            ( 10.0_wp * ibit5 * adv_mom_5                      &
+                         +     3.0_wp * ibit4 * adv_mom_3                      &
+                         +              ibit3 * adv_mom_1                      &
+                            ) *                                                &
+                                        ( u(k,j,i)   - u(k,j-1,i) )            &
+                     -      (  5.0_wp * ibit5 * adv_mom_5                      &
+                         +              ibit4 * adv_mom_3                      &
+                            ) *                                                &
+                                        ( u(k,j+1,i) - u(k,j-2,i) )            &
+                     +      (           ibit5 * adv_mom_5                      &
+                            ) *                                                &
+                                        ( u(k,j+2,i) - u(k,j-3,i) )            &
                                                     )
 
@@ -1984,11 +2214,11 @@
 
              v_comp(k)      = v(k,j,i) + v(k,j,i-1) - gv
-             flux_s_u(k,tn) = v_comp(k) * (                                   &
-                           37.0_wp * ( u(k,j,i) + u(k,j-1,i)   )              &
-                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )              &
-                         +           ( u(k,j+2,i) + u(k,j-3,i) ) ) * adv_mom_5
-             diss_s_u(k,tn) = - ABS(v_comp(k)) * (                            &
-                           10.0_wp * ( u(k,j,i) - u(k,j-1,i)   )              &
-                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )              &
+             flux_s_u(k,tn) = v_comp(k) * (                                    &
+                           37.0_wp * ( u(k,j,i)   + u(k,j-1,i)   )             &
+                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )               &
+                         +           ( u(k,j+2,i) + u(k,j-3,i) ) ) * adv_mom_5 
+             diss_s_u(k,tn) = - ABS(v_comp(k)) * (                             &
+                           10.0_wp * ( u(k,j,i)   - u(k,j-1,i)   )             &
+                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )               &
                          +           ( u(k,j+2,i) - u(k,j-3,i) ) ) * adv_mom_5
 
@@ -2002,50 +2232,50 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit11 = REAL( IBITS(advc_flags_1(k,j,i-1),11,1), KIND = wp )
-             ibit10 = REAL( IBITS(advc_flags_1(k,j,i-1),10,1), KIND = wp )
-             ibit9  = REAL( IBITS(advc_flags_1(k,j,i-1),9,1),  KIND = wp )
-
-             u_comp_l         = u(k,j,i) + u(k,j,i-1) - gu
-             flux_l_u(k,j,tn) = u_comp_l * (                                  &
-                              ( 37.0_wp * ibit11 * adv_mom_5                  &
-                           +     7.0_wp * ibit10 * adv_mom_3                  &
-                           +              ibit9  * adv_mom_1                  &
-                              ) *                                             &
-                                          ( u(k,j,i)   + u(k,j,i-1) )         &
-                       -      (  8.0_wp * ibit11 * adv_mom_5                  &
-                           +              ibit10 * adv_mom_3                  &
-                              ) *                                             &
-                                          ( u(k,j,i+1) + u(k,j,i-2) )         &
-                       +      (           ibit11 * adv_mom_5                  &
-                              ) *                                             &
-                                          ( u(k,j,i+2) + u(k,j,i-3) )         &
-                                           )
-
-              diss_l_u(k,j,tn) = - ABS( u_comp_l ) * (                        &
-                              ( 10.0_wp * ibit11 * adv_mom_5                  &
-                           +     3.0_wp * ibit10 * adv_mom_3                  &
-                           +              ibit9  * adv_mom_1                  &
-                              ) *                                             &
-                                        ( u(k,j,i)   - u(k,j,i-1) )           &
-                       -      (  5.0_wp * ibit11 * adv_mom_5                  &
-                           +              ibit10 * adv_mom_3                  &
-                              ) *                                             &
-                                        ( u(k,j,i+1) - u(k,j,i-2) )           &
-                       +      (           ibit11 * adv_mom_5                  &
-                              ) *                                             &
-                                        ( u(k,j,i+2) - u(k,j,i-3) )           &
-                                                     )
-
-          ENDDO
-
-          DO  k = nzb_max_l+1, nzt
+             ibit2 = REAL( IBITS(advc_flags_m(k,j,i-1),2,1), KIND = wp )
+             ibit1 = REAL( IBITS(advc_flags_m(k,j,i-1),1,1), KIND = wp )
+             ibit0 = REAL( IBITS(advc_flags_m(k,j,i-1),0,1), KIND = wp )
 
              u_comp_l         = u(k,j,i) + u(k,j,i-1) - gu
              flux_l_u(k,j,tn) = u_comp_l * (                                   &
-                             37.0_wp * ( u(k,j,i) + u(k,j,i-1)   )             &
+                              ( 37.0_wp * ibit2 * adv_mom_5                    &
+                           +     7.0_wp * ibit1 * adv_mom_3                    &
+                           +              ibit0 * adv_mom_1                    &
+                              ) *                                              &
+                                          ( u(k,j,i)   + u(k,j,i-1) )          &
+                       -      (  8.0_wp * ibit2 * adv_mom_5                    &
+                           +              ibit1 * adv_mom_3                    &
+                              ) *                                              &
+                                          ( u(k,j,i+1) + u(k,j,i-2) )          &
+                       +      (           ibit2 * adv_mom_5                    &
+                              ) *                                              &
+                                          ( u(k,j,i+2) + u(k,j,i-3) )          &
+                                           )                                  
+                                                                              
+              diss_l_u(k,j,tn) = - ABS( u_comp_l ) * (                         &
+                              ( 10.0_wp * ibit2 * adv_mom_5                    &
+                           +     3.0_wp * ibit1 * adv_mom_3                    &
+                           +              ibit0  * adv_mom_1                   &
+                              ) *                                              &
+                                        ( u(k,j,i)   - u(k,j,i-1) )            &
+                       -      (  5.0_wp * ibit2 * adv_mom_5                    &
+                           +              ibit1 * adv_mom_3                    &
+                              ) *                                              &
+                                        ( u(k,j,i+1) - u(k,j,i-2) )            &
+                       +      (           ibit2 * adv_mom_5                    &
+                              ) *                                              &
+                                        ( u(k,j,i+2) - u(k,j,i-3) )            &
+                                                     )
+
+          ENDDO
+
+          DO  k = nzb_max_l+1, nzt
+
+             u_comp_l         = u(k,j,i) + u(k,j,i-1) - gu
+             flux_l_u(k,j,tn) = u_comp_l * (                                   &
+                             37.0_wp * ( u(k,j,i)   + u(k,j,i-1)   )           &
                            -  8.0_wp * ( u(k,j,i+1) + u(k,j,i-2) )             &
                            +           ( u(k,j,i+2) + u(k,j,i-3) ) ) * adv_mom_5
              diss_l_u(k,j,tn) = - ABS(u_comp_l) * (                            &
-                             10.0_wp * ( u(k,j,i) - u(k,j,i-1)   )             &
+                             10.0_wp * ( u(k,j,i)   - u(k,j,i-1)   )           &
                            -  5.0_wp * ( u(k,j,i+1) - u(k,j,i-2) )             &
                            +           ( u(k,j,i+2) - u(k,j,i-3) ) ) * adv_mom_5
@@ -2059,72 +2289,72 @@
        DO  k = nzb+1, nzb_max_l
 
-          ibit11 = REAL( IBITS(advc_flags_1(k,j,i),11,1), KIND = wp )
-          ibit10 = REAL( IBITS(advc_flags_1(k,j,i),10,1), KIND = wp )
-          ibit9  = REAL( IBITS(advc_flags_1(k,j,i),9,1),  KIND = wp )
+          ibit2 = REAL( IBITS(advc_flags_m(k,j,i),2,1), KIND = wp )
+          ibit1 = REAL( IBITS(advc_flags_m(k,j,i),1,1), KIND = wp )
+          ibit0 = REAL( IBITS(advc_flags_m(k,j,i),0,1), KIND = wp )
 
           u_comp(k) = u(k,j,i+1) + u(k,j,i)
-          flux_r(k) = ( u_comp(k) - gu ) * (                                  &
-                     ( 37.0_wp * ibit11 * adv_mom_5                           &
-                  +     7.0_wp * ibit10 * adv_mom_3                           &
-                  +              ibit9  * adv_mom_1                           &
-                     ) *                                                      &
-                                    ( u(k,j,i+1) + u(k,j,i)   )               &
-              -      (  8.0_wp * ibit11 * adv_mom_5                           &
-                  +              ibit10 * adv_mom_3                           & 
-                     ) *                                                      &
-                                    ( u(k,j,i+2) + u(k,j,i-1) )               &
-              +      (           ibit11 * adv_mom_5                           &
-                     ) *                                                      &
-                                    ( u(k,j,i+3) + u(k,j,i-2) )               &
-                                           )
-
-          diss_r(k) = - ABS( u_comp(k) - gu ) * (                             &
-                     ( 10.0_wp * ibit11 * adv_mom_5                           &
-                  +     3.0_wp * ibit10 * adv_mom_3                           &
-                  +              ibit9  * adv_mom_1                           &
-                     ) *                                                      &
-                                    ( u(k,j,i+1) - u(k,j,i)   )               &
-              -      (  5.0_wp * ibit11 * adv_mom_5                           &
-                  +              ibit10 * adv_mom_3                           &
-                     ) *                                                      &
-                                    ( u(k,j,i+2) - u(k,j,i-1) )               &
-              +      (           ibit11 * adv_mom_5                           &
-                     ) *                                                      &
-                                    ( u(k,j,i+3) - u(k,j,i-2) )               &
+          flux_r(k) = ( u_comp(k) - gu ) * (                                   &
+                     ( 37.0_wp * ibit2 * adv_mom_5                             &
+                  +     7.0_wp * ibit1 * adv_mom_3                             &
+                  +              ibit0 * adv_mom_1                             &
+                     ) *                                                       &
+                                    ( u(k,j,i+1) + u(k,j,i)   )                &
+              -      (  8.0_wp * ibit2 * adv_mom_5                             &
+                  +              ibit1 * adv_mom_3                             & 
+                     ) *                                                       &
+                                    ( u(k,j,i+2) + u(k,j,i-1) )                &
+              +      (           ibit2 * adv_mom_5                             &
+                     ) *                                                       &
+                                    ( u(k,j,i+3) + u(k,j,i-2) )                &
+                                           )                                  
+                                                                              
+          diss_r(k) = - ABS( u_comp(k) - gu ) * (                              &
+                     ( 10.0_wp * ibit2 * adv_mom_5                             &
+                  +     3.0_wp * ibit1 * adv_mom_3                             &
+                  +              ibit0 * adv_mom_1                             &
+                     ) *                                                       &
+                                    ( u(k,j,i+1) - u(k,j,i)   )                &
+              -      (  5.0_wp * ibit2 * adv_mom_5                             &
+                  +              ibit1 * adv_mom_3                             &
+                     ) *                                                       &
+                                    ( u(k,j,i+2) - u(k,j,i-1) )                &
+              +      (           ibit2 * adv_mom_5                             &
+                     ) *                                                       &
+                                    ( u(k,j,i+3) - u(k,j,i-2) )                &
                                                 )
 
-          ibit14 = REAL( IBITS(advc_flags_1(k,j,i),14,1), KIND = wp )
-          ibit13 = REAL( IBITS(advc_flags_1(k,j,i),13,1), KIND = wp )
-          ibit12 = REAL( IBITS(advc_flags_1(k,j,i),12,1), KIND = wp )
+          ibit5 = REAL( IBITS(advc_flags_m(k,j,i),5,1), KIND = wp )
+          ibit4 = REAL( IBITS(advc_flags_m(k,j,i),4,1), KIND = wp )
+          ibit3 = REAL( IBITS(advc_flags_m(k,j,i),3,1), KIND = wp )
 
           v_comp(k) = v(k,j+1,i) + v(k,j+1,i-1) - gv
-          flux_n(k) = v_comp(k) * (                                           &
-                     ( 37.0_wp * ibit14 * adv_mom_5                           &
-                  +     7.0_wp * ibit13 * adv_mom_3                           &
-                  +              ibit12 * adv_mom_1                           &
-                     ) *                                                      &
-                                    ( u(k,j+1,i) + u(k,j,i)   )               &
-              -      (  8.0_wp * ibit14 * adv_mom_5                           &
-                  +              ibit13 * adv_mom_3                           &
-                     ) *                                                      &
-                                    ( u(k,j+2,i) + u(k,j-1,i) )               &
-              +      (           ibit14 * adv_mom_5                           &
-                     ) *                                                      &
-                                    ( u(k,j+3,i) + u(k,j-2,i) )               &
-                                  )
-
-          diss_n(k) = - ABS ( v_comp(k) ) * (                                 &
-                     ( 10.0_wp * ibit14 * adv_mom_5                           &
-                  +     3.0_wp * ibit13 * adv_mom_3                           &
-                  +              ibit12 * adv_mom_1                           &
-                     ) *                                                      &
-                                    ( u(k,j+1,i) - u(k,j,i)   )               &
-              -      (  5.0_wp * ibit14 * adv_mom_5                           &
-                  +              ibit13 * adv_mom_3                           &
-                     ) *                                                      &
-                                    ( u(k,j+2,i) - u(k,j-1,i) )               &
-              +      (           ibit14 * adv_mom_5                           &
-                     ) *                                                      &
-                                    ( u(k,j+3,i) - u(k,j-2,i) )               &
+          flux_n(k) = v_comp(k) * (                                            &
+                     ( 37.0_wp * ibit5 * adv_mom_5                             &
+                  +     7.0_wp * ibit4 * adv_mom_3                             &
+                  +              ibit3 * adv_mom_1                             &
+                     ) *                                                       &
+                                    ( u(k,j+1,i) + u(k,j,i)   )                &
+              -      (  8.0_wp * ibit5 * adv_mom_5                             &
+                  +              ibit4 * adv_mom_3                             &
+                     ) *                                                       &
+                                    ( u(k,j+2,i) + u(k,j-1,i) )                &
+              +      (           ibit5 * adv_mom_5                             &
+                     ) *                                                       &
+                                    ( u(k,j+3,i) + u(k,j-2,i) )                &
+                                  )                                           
+                                                                              
+          diss_n(k) = - ABS ( v_comp(k) ) * (                                  &
+                     ( 10.0_wp * ibit5 * adv_mom_5                             &
+                  +     3.0_wp * ibit4 * adv_mom_3                             &
+                  +              ibit3 * adv_mom_1                             &
+                     ) *                                                       &
+                                    ( u(k,j+1,i) - u(k,j,i)   )                &
+              -      (  5.0_wp * ibit5 * adv_mom_5                             &
+                  +              ibit4 * adv_mom_3                             &
+                     ) *                                                       &
+                                    ( u(k,j+2,i) - u(k,j-1,i) )                &
+              +      (           ibit5 * adv_mom_5                             &
+                     ) *                                                       &
+                                    ( u(k,j+3,i) - u(k,j-2,i) )                &
                                             )
        ENDDO
@@ -2133,21 +2363,21 @@
 
           u_comp(k) = u(k,j,i+1) + u(k,j,i)
-          flux_r(k) = ( u_comp(k) - gu ) * (                                  &
-                         37.0_wp * ( u(k,j,i+1) + u(k,j,i)   )                &
-                       -  8.0_wp * ( u(k,j,i+2) + u(k,j,i-1) )                &
-                       +           ( u(k,j,i+3) + u(k,j,i-2) ) ) * adv_mom_5
-          diss_r(k) = - ABS( u_comp(k) - gu ) * (                             &
-                         10.0_wp * ( u(k,j,i+1) - u(k,j,i)   )                &
-                       -  5.0_wp * ( u(k,j,i+2) - u(k,j,i-1) )                &
-                       +           ( u(k,j,i+3) - u(k,j,i-2) ) ) * adv_mom_5
-
-          v_comp(k) = v(k,j+1,i) + v(k,j+1,i-1) - gv
-          flux_n(k) = v_comp(k) * (                                           &
-                         37.0_wp * ( u(k,j+1,i) + u(k,j,i)   )                &
-                       -  8.0_wp * ( u(k,j+2,i) + u(k,j-1,i) )                &
-                       +           ( u(k,j+3,i) + u(k,j-2,i) ) ) * adv_mom_5
-          diss_n(k) = - ABS( v_comp(k) ) * (                                  &
-                         10.0_wp * ( u(k,j+1,i) - u(k,j,i)   )                &
-                       -  5.0_wp * ( u(k,j+2,i) - u(k,j-1,i) )                &
+          flux_r(k) = ( u_comp(k) - gu ) * (                                   &
+                         37.0_wp * ( u(k,j,i+1) + u(k,j,i)   )                 &
+                       -  8.0_wp * ( u(k,j,i+2) + u(k,j,i-1) )                 &
+                       +           ( u(k,j,i+3) + u(k,j,i-2) ) ) * adv_mom_5   
+          diss_r(k) = - ABS( u_comp(k) - gu ) * (                              &
+                         10.0_wp * ( u(k,j,i+1) - u(k,j,i)   )                 &
+                       -  5.0_wp * ( u(k,j,i+2) - u(k,j,i-1) )                 &
+                       +           ( u(k,j,i+3) - u(k,j,i-2) ) ) * adv_mom_5   
+                                                                               
+          v_comp(k) = v(k,j+1,i) + v(k,j+1,i-1) - gv                           
+          flux_n(k) = v_comp(k) * (                                            &
+                         37.0_wp * ( u(k,j+1,i) + u(k,j,i)   )                 &
+                       -  8.0_wp * ( u(k,j+2,i) + u(k,j-1,i) )                 &
+                       +           ( u(k,j+3,i) + u(k,j-2,i) ) ) * adv_mom_5   
+          diss_n(k) = - ABS( v_comp(k) ) * (                                   &
+                         10.0_wp * ( u(k,j+1,i) - u(k,j,i)   )                 &
+                       -  5.0_wp * ( u(k,j+2,i) - u(k,j-1,i) )                 &
                        +           ( u(k,j+3,i) - u(k,j-2,i) ) ) * adv_mom_5
 
@@ -2161,5 +2391,5 @@
 !--    calculated explicetely for the tendency at
 !--    the first w-level. For topography wall this is done implicitely by
-!--    advc_flags_1.
+!--    advc_flags_m.
        flux_t(nzb) = 0.0_wp
        diss_t(nzb) = 0.0_wp
@@ -2169,41 +2399,41 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-          ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-          ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit17
-          k_pp  = k + 2 * ( 1 - ibit15 )
-          k_mm  = k - 2 * ibit17
+          ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit8
+          k_pp  = k + 2 * ( 1 - ibit6 )
+          k_mm  = k - 2 * ibit8
 
           w_comp(k) = w(k,j,i) + w(k,j,i-1)
-          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit17 * adv_mom_5                           &
-                  +     7.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)  + u(k,j,i)     )                &
-              -      (  8.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k_pp,j,i) + u(k-1,j,i)   )                &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k_ppp,j,i) + u(k_mm,j,i) )                &
-                                                  )
-
-          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit17 * adv_mom_5                           &
-                  +     3.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)   - u(k,j,i)    )                &
-              -      (  5.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k_pp,j,i)  - u(k-1,j,i)  )                &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k_ppp,j,i) - u(k_mm,j,i) )                &
+          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                            &
+                     ( 37.0_wp * ibit8 * adv_mom_5                             &
+                  +     7.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)   + u(k,j,i)    )                 &
+              -      (  8.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k_pp,j,i)  + u(k-1,j,i)  )                 &
+              +      (           ibit8 * adv_mom_5                             &
+                     ) *                                                       &
+                                ( u(k_ppp,j,i) + u(k_mm,j,i) )                 &
+                                                  )                            
+                                                                               
+          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                   &
+                     ( 10.0_wp * ibit8 * adv_mom_5                             &
+                  +     3.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)   - u(k,j,i)    )                 &
+              -      (  5.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k_pp,j,i)  - u(k-1,j,i)  )                 &
+              +      (           ibit8 * adv_mom_5                             &
+                     ) *                                                       &
+                                ( u(k_ppp,j,i) - u(k_mm,j,i) )                 &
                                                            )
        ENDDO
@@ -2211,37 +2441,37 @@
        DO  k = nzb+3, nzt-2
 
-          ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-          ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-          ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
 
           w_comp(k) = w(k,j,i) + w(k,j,i-1)
-          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit17 * adv_mom_5                           &
-                  +     7.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)  + u(k,j,i)     )                &
-              -      (  8.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k+2,j,i) + u(k-1,j,i)   )                 &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k+3,j,i) + u(k-2,j,i) )                   &
+          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                            &
+                     ( 37.0_wp * ibit8 * adv_mom_5                             &
+                  +     7.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)  + u(k,j,i)     )                 &
+              -      (  8.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k+2,j,i) + u(k-1,j,i)   )                  &
+              +      (           ibit8 * adv_mom_5                             & 
+                     ) *                                                       &
+                                ( u(k+3,j,i) + u(k-2,j,i) )                    &
                                                   )
 
-          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit17 * adv_mom_5                           &
-                  +     3.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)   - u(k,j,i)    )                &
-              -      (  5.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k+2,j,i)  - u(k-1,j,i)  )                 &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k+3,j,i) - u(k-2,j,i) )                   &
+          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                   &
+                     ( 10.0_wp * ibit8 * adv_mom_5                             &
+                  +     3.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)  - u(k,j,i)    )                  &
+              -      (  5.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k+2,j,i)  - u(k-1,j,i)  )                  &
+              +      (           ibit8 * adv_mom_5                             &
+                     ) *                                                       &
+                                ( u(k+3,j,i) - u(k-2,j,i)   )                  &
                                                            )
        ENDDO
@@ -2251,41 +2481,41 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-          ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-          ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit17
-          k_pp  = k + 2 * ( 1 - ibit15 )
-          k_mm  = k - 2 * ibit17
+          ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit8
+          k_pp  = k + 2 * ( 1 - ibit6 )
+          k_mm  = k - 2 * ibit8
 
           w_comp(k) = w(k,j,i) + w(k,j,i-1)
-          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit17 * adv_mom_5                           &
-                  +     7.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)  + u(k,j,i)     )                &
-              -      (  8.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k_pp,j,i) + u(k-1,j,i)   )                &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k_ppp,j,i) + u(k_mm,j,i) )                &
+          flux_t(k) = w_comp(k) * rho_air_zw(k) * (                            &
+                     ( 37.0_wp * ibit8 * adv_mom_5                             &
+                  +     7.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)   + u(k,j,i)    )                 &
+              -      (  8.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k_pp,j,i)  + u(k-1,j,i)  )                 &
+              +      (           ibit8 * adv_mom_5                             &
+                     ) *                                                       &
+                                ( u(k_ppp,j,i) + u(k_mm,j,i) )                 &
                                                   )
 
-          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit17 * adv_mom_5                           &
-                  +     3.0_wp * ibit16 * adv_mom_3                           &
-                  +              ibit15 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( u(k+1,j,i)   - u(k,j,i)    )                &
-              -      (  5.0_wp * ibit17 * adv_mom_5                           &
-                  +              ibit16 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( u(k_pp,j,i)  - u(k-1,j,i)  )                &
-              +      (           ibit17 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( u(k_ppp,j,i) - u(k_mm,j,i) )                &
+          diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                   &
+                     ( 10.0_wp * ibit8 * adv_mom_5                             &
+                  +     3.0_wp * ibit7 * adv_mom_3                             &
+                  +              ibit6 * adv_mom_1                             &
+                     ) *                                                       &
+                                ( u(k+1,j,i)   - u(k,j,i)    )                 &
+              -      (  5.0_wp * ibit8 * adv_mom_5                             &
+                  +              ibit7 * adv_mom_3                             &
+                     ) *                                                       &
+                                ( u(k_pp,j,i)  - u(k-1,j,i)  )                 &
+              +      (           ibit8 * adv_mom_5                             &
+                     ) *                                                       &
+                                ( u(k_ppp,j,i) - u(k_mm,j,i) )                 &
                                                            )
        ENDDO
@@ -2296,53 +2526,53 @@
           diss_d    = diss_t(k-1)
           
-          ibit11 = REAL( IBITS(advc_flags_1(k,j,i),11,1), KIND = wp )
-          ibit10 = REAL( IBITS(advc_flags_1(k,j,i),10,1), KIND = wp )
-          ibit9  = REAL( IBITS(advc_flags_1(k,j,i),9,1),  KIND = wp )
+          ibit2 = REAL( IBITS(advc_flags_m(k,j,i),2,1), KIND = wp )
+          ibit1 = REAL( IBITS(advc_flags_m(k,j,i),1,1), KIND = wp )
+          ibit0 = REAL( IBITS(advc_flags_m(k,j,i),0,1), KIND = wp )
           
-          ibit14 = REAL( IBITS(advc_flags_1(k,j,i),14,1), KIND = wp )
-          ibit13 = REAL( IBITS(advc_flags_1(k,j,i),13,1), KIND = wp )
-          ibit12 = REAL( IBITS(advc_flags_1(k,j,i),12,1), KIND = wp )
+          ibit5 = REAL( IBITS(advc_flags_m(k,j,i),5,1), KIND = wp )
+          ibit4 = REAL( IBITS(advc_flags_m(k,j,i),4,1), KIND = wp )
+          ibit3 = REAL( IBITS(advc_flags_m(k,j,i),3,1), KIND = wp )
           
-          ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-          ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-          ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
+          ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+          ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+          ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
 !
 !--       Calculate the divergence of the velocity field. A respective
 !--       correction is needed to overcome numerical instabilities introduced
 !--       by a not sufficient reduction of divergences near topography.
-          div = ( ( u_comp(k)       * ( ibit9 + ibit10 + ibit11 )             &
-                - ( u(k,j,i)   + u(k,j,i-1)   )                               &
-                                    * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j,i-1),9,1),  KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),10,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),11,1), KIND = wp )     &
-                                      )                                       &
-                  ) * ddx                                                     &
-               +  ( ( v_comp(k) + gv ) * ( ibit12 + ibit13 + ibit14 )         &
-                  - ( v(k,j,i)   + v(k,j,i-1 )  )                             &
-                                    * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j-1,i),12,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),13,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),14,1), KIND = wp )     &
-                                      )                                       &
-                  ) * ddy                                                     &
-               +  ( w_comp(k)   * rho_air_zw(k) * ( ibit15 + ibit16 + ibit17 )&
-                -   w_comp(k-1) * rho_air_zw(k-1)                             &
-                                    * (                                       &
-                     REAL( IBITS(advc_flags_1(k-1,j,i),15,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k-1,j,i),16,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k-1,j,i),17,1), KIND = wp )     &
-                                      )                                       &  
-                  ) * drho_air(k) * ddzw(k)                                   &
-                ) * 0.5_wp
-
-          tend(k,j,i) = tend(k,j,i) - (                                       &
-                            ( flux_r(k) + diss_r(k)                           &
-                          -   flux_l_u(k,j,tn) - diss_l_u(k,j,tn) ) * ddx     &
-                          + ( flux_n(k) + diss_n(k)                           &
-                          -   flux_s_u(k,tn) - diss_s_u(k,tn)     ) * ddy     &
-                          + ( ( flux_t(k) + diss_t(k) )                       &
-                          -   ( flux_d    + diss_d    )                       &
-                                                    ) * drho_air(k) * ddzw(k) &
+          div = ( ( u_comp(k)       * ( ibit0 + ibit1 + ibit2 )                &
+                - ( u(k,j,i)   + u(k,j,i-1)   )                                &
+                                    * (                                        &
+                     REAL( IBITS(advc_flags_m(k,j,i-1),0,1),  KIND = wp )      &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),1,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),2,1), KIND = wp )       &
+                                      )                                        &
+                  ) * ddx                                                      &
+               +  ( ( v_comp(k) + gv ) * ( ibit3 + ibit4 + ibit5 )             &
+                  - ( v(k,j,i)   + v(k,j,i-1 )  )                              &
+                                    * (                                        &
+                     REAL( IBITS(advc_flags_m(k,j-1,i),3,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),4,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),5,1), KIND = wp )       &
+                                      )                                        &
+                  ) * ddy                                                      &
+               +  ( w_comp(k)   * rho_air_zw(k) * ( ibit6 + ibit7 + ibit8 )    &
+                -   w_comp(k-1) * rho_air_zw(k-1)                              &
+                                    * (                                        &
+                     REAL( IBITS(advc_flags_m(k-1,j,i),6,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),7,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),8,1), KIND = wp )       &
+                                      )                                        &  
+                  ) * drho_air(k) * ddzw(k)                                    &
+                ) * 0.5_wp                                                     
+                                                                               
+          tend(k,j,i) = tend(k,j,i) - (                                        &
+                            ( flux_r(k) + diss_r(k)                            &
+                          -   flux_l_u(k,j,tn) - diss_l_u(k,j,tn) ) * ddx      &
+                          + ( flux_n(k) + diss_n(k)                            &
+                          -   flux_s_u(k,tn) - diss_s_u(k,tn)     ) * ddy      &
+                          + ( ( flux_t(k) + diss_t(k) )                        &
+                          -   ( flux_d    + diss_d    )                        &
+                                                    ) * drho_air(k) * ddzw(k)  &
                                        ) + div * u(k,j,i)
 
@@ -2450,13 +2680,13 @@
        INTEGER(iwp)  ::  tn        !< number of OpenMP thread
        
-       REAL(wp)      ::  ibit18   !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)      ::  ibit19   !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)      ::  ibit20   !< flag indicating 5th-order scheme along x-direction
-       REAL(wp)      ::  ibit21   !< flag indicating 1st-order scheme along y-direction 
-       REAL(wp)      ::  ibit22   !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)      ::  ibit23   !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)      ::  ibit24   !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)      ::  ibit25   !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)      ::  ibit26   !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)      ::  ibit9    !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)      ::  ibit10   !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)      ::  ibit11   !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)      ::  ibit12   !< flag indicating 1st-order scheme along y-direction 
+       REAL(wp)      ::  ibit13   !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)      ::  ibit14   !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)      ::  ibit15   !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)      ::  ibit16   !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)      ::  ibit17   !< flag indicating 3rd-order scheme along z-direction
        REAL(wp)      ::  diss_d   !< artificial dissipation term at grid box bottom
        REAL(wp)      ::  div      !< divergence on v-grid
@@ -2498,20 +2728,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit20 = REAL( IBITS(advc_flags_1(k,j,i-1),20,1), KIND = wp )
-             ibit19 = REAL( IBITS(advc_flags_1(k,j,i-1),19,1), KIND = wp )
-             ibit18 = REAL( IBITS(advc_flags_1(k,j,i-1),18,1), KIND = wp )
+             ibit11 = REAL( IBITS(advc_flags_m(k,j,i-1),11,1), KIND = wp )
+             ibit10 = REAL( IBITS(advc_flags_m(k,j,i-1),10,1), KIND = wp )
+             ibit9  = REAL( IBITS(advc_flags_m(k,j,i-1),9,1),  KIND = wp )
 
              u_comp(k)        = u(k,j-1,i) + u(k,j,i) - gu
              flux_l_v(k,j,tn) = u_comp(k) * (                                 &
-                              ( 37.0_wp * ibit20 * adv_mom_5                  &
-                           +     7.0_wp * ibit19 * adv_mom_3                  &
-                           +              ibit18 * adv_mom_1                  &
+                              ( 37.0_wp * ibit11 * adv_mom_5                  &
+                           +     7.0_wp * ibit10 * adv_mom_3                  &
+                           +              ibit9  * adv_mom_1                  &
                               ) *                                             &
                                         ( v(k,j,i)   + v(k,j,i-1) )           &
-                       -      (  8.0_wp * ibit20 * adv_mom_5                  &
-                           +              ibit19 * adv_mom_3                  &
+                       -      (  8.0_wp * ibit11 * adv_mom_5                  &
+                           +              ibit10 * adv_mom_3                  &
                               ) *                                             &
                                         ( v(k,j,i+1) + v(k,j,i-2) )           &
-                       +      (           ibit20 * adv_mom_5                  &
+                       +      (           ibit11 * adv_mom_5                  &
                               ) *                                             &
                                         ( v(k,j,i+2) + v(k,j,i-3) )           &
@@ -2519,14 +2749,14 @@
 
               diss_l_v(k,j,tn) = - ABS( u_comp(k) ) * (                       &
-                              ( 10.0_wp * ibit20 * adv_mom_5                  &
-                           +     3.0_wp * ibit19 * adv_mom_3                  &
-                           +              ibit18 * adv_mom_1                  &
+                              ( 10.0_wp * ibit11 * adv_mom_5                  &
+                           +     3.0_wp * ibit10 * adv_mom_3                  &
+                           +              ibit9  * adv_mom_1                  &
                               ) *                                             &
                                         ( v(k,j,i)   - v(k,j,i-1) )           &
-                       -      (  5.0_wp * ibit20 * adv_mom_5                  &
-                           +              ibit19 * adv_mom_3                  &
+                       -      (  5.0_wp * ibit11 * adv_mom_5                  &
+                           +              ibit10 * adv_mom_3                  &
                               ) *                                             &
                                         ( v(k,j,i+1) - v(k,j,i-2) )           &
-                       +      (           ibit20 * adv_mom_5                  &
+                       +      (           ibit11 * adv_mom_5                  &
                               ) *                                             &
                                         ( v(k,j,i+2) - v(k,j,i-3) )           &
@@ -2537,11 +2767,11 @@
           DO  k = nzb_max_l+1, nzt
 
-             u_comp(k)           = u(k,j-1,i) + u(k,j,i) - gu
+             u_comp(k)        = u(k,j-1,i) + u(k,j,i) - gu
              flux_l_v(k,j,tn) = u_comp(k) * (                                 &
-                             37.0_wp * ( v(k,j,i) + v(k,j,i-1)   )            &
+                             37.0_wp * ( v(k,j,i)   + v(k,j,i-1)   )          &
                            -  8.0_wp * ( v(k,j,i+1) + v(k,j,i-2) )            &
                            +           ( v(k,j,i+2) + v(k,j,i-3) ) ) * adv_mom_5
              diss_l_v(k,j,tn) = - ABS( u_comp(k) ) * (                        &
-                             10.0_wp * ( v(k,j,i) - v(k,j,i-1)   )            &
+                             10.0_wp * ( v(k,j,i)   - v(k,j,i-1)   )          &
                            -  5.0_wp * ( v(k,j,i+1) - v(k,j,i-2) )            &
                            +           ( v(k,j,i+2) - v(k,j,i-3) ) ) * adv_mom_5
@@ -2556,20 +2786,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit23 = REAL( IBITS(advc_flags_1(k,j-1,i),23,1), KIND = wp )
-             ibit22 = REAL( IBITS(advc_flags_1(k,j-1,i),22,1), KIND = wp )
-             ibit21 = REAL( IBITS(advc_flags_1(k,j-1,i),21,1), KIND = wp )
+             ibit14 = REAL( IBITS(advc_flags_m(k,j-1,i),14,1), KIND = wp )
+             ibit13 = REAL( IBITS(advc_flags_m(k,j-1,i),13,1), KIND = wp )
+             ibit12 = REAL( IBITS(advc_flags_m(k,j-1,i),12,1), KIND = wp )
 
              v_comp_l       = v(k,j,i) + v(k,j-1,i) - gv
              flux_s_v(k,tn) = v_comp_l * (                                    &
-                            ( 37.0_wp * ibit23 * adv_mom_5                    &
-                         +     7.0_wp * ibit22 * adv_mom_3                    &
-                         +              ibit21 * adv_mom_1                    &
+                            ( 37.0_wp * ibit14 * adv_mom_5                    &
+                         +     7.0_wp * ibit13 * adv_mom_3                    &
+                         +              ibit12 * adv_mom_1                    &
                             ) *                                               &
                                         ( v(k,j,i)   + v(k,j-1,i) )           &
-                     -      (  8.0_wp * ibit23 * adv_mom_5                    &
-                         +              ibit22 * adv_mom_3                    &
+                     -      (  8.0_wp * ibit14 * adv_mom_5                    &
+                         +              ibit13 * adv_mom_3                    &
                             ) *                                               &
                                         ( v(k,j+1,i) + v(k,j-2,i) )           &
-                     +      (           ibit23 * adv_mom_5                    &
+                     +      (           ibit14 * adv_mom_5                    &
                             ) *                                               &
                                         ( v(k,j+2,i) + v(k,j-3,i) )           &
@@ -2577,14 +2807,14 @@
 
              diss_s_v(k,tn) = - ABS( v_comp_l ) * (                           &
-                            ( 10.0_wp * ibit23 * adv_mom_5                    &
-                         +     3.0_wp * ibit22 * adv_mom_3                    &
-                         +              ibit21 * adv_mom_1                    &
+                            ( 10.0_wp * ibit14 * adv_mom_5                    &
+                         +     3.0_wp * ibit13 * adv_mom_3                    &
+                         +              ibit12 * adv_mom_1                    &
                             ) *                                               &
                                         ( v(k,j,i)   - v(k,j-1,i) )           &
-                     -      (  5.0_wp * ibit23 * adv_mom_5                    &
-                         +              ibit22 * adv_mom_3                    &
+                     -      (  5.0_wp * ibit14 * adv_mom_5                    &
+                         +              ibit13 * adv_mom_3                    &
                             ) *                                               &
                                         ( v(k,j+1,i) - v(k,j-2,i) )           &
-                     +      (           ibit23 * adv_mom_5                    &
+                     +      (           ibit14 * adv_mom_5                    &
                             ) *                                               &
                                         ( v(k,j+2,i) - v(k,j-3,i) )           &
@@ -2597,9 +2827,9 @@
              v_comp_l       = v(k,j,i) + v(k,j-1,i) - gv
              flux_s_v(k,tn) = v_comp_l * (                                    &
-                           37.0_wp * ( v(k,j,i) + v(k,j-1,i)   )              &
+                           37.0_wp * ( v(k,j,i)   + v(k,j-1,i)   )            &
                          -  8.0_wp * ( v(k,j+1,i) + v(k,j-2,i) )              &
                          +           ( v(k,j+2,i) + v(k,j-3,i) ) ) * adv_mom_5
              diss_s_v(k,tn) = - ABS( v_comp_l ) * (                           &
-                           10.0_wp * ( v(k,j,i) - v(k,j-1,i)   )              &
+                           10.0_wp * ( v(k,j,i)   - v(k,j-1,i)   )            &
                          -  5.0_wp * ( v(k,j+1,i) - v(k,j-2,i) )              &
                          +           ( v(k,j+2,i) - v(k,j-3,i) ) ) * adv_mom_5
@@ -2613,20 +2843,20 @@
        DO  k = nzb+1, nzb_max_l
 
-          ibit20 = REAL( IBITS(advc_flags_1(k,j,i),20,1), KIND = wp )
-          ibit19 = REAL( IBITS(advc_flags_1(k,j,i),19,1), KIND = wp )
-          ibit18 = REAL( IBITS(advc_flags_1(k,j,i),18,1), KIND = wp )
+          ibit11 = REAL( IBITS(advc_flags_m(k,j,i),11,1), KIND = wp )
+          ibit10 = REAL( IBITS(advc_flags_m(k,j,i),10,1), KIND = wp )
+          ibit9  = REAL( IBITS(advc_flags_m(k,j,i),9,1),  KIND = wp )
  
           u_comp(k) = u(k,j-1,i+1) + u(k,j,i+1) - gu
           flux_r(k) = u_comp(k) * (                                           &
-                     ( 37.0_wp * ibit20 * adv_mom_5                           &
-                  +     7.0_wp * ibit19 * adv_mom_3                           &
-                  +              ibit18 * adv_mom_1                           &
+                     ( 37.0_wp * ibit11 * adv_mom_5                           &
+                  +     7.0_wp * ibit10 * adv_mom_3                           &
+                  +              ibit9  * adv_mom_1                           &
                      ) *                                                      &
                                     ( v(k,j,i+1) + v(k,j,i)   )               &
-              -      (  8.0_wp * ibit20 * adv_mom_5                           &
-                  +              ibit19 * adv_mom_3                           &
+              -      (  8.0_wp * ibit11 * adv_mom_5                           &
+                  +              ibit10 * adv_mom_3                           &
                      ) *                                                      &
                                     ( v(k,j,i+2) + v(k,j,i-1) )               &
-              +      (           ibit20 * adv_mom_5                           &
+              +      (           ibit11 * adv_mom_5                           &
                      ) *                                                      &
                                     ( v(k,j,i+3) + v(k,j,i-2) )               &
@@ -2634,35 +2864,35 @@
 
           diss_r(k) = - ABS( u_comp(k) ) * (                                  &
-                     ( 10.0_wp * ibit20 * adv_mom_5                           &
-                  +     3.0_wp * ibit19 * adv_mom_3                           &
-                  +              ibit18 * adv_mom_1                           &
+                     ( 10.0_wp * ibit11 * adv_mom_5                           &
+                  +     3.0_wp * ibit10 * adv_mom_3                           &
+                  +              ibit9  * adv_mom_1                           &
                      ) *                                                      &
                                     ( v(k,j,i+1) - v(k,j,i)  )                &
-              -      (  5.0_wp * ibit20 * adv_mom_5                           &
-                  +              ibit19 * adv_mom_3                           &
+              -      (  5.0_wp * ibit11 * adv_mom_5                           &
+                  +              ibit10 * adv_mom_3                           &
                      ) *                                                      &
                                     ( v(k,j,i+2) - v(k,j,i-1) )               &
-              +      (           ibit20 * adv_mom_5                           &
+              +      (           ibit11 * adv_mom_5                           &
                      ) *                                                      &
                                     ( v(k,j,i+3) - v(k,j,i-2) )               &
                                            )
 
-          ibit23 = REAL( IBITS(advc_flags_1(k,j,i),23,1), KIND = wp )
-          ibit22 = REAL( IBITS(advc_flags_1(k,j,i),22,1), KIND = wp )
-          ibit21 = REAL( IBITS(advc_flags_1(k,j,i),21,1), KIND = wp )
+          ibit14 = REAL( IBITS(advc_flags_m(k,j,i),14,1), KIND = wp )
+          ibit13 = REAL( IBITS(advc_flags_m(k,j,i),13,1), KIND = wp )
+          ibit12 = REAL( IBITS(advc_flags_m(k,j,i),12,1), KIND = wp )
 
 
           v_comp(k) = v(k,j+1,i) + v(k,j,i)
           flux_n(k) = ( v_comp(k) - gv ) * (                                  &
-                     ( 37.0_wp * ibit23 * adv_mom_5                           &
-                  +     7.0_wp * ibit22 * adv_mom_3                           &
-                  +              ibit21 * adv_mom_1                           &
+                     ( 37.0_wp * ibit14 * adv_mom_5                           &
+                  +     7.0_wp * ibit13 * adv_mom_3                           &
+                  +              ibit12 * adv_mom_1                           &
                      ) *                                                      &
                                     ( v(k,j+1,i) + v(k,j,i)   )               &
-              -      (  8.0_wp * ibit23 * adv_mom_5                           &
-                  +              ibit22 * adv_mom_3                           &
+              -      (  8.0_wp * ibit14 * adv_mom_5                           &
+                  +              ibit13 * adv_mom_3                           &
                      ) *                                                      &
                                     ( v(k,j+2,i) + v(k,j-1,i) )               &
-              +      (           ibit23 * adv_mom_5                           &
+              +      (           ibit14 * adv_mom_5                           &
                      ) *                                                      &
                                     ( v(k,j+3,i) + v(k,j-2,i) )               &
@@ -2670,14 +2900,14 @@
 
           diss_n(k) = - ABS( v_comp(k) - gv ) * (                             &
-                     ( 10.0_wp * ibit23 * adv_mom_5                           &
-                  +     3.0_wp * ibit22 * adv_mom_3                           &
-                  +              ibit21 * adv_mom_1                           &
+                     ( 10.0_wp * ibit14 * adv_mom_5                           &
+                  +     3.0_wp * ibit13 * adv_mom_3                           &
+                  +              ibit12 * adv_mom_1                           &
                      ) *                                                      &
                                     ( v(k,j+1,i) - v(k,j,i)   )               &
-              -      (  5.0_wp * ibit23 * adv_mom_5                           &
-                  +              ibit22 * adv_mom_3                           &
+              -      (  5.0_wp * ibit14 * adv_mom_5                           &
+                  +              ibit13 * adv_mom_3                           &
                      ) *                                                      &
                                     ( v(k,j+2,i) - v(k,j-1,i) )               &
-              +      (           ibit23 * adv_mom_5                           &
+              +      (           ibit14 * adv_mom_5                           &
                      ) *                                                      &
                                     ( v(k,j+3,i) - v(k,j-2,i) )               &
@@ -2718,5 +2948,5 @@
 !--    calculated explicetely for the tendency at
 !--    the first w-level. For topography wall this is done implicitely by
-!--    advc_flags_1.
+!--    advc_flags_m.
        flux_t(nzb) = 0.0_wp
        diss_t(nzb) = 0.0_wp
@@ -2727,24 +2957,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-          ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-          ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit26
-          k_pp  = k + 2 * ( 1 - ibit24  )
-          k_mm  = k - 2 * ibit26
+          ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+          ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+          ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit17
+          k_pp  = k + 2 * ( 1 - ibit15  )
+          k_mm  = k - 2 * ibit17
 
           w_comp(k) = w(k,j-1,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit26 * adv_mom_5                           &
-                  +     7.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
+                     ( 37.0_wp * ibit17 * adv_mom_5                           &
+                  +     7.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
                      ) *                                                      &
                                 ( v(k+1,j,i)   + v(k,j,i)    )                &
-              -      (  8.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
+              -      (  8.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
                      ) *                                                      &
                                 ( v(k_pp,j,i)  + v(k-1,j,i)  )                &
-              +      (           ibit26 * adv_mom_5                           &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k_ppp,j,i) + v(k_mm,j,i) )                &
@@ -2752,14 +2982,14 @@
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit26 * adv_mom_5                           &
-                  +     3.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
+                     ( 10.0_wp * ibit17 * adv_mom_5                           &
+                  +     3.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
                      ) *                                                      &
                                 ( v(k+1,j,i)   - v(k,j,i)    )                &
-              -      (  5.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
+              -      (  5.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
                      ) *                                                      &
                                 ( v(k_pp,j,i)  - v(k-1,j,i)  )                &
-              +      (           ibit26 * adv_mom_5                           &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k_ppp,j,i) - v(k_mm,j,i) )                &
@@ -2769,20 +2999,20 @@
        DO  k = nzb+3, nzt-2
 
-          ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-          ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-          ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
+          ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+          ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+          ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
 
           w_comp(k) = w(k,j-1,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit26 * adv_mom_5                           &
-                  +     7.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( v(k+1,j,i)   + v(k,j,i)    )                &
-              -      (  8.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( v(k+2,j,i)  + v(k-1,j,i)  )                 &
-              +      (           ibit26 * adv_mom_5                           &
+                     ( 37.0_wp * ibit17 * adv_mom_5                           &
+                  +     7.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( v(k+1,j,i) + v(k,j,i)   )                   &
+              -      (  8.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
+                     ) *                                                      &
+                                ( v(k+2,j,i) + v(k-1,j,i) )                   &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k+3,j,i) + v(k-2,j,i) )                   &
@@ -2790,14 +3020,14 @@
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit26 * adv_mom_5                           &
-                  +     3.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( v(k+1,j,i)   - v(k,j,i)    )                &
-              -      (  5.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( v(k+2,j,i)  - v(k-1,j,i)  )                 &
-              +      (           ibit26 * adv_mom_5                           &
+                     ( 10.0_wp * ibit17 * adv_mom_5                           &
+                  +     3.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( v(k+1,j,i) - v(k,j,i)   )                   &
+              -      (  5.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
+                     ) *                                                      &
+                                ( v(k+2,j,i) - v(k-1,j,i) )                    &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k+3,j,i) - v(k-2,j,i) )                   &
@@ -2809,24 +3039,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-          ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-          ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit26
-          k_pp  = k + 2 * ( 1 - ibit24  )
-          k_mm  = k - 2 * ibit26
+          ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+          ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+          ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit17
+          k_pp  = k + 2 * ( 1 - ibit15  )
+          k_mm  = k - 2 * ibit17
 
           w_comp(k) = w(k,j-1,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air_zw(k) * (                           &
-                     ( 37.0_wp * ibit26 * adv_mom_5                           &
-                  +     7.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
+                     ( 37.0_wp * ibit17 * adv_mom_5                           &
+                  +     7.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
                      ) *                                                      &
                                 ( v(k+1,j,i)   + v(k,j,i)    )                &
-              -      (  8.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
+              -      (  8.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
                      ) *                                                      &
                                 ( v(k_pp,j,i)  + v(k-1,j,i)  )                &
-              +      (           ibit26 * adv_mom_5                           &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k_ppp,j,i) + v(k_mm,j,i) )                &
@@ -2834,14 +3064,14 @@
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air_zw(k) * (                  &
-                     ( 10.0_wp * ibit26 * adv_mom_5                           &
-                  +     3.0_wp * ibit25 * adv_mom_3                           &
-                  +              ibit24 * adv_mom_1                           &
+                     ( 10.0_wp * ibit17 * adv_mom_5                           &
+                  +     3.0_wp * ibit16 * adv_mom_3                           &
+                  +              ibit15 * adv_mom_1                           &
                      ) *                                                      &
                                 ( v(k+1,j,i)   - v(k,j,i)    )                &
-              -      (  5.0_wp * ibit26 * adv_mom_5                           &
-                  +              ibit25 * adv_mom_3                           &
+              -      (  5.0_wp * ibit17 * adv_mom_5                           &
+                  +              ibit16 * adv_mom_3                           &
                      ) *                                                      &
                                 ( v(k_pp,j,i)  - v(k-1,j,i)  )                &
-              +      (           ibit26 * adv_mom_5                           &
+              +      (           ibit17 * adv_mom_5                           &
                      ) *                                                      &
                                 ( v(k_ppp,j,i) - v(k_mm,j,i) )                &
@@ -2854,15 +3084,15 @@
           diss_d    = diss_t(k-1)
           
-          ibit20 = REAL( IBITS(advc_flags_1(k,j,i),20,1), KIND = wp )
-          ibit19 = REAL( IBITS(advc_flags_1(k,j,i),19,1), KIND = wp )
-          ibit18 = REAL( IBITS(advc_flags_1(k,j,i),18,1), KIND = wp )
+          ibit11 = REAL( IBITS(advc_flags_m(k,j,i),11,1), KIND = wp )
+          ibit10 = REAL( IBITS(advc_flags_m(k,j,i),10,1), KIND = wp )
+          ibit9  = REAL( IBITS(advc_flags_m(k,j,i),9,1), KIND = wp )
           
-          ibit23 = REAL( IBITS(advc_flags_1(k,j,i),23,1), KIND = wp )
-          ibit22 = REAL( IBITS(advc_flags_1(k,j,i),22,1), KIND = wp )
-          ibit21 = REAL( IBITS(advc_flags_1(k,j,i),21,1), KIND = wp )
+          ibit14 = REAL( IBITS(advc_flags_m(k,j,i),14,1), KIND = wp )
+          ibit13 = REAL( IBITS(advc_flags_m(k,j,i),13,1), KIND = wp )
+          ibit12 = REAL( IBITS(advc_flags_m(k,j,i),12,1), KIND = wp )
           
-          ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-          ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-          ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
+          ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+          ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+          ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
 !
 !--       Calculate the divergence of the velocity field. A respective
@@ -2870,27 +3100,27 @@
 !--       by a not sufficient reduction of divergences near topography.
           div = ( ( ( u_comp(k)     + gu )                                    &
-                                       * ( ibit18 + ibit19 + ibit20 )         &
+                                       * ( ibit9 + ibit10 + ibit11 )          &
                   - ( u(k,j-1,i) + u(k,j,i) )                                 &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j,i-1),18,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),19,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),20,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k,j,i-1),9,1),  KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j,i-1),10,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j,i-1),11,1), KIND = wp )  &
                                          )                                    &
                   ) * ddx                                                     &
                +  ( v_comp(k)                                                 &
-                                       * ( ibit21 + ibit22 + ibit23 )         &
+                                       * ( ibit12 + ibit13 + ibit14 )         &
                 - ( v(k,j,i)     + v(k,j-1,i) )                               &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j-1,i),21,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),22,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),23,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k,j-1,i),12,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j-1,i),13,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j-1,i),14,1), KIND = wp )  &
                                          )                                    &
                   ) * ddy                                                     &
-               +  ( w_comp(k)   * rho_air_zw(k) * ( ibit24 + ibit25 + ibit26 )&
+               +  ( w_comp(k)   * rho_air_zw(k) * ( ibit15 + ibit16 + ibit17 )&
                 -   w_comp(k-1) * rho_air_zw(k-1)                             &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k-1,j,i),24,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),25,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),26,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k-1,j,i),15,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k-1,j,i),16,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k-1,j,i),17,1), KIND = wp )  &
                                          )                                    &
                    ) * drho_air(k) * ddzw(k)                                  &
@@ -3011,13 +3241,13 @@
        INTEGER(iwp) ::  tn        !< number of OpenMP thread
        
-       REAL(wp)    ::  ibit27  !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit28  !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit29  !< flag indicating 5th-order scheme along x-direction
-       REAL(wp)    ::  ibit30  !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit31  !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit32  !< flag indicating 5th-order scheme along y-direction
-       REAL(wp)    ::  ibit33  !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)    ::  ibit34  !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)    ::  ibit35  !< flag indicating 5th-order scheme along z-direction
+       REAL(wp)    ::  ibit18  !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit19  !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit20  !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit21  !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit22  !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit23  !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit24  !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)    ::  ibit25  !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)    ::  ibit26  !< flag indicating 5th-order scheme along z-direction
        REAL(wp)    ::  diss_d  !< discretized artificial dissipation at top of the grid box
        REAL(wp)    ::  div     !< divergence on w-grid
@@ -3056,20 +3286,20 @@
 
           DO  k = nzb+1, nzb_max_l
-             ibit32 = REAL( IBITS(advc_flags_2(k,j-1,i),0,1),  KIND = wp )
-             ibit31 = REAL( IBITS(advc_flags_1(k,j-1,i),31,1), KIND = wp )
-             ibit30 = REAL( IBITS(advc_flags_1(k,j-1,i),30,1), KIND = wp )
+             ibit23 = REAL( IBITS(advc_flags_m(k,j-1,i),23,1), KIND = wp )
+             ibit22 = REAL( IBITS(advc_flags_m(k,j-1,i),22,1), KIND = wp )
+             ibit21 = REAL( IBITS(advc_flags_m(k,j-1,i),21,1), KIND = wp )
 
              v_comp(k)      = v(k+1,j,i) + v(k,j,i) - gv
              flux_s_w(k,tn) = v_comp(k) * (                                   &
-                            ( 37.0_wp * ibit32 * adv_mom_5                    &
-                         +     7.0_wp * ibit31 * adv_mom_3                    &
-                         +              ibit30 * adv_mom_1                    &
+                            ( 37.0_wp * ibit23 * adv_mom_5                    &
+                         +     7.0_wp * ibit22 * adv_mom_3                    &
+                         +              ibit21 * adv_mom_1                    &
                             ) *                                               &
                                         ( w(k,j,i)   + w(k,j-1,i) )           &
-                     -      (  8.0_wp * ibit32 * adv_mom_5                    &
-                         +              ibit31 * adv_mom_3                    &
+                     -      (  8.0_wp * ibit23 * adv_mom_5                    &
+                         +              ibit22 * adv_mom_3                    &
                             ) *                                               &
                                         ( w(k,j+1,i) + w(k,j-2,i) )           &
-                     +      (           ibit32 * adv_mom_5                    &
+                     +      (           ibit23 * adv_mom_5                    &
                             ) *                                               &
                                         ( w(k,j+2,i) + w(k,j-3,i) )           &
@@ -3077,14 +3307,14 @@
 
              diss_s_w(k,tn) = - ABS( v_comp(k) ) * (                          &
-                            ( 10.0_wp * ibit32 * adv_mom_5                    &
-                         +     3.0_wp * ibit31 * adv_mom_3                    &
-                         +              ibit30 * adv_mom_1                    &
+                            ( 10.0_wp * ibit23 * adv_mom_5                    &
+                         +     3.0_wp * ibit22 * adv_mom_3                    &
+                         +              ibit21 * adv_mom_1                    &
                             ) *                                               &
                                         ( w(k,j,i)   - w(k,j-1,i) )           &
-                     -      (  5.0_wp * ibit32 * adv_mom_5                    &
-                         +              ibit31 * adv_mom_3                    &
+                     -      (  5.0_wp * ibit23 * adv_mom_5                    &
+                         +              ibit22 * adv_mom_3                    &
                             ) *                                               &
                                         ( w(k,j+1,i) - w(k,j-2,i) )           &
-                     +      (           ibit32 * adv_mom_5                    &
+                     +      (           ibit23 * adv_mom_5                    &
                             ) *                                               &
                                         ( w(k,j+2,i) - w(k,j-3,i) )           &
@@ -3097,9 +3327,9 @@
              v_comp(k)      = v(k+1,j,i) + v(k,j,i) - gv
              flux_s_w(k,tn) = v_comp(k) * (                                   &
-                           37.0_wp * ( w(k,j,i) + w(k,j-1,i)   )              &
-                         -  8.0_wp * ( w(k,j+1,i) +w(k,j-2,i)  )              &
+                           37.0_wp * ( w(k,j,i)   + w(k,j-1,i) )              &
+                         -  8.0_wp * ( w(k,j+1,i) + w(k,j-2,i) )              &
                          +           ( w(k,j+2,i) + w(k,j-3,i) ) ) * adv_mom_5
              diss_s_w(k,tn) = - ABS( v_comp(k) ) * (                          &
-                           10.0_wp * ( w(k,j,i) - w(k,j-1,i)   )              &
+                           10.0_wp * ( w(k,j,i)   - w(k,j-1,i) )              &
                          -  5.0_wp * ( w(k,j+1,i) - w(k,j-2,i) )              &
                          +           ( w(k,j+2,i) - w(k,j-3,i) ) ) * adv_mom_5
@@ -3114,20 +3344,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit29 = REAL( IBITS(advc_flags_1(k,j,i-1),29,1), KIND = wp )
-             ibit28 = REAL( IBITS(advc_flags_1(k,j,i-1),28,1), KIND = wp )
-             ibit27 = REAL( IBITS(advc_flags_1(k,j,i-1),27,1), KIND = wp )
+             ibit20 = REAL( IBITS(advc_flags_m(k,j,i-1),20,1), KIND = wp )
+             ibit19 = REAL( IBITS(advc_flags_m(k,j,i-1),19,1), KIND = wp )
+             ibit18 = REAL( IBITS(advc_flags_m(k,j,i-1),18,1), KIND = wp )
 
              u_comp(k)        = u(k+1,j,i) + u(k,j,i) - gu
              flux_l_w(k,j,tn) = u_comp(k) * (                                 &
-                             ( 37.0_wp * ibit29 * adv_mom_5                   &
-                          +     7.0_wp * ibit28 * adv_mom_3                   &
-                          +              ibit27 * adv_mom_1                   &
+                             ( 37.0_wp * ibit20 * adv_mom_5                   &
+                          +     7.0_wp * ibit19 * adv_mom_3                   &
+                          +              ibit18 * adv_mom_1                   &
                              ) *                                              &
                                         ( w(k,j,i)   + w(k,j,i-1) )           &
-                      -      (  8.0_wp * ibit29 * adv_mom_5                   &
-                          +              ibit28 * adv_mom_3                   &
+                      -      (  8.0_wp * ibit20 * adv_mom_5                   &
+                          +              ibit19 * adv_mom_3                   &
                              ) *                                              &
                                         ( w(k,j,i+1) + w(k,j,i-2) )           &
-                      +      (           ibit29 * adv_mom_5                   &
+                      +      (           ibit20 * adv_mom_5                   &
                              ) *                                              &
                                         ( w(k,j,i+2) + w(k,j,i-3) )           &
@@ -3135,14 +3365,14 @@
 
                diss_l_w(k,j,tn) = - ABS( u_comp(k) ) * (                      &
-                             ( 10.0_wp * ibit29 * adv_mom_5                   &
-                          +     3.0_wp * ibit28 * adv_mom_3                   &
-                          +              ibit27 * adv_mom_1                   &
+                             ( 10.0_wp * ibit20 * adv_mom_5                   &
+                          +     3.0_wp * ibit19 * adv_mom_3                   &
+                          +              ibit18 * adv_mom_1                   &
                              ) *                                              &
                                         ( w(k,j,i)   - w(k,j,i-1) )           &
-                      -      (  5.0_wp * ibit29 * adv_mom_5                   &
-                          +              ibit28 * adv_mom_3                   &
+                      -      (  5.0_wp * ibit20 * adv_mom_5                   &
+                          +              ibit19 * adv_mom_3                   &
                              ) *                                              &
                                         ( w(k,j,i+1) - w(k,j,i-2) )           &
-                      +      (           ibit29 * adv_mom_5                   &
+                      +      (           ibit20 * adv_mom_5                   &
                              ) *                                              &
                                         ( w(k,j,i+2) - w(k,j,i-3) )           &
@@ -3155,9 +3385,9 @@
              u_comp(k)        = u(k+1,j,i) + u(k,j,i) - gu
              flux_l_w(k,j,tn) = u_comp(k) * (                                 &
-                            37.0_wp * ( w(k,j,i) + w(k,j,i-1)   )             &
+                            37.0_wp * ( w(k,j,i)   + w(k,j,i-1) )             &
                           -  8.0_wp * ( w(k,j,i+1) + w(k,j,i-2) )             &
                           +           ( w(k,j,i+2) + w(k,j,i-3) ) ) * adv_mom_5
              diss_l_w(k,j,tn) = - ABS( u_comp(k) ) * (                        &
-                            10.0_wp * ( w(k,j,i) - w(k,j,i-1)   )             &
+                            10.0_wp * ( w(k,j,i)   - w(k,j,i-1) )             &
                           -  5.0_wp * ( w(k,j,i+1) - w(k,j,i-2) )             &
                           +           ( w(k,j,i+2) - w(k,j,i-3) ) ) * adv_mom_5 
@@ -3171,20 +3401,20 @@
        DO  k = nzb+1, nzb_max_l
 
-          ibit29 = REAL( IBITS(advc_flags_1(k,j,i),29,1), KIND = wp )
-          ibit28 = REAL( IBITS(advc_flags_1(k,j,i),28,1), KIND = wp )
-          ibit27 = REAL( IBITS(advc_flags_1(k,j,i),27,1), KIND = wp )
+          ibit20 = REAL( IBITS(advc_flags_m(k,j,i),20,1), KIND = wp )
+          ibit19 = REAL( IBITS(advc_flags_m(k,j,i),19,1), KIND = wp )
+          ibit18 = REAL( IBITS(advc_flags_m(k,j,i),18,1), KIND = wp )
 
           u_comp(k) = u(k+1,j,i+1) + u(k,j,i+1) - gu
           flux_r(k) = u_comp(k) * (                                           &
-                     ( 37.0_wp * ibit29 * adv_mom_5                           &
-                  +     7.0_wp * ibit28 * adv_mom_3                           &
-                  +              ibit27 * adv_mom_1                           &
+                     ( 37.0_wp * ibit20 * adv_mom_5                           &
+                  +     7.0_wp * ibit19 * adv_mom_3                           &
+                  +              ibit18 * adv_mom_1                           &
                      ) *                                                      &
                                     ( w(k,j,i+1) + w(k,j,i)   )               &
-              -      (  8.0_wp * ibit29 * adv_mom_5                           &
-                  +              ibit28 * adv_mom_3                           &
+              -      (  8.0_wp * ibit20 * adv_mom_5                           &
+                  +              ibit19 * adv_mom_3                           &
                      ) *                                                      &
                                     ( w(k,j,i+2) + w(k,j,i-1) )               &
-              +      (           ibit29 * adv_mom_5                           &
+              +      (           ibit20 * adv_mom_5                           &
                      ) *                                                      &
                                     ( w(k,j,i+3) + w(k,j,i-2) )               &
@@ -3192,34 +3422,34 @@
 
           diss_r(k) = - ABS( u_comp(k) ) * (                                  &
-                     ( 10.0_wp * ibit29 * adv_mom_5                           &
-                  +     3.0_wp * ibit28 * adv_mom_3                           &
-                  +              ibit27 * adv_mom_1                           &
+                     ( 10.0_wp * ibit20 * adv_mom_5                           &
+                  +     3.0_wp * ibit19 * adv_mom_3                           &
+                  +              ibit18 * adv_mom_1                           &
                      ) *                                                      &
                                     ( w(k,j,i+1) - w(k,j,i)   )               &
-              -      (  5.0_wp * ibit29 * adv_mom_5                           &
-                  +              ibit28 * adv_mom_3                           &
+              -      (  5.0_wp * ibit20 * adv_mom_5                           &
+                  +              ibit19 * adv_mom_3                           &
                      ) *                                                      &
                                     ( w(k,j,i+2) - w(k,j,i-1) )               &
-              +      (           ibit29 * adv_mom_5                           &
+              +      (           ibit20 * adv_mom_5                           &
                      ) *                                                      &
                                     ( w(k,j,i+3) - w(k,j,i-2) )               &
                                            )
 
-          ibit32 = REAL( IBITS(advc_flags_2(k,j,i),0,1),  KIND = wp )
-          ibit31 = REAL( IBITS(advc_flags_1(k,j,i),31,1), KIND = wp )
-          ibit30 = REAL( IBITS(advc_flags_1(k,j,i),30,1), KIND = wp )
+          ibit23 = REAL( IBITS(advc_flags_m(k,j,i),23,1), KIND = wp )
+          ibit22 = REAL( IBITS(advc_flags_m(k,j,i),22,1), KIND = wp )
+          ibit21 = REAL( IBITS(advc_flags_m(k,j,i),21,1), KIND = wp )
 
           v_comp(k) = v(k+1,j+1,i) + v(k,j+1,i) - gv
           flux_n(k) = v_comp(k) * (                                           &
-                     ( 37.0_wp * ibit32 * adv_mom_5                           &
-                  +     7.0_wp * ibit31 * adv_mom_3                           &
-                  +              ibit30 * adv_mom_1                           &
+                     ( 37.0_wp * ibit23 * adv_mom_5                           &
+                  +     7.0_wp * ibit22 * adv_mom_3                           &
+                  +              ibit21 * adv_mom_1                           &
                      ) *                                                      &
                                     ( w(k,j+1,i) + w(k,j,i)   )               &
-              -      (  8.0_wp * ibit32 * adv_mom_5                           &
-                  +              ibit31 * adv_mom_3                           &
+              -      (  8.0_wp * ibit23 * adv_mom_5                           &
+                  +              ibit22 * adv_mom_3                           &
                      ) *                                                      &
                                     ( w(k,j+2,i) + w(k,j-1,i) )               &
-              +      (           ibit32 * adv_mom_5                           &
+              +      (           ibit23 * adv_mom_5                           &
                      ) *                                                      &
                                     ( w(k,j+3,i) + w(k,j-2,i) )               &
@@ -3227,16 +3457,16 @@
 
           diss_n(k) = - ABS( v_comp(k) ) * (                                  &
-                     ( 10.0_wp * ibit32 * adv_mom_5                           &
-                  +     3.0_wp * ibit31 * adv_mom_3                           &
-                  +              ibit30 * adv_mom_1                           &
-                     ) *                                                      &
-                                    ( w(k,j+1,i) - w(k,j,i)  )                &
-              -      (  5.0_wp * ibit32 * adv_mom_5                           &
-                  +              ibit31 * adv_mom_3                           &
-                     ) *                                                      &
-                                   ( w(k,j+2,i) - w(k,j-1,i) )                &
-              +      (           ibit32 * adv_mom_5                           &
-                     ) *                                                      &
-                                   ( w(k,j+3,i) - w(k,j-2,i) )                &
+                     ( 10.0_wp * ibit23 * adv_mom_5                           &
+                  +     3.0_wp * ibit22 * adv_mom_3                           &
+                  +              ibit21 * adv_mom_1                           &
+                     ) *                                                      &
+                                    ( w(k,j+1,i) - w(k,j,i)   )               &
+              -      (  5.0_wp * ibit23 * adv_mom_5                           &
+                  +              ibit22 * adv_mom_3                           &
+                     ) *                                                      &
+                                   ( w(k,j+2,i)  - w(k,j-1,i) )               &
+              +      (           ibit23 * adv_mom_5                           &
+                     ) *                                                      &
+                                   ( w(k,j+3,i)  - w(k,j-2,i) )               &
                                            )
        ENDDO
@@ -3275,5 +3505,5 @@
 !--    calculated explicetely for the tendency at
 !--    the first w-level. For topography wall this is done implicitely by
-!--    advc_flags_1.
+!--    advc_flags_m.
        k         = nzb + 1
        w_comp(k) = w(k,j,i) + w(k-1,j,i)
@@ -3285,24 +3515,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-          ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-          ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit35
-          k_pp  = k + 2 * ( 1 - ibit33  )
-          k_mm  = k - 2 * ibit35
+          ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+          ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+          ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit26
+          k_pp  = k + 2 * ( 1 - ibit24  )
+          k_mm  = k - 2 * ibit26
 
           w_comp(k) = w(k+1,j,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air(k+1) * (                            &
-                     ( 37.0_wp * ibit35 * adv_mom_5                           &
-                  +     7.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( w(k+1,j,i)  + w(k,j,i)     )                &
-              -      (  8.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
+                     ( 37.0_wp * ibit26 * adv_mom_5                           &
+                  +     7.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( w(k+1,j,i)   + w(k,j,i)    )                &
+              -      (  8.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
                      ) *                                                      &
                                 ( w(k_pp,j,i)  + w(k-1,j,i)  )                &
-              +      (           ibit35 * adv_mom_5                           &
+              +      (           ibit26 * adv_mom_5                           &
                      ) *                                                      &
                                 ( w(k_ppp,j,i) + w(k_mm,j,i) )                &
@@ -3310,14 +3540,14 @@
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air(k+1) * (                   &
-                     ( 10.0_wp * ibit35 * adv_mom_5                           &
-                  +     3.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
+                     ( 10.0_wp * ibit26 * adv_mom_5                           &
+                  +     3.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
                      ) *                                                      &
                                 ( w(k+1,j,i)   - w(k,j,i)    )                &
-              -      (  5.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
+              -      (  5.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
                      ) *                                                      &
                                 ( w(k_pp,j,i)  - w(k-1,j,i)  )                &
-              +      (           ibit35 * adv_mom_5                           &
+              +      (           ibit26 * adv_mom_5                           &
                      ) *                                                      &
                                 ( w(k_ppp,j,i) - w(k_mm,j,i) )                &
@@ -3327,37 +3557,37 @@
        DO  k = nzb+3, nzt-2
        
-          ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-          ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-          ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
+          ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+          ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+          ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
 
           w_comp(k) = w(k+1,j,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air(k+1) * (                            &
-                     ( 37.0_wp * ibit35 * adv_mom_5                           &
-                  +     7.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( w(k+1,j,i)  + w(k,j,i)     )                &
-              -      (  8.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( w(k+2,j,i)  + w(k-1,j,i)  )                 &
-              +      (           ibit35 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( w(k+3,j,i) + w(k-2,j,i) )                   &
+                     ( 37.0_wp * ibit26 * adv_mom_5                           &
+                  +     7.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( w(k+1,j,i)  + w(k,j,i)   )                  &
+              -      (  8.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
+                     ) *                                                      &
+                                ( w(k+2,j,i)  + w(k-1,j,i) )                  &
+              +      (           ibit26 * adv_mom_5                           &
+                     ) *                                                      &
+                                ( w(k+3,j,i)  + w(k-2,j,i) )                  &
                                                  )
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air(k+1) * (                   &
-                     ( 10.0_wp * ibit35 * adv_mom_5                           &
-                  +     3.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( w(k+1,j,i)   - w(k,j,i)    )                &
-              -      (  5.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
-                     ) *                                                      &
-                                ( w(k+2,j,i)  - w(k-1,j,i)  )                 &
-              +      (           ibit35 * adv_mom_5                           &
-                     ) *                                                      &
-                                ( w(k+3,j,i) - w(k-2,j,i) )                   &
+                     ( 10.0_wp * ibit26 * adv_mom_5                           &
+                  +     3.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( w(k+1,j,i) - w(k,j,i)    )                  &
+              -      (  5.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
+                     ) *                                                      &
+                                ( w(k+2,j,i) - w(k-1,j,i)  )                  &
+              +      (           ibit26 * adv_mom_5                           &
+                     ) *                                                      &
+                                ( w(k+3,j,i) - w(k-2,j,i)  )                  &
                                                           )
        ENDDO
@@ -3367,24 +3597,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-          ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-          ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
-
-          k_ppp = k + 3 * ibit35
-          k_pp  = k + 2 * ( 1 - ibit33  )
-          k_mm  = k - 2 * ibit35
+          ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+          ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+          ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
+
+          k_ppp = k + 3 * ibit26
+          k_pp  = k + 2 * ( 1 - ibit24  )
+          k_mm  = k - 2 * ibit26
 
           w_comp(k) = w(k+1,j,i) + w(k,j,i)
           flux_t(k) = w_comp(k) * rho_air(k+1) * (                            &
-                     ( 37.0_wp * ibit35 * adv_mom_5                           &
-                  +     7.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
-                     ) *                                                      &
-                                ( w(k+1,j,i)  + w(k,j,i)     )                &
-              -      (  8.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
+                     ( 37.0_wp * ibit26 * adv_mom_5                           &
+                  +     7.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
+                     ) *                                                      &
+                                ( w(k+1,j,i)   + w(k,j,i)    )                &
+              -      (  8.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
                      ) *                                                      &
                                 ( w(k_pp,j,i)  + w(k-1,j,i)  )                &
-              +      (           ibit35 * adv_mom_5                           &
+              +      (           ibit26 * adv_mom_5                           &
                      ) *                                                      &
                                 ( w(k_ppp,j,i) + w(k_mm,j,i) )                &
@@ -3392,14 +3622,14 @@
 
           diss_t(k) = - ABS( w_comp(k) ) * rho_air(k+1) * (                   &
-                     ( 10.0_wp * ibit35 * adv_mom_5                           &
-                  +     3.0_wp * ibit34 * adv_mom_3                           &
-                  +              ibit33 * adv_mom_1                           &
+                     ( 10.0_wp * ibit26 * adv_mom_5                           &
+                  +     3.0_wp * ibit25 * adv_mom_3                           &
+                  +              ibit24 * adv_mom_1                           &
                      ) *                                                      &
                                 ( w(k+1,j,i)   - w(k,j,i)    )                &
-              -      (  5.0_wp * ibit35 * adv_mom_5                           &
-                  +              ibit34 * adv_mom_3                           &
+              -      (  5.0_wp * ibit26 * adv_mom_5                           &
+                  +              ibit25 * adv_mom_3                           &
                      ) *                                                      &
                                 ( w(k_pp,j,i)  - w(k-1,j,i)  )                &
-              +      (           ibit35 * adv_mom_5                           &
+              +      (           ibit26 * adv_mom_5                           &
                      ) *                                                      &
                                 ( w(k_ppp,j,i) - w(k_mm,j,i) )                &
@@ -3412,42 +3642,42 @@
           diss_d    = diss_t(k-1)
           
-          ibit29 = REAL( IBITS(advc_flags_1(k,j,i),29,1), KIND = wp )
-          ibit28 = REAL( IBITS(advc_flags_1(k,j,i),28,1), KIND = wp )
-          ibit27 = REAL( IBITS(advc_flags_1(k,j,i),27,1), KIND = wp )
+          ibit20 = REAL( IBITS(advc_flags_m(k,j,i),20,1), KIND = wp )
+          ibit19 = REAL( IBITS(advc_flags_m(k,j,i),19,1), KIND = wp )
+          ibit18 = REAL( IBITS(advc_flags_m(k,j,i),18,1), KIND = wp )
           
-          ibit32 = REAL( IBITS(advc_flags_2(k,j,i),0,1),  KIND = wp )
-          ibit31 = REAL( IBITS(advc_flags_1(k,j,i),31,1), KIND = wp )
-          ibit30 = REAL( IBITS(advc_flags_1(k,j,i),30,1), KIND = wp )
+          ibit23 = REAL( IBITS(advc_flags_m(k,j,i),23,1), KIND = wp )
+          ibit22 = REAL( IBITS(advc_flags_m(k,j,i),22,1), KIND = wp )
+          ibit21 = REAL( IBITS(advc_flags_m(k,j,i),21,1), KIND = wp )
           
-          ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-          ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-          ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
+          ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+          ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+          ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
 !
 !--       Calculate the divergence of the velocity field. A respective
 !--       correction is needed to overcome numerical instabilities introduced
 !--       by a not sufficient reduction of divergences near topography.
-          div = ( ( ( u_comp(k) + gu ) * ( ibit27 + ibit28 + ibit29 )         &
+          div = ( ( ( u_comp(k) + gu ) * ( ibit18 + ibit19 + ibit20 )         &
                   - ( u(k+1,j,i) + u(k,j,i)   )                               & 
                                     * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j,i-1),27,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),28,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),29,1), KIND = wp )     &
+                     REAL( IBITS(advc_flags_m(k,j,i-1),18,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),19,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),20,1), KIND = wp )     &
                                       )                                       &
                   ) * ddx                                                     &
-              +   ( ( v_comp(k) + gv ) * ( ibit30 + ibit31 + ibit32 )         & 
+              +   ( ( v_comp(k) + gv ) * ( ibit21 + ibit22 + ibit23 )         & 
                   - ( v(k+1,j,i) + v(k,j,i)   )                               &
                                     * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j-1,i),30,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),31,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_2(k,j-1,i),0,1),  KIND = wp )     &
+                     REAL( IBITS(advc_flags_m(k,j-1,i),21,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),22,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),23,1), KIND = wp )     &
                                       )                                       &
                   ) * ddy                                                     &
               +   ( w_comp(k)               * rho_air(k+1)                    &
-                                            * ( ibit33 + ibit34 + ibit35 )    &
+                                            * ( ibit24 + ibit25 + ibit26 )    &
                 - ( w(k,j,i) + w(k-1,j,i) ) * rho_air(k)                      &
                                     * (                                       &
-                     REAL( IBITS(advc_flags_2(k-1,j,i),1,1), KIND = wp )      &
-                   + REAL( IBITS(advc_flags_2(k-1,j,i),2,1), KIND = wp )      &
-                   + REAL( IBITS(advc_flags_2(k-1,j,i),3,1), KIND = wp )      &
+                     REAL( IBITS(advc_flags_m(k-1,j,i),24,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),25,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),26,1), KIND = wp )     &
                                       )                                       & 
                   ) * drho_air_zw(k) * ddzu(k+1)                              &
@@ -3531,19 +3761,28 @@
 !> Scalar advection - Call for all grid points
 !------------------------------------------------------------------------------!
-    SUBROUTINE advec_s_ws( sk, sk_char )
+    SUBROUTINE advec_s_ws( advc_flag, sk, sk_char,                             &
+                           non_cyclic_l, non_cyclic_n,                         &
+                           non_cyclic_r, non_cyclic_s )
 
 
        CHARACTER (LEN = *), INTENT(IN)    ::  sk_char !< string identifier, used for assign fluxes to the correct dimension in the analysis array 
-       INTEGER(iwp) ::  sk_num !< integer identifier, used for assign fluxes to the correct dimension in the analysis array
+       INTEGER(iwp) ::  sk_num = 0 !< integer identifier, used for assign fluxes to the correct dimension in the analysis array
        
-       INTEGER(iwp) ::  i         !< grid index along x-direction
-       INTEGER(iwp) ::  j         !< grid index along y-direction
-       INTEGER(iwp) ::  k         !< grid index along z-direction
-       INTEGER(iwp) ::  k_mm      !< k-2 index in disretization, can be modified to avoid segmentation faults
-       INTEGER(iwp) ::  k_pp      !< k+2 index in disretization, can be modified to avoid segmentation faults
-       INTEGER(iwp) ::  k_ppp     !< k+3 index in disretization, can be modified to avoid segmentation faults
-       INTEGER(iwp) ::  nzb_max_l !< index indicating upper bound for order degradation of horizontal advection terms 
-       INTEGER(iwp) ::  tn = 0    !< number of OpenMP thread
+       INTEGER(iwp) ::  i          !< grid index along x-direction
+       INTEGER(iwp) ::  j          !< grid index along y-direction
+       INTEGER(iwp) ::  k          !< grid index along z-direction
+       INTEGER(iwp) ::  k_mm       !< k-2 index in disretization, can be modified to avoid segmentation faults
+       INTEGER(iwp) ::  k_pp       !< k+2 index in disretization, can be modified to avoid segmentation faults
+       INTEGER(iwp) ::  k_ppp      !< k+3 index in disretization, can be modified to avoid segmentation faults
+       INTEGER(iwp) ::  nzb_max_l  !< index indicating upper bound for order degradation of horizontal advection terms 
+       INTEGER(iwp) ::  tn = 0     !< number of OpenMP thread
        
+       INTEGER(iwp), INTENT(IN), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::   &
+                                                  advc_flag !< flag array to control order of scalar advection
+                                                  
+       LOGICAL ::  non_cyclic_l    !< flag that indicates non-cyclic boundary on the left
+       LOGICAL ::  non_cyclic_n    !< flag that indicates non-cyclic boundary on the north
+       LOGICAL ::  non_cyclic_r    !< flag that indicates non-cyclic boundary on the right
+       LOGICAL ::  non_cyclic_s    !< flag that indicates non-cyclic boundary on the south  
 !       
 !--    sk is an array from parameter list. It should not be a pointer, because 
@@ -3552,5 +3791,5 @@
 !--    even worse, because the compiler cannot assume strided one in the 
 !--    caller side.
-       REAL(wp), INTENT(IN),DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !<  advected scalar
+       REAL(wp), INTENT(IN), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  sk !<  advected scalar
 
        REAL(wp) ::  ibit0  !< flag indicating 1st-order scheme along x-direction
@@ -3612,8 +3851,6 @@
 !--    entire subdomain, in order to avoid unsymmetric loops which might be 
 !--    an issue for GPUs.
-       IF( bc_dirichlet_l  .OR.  bc_radiation_l  .OR.                          &
-           bc_dirichlet_r  .OR.  bc_radiation_r  .OR.                          &
-           bc_dirichlet_s  .OR.  bc_radiation_s  .OR.                          &
-           bc_dirichlet_n  .OR.  bc_radiation_n )  THEN
+       IF( non_cyclic_l  .OR.  non_cyclic_r  .OR.                             &
+           non_cyclic_s  .OR.  non_cyclic_n )  THEN
           nzb_max_l = nzt
        ELSE
@@ -3652,7 +3889,7 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit2 = REAL( IBITS(advc_flags_1(k,j,i-1),2,1), KIND = wp )
-             ibit1 = REAL( IBITS(advc_flags_1(k,j,i-1),1,1), KIND = wp )
-             ibit0 = REAL( IBITS(advc_flags_1(k,j,i-1),0,1), KIND = wp )
+             ibit2 = REAL( IBITS(advc_flag(k,j,i-1),2,1), KIND = wp )
+             ibit1 = REAL( IBITS(advc_flag(k,j,i-1),1,1), KIND = wp )
+             ibit0 = REAL( IBITS(advc_flag(k,j,i-1),0,1), KIND = wp )
 
              u_comp                 = u(k,j,i) - u_gtrans + u_stokes_zu(k)
@@ -3719,5 +3956,5 @@
        !$ACC PRIVATE(flux_t, diss_t, flux_d, diss_d) &
        !$ACC PRIVATE(div, u_comp, u_comp_l, v_comp, v_comp_s) &
-       !$ACC PRESENT(advc_flags_1) &
+       !$ACC PRESENT(advc_flag) &
        !$ACC PRESENT(sk, u, v, w, u_stokes_zu, v_stokes_zu) &
        !$ACC PRESENT(drho_air, rho_air_zw, ddzw) &
@@ -3736,7 +3973,7 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit5 = REAL( IBITS(advc_flags_1(k,j-1,i),5,1), KIND = wp )
-             ibit4 = REAL( IBITS(advc_flags_1(k,j-1,i),4,1), KIND = wp )
-             ibit3 = REAL( IBITS(advc_flags_1(k,j-1,i),3,1), KIND = wp )
+             ibit5 = REAL( IBITS(advc_flag(k,j-1,i),5,1), KIND = wp )
+             ibit4 = REAL( IBITS(advc_flag(k,j-1,i),4,1), KIND = wp )
+             ibit3 = REAL( IBITS(advc_flag(k,j-1,i),3,1), KIND = wp )
 
              v_comp               = v(k,j,i) - v_gtrans + v_stokes_zu(k)
@@ -3798,7 +4035,7 @@
              DO  k = nzb+1, nzb_max_l
 
-                ibit2 = REAL( IBITS(advc_flags_1(k,j,i),2,1), KIND = wp )
-                ibit1 = REAL( IBITS(advc_flags_1(k,j,i),1,1), KIND = wp )
-                ibit0 = REAL( IBITS(advc_flags_1(k,j,i),0,1), KIND = wp )
+                ibit2 = REAL( IBITS(advc_flag(k,j,i),2,1), KIND = wp )
+                ibit1 = REAL( IBITS(advc_flag(k,j,i),1,1), KIND = wp )
+                ibit0 = REAL( IBITS(advc_flag(k,j,i),0,1), KIND = wp )
 
                 u_comp = u(k,j,i+1) - u_gtrans + u_stokes_zu(k)
@@ -3836,7 +4073,7 @@
 !
 !--             Recompute the left fluxes.
-                ibit2_l = REAL( IBITS(advc_flags_1(k,j,i-1),2,1), KIND = wp )
-                ibit1_l = REAL( IBITS(advc_flags_1(k,j,i-1),1,1), KIND = wp )
-                ibit0_l = REAL( IBITS(advc_flags_1(k,j,i-1),0,1), KIND = wp )
+                ibit2_l = REAL( IBITS(advc_flag(k,j,i-1),2,1), KIND = wp )
+                ibit1_l = REAL( IBITS(advc_flag(k,j,i-1),1,1), KIND = wp )
+                ibit0_l = REAL( IBITS(advc_flag(k,j,i-1),0,1), KIND = wp )
 
                 u_comp_l = u(k,j,i) - u_gtrans + u_stokes_zu(k)
@@ -3875,7 +4112,7 @@
 #endif
 
-                ibit5 = REAL( IBITS(advc_flags_1(k,j,i),5,1), KIND = wp )
-                ibit4 = REAL( IBITS(advc_flags_1(k,j,i),4,1), KIND = wp )
-                ibit3 = REAL( IBITS(advc_flags_1(k,j,i),3,1), KIND = wp )
+                ibit5 = REAL( IBITS(advc_flag(k,j,i),5,1), KIND = wp )
+                ibit4 = REAL( IBITS(advc_flag(k,j,i),4,1), KIND = wp )
+                ibit3 = REAL( IBITS(advc_flag(k,j,i),3,1), KIND = wp )
 
                 v_comp = v(k,j+1,i) - v_gtrans + v_stokes_zu(k)
@@ -3913,7 +4150,7 @@
 !
 !--             Recompute the south fluxes.
-                ibit5_s = REAL( IBITS(advc_flags_1(k,j-1,i),5,1), KIND = wp )
-                ibit4_s = REAL( IBITS(advc_flags_1(k,j-1,i),4,1), KIND = wp )
-                ibit3_s = REAL( IBITS(advc_flags_1(k,j-1,i),3,1), KIND = wp )
+                ibit5_s = REAL( IBITS(advc_flag(k,j-1,i),5,1), KIND = wp )
+                ibit4_s = REAL( IBITS(advc_flag(k,j-1,i),4,1), KIND = wp )
+                ibit3_s = REAL( IBITS(advc_flag(k,j-1,i),3,1), KIND = wp )
 
                 v_comp_s = v(k,j,i) - v_gtrans + v_stokes_zu(k)
@@ -3955,7 +4192,7 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-                ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-                ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+                ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+                ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+                ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 
                 k_ppp = k + 3 * ibit8
@@ -3998,14 +4235,14 @@
                 div   =   ( u(k,j,i+1) * ( ibit0 + ibit1 + ibit2 )             &
                           - u(k,j,i)   * (                                     &
-                        REAL( IBITS(advc_flags_1(k,j,i-1),0,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),1,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),2,1), KIND = wp )    &
+                        REAL( IBITS(advc_flag(k,j,i-1),0,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k,j,i-1),1,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k,j,i-1),2,1), KIND = wp )       &
                                          )                                     &
                           ) * ddx                                              &
                         + ( v(k,j+1,i) * ( ibit3 + ibit4 + ibit5 )             &
                           - v(k,j,i)   * (                                     &
-                        REAL( IBITS(advc_flags_1(k,j-1,i),3,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),4,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),5,1), KIND = wp )    &
+                        REAL( IBITS(advc_flag(k,j-1,i),3,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k,j-1,i),4,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k,j-1,i),5,1), KIND = wp )       &
                                          )                                     &
                           ) * ddy                                              &
@@ -4014,7 +4251,7 @@
                           - w(k-1,j,i) * rho_air_zw(k-1) *                     &
                                          (                                     &
-                        REAL( IBITS(advc_flags_1(k-1,j,i),6,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),7,1), KIND = wp )    &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),8,1), KIND = wp )    &
+                        REAL( IBITS(advc_flag(k-1,j,i),6,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k-1,j,i),7,1), KIND = wp )       &
+                      + REAL( IBITS(advc_flag(k-1,j,i),8,1), KIND = wp )       &
                                          )                                     &      
                           ) * drho_air(k) * ddzw(k)
@@ -4202,7 +4439,7 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit8 = REAL( IBITS(advc_flags_1(k,j,i),8,1), KIND = wp )
-                ibit7 = REAL( IBITS(advc_flags_1(k,j,i),7,1), KIND = wp )
-                ibit6 = REAL( IBITS(advc_flags_1(k,j,i),6,1), KIND = wp )
+                ibit8 = REAL( IBITS(advc_flag(k,j,i),8,1), KIND = wp )
+                ibit7 = REAL( IBITS(advc_flag(k,j,i),7,1), KIND = wp )
+                ibit6 = REAL( IBITS(advc_flag(k,j,i),6,1), KIND = wp )
 
                 k_ppp = k + 3 * ibit8
@@ -4389,23 +4626,23 @@
        INTEGER(iwp) ::  tn = 0    !< number of OpenMP thread
        
-       REAL(wp)    ::  ibit9  !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit10 !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit11 !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit0 !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit1 !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit2 !< flag indicating 5th-order scheme along x-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit9_l  !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit10_l !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit11_l !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit0_l !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit1_l !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit2_l !< flag indicating 5th-order scheme along x-direction
 #endif
-       REAL(wp)    ::  ibit12 !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit13 !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit14 !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit3 !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit4 !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit5 !< flag indicating 5th-order scheme along y-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit12_s !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit13_s !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit14_s !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit3_s !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit4_s !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit5_s !< flag indicating 5th-order scheme along y-direction
 #endif
-       REAL(wp)    ::  ibit15 !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)    ::  ibit16 !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)    ::  ibit17 !< flag indicating 5th-order scheme along z-direction
+       REAL(wp)    ::  ibit6  !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)    ::  ibit7  !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)    ::  ibit8  !< flag indicating 5th-order scheme along z-direction
        REAL(wp)    ::  diss_d !< artificial dissipation term at grid box bottom
        REAL(wp)    ::  div    !< diverence on u-grid
@@ -4468,20 +4705,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit11 = REAL( IBITS(advc_flags_1(k,j,i-1),11,1), KIND = wp )
-             ibit10 = REAL( IBITS(advc_flags_1(k,j,i-1),10,1), KIND = wp )
-             ibit9  = REAL( IBITS(advc_flags_1(k,j,i-1),9,1),  KIND = wp )
+             ibit2 = REAL( IBITS(advc_flags_m(k,j,i-1),2,1), KIND = wp )
+             ibit1 = REAL( IBITS(advc_flags_m(k,j,i-1),1,1), KIND = wp )
+             ibit0 = REAL( IBITS(advc_flags_m(k,j,i-1),0,1), KIND = wp )
 
              u_comp                   = u(k,j,i) + u(k,j,i-1) - gu
              swap_flux_x_local_u(k,j) = u_comp * (                             &
-                                       ( 37.0_wp * ibit11 * adv_mom_5          &
-                                    +     7.0_wp * ibit10 * adv_mom_3          &
-                                    +              ibit9  * adv_mom_1          &
+                                       ( 37.0_wp * ibit2 * adv_mom_5           &
+                                    +     7.0_wp * ibit1 * adv_mom_3           &
+                                    +              ibit0 * adv_mom_1          &
                                        ) *                                     &
                                      ( u(k,j,i)   + u(k,j,i-1) )               &
-                                -      (  8.0_wp * ibit11 * adv_mom_5          &
-                                    +              ibit10 * adv_mom_3          &
+                                -      (  8.0_wp * ibit2 * adv_mom_5           &
+                                    +              ibit1 * adv_mom_3           &
                                        ) *                                     &
                                      ( u(k,j,i+1) + u(k,j,i-2) )               &
-                                +      (           ibit11 * adv_mom_5          &
+                                +      (           ibit2 * adv_mom_5           &
                                        ) *                                     &
                                      ( u(k,j,i+2) + u(k,j,i-3) )               &
@@ -4489,14 +4726,14 @@
 
               swap_diss_x_local_u(k,j) = - ABS( u_comp ) * (                   &
-                                       ( 10.0_wp * ibit11 * adv_mom_5          &
-                                    +     3.0_wp * ibit10 * adv_mom_3          &
-                                    +              ibit9  * adv_mom_1          &
+                                       ( 10.0_wp * ibit2 * adv_mom_5           &
+                                    +     3.0_wp * ibit1 * adv_mom_3           &
+                                    +              ibit0 * adv_mom_1          &
                                        ) *                                     &
                                      ( u(k,j,i)   - u(k,j,i-1) )               &
-                                -      (  5.0_wp * ibit11 * adv_mom_5          &
-                                    +              ibit10 * adv_mom_3          &
+                                -      (  5.0_wp * ibit2 * adv_mom_5           &
+                                    +              ibit1 * adv_mom_3           &
                                        ) *                                     &
                                      ( u(k,j,i+1) - u(k,j,i-2) )               &
-                                +      (           ibit11 * adv_mom_5          &
+                                +      (           ibit2 * adv_mom_5           &
                                        ) *                                     &
                                      ( u(k,j,i+2) - u(k,j,i-3) )               &
@@ -4523,13 +4760,13 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) FIRSTPRIVATE(tn, gu, gv) &
        !$ACC PRIVATE(i, j, k, k_mm, k_pp, k_ppp) &
-       !$ACC PRIVATE(ibit9, ibit10, ibit11, ibit12, ibit13, ibit14) &
-       !$ACC PRIVATE(ibit9_l, ibit10_l, ibit11_l) &
-       !$ACC PRIVATE(ibit12_s, ibit13_s, ibit14_s) &
-       !$ACC PRIVATE(ibit15, ibit16, ibit17) &
+       !$ACC PRIVATE(ibit0, ibit1, ibit2, ibit3, ibit4, ibit5) &
+       !$ACC PRIVATE(ibit0_l, ibit1_l, ibit2_l) &
+       !$ACC PRIVATE(ibit3_s, ibit4_s, ibit5_s) &
+       !$ACC PRIVATE(ibit6, ibit7, ibit8) &
        !$ACC PRIVATE(flux_r, diss_r, flux_l, diss_l) &
        !$ACC PRIVATE(flux_n, diss_n, flux_s, diss_s) &
        !$ACC PRIVATE(flux_t, diss_t, flux_d, diss_d) &
        !$ACC PRIVATE(div, u_comp, u_comp_l, v_comp, v_comp_s, w_comp) &
-       !$ACC PRESENT(advc_flags_1) &
+       !$ACC PRESENT(advc_flags_m) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(drho_air, rho_air_zw, ddzw) &
@@ -4545,37 +4782,37 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit14 = REAL( IBITS(advc_flags_1(k,j-1,i),14,1), KIND = wp )
-             ibit13 = REAL( IBITS(advc_flags_1(k,j-1,i),13,1), KIND = wp )
-             ibit12 = REAL( IBITS(advc_flags_1(k,j-1,i),12,1), KIND = wp )
+             ibit5 = REAL( IBITS(advc_flags_m(k,j-1,i),5,1), KIND = wp )
+             ibit4 = REAL( IBITS(advc_flags_m(k,j-1,i),4,1), KIND = wp )
+             ibit3 = REAL( IBITS(advc_flags_m(k,j-1,i),3,1), KIND = wp )
 
              v_comp                 = v(k,j,i) + v(k,j,i-1) - gv
-             swap_flux_y_local_u(k) = v_comp * (                              &
-                                   ( 37.0_wp * ibit14 * adv_mom_5             &
-                                +     7.0_wp * ibit13 * adv_mom_3             &
-                                +              ibit12 * adv_mom_1             &
-                                   ) *                                        &
-                                     ( u(k,j,i)   + u(k,j-1,i) )              &
-                            -      (  8.0_wp * ibit14 * adv_mom_5             &
-                            +                  ibit13 * adv_mom_3             &
-                                   ) *                                        &
-                                     ( u(k,j+1,i) + u(k,j-2,i) )              &
-                        +      (               ibit14 * adv_mom_5             &
-                               ) *                                            &
-                                     ( u(k,j+2,i) + u(k,j-3,i) )              &
-                                               )
-
-             swap_diss_y_local_u(k) = - ABS ( v_comp ) * (                    &
-                                   ( 10.0_wp * ibit14 * adv_mom_5             &
-                                +     3.0_wp * ibit13 * adv_mom_3             &
-                                +              ibit12 * adv_mom_1             &
-                                   ) *                                        &
-                                     ( u(k,j,i)   - u(k,j-1,i) )              &
-                            -      (  5.0_wp * ibit14 * adv_mom_5             &
-                                +              ibit13 * adv_mom_3             &
-                                   ) *                                        &
-                                     ( u(k,j+1,i) - u(k,j-2,i) )              &
-                            +      (           ibit14 * adv_mom_5             &
-                                   ) *                                        &
-                                     ( u(k,j+2,i) - u(k,j-3,i) )              &
+             swap_flux_y_local_u(k) = v_comp * (                               &
+                                   ( 37.0_wp * ibit5 * adv_mom_5               &
+                                +     7.0_wp * ibit4 * adv_mom_3               &
+                                +              ibit3 * adv_mom_1               &
+                                   ) *                                         &
+                                     ( u(k,j,i)   + u(k,j-1,i) )               &
+                            -      (  8.0_wp * ibit5 * adv_mom_5               &
+                            +                  ibit4 * adv_mom_3               &
+                                   ) *                                         &
+                                     ( u(k,j+1,i) + u(k,j-2,i) )               &
+                        +      (               ibit5 * adv_mom_5               &
+                               ) *                                             &
+                                     ( u(k,j+2,i) + u(k,j-3,i) )               &
+                                               )                              
+                                                                              
+             swap_diss_y_local_u(k) = - ABS ( v_comp ) * (                     &
+                                   ( 10.0_wp * ibit5 * adv_mom_5               &
+                                +     3.0_wp * ibit4 * adv_mom_3               &
+                                +              ibit3 * adv_mom_1               &
+                                   ) *                                         &
+                                     ( u(k,j,i)   - u(k,j-1,i) )               &
+                            -      (  5.0_wp * ibit5 * adv_mom_5               &
+                                +              ibit4 * adv_mom_3               &
+                                   ) *                                         &
+                                     ( u(k,j+1,i) - u(k,j-2,i) )               &
+                            +      (           ibit5 * adv_mom_5               &
+                                   ) *                                         &
+                                     ( u(k,j+2,i) - u(k,j-3,i) )               &
                                                          )
 
@@ -4585,11 +4822,11 @@
 
              v_comp                 = v(k,j,i) + v(k,j,i-1) - gv
-             swap_flux_y_local_u(k) = v_comp * (                              &
-                           37.0_wp * ( u(k,j,i) + u(k,j-1,i)   )                 &
-                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )                 &
+             swap_flux_y_local_u(k) = v_comp * (                               &
+                           37.0_wp * ( u(k,j,i)   + u(k,j-1,i) )               &
+                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )               &
                          +           ( u(k,j+2,i) + u(k,j-3,i) ) ) * adv_mom_5
-             swap_diss_y_local_u(k) = - ABS(v_comp) * (                       &
-                           10.0_wp * ( u(k,j,i) - u(k,j-1,i)   )                 &
-                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )                 &
+             swap_diss_y_local_u(k) = - ABS(v_comp) * (                        &
+                           10.0_wp * ( u(k,j,i)   - u(k,j-1,i) )               &
+                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )               &
                          +           ( u(k,j+2,i) - u(k,j-3,i) ) ) * adv_mom_5
 
@@ -4606,37 +4843,37 @@
              DO  k = nzb+1, nzb_max_l
 
-                ibit11 = REAL( IBITS(advc_flags_1(k,j,i),11,1), KIND = wp )
-                ibit10 = REAL( IBITS(advc_flags_1(k,j,i),10,1), KIND = wp )
-                ibit9  = REAL( IBITS(advc_flags_1(k,j,i),9,1),  KIND = wp )
+                ibit2 = REAL( IBITS(advc_flags_m(k,j,i),2,1), KIND = wp )
+                ibit1 = REAL( IBITS(advc_flags_m(k,j,i),1,1), KIND = wp )
+                ibit0 = REAL( IBITS(advc_flags_m(k,j,i),0,1), KIND = wp )
 
                 u_comp = u(k,j,i+1) + u(k,j,i)
-                flux_r = ( u_comp - gu ) * (                                 &
-                          ( 37.0_wp * ibit11 * adv_mom_5                     &
-                       +     7.0_wp * ibit10 * adv_mom_3                     &
-                       +              ibit9  * adv_mom_1                     &
-                          ) *                                                &
-                                 ( u(k,j,i+1) + u(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit11 * adv_mom_5                     &
-                       +              ibit10 * adv_mom_3                     &
-                          ) *                                                &
-                                 ( u(k,j,i+2) + u(k,j,i-1) )                 &
-                   +      (           ibit11 * adv_mom_5                     &
-                          ) *                                                &
-                                 ( u(k,j,i+3) + u(k,j,i-2) )                 &
-                                                 )
-
-                diss_r = - ABS( u_comp - gu ) * (                            &
-                          ( 10.0_wp * ibit11 * adv_mom_5                     &
-                       +     3.0_wp * ibit10 * adv_mom_3                     & 
-                       +              ibit9  * adv_mom_1                     &
-                          ) *                                                &
-                                 ( u(k,j,i+1) - u(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit11 * adv_mom_5                     &
-                       +              ibit10 * adv_mom_3                     &
-                          ) *                                                &
-                                 ( u(k,j,i+2) - u(k,j,i-1) )                 &
-                   +      (           ibit11 * adv_mom_5                     &
-                          ) *                                                &
-                                 ( u(k,j,i+3) - u(k,j,i-2) )                 &
+                flux_r = ( u_comp - gu ) * (                                   &
+                          ( 37.0_wp * ibit2 * adv_mom_5                        &
+                       +     7.0_wp * ibit1 * adv_mom_3                        &
+                       +              ibit0  * adv_mom_1                       &
+                          ) *                                                  &
+                                 ( u(k,j,i+1) + u(k,j,i)   )                   &
+                   -      (  8.0_wp * ibit2 * adv_mom_5                        &
+                       +              ibit1 * adv_mom_3                        &
+                          ) *                                                  &
+                                 ( u(k,j,i+2) + u(k,j,i-1) )                   &
+                   +      (           ibit2 * adv_mom_5                        &
+                          ) *                                                  &
+                                 ( u(k,j,i+3) + u(k,j,i-2) )                   &
+                                                 )                            
+                                                                              
+                diss_r = - ABS( u_comp - gu ) * (                              &
+                          ( 10.0_wp * ibit2 * adv_mom_5                        &
+                       +     3.0_wp * ibit1 * adv_mom_3                        & 
+                       +              ibit0  * adv_mom_1                       &
+                          ) *                                                  &
+                                 ( u(k,j,i+1) - u(k,j,i)  )                    &
+                   -      (  5.0_wp * ibit2 * adv_mom_5                        &
+                       +              ibit1 * adv_mom_3                        &
+                          ) *                                                  &
+                                 ( u(k,j,i+2) - u(k,j,i-1) )                   &
+                   +      (           ibit2 * adv_mom_5                        &
+                          ) *                                                  &
+                                 ( u(k,j,i+3) - u(k,j,i-2) )                   &
                                                      )
 
@@ -4644,20 +4881,20 @@
 !
 !--             Recompute the left fluxes.
-                ibit11_l = REAL( IBITS(advc_flags_1(k,j,i-1),11,1), KIND = wp )
-                ibit10_l = REAL( IBITS(advc_flags_1(k,j,i-1),10,1), KIND = wp )
-                ibit9_l  = REAL( IBITS(advc_flags_1(k,j,i-1),9,1),  KIND = wp )
+                ibit2_l = REAL( IBITS(advc_flags_m(k,j,i-1),2,1), KIND = wp )
+                ibit1_l = REAL( IBITS(advc_flags_m(k,j,i-1),1,1), KIND = wp )
+                ibit0_l = REAL( IBITS(advc_flags_m(k,j,i-1),0,1), KIND = wp )
 
                 u_comp_l = u(k,j,i) + u(k,j,i-1) - gu
                 flux_l   = u_comp_l * (                                        &
-                                       ( 37.0_wp * ibit11_l * adv_mom_5           &
-                                    +     7.0_wp * ibit10_l * adv_mom_3           &
-                                    +              ibit9_l  * adv_mom_1           &
+                                       ( 37.0_wp * ibit2_l * adv_mom_5         &
+                                    +     7.0_wp * ibit1_l * adv_mom_3         &
+                                    +              ibit0_l  * adv_mom_1        &
                                        ) *                                     &
                                      ( u(k,j,i)   + u(k,j,i-1) )               &
-                                -      (  8.0_wp * ibit11_l * adv_mom_5           &
-                                    +              ibit10_l * adv_mom_3           &
+                                -      (  8.0_wp * ibit2_l * adv_mom_5         &
+                                    +              ibit1_l * adv_mom_3         &
                                        ) *                                     &
                                      ( u(k,j,i+1) + u(k,j,i-2) )               &
-                                +      (           ibit11_l * adv_mom_5           &
+                                +      (           ibit2_l * adv_mom_5         &
                                        ) *                                     &
                                      ( u(k,j,i+2) + u(k,j,i-3) )               &
@@ -4665,14 +4902,14 @@
 
                 diss_l   = - ABS( u_comp_l ) * (                               &
-                                       ( 10.0_wp * ibit11_l * adv_mom_5           &
-                                    +     3.0_wp * ibit10_l * adv_mom_3           &
-                                    +              ibit9_l  * adv_mom_1           &
+                                       ( 10.0_wp * ibit2_l * adv_mom_5         &
+                                    +     3.0_wp * ibit1_l * adv_mom_3         &
+                                    +              ibit0_l  * adv_mom_1        &
                                        ) *                                     &
                                      ( u(k,j,i)   - u(k,j,i-1) )               &
-                                -      (  5.0_wp * ibit11_l * adv_mom_5           &
-                                    +              ibit10_l * adv_mom_3           &
+                                -      (  5.0_wp * ibit2_l * adv_mom_5         &
+                                    +              ibit1_l * adv_mom_3         &
                                        ) *                                     &
                                      ( u(k,j,i+1) - u(k,j,i-2) )               &
-                                +      (           ibit11_l * adv_mom_5           &
+                                +      (           ibit2_l * adv_mom_5         &
                                        ) *                                     &
                                      ( u(k,j,i+2) - u(k,j,i-3) )               &
@@ -4683,37 +4920,37 @@
 #endif
 
-                ibit14 = REAL( IBITS(advc_flags_1(k,j,i),14,1), KIND = wp )
-                ibit13 = REAL( IBITS(advc_flags_1(k,j,i),13,1), KIND = wp )
-                ibit12 = REAL( IBITS(advc_flags_1(k,j,i),12,1), KIND = wp )
+                ibit5 = REAL( IBITS(advc_flags_m(k,j,i),5,1), KIND = wp )
+                ibit4 = REAL( IBITS(advc_flags_m(k,j,i),4,1), KIND = wp )
+                ibit3 = REAL( IBITS(advc_flags_m(k,j,i),3,1), KIND = wp )
 
                 v_comp = v(k,j+1,i) + v(k,j+1,i-1) - gv
-                flux_n = v_comp * (                                          &
-                          ( 37.0_wp * ibit14 * adv_mom_5                     &
-                       +     7.0_wp * ibit13 * adv_mom_3                     &
-                       +              ibit12 * adv_mom_1                     &
-                          ) *                                                &
-                                 ( u(k,j+1,i) + u(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit14 * adv_mom_5                     &
-                       +              ibit13 * adv_mom_3                     &
-                          ) *                                                &
-                                 ( u(k,j+2,i) + u(k,j-1,i) )                 &
-                   +      (           ibit14 * adv_mom_5                     & 
-                          ) *                                                &
-                                 ( u(k,j+3,i) + u(k,j-2,i) )                 &
-                                                 )
-
-                diss_n = - ABS ( v_comp ) * (                                &
-                          ( 10.0_wp * ibit14 * adv_mom_5                     &
-                       +     3.0_wp * ibit13 * adv_mom_3                     &
-                       +              ibit12 * adv_mom_1                     &
-                          ) *                                                &
-                                 ( u(k,j+1,i) - u(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit14 * adv_mom_5                     &
-                       +              ibit13 * adv_mom_3                     &
-                          ) *                                                &
-                                 ( u(k,j+2,i) - u(k,j-1,i) )                 &
-                   +      (           ibit14 * adv_mom_5                     &
-                          ) *                                                &
-                                 ( u(k,j+3,i) - u(k,j-2,i) )                 &
+                flux_n = v_comp * (                                            &
+                          ( 37.0_wp * ibit5 * adv_mom_5                        &
+                       +     7.0_wp * ibit4 * adv_mom_3                        &
+                       +              ibit3 * adv_mom_1                        &
+                          ) *                                                  &
+                                 ( u(k,j+1,i) + u(k,j,i)   )                   &
+                   -      (  8.0_wp * ibit5 * adv_mom_5                        &
+                       +              ibit4 * adv_mom_3                        &
+                          ) *                                                  &
+                                 ( u(k,j+2,i) + u(k,j-1,i) )                   &
+                   +      (           ibit5 * adv_mom_5                        & 
+                          ) *                                                  &
+                                 ( u(k,j+3,i) + u(k,j-2,i) )                   &
+                                                 )                            
+                                                                              
+                diss_n = - ABS ( v_comp ) * (                                  &
+                          ( 10.0_wp * ibit5 * adv_mom_5                        &
+                       +     3.0_wp * ibit4 * adv_mom_3                        &
+                       +              ibit3 * adv_mom_1                        &
+                          ) *                                                  &
+                                 ( u(k,j+1,i) - u(k,j,i)  )                    &
+                   -      (  5.0_wp * ibit5 * adv_mom_5                        &
+                       +              ibit4 * adv_mom_3                        &
+                          ) *                                                  &
+                                 ( u(k,j+2,i) - u(k,j-1,i) )                   &
+                   +      (           ibit5 * adv_mom_5                        &
+                          ) *                                                  &
+                                 ( u(k,j+3,i) - u(k,j-2,i) )                   &
                                                       )
 
@@ -4721,37 +4958,37 @@
 !
 !--             Recompute the south fluxes.
-                ibit14_s = REAL( IBITS(advc_flags_1(k,j-1,i),14,1), KIND = wp )
-                ibit13_s = REAL( IBITS(advc_flags_1(k,j-1,i),13,1), KIND = wp )
-                ibit12_s = REAL( IBITS(advc_flags_1(k,j-1,i),12,1), KIND = wp )
+                ibit5_s = REAL( IBITS(advc_flags_m(k,j-1,i),5,1), KIND = wp )
+                ibit4_s = REAL( IBITS(advc_flags_m(k,j-1,i),4,1), KIND = wp )
+                ibit3_s = REAL( IBITS(advc_flags_m(k,j-1,i),3,1), KIND = wp )
 
                 v_comp_s = v(k,j,i) + v(k,j,i-1) - gv
-                flux_s   = v_comp_s * (                                      &
-                                   ( 37.0_wp * ibit14_s * adv_mom_5             &
-                                +     7.0_wp * ibit13_s * adv_mom_3             &
-                                +              ibit12_s * adv_mom_1             &
-                                   ) *                                       &
-                                     ( u(k,j,i)   + u(k,j-1,i) )             &
-                            -      (  8.0_wp * ibit14_s * adv_mom_5             &
-                            +                  ibit13_s * adv_mom_3             &
-                                   ) *                                       &
-                                     ( u(k,j+1,i) + u(k,j-2,i) )             &
-                        +      (               ibit14_s * adv_mom_5             &
-                               ) *                                           &
-                                     ( u(k,j+2,i) + u(k,j-3,i) )             &
+                flux_s   = v_comp_s * (                                        &
+                                   ( 37.0_wp * ibit5_s * adv_mom_5             &
+                                +     7.0_wp * ibit4_s * adv_mom_3             &
+                                +              ibit3_s * adv_mom_1             &
+                                   ) *                                         &
+                                     ( u(k,j,i)   + u(k,j-1,i) )               &
+                            -      (  8.0_wp * ibit5_s * adv_mom_5             &
+                            +                  ibit4_s * adv_mom_3             &
+                                   ) *                                         &
+                                     ( u(k,j+1,i) + u(k,j-2,i) )               &
+                        +      (               ibit5_s * adv_mom_5             &
+                               ) *                                             &
+                                     ( u(k,j+2,i) + u(k,j-3,i) )               &
                                                )
 
-                diss_s   = - ABS ( v_comp_s ) * (                            &
-                                   ( 10.0_wp * ibit14_s * adv_mom_5              &
-                                +     3.0_wp * ibit13_s * adv_mom_3              &
-                                +              ibit12_s * adv_mom_1              &
-                                   ) *                                        &
-                                     ( u(k,j,i)   - u(k,j-1,i) )              &
-                            -      (  5.0_wp * ibit14_s * adv_mom_5              &
-                                +              ibit13_s * adv_mom_3              &
-                                   ) *                                        &
-                                     ( u(k,j+1,i) - u(k,j-2,i) )              &
-                            +      (           ibit14_s * adv_mom_5              &
-                                   ) *                                        &
-                                     ( u(k,j+2,i) - u(k,j-3,i) )              &
+                diss_s   = - ABS ( v_comp_s ) * (                              &
+                                   ( 10.0_wp * ibit5_s * adv_mom_5             &
+                                +     3.0_wp * ibit4_s * adv_mom_3             &
+                                +              ibit3_s * adv_mom_1             &
+                                   ) *                                         &
+                                     ( u(k,j,i)   - u(k,j-1,i) )               &
+                            -      (  5.0_wp * ibit5_s * adv_mom_5             &
+                                +              ibit4_s * adv_mom_3             &
+                                   ) *                                         &
+                                     ( u(k,j+1,i) - u(k,j-2,i) )               &
+                            +      (           ibit5_s * adv_mom_5             &
+                                   ) *                                         &
+                                     ( u(k,j+2,i) - u(k,j-3,i) )               &
                                                          )
 #else
@@ -4763,41 +5000,41 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-                ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-                ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit17
-                k_pp  = k + 2 * ( 1 - ibit15  )
-                k_mm  = k - 2 * ibit17
+                ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+                ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+                ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit8
+                k_pp  = k + 2 * ( 1 - ibit6  )
+                k_mm  = k - 2 * ibit8
 
                 w_comp = w(k,j,i) + w(k,j,i-1)
-                flux_t = w_comp * rho_air_zw(k) * (                          &
-                          ( 37.0_wp * ibit17 * adv_mom_5                     &
-                       +     7.0_wp * ibit16 * adv_mom_3                     &
-                       +              ibit15 * adv_mom_1                     & 
-                          ) *                                                &
-                             ( u(k+1,j,i)  + u(k,j,i)     )                  &
-                   -      (  8.0_wp * ibit17 * adv_mom_5                     &
-                       +              ibit16 * adv_mom_3                     &
-                          ) *                                                &
-                             ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-                   +      (           ibit17 * adv_mom_5                     &
-                          ) *                                                &
-                             ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
-                                      )
-
-                diss_t = - ABS( w_comp ) * rho_air_zw(k) * (                 &
-                          ( 10.0_wp * ibit17 * adv_mom_5                     &
-                       +     3.0_wp * ibit16 * adv_mom_3                     &
-                       +              ibit15 * adv_mom_1                     &
-                          ) *                                                &
-                             ( u(k+1,j,i)   - u(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit17 * adv_mom_5                     &
-                       +              ibit16 * adv_mom_3                     &
-                          ) *                                                &
-                             ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-                   +      (           ibit17 * adv_mom_5                     &
-                           ) *                                               &
-                             ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
+                flux_t = w_comp * rho_air_zw(k) * (                            &
+                          ( 37.0_wp * ibit8 * adv_mom_5                        &
+                       +     7.0_wp * ibit7 * adv_mom_3                        &
+                       +              ibit6 * adv_mom_1                        & 
+                          ) *                                                  &
+                             ( u(k+1,j,i)  + u(k,j,i)     )                    &
+                   -      (  8.0_wp * ibit8 * adv_mom_5                        &
+                       +              ibit7 * adv_mom_3                        &
+                          ) *                                                  &
+                             ( u(k_pp,j,i) + u(k-1,j,i)   )                    &
+                   +      (           ibit8 * adv_mom_5                        &
+                          ) *                                                  &
+                             ( u(k_ppp,j,i) + u(k_mm,j,i) )                    &
+                                      )                                       
+                                                                              
+                diss_t = - ABS( w_comp ) * rho_air_zw(k) * (                   &
+                          ( 10.0_wp * ibit8 * adv_mom_5                        &
+                       +     3.0_wp * ibit7 * adv_mom_3                        &
+                       +              ibit6 * adv_mom_1                        &
+                          ) *                                                  &
+                             ( u(k+1,j,i)   - u(k,j,i)    )                    &
+                   -      (  5.0_wp * ibit8 * adv_mom_5                        &
+                       +              ibit7 * adv_mom_3                        &
+                          ) *                                                  &
+                             ( u(k_pp,j,i)  - u(k-1,j,i)  )                    &
+                   +      (           ibit8 * adv_mom_5                        &
+                           ) *                                                 &
+                             ( u(k_ppp,j,i) - u(k_mm,j,i) )                    &
                                               )
 !
@@ -4805,28 +5042,28 @@
 !--             correction is needed to overcome numerical instabilities caused
 !--             by a not sufficient reduction of divergences near topography.
-                div = ( ( u_comp * ( ibit9 + ibit10 + ibit11 )                &
-                - ( u(k,j,i)   + u(k,j,i-1)   )                               &
-                                    * (                                       &
-                    REAL( IBITS(advc_flags_1(k,j,i-1),9,1),  KIND = wp )      &
-                  + REAL( IBITS(advc_flags_1(k,j,i-1),10,1), KIND = wp )      &
-                  + REAL( IBITS(advc_flags_1(k,j,i-1),11,1), KIND = wp )      &
-                                      )                                       &
-                  ) * ddx                                                     &
-               +  ( ( v_comp + gv ) * ( ibit12 + ibit13 + ibit14 )            &
-                  - ( v(k,j,i)   + v(k,j,i-1 )  )                             &
-                                    * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j-1,i),12,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),13,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),14,1), KIND = wp )     &
-                                      )                                       &
-                  ) * ddy                                                     &
-               +  ( w_comp * rho_air_zw(k) * ( ibit15 + ibit16 + ibit17 )     &
-                - ( w(k-1,j,i) + w(k-1,j,i-1) ) * rho_air_zw(k-1)             &
-                                    * (                                       &
-                     REAL( IBITS(advc_flags_1(k-1,j,i),15,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k-1,j,i),16,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k-1,j,i),17,1), KIND = wp )     &
-                                      )                                       &  
-                  ) * drho_air(k) * ddzw(k)                                   &
+                div = ( ( u_comp * ( ibit0 + ibit1 + ibit2 )                   &
+                - ( u(k,j,i)   + u(k,j,i-1)   )                                &
+                                    * (                                        &
+                    REAL( IBITS(advc_flags_m(k,j,i-1),0,1),  KIND = wp )       &
+                  + REAL( IBITS(advc_flags_m(k,j,i-1),1,1), KIND = wp )        &
+                  + REAL( IBITS(advc_flags_m(k,j,i-1),2,1), KIND = wp )        &
+                                      )                                        &
+                  ) * ddx                                                      &
+               +  ( ( v_comp + gv ) * ( ibit3 + ibit4 + ibit5 )                &
+                  - ( v(k,j,i)   + v(k,j,i-1 )  )                              &
+                                    * (                                        &
+                     REAL( IBITS(advc_flags_m(k,j-1,i),3,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),4,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),5,1), KIND = wp )       &
+                                      )                                        &
+                  ) * ddy                                                      &
+               +  ( w_comp * rho_air_zw(k) * ( ibit6 + ibit7 + ibit8 )         &
+                - ( w(k-1,j,i) + w(k-1,j,i-1) ) * rho_air_zw(k-1)              &
+                                    * (                                        &
+                     REAL( IBITS(advc_flags_m(k-1,j,i),6,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),7,1), KIND = wp )       &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),8,1), KIND = wp )       &
+                                      )                                        &  
+                  ) * drho_air(k) * ddzw(k)                                    &
                 ) * 0.5_wp
 
@@ -4879,11 +5116,11 @@
 
                 u_comp = u(k,j,i+1) + u(k,j,i)
-                flux_r = ( u_comp - gu ) * (                                  &
-                         37.0_wp * ( u(k,j,i+1) + u(k,j,i)   )                   &
-                       -  8.0_wp * ( u(k,j,i+2) + u(k,j,i-1) )                   &
+                flux_r = ( u_comp - gu ) * (                                   &
+                         37.0_wp * ( u(k,j,i+1) + u(k,j,i)   )                 &
+                       -  8.0_wp * ( u(k,j,i+2) + u(k,j,i-1) )                 &
                        +           ( u(k,j,i+3) + u(k,j,i-2) ) ) * adv_mom_5
-                diss_r = - ABS( u_comp - gu ) * (                             &
-                         10.0_wp * ( u(k,j,i+1) - u(k,j,i)   )                   &
-                       -  5.0_wp * ( u(k,j,i+2) - u(k,j,i-1) )                   &
+                diss_r = - ABS( u_comp - gu ) * (                              &
+                         10.0_wp * ( u(k,j,i+1) - u(k,j,i)   )                 &
+                       -  5.0_wp * ( u(k,j,i+2) - u(k,j,i-1) )                 &
                        +           ( u(k,j,i+3) - u(k,j,i-2) ) ) * adv_mom_5
 
@@ -4892,11 +5129,11 @@
 !--             Recompute the left fluxes.
                 u_comp_l = u(k,j,i) + u(k,j,i-1) - gu
-                flux_l   = u_comp_l * (                                       &
-                             37.0_wp * ( u(k,j,i) + u(k,j,i-1)   )                &
-                           -  8.0_wp * ( u(k,j,i+1) + u(k,j,i-2) )                &
+                flux_l   = u_comp_l * (                                        &
+                             37.0_wp * ( u(k,j,i) + u(k,j,i-1)   )             &
+                           -  8.0_wp * ( u(k,j,i+1) + u(k,j,i-2) )             &
                            +           ( u(k,j,i+2) + u(k,j,i-3) ) ) * adv_mom_5
-                diss_l   = - ABS(u_comp_l) * (                                &
-                             10.0_wp * ( u(k,j,i) - u(k,j,i-1)   )                &
-                           -  5.0_wp * ( u(k,j,i+1) - u(k,j,i-2) )                &
+                diss_l   = - ABS(u_comp_l) * (                                 &
+                             10.0_wp * ( u(k,j,i) - u(k,j,i-1)   )             &
+                           -  5.0_wp * ( u(k,j,i+1) - u(k,j,i-2) )             &
                            +           ( u(k,j,i+2) - u(k,j,i-3) ) ) * adv_mom_5
 #else
@@ -4906,11 +5143,11 @@
 
                 v_comp = v(k,j+1,i) + v(k,j+1,i-1) - gv
-                flux_n = v_comp * (                                           &
-                         37.0_wp * ( u(k,j+1,i) + u(k,j,i)   )                   &
-                       -  8.0_wp * ( u(k,j+2,i) + u(k,j-1,i) )                   &
+                flux_n = v_comp * (                                            &
+                         37.0_wp * ( u(k,j+1,i) + u(k,j,i)   )                 &
+                       -  8.0_wp * ( u(k,j+2,i) + u(k,j-1,i) )                 &
                        +           ( u(k,j+3,i) + u(k,j-2,i) ) ) * adv_mom_5
-                diss_n = - ABS( v_comp ) * (                                  &
-                         10.0_wp * ( u(k,j+1,i) - u(k,j,i)   )                   &
-                       -  5.0_wp * ( u(k,j+2,i) - u(k,j-1,i) )                   &
+                diss_n = - ABS( v_comp ) * (                                   &
+                         10.0_wp * ( u(k,j+1,i) - u(k,j,i)   )                 &
+                       -  5.0_wp * ( u(k,j+2,i) - u(k,j-1,i) )                 &
                        +           ( u(k,j+3,i) - u(k,j-2,i) ) ) * adv_mom_5
 
@@ -4919,11 +5156,11 @@
 !--             Recompute the south fluxes.
                 v_comp_s = v(k,j,i) + v(k,j,i-1) - gv
-                flux_s   = v_comp_s * (                                       &
-                           37.0_wp * ( u(k,j,i) + u(k,j-1,i)   )                 &
-                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )                 &
+                flux_s   = v_comp_s * (                                        &
+                           37.0_wp * ( u(k,j,i) + u(k,j-1,i)   )               &
+                         -  8.0_wp * ( u(k,j+1,i) + u(k,j-2,i) )               &
                          +           ( u(k,j+2,i) + u(k,j-3,i) ) ) * adv_mom_5
-                diss_s   = - ABS( v_comp_s ) * (                              &
-                           10.0_wp * ( u(k,j,i) - u(k,j-1,i)   )                 &
-                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )                 &
+                diss_s   = - ABS( v_comp_s ) * (                               &
+                           10.0_wp * ( u(k,j,i) - u(k,j-1,i)   )               &
+                         -  5.0_wp * ( u(k,j+1,i) - u(k,j-2,i) )               &
                          +           ( u(k,j+2,i) - u(k,j-3,i) ) ) * adv_mom_5
 #else
@@ -4935,24 +5172,24 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit17 = REAL( IBITS(advc_flags_1(k,j,i),17,1), KIND = wp )
-                ibit16 = REAL( IBITS(advc_flags_1(k,j,i),16,1), KIND = wp )
-                ibit15 = REAL( IBITS(advc_flags_1(k,j,i),15,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit17
-                k_pp  = k + 2 * ( 1 - ibit15  )
-                k_mm  = k - 2 * ibit17
+                ibit8 = REAL( IBITS(advc_flags_m(k,j,i),8,1), KIND = wp )
+                ibit7 = REAL( IBITS(advc_flags_m(k,j,i),7,1), KIND = wp )
+                ibit6 = REAL( IBITS(advc_flags_m(k,j,i),6,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit8
+                k_pp  = k + 2 * ( 1 - ibit6  )
+                k_mm  = k - 2 * ibit8
 
                 w_comp = w(k,j,i) + w(k,j,i-1)
                 flux_t = w_comp * rho_air_zw(k) * (                          &
-                          ( 37.0_wp * ibit17 * adv_mom_5                        &
-                       +     7.0_wp * ibit16 * adv_mom_3                        &
-                       +              ibit15 * adv_mom_1                        &
+                          ( 37.0_wp * ibit8 * adv_mom_5                        &
+                       +     7.0_wp * ibit7 * adv_mom_3                        &
+                       +              ibit6 * adv_mom_1                        &
                           ) *                                                &
                              ( u(k+1,j,i)  + u(k,j,i)     )                  &
-                   -      (  8.0_wp * ibit17 * adv_mom_5                        &
-                       +              ibit16 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit8 * adv_mom_5                        &
+                       +              ibit7 * adv_mom_3                        &
                           ) *                                                &
                              ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-                   +      (           ibit17 * adv_mom_5                        &
+                   +      (           ibit8 * adv_mom_5                        &
                           ) *                                                &
                              ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
@@ -4960,14 +5197,14 @@
 
                 diss_t = - ABS( w_comp ) * rho_air_zw(k) * (                 &
-                          ( 10.0_wp * ibit17 * adv_mom_5                        &
-                       +     3.0_wp * ibit16 * adv_mom_3                        &
-                       +              ibit15 * adv_mom_1                        &
+                          ( 10.0_wp * ibit8 * adv_mom_5                        &
+                       +     3.0_wp * ibit7 * adv_mom_3                        &
+                       +              ibit6 * adv_mom_1                        &
                           ) *                                                &
                              ( u(k+1,j,i)   - u(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit17 * adv_mom_5                        &
-                       +              ibit16 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit8 * adv_mom_5                        &
+                       +              ibit7 * adv_mom_3                        &
                           ) *                                                &
                              ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-                   +      (           ibit17 * adv_mom_5                        &
+                   +      (           ibit8 * adv_mom_5                        &
                            ) *                                               &
                              ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
@@ -5048,23 +5285,23 @@
        INTEGER(iwp) ::  tn = 0    !< number of OpenMP thread
        
-       REAL(wp)    ::  ibit18 !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit19 !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit20 !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit9 !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit10 !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit11 !< flag indicating 5th-order scheme along x-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit18_l !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit19_l !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit20_l !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit9_l !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit10_l !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit11_l !< flag indicating 5th-order scheme along x-direction
 #endif
-       REAL(wp)    ::  ibit21 !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit22 !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit23 !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit12 !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit13 !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit14 !< flag indicating 5th-order scheme along y-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit21_s !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit22_s !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit23_s !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit12_s !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit13_s !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit14_s !< flag indicating 5th-order scheme along y-direction
 #endif
-       REAL(wp)    ::  ibit24 !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)    ::  ibit25 !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)    ::  ibit26 !< flag indicating 5th-order scheme along z-direction
+       REAL(wp)    ::  ibit15 !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)    ::  ibit16 !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)    ::  ibit17 !< flag indicating 5th-order scheme along z-direction
        REAL(wp)    ::  diss_d !< artificial dissipation term at grid box bottom
        REAL(wp)    ::  div    !< diverence on v-grid
@@ -5127,20 +5364,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit20 = REAL( IBITS(advc_flags_1(k,j,i-1),20,1), KIND = wp )
-             ibit19 = REAL( IBITS(advc_flags_1(k,j,i-1),19,1), KIND = wp )
-             ibit18 = REAL( IBITS(advc_flags_1(k,j,i-1),18,1), KIND = wp )
+             ibit11 = REAL( IBITS(advc_flags_m(k,j,i-1),11,1), KIND = wp )
+             ibit10 = REAL( IBITS(advc_flags_m(k,j,i-1),10,1), KIND = wp )
+             ibit9  = REAL( IBITS(advc_flags_m(k,j,i-1),9,1),  KIND = wp )
 
              u_comp                   = u(k,j-1,i) + u(k,j,i) - gu
              swap_flux_x_local_v(k,j) = u_comp * (                             &
-                                      ( 37.0_wp * ibit20 * adv_mom_5              &
-                                   +     7.0_wp * ibit19 * adv_mom_3              &
-                                   +              ibit18 * adv_mom_1              &
+                                      ( 37.0_wp * ibit11 * adv_mom_5              &
+                                   +     7.0_wp * ibit10 * adv_mom_3              &
+                                   +              ibit9 * adv_mom_1              &
                                       ) *                                      &
                                      ( v(k,j,i)   + v(k,j,i-1) )               &
-                               -      (  8.0_wp * ibit20 * adv_mom_5              &
-                                   +              ibit19 * adv_mom_3              &
+                               -      (  8.0_wp * ibit11 * adv_mom_5              &
+                                   +              ibit10 * adv_mom_3              &
                                       ) *                                      &
                                      ( v(k,j,i+1) + v(k,j,i-2) )               &
-                               +      (           ibit20 * adv_mom_5              &
+                               +      (           ibit11 * adv_mom_5              &
                                       ) *                                      &
                                      ( v(k,j,i+2) + v(k,j,i-3) )               &
@@ -5148,14 +5385,14 @@
 
               swap_diss_x_local_v(k,j) = - ABS( u_comp ) * (                   &
-                                      ( 10.0_wp * ibit20 * adv_mom_5              &
-                                   +     3.0_wp * ibit19 * adv_mom_3              &
-                                   +              ibit18 * adv_mom_1              &
+                                      ( 10.0_wp * ibit11 * adv_mom_5              &
+                                   +     3.0_wp * ibit10 * adv_mom_3              &
+                                   +              ibit9 * adv_mom_1              &
                                       ) *                                      &
                                      ( v(k,j,i)   - v(k,j,i-1) )               &
-                               -      (  5.0_wp * ibit20 * adv_mom_5              &
-                                   +              ibit19 * adv_mom_3              &
+                               -      (  5.0_wp * ibit11 * adv_mom_5              &
+                                   +              ibit10 * adv_mom_3              &
                                       ) *                                      &
                                      ( v(k,j,i+1) - v(k,j,i-2) )               &
-                               +      (           ibit20 * adv_mom_5              &
+                               +      (           ibit11 * adv_mom_5              &
                                       ) *                                      &
                                      ( v(k,j,i+2) - v(k,j,i-3) )               &
@@ -5183,13 +5420,13 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) FIRSTPRIVATE(tn, gu, gv) &
        !$ACC PRIVATE(i, j, k, k_mm, k_pp, k_ppp) &
-       !$ACC PRIVATE(ibit18, ibit19, ibit20, ibit21, ibit22, ibit23) &
-       !$ACC PRIVATE(ibit18_l, ibit19_l, ibit20_l) &
-       !$ACC PRIVATE(ibit21_s, ibit22_s, ibit23_s) &
-       !$ACC PRIVATE(ibit24, ibit25, ibit26) &
+       !$ACC PRIVATE(ibit9, ibit10, ibit11, ibit12, ibit13, ibit14) &
+       !$ACC PRIVATE(ibit9_l, ibit10_l, ibit11_l) &
+       !$ACC PRIVATE(ibit12_s, ibit13_s, ibit14_s) &
+       !$ACC PRIVATE(ibit15, ibit16, ibit17) &
        !$ACC PRIVATE(flux_r, diss_r, flux_l, diss_l) &
        !$ACC PRIVATE(flux_n, diss_n, flux_s, diss_s) &
        !$ACC PRIVATE(flux_t, diss_t, flux_d, diss_d) &
        !$ACC PRIVATE(div, u_comp, u_comp_l, v_comp, v_comp_s, w_comp) &
-       !$ACC PRESENT(advc_flags_1) &
+       !$ACC PRESENT(advc_flags_m) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(drho_air, rho_air_zw, ddzw) &
@@ -5204,20 +5441,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit23 = REAL( IBITS(advc_flags_1(k,j-1,i),23,1), KIND = wp )
-             ibit22 = REAL( IBITS(advc_flags_1(k,j-1,i),22,1), KIND = wp )
-             ibit21 = REAL( IBITS(advc_flags_1(k,j-1,i),21,1), KIND = wp )
+             ibit14 = REAL( IBITS(advc_flags_m(k,j-1,i),14,1), KIND = wp )
+             ibit13 = REAL( IBITS(advc_flags_m(k,j-1,i),13,1), KIND = wp )
+             ibit12 = REAL( IBITS(advc_flags_m(k,j-1,i),12,1), KIND = wp )
 
              v_comp                 = v(k,j,i) + v(k,j-1,i) - gv
              swap_flux_y_local_v(k) = v_comp * (                              &
-                                   ( 37.0_wp * ibit23 * adv_mom_5                &
-                                +     7.0_wp * ibit22 * adv_mom_3                &
-                                +              ibit21 * adv_mom_1                &
+                                   ( 37.0_wp * ibit14 * adv_mom_5                &
+                                +     7.0_wp * ibit13 * adv_mom_3                &
+                                +              ibit12 * adv_mom_1                &
                                    ) *                                        &
                                      ( v(k,j,i)   + v(k,j-1,i) )              &
-                            -      (  8.0_wp * ibit23 * adv_mom_5                &
-                                +              ibit22 * adv_mom_3                &
+                            -      (  8.0_wp * ibit14 * adv_mom_5                &
+                                +              ibit13 * adv_mom_3                &
                                    ) *                                        &
                                      ( v(k,j+1,i) + v(k,j-2,i) )              &
-                            +      (           ibit23 * adv_mom_5                &
+                            +      (           ibit14 * adv_mom_5                &
                                    ) *                                        &
                                      ( v(k,j+2,i) + v(k,j-3,i) )              &
@@ -5225,14 +5462,14 @@
 
              swap_diss_y_local_v(k) = - ABS( v_comp ) * (                     &
-                                   ( 10.0_wp * ibit23 * adv_mom_5                &
-                                +     3.0_wp * ibit22 * adv_mom_3                &
-                                +              ibit21 * adv_mom_1                &
+                                   ( 10.0_wp * ibit14 * adv_mom_5                &
+                                +     3.0_wp * ibit13 * adv_mom_3                &
+                                +              ibit12 * adv_mom_1                &
                                    ) *                                        &
                                      ( v(k,j,i)   - v(k,j-1,i) )              &
-                            -      (  5.0_wp * ibit23 * adv_mom_5                &
-                                +              ibit22 * adv_mom_3                &
+                            -      (  5.0_wp * ibit14 * adv_mom_5                &
+                                +              ibit13 * adv_mom_3                &
                                    ) *                                        &
                                      ( v(k,j+1,i) - v(k,j-2,i) )              &
-                            +      (           ibit23 * adv_mom_5                &
+                            +      (           ibit14 * adv_mom_5                &
                                    ) *                                        &
                                      ( v(k,j+2,i) - v(k,j-3,i) )              &
@@ -5263,20 +5500,20 @@
              DO  k = nzb+1, nzb_max_l
 
-                ibit20 = REAL( IBITS(advc_flags_1(k,j,i),20,1), KIND = wp )
-                ibit19 = REAL( IBITS(advc_flags_1(k,j,i),19,1), KIND = wp )
-                ibit18 = REAL( IBITS(advc_flags_1(k,j,i),18,1), KIND = wp )
+                ibit11 = REAL( IBITS(advc_flags_m(k,j,i),11,1), KIND = wp )
+                ibit10 = REAL( IBITS(advc_flags_m(k,j,i),10,1), KIND = wp )
+                ibit9  = REAL( IBITS(advc_flags_m(k,j,i),9,1),  KIND = wp )
 
                 u_comp = u(k,j-1,i+1) + u(k,j,i+1) - gu
                 flux_r = u_comp * (                                          &
-                          ( 37.0_wp * ibit20 * adv_mom_5                        &
-                       +     7.0_wp * ibit19 * adv_mom_3                        &
-                       +              ibit18 * adv_mom_1                        &
+                          ( 37.0_wp * ibit11 * adv_mom_5                        &
+                       +     7.0_wp * ibit10 * adv_mom_3                        &
+                       +              ibit9 * adv_mom_1                        &
                           ) *                                                &
                                  ( v(k,j,i+1) + v(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit20 * adv_mom_5                        &
-                       +              ibit19 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit11 * adv_mom_5                        &
+                       +              ibit10 * adv_mom_3                        &
                           ) *                                                &
                                  ( v(k,j,i+2) + v(k,j,i-1) )                 &
-                   +      (           ibit20 * adv_mom_5                        &
+                   +      (           ibit11 * adv_mom_5                        &
                           ) *                                                &
                                  ( v(k,j,i+3) + v(k,j,i-2) )                 &
@@ -5284,14 +5521,14 @@
 
                 diss_r = - ABS( u_comp ) * (                                 &
-                          ( 10.0_wp * ibit20 * adv_mom_5                        &
-                       +     3.0_wp * ibit19 * adv_mom_3                        &
-                       +              ibit18 * adv_mom_1                        &
+                          ( 10.0_wp * ibit11 * adv_mom_5                        &
+                       +     3.0_wp * ibit10 * adv_mom_3                        &
+                       +              ibit9 * adv_mom_1                        &
                           ) *                                                &
                                  ( v(k,j,i+1) - v(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit20 * adv_mom_5                        &
-                       +              ibit19 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit11 * adv_mom_5                        &
+                       +              ibit10 * adv_mom_3                        &
                           ) *                                                &
                                  ( v(k,j,i+2) - v(k,j,i-1) )                 &
-                   +      (           ibit20 * adv_mom_5                        &
+                   +      (           ibit11 * adv_mom_5                        &
                           ) *                                                &
                                  ( v(k,j,i+3) - v(k,j,i-2) )                 &
@@ -5301,20 +5538,20 @@
 !
 !--             Recompute the left fluxes.
-                ibit20_l = REAL( IBITS(advc_flags_1(k,j,i-1),20,1), KIND = wp )
-                ibit19_l = REAL( IBITS(advc_flags_1(k,j,i-1),19,1), KIND = wp )
-                ibit18_l = REAL( IBITS(advc_flags_1(k,j,i-1),18,1), KIND = wp )
+                ibit11_l = REAL( IBITS(advc_flags_m(k,j,i-1),11,1), KIND = wp )
+                ibit10_l = REAL( IBITS(advc_flags_m(k,j,i-1),10,1), KIND = wp )
+                ibit9_l  = REAL( IBITS(advc_flags_m(k,j,i-1),9,1),  KIND = wp )
 
                 u_comp_l  = u(k,j-1,i) + u(k,j,i) - gu
                 flux_l    = u_comp_l * (                                     &
-                                      ( 37.0_wp * ibit20_l * adv_mom_5          &
-                                   +     7.0_wp * ibit19_l * adv_mom_3          &
-                                   +              ibit18_l * adv_mom_1          &
+                                      ( 37.0_wp * ibit11_l * adv_mom_5          &
+                                   +     7.0_wp * ibit10_l * adv_mom_3          &
+                                   +              ibit9_l * adv_mom_1          &
                                       ) *                                    &
                                      ( v(k,j,i)   + v(k,j,i-1) )             &
-                               -      (  8.0_wp * ibit20_l * adv_mom_5          &
-                                   +              ibit19_l * adv_mom_3          &
+                               -      (  8.0_wp * ibit11_l * adv_mom_5          &
+                                   +              ibit10_l * adv_mom_3          &
                                       ) *                                    &
                                      ( v(k,j,i+1) + v(k,j,i-2) )             &
-                               +      (           ibit20_l * adv_mom_5          &
+                               +      (           ibit11_l * adv_mom_5          &
                                       ) *                                    &
                                      ( v(k,j,i+2) + v(k,j,i-3) )             &
@@ -5322,14 +5559,14 @@
 
                  diss_l   = - ABS( u_comp_l ) * (                            &
-                                      ( 10.0_wp * ibit20_l * adv_mom_5          &
-                                   +     3.0_wp * ibit19_l * adv_mom_3          &
-                                   +              ibit18_l * adv_mom_1          &
+                                      ( 10.0_wp * ibit11_l * adv_mom_5          &
+                                   +     3.0_wp * ibit10_l * adv_mom_3          &
+                                   +              ibit9_l * adv_mom_1          &
                                       ) *                                    &
                                      ( v(k,j,i)   - v(k,j,i-1) )             &
-                               -      (  5.0_wp * ibit20_l * adv_mom_5          &
-                                   +              ibit19_l * adv_mom_3          &
+                               -      (  5.0_wp * ibit11_l * adv_mom_5          &
+                                   +              ibit10_l * adv_mom_3          &
                                       ) *                                    &
                                      ( v(k,j,i+1) - v(k,j,i-2) )             &
-                               +      (           ibit20_l * adv_mom_5          &
+                               +      (           ibit11_l * adv_mom_5          &
                                       ) *                                    &
                                      ( v(k,j,i+2) - v(k,j,i-3) )             &
@@ -5340,20 +5577,20 @@
 #endif
 
-                ibit23 = REAL( IBITS(advc_flags_1(k,j,i),23,1), KIND = wp )
-                ibit22 = REAL( IBITS(advc_flags_1(k,j,i),22,1), KIND = wp )
-                ibit21 = REAL( IBITS(advc_flags_1(k,j,i),21,1), KIND = wp )
+                ibit14 = REAL( IBITS(advc_flags_m(k,j,i),14,1), KIND = wp )
+                ibit13 = REAL( IBITS(advc_flags_m(k,j,i),13,1), KIND = wp )
+                ibit12 = REAL( IBITS(advc_flags_m(k,j,i),12,1), KIND = wp )
 
                 v_comp = v(k,j+1,i) + v(k,j,i)
                 flux_n = ( v_comp - gv ) * (                                 &
-                          ( 37.0_wp * ibit23 * adv_mom_5                        &
-                       +     7.0_wp * ibit22 * adv_mom_3                        &
-                       +              ibit21 * adv_mom_1                        &
+                          ( 37.0_wp * ibit14 * adv_mom_5                        &
+                       +     7.0_wp * ibit13 * adv_mom_3                        &
+                       +              ibit12 * adv_mom_1                        &
                           ) *                                                &
                                  ( v(k,j+1,i) + v(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit23 * adv_mom_5                        &
-                       +              ibit22 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit14 * adv_mom_5                        &
+                       +              ibit13 * adv_mom_3                        &
                           ) *                                                &
                                  ( v(k,j+2,i) + v(k,j-1,i) )                 &
-                   +      (           ibit23 * adv_mom_5                        &
+                   +      (           ibit14 * adv_mom_5                        &
                           ) *                                                &
                                  ( v(k,j+3,i) + v(k,j-2,i) )                 &
@@ -5361,14 +5598,14 @@
 
                 diss_n = - ABS( v_comp - gv ) * (                            &
-                          ( 10.0_wp * ibit23 * adv_mom_5                        &
-                       +     3.0_wp * ibit22 * adv_mom_3                        &
-                       +              ibit21 * adv_mom_1                        &
+                          ( 10.0_wp * ibit14 * adv_mom_5                        &
+                       +     3.0_wp * ibit13 * adv_mom_3                        &
+                       +              ibit12 * adv_mom_1                        &
                           ) *                                                &
                                  ( v(k,j+1,i) - v(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit23 * adv_mom_5                        &
-                       +              ibit22 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit14 * adv_mom_5                        &
+                       +              ibit13 * adv_mom_3                        &
                           ) *                                                &
                                  ( v(k,j+2,i) - v(k,j-1,i) )                 &
-                   +      (           ibit23 * adv_mom_5                        &
+                   +      (           ibit14 * adv_mom_5                        &
                           ) *                                                &
                                  ( v(k,j+3,i) - v(k,j-2,i) )                 &
@@ -5378,20 +5615,20 @@
 !
 !--             Recompute the south fluxes.
-                ibit23_s = REAL( IBITS(advc_flags_1(k,j-1,i),23,1), KIND = wp )
-                ibit22_s = REAL( IBITS(advc_flags_1(k,j-1,i),22,1), KIND = wp )
-                ibit21_s = REAL( IBITS(advc_flags_1(k,j-1,i),21,1), KIND = wp )
+                ibit14_s = REAL( IBITS(advc_flags_m(k,j-1,i),14,1), KIND = wp )
+                ibit13_s = REAL( IBITS(advc_flags_m(k,j-1,i),13,1), KIND = wp )
+                ibit12_s = REAL( IBITS(advc_flags_m(k,j-1,i),12,1), KIND = wp )
 
                 v_comp_s = v(k,j,i) + v(k,j-1,i) - gv
                 flux_s   = v_comp_s * (                                      &
-                                   ( 37.0_wp * ibit23_s * adv_mom_5             &
-                                +     7.0_wp * ibit22_s * adv_mom_3             &
-                                +              ibit21_s * adv_mom_1             &
+                                   ( 37.0_wp * ibit14_s * adv_mom_5             &
+                                +     7.0_wp * ibit13_s * adv_mom_3             &
+                                +              ibit12_s * adv_mom_1             &
                                    ) *                                       &
                                      ( v(k,j,i)   + v(k,j-1,i) )             &
-                            -      (  8.0_wp * ibit23_s * adv_mom_5             &
-                                +              ibit22_s * adv_mom_3             &
+                            -      (  8.0_wp * ibit14_s * adv_mom_5             &
+                                +              ibit13_s * adv_mom_3             &
                                    ) *                                       &
                                      ( v(k,j+1,i) + v(k,j-2,i) )             &
-                            +      (           ibit23_s * adv_mom_5             &
+                            +      (           ibit14_s * adv_mom_5             &
                                    ) *                                       &
                                      ( v(k,j+2,i) + v(k,j-3,i) )             &
@@ -5399,14 +5636,14 @@
 
                 diss_s   = - ABS( v_comp_s ) * (                             &
-                                   ( 10.0_wp * ibit23_s * adv_mom_5             &
-                                +     3.0_wp * ibit22_s * adv_mom_3             &
-                                +              ibit21_s * adv_mom_1             &
+                                   ( 10.0_wp * ibit14_s * adv_mom_5             &
+                                +     3.0_wp * ibit13_s * adv_mom_3             &
+                                +              ibit12_s * adv_mom_1             &
                                    ) *                                       &
                                      ( v(k,j,i)   - v(k,j-1,i) )             &
-                            -      (  5.0_wp * ibit23_s * adv_mom_5             &
-                                +              ibit22_s * adv_mom_3             &
+                            -      (  5.0_wp * ibit14_s * adv_mom_5             &
+                                +              ibit13_s * adv_mom_3             &
                                    ) *                                       &
                                      ( v(k,j+1,i) - v(k,j-2,i) )             &
-                            +      (           ibit23_s * adv_mom_5             &
+                            +      (           ibit14_s * adv_mom_5             &
                                    ) *                                       &
                                      ( v(k,j+2,i) - v(k,j-3,i) )             &
@@ -5420,24 +5657,24 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-                ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-                ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit26
-                k_pp  = k + 2 * ( 1 - ibit24  )
-                k_mm  = k - 2 * ibit26
+                ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+                ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+                ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit17
+                k_pp  = k + 2 * ( 1 - ibit15  )
+                k_mm  = k - 2 * ibit17
 
                 w_comp = w(k,j-1,i) + w(k,j,i)
                 flux_t = w_comp * rho_air_zw(k) * (                          &
-                          ( 37.0_wp * ibit26 * adv_mom_5                        &
-                       +     7.0_wp * ibit25 * adv_mom_3                        &
-                       +              ibit24 * adv_mom_1                        &
+                          ( 37.0_wp * ibit17 * adv_mom_5                        &
+                       +     7.0_wp * ibit16 * adv_mom_3                        &
+                       +              ibit15 * adv_mom_1                        &
                           ) *                                                &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-                   -      (  8.0_wp * ibit26 * adv_mom_5                        &
-                       +              ibit25 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit17 * adv_mom_5                        &
+                       +              ibit16 * adv_mom_3                        &
                           ) *                                                &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-                   +      (           ibit26 * adv_mom_5                        &
+                   +      (           ibit17 * adv_mom_5                        &
                           ) *                                                &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
@@ -5445,14 +5682,14 @@
 
                 diss_t = - ABS( w_comp ) * rho_air_zw(k) * (                 &
-                          ( 10.0_wp * ibit26 * adv_mom_5                        &
-                       +     3.0_wp * ibit25 * adv_mom_3                        &
-                       +              ibit24 * adv_mom_1                        &
+                          ( 10.0_wp * ibit17 * adv_mom_5                        &
+                       +     3.0_wp * ibit16 * adv_mom_3                        &
+                       +              ibit15 * adv_mom_1                        &
                           ) *                                                &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit26 * adv_mom_5                        &
-                       +              ibit25 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit17 * adv_mom_5                        &
+                       +              ibit16 * adv_mom_3                        &
                           ) *                                                &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-                   +      (           ibit26 * adv_mom_5                        &
+                   +      (           ibit17 * adv_mom_5                        &
                           ) *                                                &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
@@ -5463,28 +5700,28 @@
 !--             by a not sufficient reduction of divergences near topography.
                 div = ( ( ( u_comp     + gu )                                 &
-                                       * ( ibit18 + ibit19 + ibit20 )         &
+                                       * ( ibit9 + ibit10 + ibit11 )         &
                 - ( u(k,j-1,i)   + u(k,j,i) )                                 &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j,i-1),18,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),19,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j,i-1),20,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k,j,i-1),9,1), KIND = wp )   &
+                      + REAL( IBITS(advc_flags_m(k,j,i-1),10,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j,i-1),11,1), KIND = wp )  &
                                          )                                    &
                   ) * ddx                                                     &
                +  ( v_comp                                                    &
-                                       * ( ibit21 + ibit22 + ibit23 )         &
+                                       * ( ibit12 + ibit13 + ibit14 )         &
                 - ( v(k,j,i)     + v(k,j-1,i) )                               &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k,j-1,i),21,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),22,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k,j-1,i),23,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k,j-1,i),12,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j-1,i),13,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k,j-1,i),14,1), KIND = wp )  &
                                          )                                    &
                   ) * ddy                                                     &
                +  ( w_comp * rho_air_zw(k)                                    &
-                                       * ( ibit24 + ibit25 + ibit26 )         &
+                                       * ( ibit15 + ibit16 + ibit17 )         &
                 - ( w(k-1,j-1,i) + w(k-1,j,i) ) * rho_air_zw(k-1)             &
                                        * (                                    &
-                        REAL( IBITS(advc_flags_1(k-1,j,i),24,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),25,1), KIND = wp )  &
-                      + REAL( IBITS(advc_flags_1(k-1,j,i),26,1), KIND = wp )  &
+                        REAL( IBITS(advc_flags_m(k-1,j,i),15,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k-1,j,i),16,1), KIND = wp )  &
+                      + REAL( IBITS(advc_flags_m(k-1,j,i),17,1), KIND = wp )  &
                                          )                                    &
                    ) * drho_air(k) * ddzw(k)                                  &
@@ -5597,24 +5834,24 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit26 = REAL( IBITS(advc_flags_1(k,j,i),26,1), KIND = wp )
-                ibit25 = REAL( IBITS(advc_flags_1(k,j,i),25,1), KIND = wp )
-                ibit24 = REAL( IBITS(advc_flags_1(k,j,i),24,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit26
-                k_pp  = k + 2 * ( 1 - ibit24  )
-                k_mm  = k - 2 * ibit26
+                ibit17 = REAL( IBITS(advc_flags_m(k,j,i),17,1), KIND = wp )
+                ibit16 = REAL( IBITS(advc_flags_m(k,j,i),16,1), KIND = wp )
+                ibit15 = REAL( IBITS(advc_flags_m(k,j,i),15,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit17
+                k_pp  = k + 2 * ( 1 - ibit15  )
+                k_mm  = k - 2 * ibit17
 
                 w_comp = w(k,j-1,i) + w(k,j,i)
                 flux_t = w_comp * rho_air_zw(k) * (                          &
-                          ( 37.0_wp * ibit26 * adv_mom_5                        &
-                       +     7.0_wp * ibit25 * adv_mom_3                        &
-                       +              ibit24 * adv_mom_1                        &
+                          ( 37.0_wp * ibit17 * adv_mom_5                        &
+                       +     7.0_wp * ibit16 * adv_mom_3                        &
+                       +              ibit15 * adv_mom_1                        &
                           ) *                                                &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-                   -      (  8.0_wp * ibit26 * adv_mom_5                        &
-                       +              ibit25 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit17 * adv_mom_5                        &
+                       +              ibit16 * adv_mom_3                        &
                           ) *                                                &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-                   +      (           ibit26 * adv_mom_5                        &
+                   +      (           ibit17 * adv_mom_5                        &
                           ) *                                                &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
@@ -5622,14 +5859,14 @@
 
                 diss_t = - ABS( w_comp ) * rho_air_zw(k) * (                 &
-                          ( 10.0_wp * ibit26 * adv_mom_5                        &
-                       +     3.0_wp * ibit25 * adv_mom_3                        &
-                       +              ibit24 * adv_mom_1                        &
+                          ( 10.0_wp * ibit17 * adv_mom_5                        &
+                       +     3.0_wp * ibit16 * adv_mom_3                        &
+                       +              ibit15 * adv_mom_1                        &
                           ) *                                                &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit26 * adv_mom_5                        &
-                       +              ibit25 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit17 * adv_mom_5                        &
+                       +              ibit16 * adv_mom_3                        &
                           ) *                                                &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-                   +      (           ibit26 * adv_mom_5                        &
+                   +      (           ibit17 * adv_mom_5                        &
                           ) *                                                &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
@@ -5712,23 +5949,23 @@
        INTEGER(iwp) ::  tn = 0    !< number of OpenMP thread
        
-       REAL(wp)    ::  ibit27 !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit28 !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit29 !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit18 !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit19 !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit20 !< flag indicating 5th-order scheme along x-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit27_l !< flag indicating 1st-order scheme along x-direction
-       REAL(wp)    ::  ibit28_l !< flag indicating 3rd-order scheme along x-direction
-       REAL(wp)    ::  ibit29_l !< flag indicating 5th-order scheme along x-direction
+       REAL(wp)    ::  ibit18_l !< flag indicating 1st-order scheme along x-direction
+       REAL(wp)    ::  ibit19_l !< flag indicating 3rd-order scheme along x-direction
+       REAL(wp)    ::  ibit20_l !< flag indicating 5th-order scheme along x-direction
 #endif
-       REAL(wp)    ::  ibit30 !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit31 !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit32 !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit21 !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit22 !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit23 !< flag indicating 5th-order scheme along y-direction
 #ifdef _OPENACC
-       REAL(wp)    ::  ibit30_s !< flag indicating 1st-order scheme along y-direction
-       REAL(wp)    ::  ibit31_s !< flag indicating 3rd-order scheme along y-direction
-       REAL(wp)    ::  ibit32_s !< flag indicating 5th-order scheme along y-direction
+       REAL(wp)    ::  ibit21_s !< flag indicating 1st-order scheme along y-direction
+       REAL(wp)    ::  ibit22_s !< flag indicating 3rd-order scheme along y-direction
+       REAL(wp)    ::  ibit23_s !< flag indicating 5th-order scheme along y-direction
 #endif
-       REAL(wp)    ::  ibit33 !< flag indicating 1st-order scheme along z-direction
-       REAL(wp)    ::  ibit34 !< flag indicating 3rd-order scheme along z-direction
-       REAL(wp)    ::  ibit35 !< flag indicating 5th-order scheme along z-direction
+       REAL(wp)    ::  ibit24 !< flag indicating 1st-order scheme along z-direction
+       REAL(wp)    ::  ibit25 !< flag indicating 3rd-order scheme along z-direction
+       REAL(wp)    ::  ibit26 !< flag indicating 5th-order scheme along z-direction
        REAL(wp)    ::  diss_d !< artificial dissipation term at grid box bottom
        REAL(wp)    ::  div    !< divergence on w-grid
@@ -5792,20 +6029,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit29 = REAL( IBITS(advc_flags_1(k,j,i-1),29,1), KIND = wp )
-             ibit28 = REAL( IBITS(advc_flags_1(k,j,i-1),28,1), KIND = wp )
-             ibit27 = REAL( IBITS(advc_flags_1(k,j,i-1),27,1), KIND = wp )
+             ibit20 = REAL( IBITS(advc_flags_m(k,j,i-1),20,1), KIND = wp )
+             ibit19 = REAL( IBITS(advc_flags_m(k,j,i-1),19,1), KIND = wp )
+             ibit18 = REAL( IBITS(advc_flags_m(k,j,i-1),18,1), KIND = wp )
 
              u_comp                   = u(k+1,j,i) + u(k,j,i) - gu
              swap_flux_x_local_w(k,j) = u_comp * (                             &
-                                      ( 37.0_wp * ibit29 * adv_mom_5              &
-                                   +     7.0_wp * ibit28 * adv_mom_3              &
-                                   +              ibit27 * adv_mom_1              &
+                                      ( 37.0_wp * ibit20 * adv_mom_5              &
+                                   +     7.0_wp * ibit19 * adv_mom_3              &
+                                   +              ibit18 * adv_mom_1              &
                                       ) *                                      &
                                      ( w(k,j,i)   + w(k,j,i-1) )               &
-                               -      (  8.0_wp * ibit29 * adv_mom_5              &
-                                   +              ibit28 * adv_mom_3              &
+                               -      (  8.0_wp * ibit20 * adv_mom_5              &
+                                   +              ibit19 * adv_mom_3              &
                                       ) *                                      &
                                      ( w(k,j,i+1) + w(k,j,i-2) )               &
-                               +      (           ibit29 * adv_mom_5              &
+                               +      (           ibit20 * adv_mom_5              &
                                       ) *                                      &
                                      ( w(k,j,i+2) + w(k,j,i-3) )               &
@@ -5813,14 +6050,14 @@
 
                swap_diss_x_local_w(k,j) = - ABS( u_comp ) * (                  &
-                                        ( 10.0_wp * ibit29 * adv_mom_5            &
-                                     +     3.0_wp * ibit28 * adv_mom_3            &
-                                     +              ibit27 * adv_mom_1            &
+                                        ( 10.0_wp * ibit20 * adv_mom_5            &
+                                     +     3.0_wp * ibit19 * adv_mom_3            &
+                                     +              ibit18 * adv_mom_1            &
                                         ) *                                    &
                                      ( w(k,j,i)   - w(k,j,i-1) )               &
-                                 -      (  5.0_wp * ibit29 * adv_mom_5            &
-                                     +              ibit28 * adv_mom_3            &
+                                 -      (  5.0_wp * ibit20 * adv_mom_5            &
+                                     +              ibit19 * adv_mom_3            &
                                         ) *                                    &
                                      ( w(k,j,i+1) - w(k,j,i-2) )               &
-                                 +      (           ibit29 * adv_mom_5            &
+                                 +      (           ibit20 * adv_mom_5            &
                                         ) *                                    &
                                      ( w(k,j,i+2) - w(k,j,i-3) )               &
@@ -5848,13 +6085,13 @@
        !$ACC PARALLEL LOOP COLLAPSE(2) FIRSTPRIVATE(tn, gu, gv) &
        !$ACC PRIVATE(i, j, k, k_mm, k_pp, k_ppp) &
-       !$ACC PRIVATE(ibit27, ibit28, ibit29, ibit30, ibit31, ibit32) &
-       !$ACC PRIVATE(ibit27_l, ibit28_l, ibit29_l) &
-       !$ACC PRIVATE(ibit30_s, ibit31_s, ibit32_s) &
-       !$ACC PRIVATE(ibit33, ibit34, ibit35) &
+       !$ACC PRIVATE(ibit18, ibit19, ibit20, ibit21, ibit22, ibit23) &
+       !$ACC PRIVATE(ibit18_l, ibit19_l, ibit20_l) &
+       !$ACC PRIVATE(ibit21_s, ibit22_s, ibit23_s) &
+       !$ACC PRIVATE(ibit24, ibit25, ibit26) &
        !$ACC PRIVATE(flux_r, diss_r, flux_l, diss_l) &
        !$ACC PRIVATE(flux_n, diss_n, flux_s, diss_s) &
        !$ACC PRIVATE(flux_t, diss_t, flux_d, diss_d) &
        !$ACC PRIVATE(div, u_comp, u_comp_l, v_comp, v_comp_s, w_comp) &
-       !$ACC PRESENT(advc_flags_1, advc_flags_2) &
+       !$ACC PRESENT(advc_flags_m) &
        !$ACC PRESENT(u, v, w) &
        !$ACC PRESENT(rho_air, drho_air_zw, ddzu) &
@@ -5869,20 +6106,20 @@
           DO  k = nzb+1, nzb_max_l
 
-             ibit32 = REAL( IBITS(advc_flags_2(k,j-1,i),0,1),  KIND = wp )
-             ibit31 = REAL( IBITS(advc_flags_1(k,j-1,i),31,1), KIND = wp )
-             ibit30 = REAL( IBITS(advc_flags_1(k,j-1,i),30,1), KIND = wp )
+             ibit23 = REAL( IBITS(advc_flags_m(k,j-1,i),23,1),  KIND = wp )
+             ibit22 = REAL( IBITS(advc_flags_m(k,j-1,i),22,1), KIND = wp )
+             ibit21 = REAL( IBITS(advc_flags_m(k,j-1,i),21,1), KIND = wp )
 
              v_comp                 = v(k+1,j,i) + v(k,j,i) - gv
              swap_flux_y_local_w(k) = v_comp * (                              &
-                                    ( 37.0_wp * ibit32 * adv_mom_5               &
-                                 +     7.0_wp * ibit31 * adv_mom_3               &
-                                 +              ibit30 * adv_mom_1               &
+                                    ( 37.0_wp * ibit23 * adv_mom_5               &
+                                 +     7.0_wp * ibit22 * adv_mom_3               &
+                                 +              ibit21 * adv_mom_1               &
                                     ) *                                        &
                                      ( w(k,j,i)   + w(k,j-1,i) )              &
-                             -      (  8.0_wp * ibit32 * adv_mom_5               &
-                                 +              ibit31 * adv_mom_3               &
+                             -      (  8.0_wp * ibit23 * adv_mom_5               &
+                                 +              ibit22 * adv_mom_3               &
                                     ) *                                       &
                                      ( w(k,j+1,i) + w(k,j-2,i) )              &
-                             +      (           ibit32 * adv_mom_5               &
+                             +      (           ibit23 * adv_mom_5               &
                                     ) *                                       &
                                      ( w(k,j+2,i) + w(k,j-3,i) )              &
@@ -5890,14 +6127,14 @@
 
              swap_diss_y_local_w(k) = - ABS( v_comp ) * (                     &
-                                    ( 10.0_wp * ibit32 * adv_mom_5               &
-                                 +     3.0_wp * ibit31 * adv_mom_3               &
-                                 +              ibit30 * adv_mom_1               &
+                                    ( 10.0_wp * ibit23 * adv_mom_5               &
+                                 +     3.0_wp * ibit22 * adv_mom_3               &
+                                 +              ibit21 * adv_mom_1               &
                                     ) *                                       &
                                      ( w(k,j,i)   - w(k,j-1,i) )              &
-                             -      (  5.0_wp * ibit32 * adv_mom_5               &
-                                 +              ibit31 * adv_mom_3               &
+                             -      (  5.0_wp * ibit23 * adv_mom_5               &
+                                 +              ibit22 * adv_mom_3               &
                                     ) *                                       &
                                      ( w(k,j+1,i) - w(k,j-2,i) )              &
-                             +      (           ibit32 * adv_mom_5               &
+                             +      (           ibit23 * adv_mom_5               &
                                     ) *                                       &
                                      ( w(k,j+2,i) - w(k,j-3,i) )              &
@@ -5926,5 +6163,5 @@
 !--          The lower flux has to be calculated explicetely for the tendency
 !--          at the first w-level. For topography wall this is done implicitely
-!--          by advc_flags_1.
+!--          by advc_flags_m.
              k      = nzb + 1
              w_comp = w(k,j,i) + w(k-1,j,i)
@@ -5934,20 +6171,20 @@
              DO  k = nzb+1, nzb_max_l
 
-                ibit29 = REAL( IBITS(advc_flags_1(k,j,i),29,1), KIND = wp )
-                ibit28 = REAL( IBITS(advc_flags_1(k,j,i),28,1), KIND = wp )
-                ibit27 = REAL( IBITS(advc_flags_1(k,j,i),27,1), KIND = wp )
+                ibit20 = REAL( IBITS(advc_flags_m(k,j,i),20,1), KIND = wp )
+                ibit19 = REAL( IBITS(advc_flags_m(k,j,i),19,1), KIND = wp )
+                ibit18 = REAL( IBITS(advc_flags_m(k,j,i),18,1), KIND = wp )
 
                 u_comp = u(k+1,j,i+1) + u(k,j,i+1) - gu
                 flux_r = u_comp * (                                          &
-                          ( 37.0_wp * ibit29 * adv_mom_5                        &
-                       +     7.0_wp * ibit28 * adv_mom_3                        &
-                       +              ibit27 * adv_mom_1                        &
+                          ( 37.0_wp * ibit20 * adv_mom_5                        &
+                       +     7.0_wp * ibit19 * adv_mom_3                        &
+                       +              ibit18 * adv_mom_1                        &
                           ) *                                                &
                                  ( w(k,j,i+1) + w(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit29 * adv_mom_5                        &
-                       +              ibit28 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit20 * adv_mom_5                        &
+                       +              ibit19 * adv_mom_3                        &
                           ) *                                                &
                                  ( w(k,j,i+2) + w(k,j,i-1) )                 &
-                   +      (           ibit29 * adv_mom_5                        &
+                   +      (           ibit20 * adv_mom_5                        &
                           ) *                                                &
                                  ( w(k,j,i+3) + w(k,j,i-2) )                 &
@@ -5955,14 +6192,14 @@
 
                 diss_r = - ABS( u_comp ) * (                                 &
-                          ( 10.0_wp * ibit29 * adv_mom_5                        &
-                       +     3.0_wp * ibit28 * adv_mom_3                        &
-                       +              ibit27 * adv_mom_1                        &
+                          ( 10.0_wp * ibit20 * adv_mom_5                        &
+                       +     3.0_wp * ibit19 * adv_mom_3                        &
+                       +              ibit18 * adv_mom_1                        &
                           ) *                                                &
                                  ( w(k,j,i+1) - w(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit29 * adv_mom_5                        &
-                       +              ibit28 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit20 * adv_mom_5                        &
+                       +              ibit19 * adv_mom_3                        &
                           ) *                                                &
                                  ( w(k,j,i+2) - w(k,j,i-1) )                 &
-                   +      (           ibit29 * adv_mom_5                        &
+                   +      (           ibit20 * adv_mom_5                        &
                           ) *                                                &
                                  ( w(k,j,i+3) - w(k,j,i-2) )                 &
@@ -5972,20 +6209,20 @@
 !
 !--             Recompute the left fluxes.
-                ibit29_l = REAL( IBITS(advc_flags_1(k,j,i-1),29,1), KIND = wp )
-                ibit28_l = REAL( IBITS(advc_flags_1(k,j,i-1),28,1), KIND = wp )
-                ibit27_l = REAL( IBITS(advc_flags_1(k,j,i-1),27,1), KIND = wp )
+                ibit20_l = REAL( IBITS(advc_flags_m(k,j,i-1),20,1), KIND = wp )
+                ibit19_l = REAL( IBITS(advc_flags_m(k,j,i-1),19,1), KIND = wp )
+                ibit18_l = REAL( IBITS(advc_flags_m(k,j,i-1),18,1), KIND = wp )
 
                 u_comp_l = u(k+1,j,i) + u(k,j,i) - gu
                 flux_l   = u_comp_l * (                                      &
-                                      ( 37.0_wp * ibit29_l * adv_mom_5          &
-                                   +     7.0_wp * ibit28_l * adv_mom_3          &
-                                   +              ibit27_l * adv_mom_1          &
+                                      ( 37.0_wp * ibit20_l * adv_mom_5          &
+                                   +     7.0_wp * ibit19_l * adv_mom_3          &
+                                   +              ibit18_l * adv_mom_1          &
                                       ) *                                    &
                                      ( w(k,j,i)   + w(k,j,i-1) )             &
-                               -      (  8.0_wp * ibit29_l * adv_mom_5          &
-                                   +              ibit28_l * adv_mom_3          &
+                               -      (  8.0_wp * ibit20_l * adv_mom_5          &
+                                   +              ibit19_l * adv_mom_3          &
                                       ) *                                    &
                                      ( w(k,j,i+1) + w(k,j,i-2) )             &
-                               +      (           ibit29_l * adv_mom_5          &
+                               +      (           ibit20_l * adv_mom_5          &
                                       ) *                                    &
                                      ( w(k,j,i+2) + w(k,j,i-3) )             &
@@ -5993,14 +6230,14 @@
 
                 diss_l   = - ABS( u_comp_l ) * (                             &
-                                        ( 10.0_wp * ibit29_l * adv_mom_5        &
-                                     +     3.0_wp * ibit28_l * adv_mom_3        &
-                                     +              ibit27_l * adv_mom_1        &
+                                        ( 10.0_wp * ibit20_l * adv_mom_5        &
+                                     +     3.0_wp * ibit19_l * adv_mom_3        &
+                                     +              ibit18_l * adv_mom_1        &
                                         ) *                                  &
                                      ( w(k,j,i)   - w(k,j,i-1) )             &
-                                 -      (  5.0_wp * ibit29_l * adv_mom_5        &
-                                     +              ibit28_l * adv_mom_3        &
+                                 -      (  5.0_wp * ibit20_l * adv_mom_5        &
+                                     +              ibit19_l * adv_mom_3        &
                                         ) *                                  &
                                      ( w(k,j,i+1) - w(k,j,i-2) )             &
-                                 +      (           ibit29_l * adv_mom_5        &
+                                 +      (           ibit20_l * adv_mom_5        &
                                         ) *                                  &
                                      ( w(k,j,i+2) - w(k,j,i-3) )             &
@@ -6012,20 +6249,20 @@
 
 
-                ibit32 = REAL( IBITS(advc_flags_2(k,j,i),0,1),  KIND = wp )
-                ibit31 = REAL( IBITS(advc_flags_1(k,j,i),31,1), KIND = wp )
-                ibit30 = REAL( IBITS(advc_flags_1(k,j,i),30,1), KIND = wp )
+                ibit23 = REAL( IBITS(advc_flags_m(k,j,i),23,1), KIND = wp )
+                ibit22 = REAL( IBITS(advc_flags_m(k,j,i),22,1), KIND = wp )
+                ibit21 = REAL( IBITS(advc_flags_m(k,j,i),21,1), KIND = wp )
 
                 v_comp = v(k+1,j+1,i) + v(k,j+1,i) - gv
                 flux_n = v_comp * (                                          &
-                          ( 37.0_wp * ibit32 * adv_mom_5                        &
-                       +     7.0_wp * ibit31 * adv_mom_3                        &
-                       +              ibit30 * adv_mom_1                        &
+                          ( 37.0_wp * ibit23 * adv_mom_5                        &
+                       +     7.0_wp * ibit22 * adv_mom_3                        &
+                       +              ibit21 * adv_mom_1                        &
                           ) *                                                &
                                  ( w(k,j+1,i) + w(k,j,i)   )                 &
-                   -      (  8.0_wp * ibit32 * adv_mom_5                        &
-                       +              ibit31 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit23 * adv_mom_5                        &
+                       +              ibit22 * adv_mom_3                        &
                           ) *                                                 &
                                  ( w(k,j+2,i) + w(k,j-1,i) )                 &
-                   +      (           ibit32 * adv_mom_5                        &
+                   +      (           ibit23 * adv_mom_5                        &
                           ) *                                                &
                                  ( w(k,j+3,i) + w(k,j-2,i) )                 &
@@ -6033,14 +6270,14 @@
 
                 diss_n = - ABS( v_comp ) * (                                 &
-                          ( 10.0_wp * ibit32 * adv_mom_5                        &
-                       +     3.0_wp * ibit31 * adv_mom_3                        &
-                       +              ibit30 * adv_mom_1                        &
+                          ( 10.0_wp * ibit23 * adv_mom_5                        &
+                       +     3.0_wp * ibit22 * adv_mom_3                        &
+                       +              ibit21 * adv_mom_1                        &
                           ) *                                                &
                                  ( w(k,j+1,i) - w(k,j,i)  )                  &
-                   -      (  5.0_wp * ibit32 * adv_mom_5                        &
-                       +              ibit31 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit23 * adv_mom_5                        &
+                       +              ibit22 * adv_mom_3                        &
                           ) *                                                &
                                  ( w(k,j+2,i) - w(k,j-1,i) )                 &
-                   +      (           ibit32 * adv_mom_5                        &
+                   +      (           ibit23 * adv_mom_5                        &
                           ) *                                                &
                                  ( w(k,j+3,i) - w(k,j-2,i) )                 &
@@ -6050,20 +6287,20 @@
 !
 !--             Recompute the south fluxes.
-                ibit32_s = REAL( IBITS(advc_flags_2(k,j-1,i),0,1),  KIND = wp )
-                ibit31_s = REAL( IBITS(advc_flags_1(k,j-1,i),31,1), KIND = wp )
-                ibit30_s = REAL( IBITS(advc_flags_1(k,j-1,i),30,1), KIND = wp )
+                ibit23_s = REAL( IBITS(advc_flags_m(k,j-1,i),23,1), KIND = wp )
+                ibit22_s = REAL( IBITS(advc_flags_m(k,j-1,i),22,1), KIND = wp )
+                ibit21_s = REAL( IBITS(advc_flags_m(k,j-1,i),21,1), KIND = wp )
 
                 v_comp_s = v(k+1,j,i) + v(k,j,i) - gv
                 flux_s   = v_comp_s * (                                      &
-                                    ( 37.0_wp * ibit32_s * adv_mom_5            &
-                                 +     7.0_wp * ibit31_s * adv_mom_3            &
-                                 +              ibit30_s * adv_mom_1            &
+                                    ( 37.0_wp * ibit23_s * adv_mom_5            &
+                                 +     7.0_wp * ibit22_s * adv_mom_3            &
+                                 +              ibit21_s * adv_mom_1            &
                                     ) *                                      &
                                      ( w(k,j,i)   + w(k,j-1,i) )             &
-                             -      (  8.0_wp * ibit32_s * adv_mom_5            &
-                                 +              ibit31_s * adv_mom_3            &
+                             -      (  8.0_wp * ibit23_s * adv_mom_5            &
+                                 +              ibit22_s * adv_mom_3            &
                                     ) *                                      &
                                      ( w(k,j+1,i) + w(k,j-2,i) )             &
-                             +      (           ibit32_s * adv_mom_5            &
+                             +      (           ibit23_s * adv_mom_5            &
                                     ) *                                      &
                                      ( w(k,j+2,i) + w(k,j-3,i) )             &
@@ -6071,14 +6308,14 @@
 
                 diss_s   = - ABS( v_comp_s ) * (                             &
-                                    ( 10.0_wp * ibit32_s * adv_mom_5            &
-                                 +     3.0_wp * ibit31_s * adv_mom_3            &
-                                 +              ibit30_s * adv_mom_1            &
+                                    ( 10.0_wp * ibit23_s * adv_mom_5            &
+                                 +     3.0_wp * ibit22_s * adv_mom_3            &
+                                 +              ibit21_s * adv_mom_1            &
                                     ) *                                      &
                                      ( w(k,j,i)   - w(k,j-1,i) )             &
-                             -      (  5.0_wp * ibit32_s * adv_mom_5            &
-                                 +              ibit31_s * adv_mom_3            &
+                             -      (  5.0_wp * ibit23_s * adv_mom_5            &
+                                 +              ibit22_s * adv_mom_3            &
                                     ) *                                      &
                                      ( w(k,j+1,i) - w(k,j-2,i) )             &
-                             +      (           ibit32_s * adv_mom_5            &
+                             +      (           ibit23_s * adv_mom_5            &
                                     ) *                                      &
                                      ( w(k,j+2,i) - w(k,j-3,i) )             &
@@ -6092,24 +6329,24 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-                ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-                ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit35
-                k_pp  = k + 2 * ( 1 - ibit33  )
-                k_mm  = k - 2 * ibit35
+                ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+                ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+                ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit26
+                k_pp  = k + 2 * ( 1 - ibit24  )
+                k_mm  = k - 2 * ibit26
 
                 w_comp = w(k+1,j,i) + w(k,j,i)
                 flux_t = w_comp * rho_air(k+1) * (                           &
-                          ( 37.0_wp * ibit35 * adv_mom_5                        &
-                       +     7.0_wp * ibit34 * adv_mom_3                        &
-                       +              ibit33 * adv_mom_1                        &
+                          ( 37.0_wp * ibit26 * adv_mom_5                        &
+                       +     7.0_wp * ibit25 * adv_mom_3                        &
+                       +              ibit24 * adv_mom_1                        &
                           ) *                                                &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-                   -      (  8.0_wp * ibit35 * adv_mom_5                        &
-                       +              ibit34 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit26 * adv_mom_5                        &
+                       +              ibit25 * adv_mom_3                        &
                           ) *                                                &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-                   +      (           ibit35 * adv_mom_5                        &
+                   +      (           ibit26 * adv_mom_5                        &
                           ) *                                                &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
@@ -6117,14 +6354,14 @@
 
                 diss_t = - ABS( w_comp ) * rho_air(k+1) * (                  &
-                          ( 10.0_wp * ibit35 * adv_mom_5                        &
-                       +     3.0_wp * ibit34 * adv_mom_3                        &
-                       +              ibit33 * adv_mom_1                        &
+                          ( 10.0_wp * ibit26 * adv_mom_5                        &
+                       +     3.0_wp * ibit25 * adv_mom_3                        &
+                       +              ibit24 * adv_mom_1                        &
                           ) *                                                &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit35 * adv_mom_5                        &
-                       +              ibit34 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit26 * adv_mom_5                        &
+                       +              ibit25 * adv_mom_3                        &
                           ) *                                                &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-                   +      (           ibit35 * adv_mom_5                        &
+                   +      (           ibit26 * adv_mom_5                        &
                           ) *                                                &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
@@ -6134,26 +6371,26 @@
 !--             correction is needed to overcome numerical instabilities caused
 !--             by a not sufficient reduction of divergences near topography.
-                div = ( ( ( u_comp + gu ) * ( ibit27 + ibit28 + ibit29 )      &
+                div = ( ( ( u_comp + gu ) * ( ibit18 + ibit19 + ibit20 )      &
                   - ( u(k+1,j,i) + u(k,j,i)   )                               & 
                                     * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j,i-1),27,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),28,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j,i-1),29,1), KIND = wp )     &
+                     REAL( IBITS(advc_flags_m(k,j,i-1),18,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),19,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j,i-1),20,1), KIND = wp )     &
                                       )                                       &
                   ) * ddx                                                     &
-              +   ( ( v_comp + gv ) * ( ibit30 + ibit31 + ibit32 )            &
+              +   ( ( v_comp + gv ) * ( ibit21 + ibit22 + ibit23 )            &
                   - ( v(k+1,j,i) + v(k,j,i)   )                               &
                                     * (                                       &
-                     REAL( IBITS(advc_flags_1(k,j-1,i),30,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_1(k,j-1,i),31,1), KIND = wp )     &
-                   + REAL( IBITS(advc_flags_2(k,j-1,i),0,1),  KIND = wp )     &
+                     REAL( IBITS(advc_flags_m(k,j-1,i),21,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),22,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k,j-1,i),23,1),  KIND = wp )    &
                                       )                                       &
                   ) * ddy                                                     &
-              +   ( w_comp * rho_air(k+1) * ( ibit33 + ibit34 + ibit35 )      &
+              +   ( w_comp * rho_air(k+1) * ( ibit24 + ibit25 + ibit26 )      &
                 - ( w(k,j,i)   + w(k-1,j,i)   ) * rho_air(k)                  &
                                     * (                                       &
-                     REAL( IBITS(advc_flags_2(k-1,j,i),1,1), KIND = wp )      &
-                   + REAL( IBITS(advc_flags_2(k-1,j,i),2,1), KIND = wp )      &
-                   + REAL( IBITS(advc_flags_2(k-1,j,i),3,1), KIND = wp )      &
+                     REAL( IBITS(advc_flags_m(k-1,j,i),24,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),25,1), KIND = wp )     &
+                   + REAL( IBITS(advc_flags_m(k-1,j,i),26,1), KIND = wp )     &
                                       )                                       & 
                   ) * drho_air_zw(k) * ddzu(k+1)                              &
@@ -6210,9 +6447,9 @@
                 u_comp_l = u(k+1,j,i) + u(k,j,i) - gu
                 flux_l   = u_comp_l * (                                     &
-                            37.0_wp * ( w(k,j,i) + w(k,j,i-1)   )              &
+                            37.0_wp * ( w(k,j,i)   + w(k,j,i-1)   )              &
                           -  8.0_wp * ( w(k,j,i+1) + w(k,j,i-2) )              &
                           +           ( w(k,j,i+2) + w(k,j,i-3) ) ) * adv_mom_5
                 diss_l   = - ABS( u_comp_l ) * (                            &
-                            10.0_wp * ( w(k,j,i) - w(k,j,i-1)   )              &
+                            10.0_wp * ( w(k,j,i)   - w(k,j,i-1)   )              &
                           -  5.0_wp * ( w(k,j,i+1) - w(k,j,i-2) )              &
                           +           ( w(k,j,i+2) - w(k,j,i-3) ) ) * adv_mom_5
@@ -6238,9 +6475,9 @@
                 v_comp_s = v(k+1,j,i) + v(k,j,i) - gv
                 flux_s   = v_comp_s * (                                     &
-                           37.0_wp * ( w(k,j,i) + w(k,j-1,i)   )               &
+                           37.0_wp * ( w(k,j,i)   + w(k,j-1,i) )               &
                          -  8.0_wp * ( w(k,j+1,i) +w(k,j-2,i)  )               &
                          +           ( w(k,j+2,i) + w(k,j-3,i) ) ) * adv_mom_5
                 diss_s   = - ABS( v_comp_s ) * (                            &
-                           10.0_wp * ( w(k,j,i) - w(k,j-1,i)   )               &
+                           10.0_wp * ( w(k,j,i)   - w(k,j-1,i) )               &
                          -  5.0_wp * ( w(k,j+1,i) - w(k,j-2,i) )               &
                          +           ( w(k,j+2,i) - w(k,j-3,i) ) ) * adv_mom_5
@@ -6253,24 +6490,24 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                ibit35 = REAL( IBITS(advc_flags_2(k,j,i),3,1), KIND = wp )
-                ibit34 = REAL( IBITS(advc_flags_2(k,j,i),2,1), KIND = wp )
-                ibit33 = REAL( IBITS(advc_flags_2(k,j,i),1,1), KIND = wp )
-
-                k_ppp = k + 3 * ibit35
-                k_pp  = k + 2 * ( 1 - ibit33  )
-                k_mm  = k - 2 * ibit35
+                ibit26 = REAL( IBITS(advc_flags_m(k,j,i),26,1), KIND = wp )
+                ibit25 = REAL( IBITS(advc_flags_m(k,j,i),25,1), KIND = wp )
+                ibit24 = REAL( IBITS(advc_flags_m(k,j,i),24,1), KIND = wp )
+
+                k_ppp = k + 3 * ibit26
+                k_pp  = k + 2 * ( 1 - ibit24  )
+                k_mm  = k - 2 * ibit26
 
                 w_comp = w(k+1,j,i) + w(k,j,i)
                 flux_t = w_comp * rho_air(k+1) * (                           &
-                          ( 37.0_wp * ibit35 * adv_mom_5                        &
-                       +     7.0_wp * ibit34 * adv_mom_3                        &
-                       +              ibit33 * adv_mom_1                        &
+                          ( 37.0_wp * ibit26 * adv_mom_5                        &
+                       +     7.0_wp * ibit25 * adv_mom_3                        &
+                       +              ibit24 * adv_mom_1                        &
                           ) *                                                &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-                   -      (  8.0_wp * ibit35 * adv_mom_5                        &
-                       +              ibit34 * adv_mom_3                        &
+                   -      (  8.0_wp * ibit26 * adv_mom_5                        &
+                       +              ibit25 * adv_mom_3                        &
                           ) *                                                &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-                   +      (           ibit35 * adv_mom_5                        &
+                   +      (           ibit26 * adv_mom_5                        &
                           ) *                                                &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
@@ -6278,14 +6515,14 @@
 
                 diss_t = - ABS( w_comp ) * rho_air(k+1) * (                  &
-                          ( 10.0_wp * ibit35 * adv_mom_5                        &
-                       +     3.0_wp * ibit34 * adv_mom_3                        &
-                       +              ibit33 * adv_mom_1                        &
+                          ( 10.0_wp * ibit26 * adv_mom_5                        &
+                       +     3.0_wp * ibit25 * adv_mom_3                        &
+                       +              ibit24 * adv_mom_1                        &
                           ) *                                                &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-                   -      (  5.0_wp * ibit35 * adv_mom_5                        &
-                       +              ibit34 * adv_mom_3                        &
+                   -      (  5.0_wp * ibit26 * adv_mom_5                        &
+                       +              ibit25 * adv_mom_3                        &
                           ) *                                                &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-                   +      (           ibit35 * adv_mom_5                        &
+                   +      (           ibit26 * adv_mom_5                        &
                           ) *                                                &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
Index: /palm/trunk/SOURCE/bulk_cloud_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4109)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! Pass integer flag array as well as boundary flags to WS scalar advection 
+! routine
 ! 
 ! Former revisions:
@@ -249,5 +250,13 @@
 
     USE control_parameters,                                                    &
-        ONLY:  debug_output,                                                   &
+        ONLY:  bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &                                                                
+               debug_output,                                                   &
                dt_3d, dt_do2d_xy, intermediate_timestep_count,                 &
                intermediate_timestep_count_max, large_scale_forcing,           &
@@ -266,5 +275,6 @@
 
     USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt,     &
+        ONLY:  advc_flags_s,                                                   &
+               nbgp, nxl, nxlg, nxr, nxrg, nys, nysg, nyn, nyng, nzb, nzt,     &
                wall_flags_0
 
@@ -1483,5 +1493,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( qc, 'qc' )
+                   CALL advec_s_ws( advc_flags_s, qc, 'qc',                    &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( qc )
@@ -1569,5 +1583,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( nc, 'nc' )
+                   CALL advec_s_ws( advc_flags_s, nc, 'nc',                    &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( nc )
@@ -1662,5 +1680,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( qr, 'qr' )
+                   CALL advec_s_ws( advc_flags_s, qr, 'qr',                    &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( qr )
@@ -1748,5 +1770,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( nr, 'nr' )
+                   CALL advec_s_ws( advc_flags_s, nr, 'nr',                    &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( nr )
@@ -1842,7 +1868,11 @@
           THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( i, j, qc, 'qc', flux_s_qc,       &
-                                 diss_s_qc, flux_l_qc, diss_l_qc, &
-                                 i_omp_start, tn )
+                CALL advec_s_ws( advc_flags_s, i, j, qc, 'qc', flux_s_qc,      &
+                                 diss_s_qc, flux_l_qc, diss_l_qc,              &
+                                 i_omp_start, tn,                              &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( i, j, qc )
@@ -1897,7 +1927,11 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( i, j, nc, 'nc', flux_s_nc,    &
-                              diss_s_nc, flux_l_nc, diss_l_nc, &
-                              i_omp_start, tn )
+                CALL advec_s_ws( advc_flags_s, i, j, nc, 'nc', flux_s_nc,      &
+                                 diss_s_nc, flux_l_nc, diss_l_nc,              &
+                                 i_omp_start, tn,                              &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( i, j, nc )
@@ -1958,7 +1992,11 @@
           THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( i, j, qr, 'qr', flux_s_qr,       &
-                                 diss_s_qr, flux_l_qr, diss_l_qr, &
-                                 i_omp_start, tn )
+                CALL advec_s_ws( advc_flags_s, i, j, qr, 'qr', flux_s_qr,      &
+                                 diss_s_qr, flux_l_qr, diss_l_qr,              &
+                                 i_omp_start, tn,                              &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( i, j, qr )
@@ -2013,7 +2051,11 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( i, j, nr, 'nr', flux_s_nr,    &
-                              diss_s_nr, flux_l_nr, diss_l_nr, &
-                              i_omp_start, tn )
+                CALL advec_s_ws( advc_flags_s, i, j, nr, 'nr', flux_s_nr,      &
+                                 diss_s_nr, flux_l_nr, diss_l_nr,              &
+                                 i_omp_start, tn,                              &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( i, j, nr )
Index: /palm/trunk/SOURCE/chem_modules.f90
===================================================================
--- /palm/trunk/SOURCE/chem_modules.f90	(revision 4108)
+++ /palm/trunk/SOURCE/chem_modules.f90	(revision 4109)
@@ -22,5 +22,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! +cs_advc_flags_s
 ! 
 ! Former revisions:
@@ -130,4 +130,7 @@
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  match_spec_voc_input  !< index of VOC input components matching the model's VOCs
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  match_spec_voc_model  !< index of VOC model species matching the input VOCs comp.
+    
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE  ::  cs_advc_flags_s !< flags used to degrade order of advection scheme for 
+                                                                     !< chemical species near walls and lateral boundaries
 
     LOGICAL ::  constant_top_csflux(99)   = .TRUE.   !< internal flag, set to .FALSE. if no top_csflux is prescribed
Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4109)
@@ -22,5 +22,14 @@
 ! Current revisions:
 ! -----------------
-! 
+! - Decycling boundary conditions are only set at the ghost points not on the
+!   prognostic grid points 
+! - Allocation and initialization of special advection flags cs_advc_flags_s
+!   used for chemistry. These are exclusively used for chemical species in 
+!   order to distinguish from the usually-used flags which might be different
+!   when decycling is applied in combination with cyclic boundary conditions. 
+!   Moreover, cs_advc_flags_s considers extended zones around buildings where 
+!   first-order upwind scheme is applied for the horizontal advection terms, 
+!   in order to overcome high concentration peaks due to stationary numerical 
+!   oscillations caused by horizontal advection discretization.
 ! 
 ! Former revisions:
@@ -344,5 +353,5 @@
 
     USE advec_ws,                                                                                  &
-         ONLY:  advec_s_ws
+         ONLY:  advec_s_ws, ws_init_flags_scalar
 
     USE diffusion_s_mod,                                                                           &
@@ -353,5 +362,6 @@
 
     USE indices,                                                                                   &
-         ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, nzb, nzt, wall_flags_0
+         ONLY:  advc_flags_s,                                                                      &
+                nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz, nzb, nzt, wall_flags_0
 
     USE pegrid,                                                                                    &
@@ -363,4 +373,12 @@
     USE control_parameters,                                                                        &
          ONLY:  bc_lr_cyc, bc_ns_cyc,                                                              &
+                bc_dirichlet_l,                                                                    &
+                bc_dirichlet_n,                                                                    &
+                bc_dirichlet_r,                                                                    &
+                bc_dirichlet_s,                                                                    &
+                bc_radiation_l,                                                                    &
+                bc_radiation_n,                                                                    &
+                bc_radiation_r,                                                                    &
+                bc_radiation_s,                                                                    &
                 debug_output,                                                                      &
                 dt_3d, humidity, initializing_actions, message_string,                             &
@@ -368,4 +386,5 @@
                 max_pr_user,                                                                       &
                 monotonic_limiter_z,                                                               &
+                scalar_advec,                                                                      &
                 timestep_scheme, use_prescribed_profile_data, ws_scheme_sca, air_chemistry
 
@@ -962,7 +981,7 @@
             IF ( boundary == 1  .AND.  nxl == 0 )  THEN
                ss = nxlg
-               ee = nxl+2
+               ee = nxl-1
             ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
-               ss = nxr-2
+               ss = nxr+1
                ee = nxrg
             ENDIF
@@ -1026,7 +1045,7 @@
             IF ( boundary == 3  .AND.  nys == 0 )  THEN
                ss = nysg
-               ee = nys+2
+               ee = nys-1
             ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
-               ss = nyn-2
+               ss = nyn+1
                ee = nyng
             ENDIF
@@ -1854,5 +1873,5 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE chem_init_internal
-
+ 
     USE pegrid
 
@@ -1921,4 +1940,102 @@
 
     ENDDO
+!
+!-- Set control flags for decycling only at lateral boundary cores, within the 
+!-- inner cores the decycle flag is set to .False.. Even though it does not 
+!-- affect the setting of chemistry boundary conditions, this flag is used to
+!-- set advection control flags appropriately. 
+    decycle_chem_lr = MERGE( decycle_chem_lr, .FALSE.,                         &
+                             nxl == 0  .OR.  nxr == nx )
+    decycle_chem_ns = MERGE( decycle_chem_ns, .FALSE.,                         &
+                             nys == 0  .OR.  nyn == ny )
+!
+!-- For some passive scalars decycling may be enabled. This case, the lateral 
+!-- boundary conditions are non-cyclic for these scalars (chemical species
+!-- and aerosols), while the other scalars may have
+!-- cyclic boundary conditions. However, large gradients near the boundaries
+!-- may produce stationary numerical oscillations near the lateral boundaries
+!-- when a higher-order scheme is applied near these boundaries. 
+!-- To get rid-off this, set-up additional flags that control the order of the 
+!-- scalar advection scheme near the lateral boundaries for passive scalars 
+!-- with decycling.
+    IF ( scalar_advec == 'ws-scheme' )  THEN
+       ALLOCATE( cs_advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+!
+!--    In case of decyling, set Neumann boundary conditions for wall_flags_0 
+!--    bit 31 instead of cyclic boundary conditions.
+!--    Bit 31 is used to identify extended degradation zones (please see
+!--    following comment). 
+!--    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_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
+!--    bit 31 won't be used to control the numerical order. 
+!--    Initialize with flag 31 only. 
+       cs_advc_flags_s = 0
+       cs_advc_flags_s = MERGE( IBSET( cs_advc_flags_s, 31 ), 0,               &
+                                BTEST( wall_flags_0, 31 ) )
+
+       IF ( decycle_chem_ns )  THEN
+          IF ( nys == 0  )  THEN
+             DO  i = 1, nbgp     
+                cs_advc_flags_s(:,nys-i,:) = MERGE(                            &
+                                        IBSET( cs_advc_flags_s(:,nys,:), 31 ), &
+                                        IBCLR( cs_advc_flags_s(:,nys,:), 31 ), &
+                                        BTEST( cs_advc_flags_s(:,nys,:), 31 )  &
+                                                  )
+             ENDDO
+          ENDIF
+          IF ( nyn == ny )  THEN
+             DO  i = 1, nbgp  
+                cs_advc_flags_s(:,nyn+i,:) = MERGE(                            &
+                                        IBSET( cs_advc_flags_s(:,nyn,:), 31 ), &
+                                        IBCLR( cs_advc_flags_s(:,nyn,:), 31 ), &
+                                        BTEST( cs_advc_flags_s(:,nyn,:), 31 )  &
+                                                  )
+             ENDDO
+          ENDIF
+       ENDIF
+       IF ( .NOT. decycle_chem_lr )  THEN
+          IF ( nxl == 0  )  THEN
+             DO  i = 1, nbgp   
+                cs_advc_flags_s(:,:,nxl-i) = MERGE(                            &
+                                        IBSET( cs_advc_flags_s(:,:,nxl), 31 ), &
+                                        IBCLR( cs_advc_flags_s(:,:,nxl), 31 ), &
+                                        BTEST( cs_advc_flags_s(:,:,nxl), 31 )  &
+                                                  )
+             ENDDO
+          ENDIF
+          IF ( nxr == nx )  THEN 
+             DO  i = 1, nbgp   
+                cs_advc_flags_s(:,:,nxr+i) = MERGE(                            &
+                                        IBSET( cs_advc_flags_s(:,:,nxr), 31 ), &
+                                        IBCLR( cs_advc_flags_s(:,:,nxr), 31 ), &
+                                        BTEST( cs_advc_flags_s(:,:,nxr), 31 )  &
+                                                  )
+             ENDDO
+          ENDIF      
+       ENDIF
+!
+!--    To initialize advection flags appropriately, pass the boundary flags. 
+!--    The last argument indicates that a passive scalar is treated, where
+!--    the horizontal advection terms are degraded already 2 grid points before
+!--    the lateral boundary to avoid stationary oscillations at large-gradients. 
+!--    Also, extended degradation zones are applied, where horizontal advection of 
+!--    passive scalars is discretized by first-order scheme at all grid points 
+!--    that in the vicinity of buildings (<= 3 grid points). Even though no 
+!--    building is within the numerical stencil, first-order scheme is used. 
+!--    At fourth and fifth grid point the order of the horizontal advection scheme
+!--    is successively upgraded.
+!--    These extended degradation zones are used to avoid stationary numerical 
+!--    oscillations, which are responsible for high concentration maxima that may
+!--    appear under shear-free stable conditions. 
+       CALL ws_init_flags_scalar(                                              &
+                  bc_dirichlet_l  .OR.  bc_radiation_l  .OR.  decycle_chem_lr, &
+                  bc_dirichlet_n  .OR.  bc_radiation_n  .OR.  decycle_chem_ns, &
+                  bc_dirichlet_r  .OR.  bc_radiation_r  .OR.  decycle_chem_lr, &
+                  bc_dirichlet_s  .OR.  bc_radiation_s  .OR.  decycle_chem_ns, &
+                  cs_advc_flags_s, .TRUE. )
+    ENDIF
 !
 !-- Initial concentration of profiles is prescribed by parameters cs_profile
@@ -2650,5 +2767,9 @@
        IF ( timestep_scheme(1:5) == 'runge' )  THEN
           IF ( ws_scheme_sca )  THEN
-             CALL advec_s_ws( chem_species(ilsp)%conc, 'kc' )
+             CALL advec_s_ws( cs_advc_flags_s, chem_species(ilsp)%conc, 'kc',                      &
+                              bc_dirichlet_l  .OR.  bc_radiation_l  .OR.  decycle_chem_lr,         &
+                              bc_dirichlet_n  .OR.  bc_radiation_n  .OR.  decycle_chem_ns,         &
+                              bc_dirichlet_r  .OR.  bc_radiation_r  .OR.  decycle_chem_lr,         &
+                              bc_dirichlet_s  .OR.  bc_radiation_s  .OR.  decycle_chem_ns )
           ELSE
              CALL advec_s_pw( chem_species(ilsp)%conc )
@@ -2755,7 +2876,20 @@
        IF ( timestep_scheme(1:5) == 'runge' )  THEN
           IF ( ws_scheme_sca )  THEN
-             CALL advec_s_ws( i, j, chem_species(ilsp)%conc, 'kc', chem_species(ilsp)%flux_s_cs,   &
-                              chem_species(ilsp)%diss_s_cs, chem_species(ilsp)%flux_l_cs,          &
-                              chem_species(ilsp)%diss_l_cs, i_omp_start, tn, monotonic_limiter_z )
+             CALL advec_s_ws( cs_advc_flags_s,                                                     &
+                              i,                                                                   &
+                              j,                                                                   &
+                              chem_species(ilsp)%conc,                                             &
+                              'kc',                                                                &
+                              chem_species(ilsp)%flux_s_cs,                                        &
+                              chem_species(ilsp)%diss_s_cs,                                        &
+                              chem_species(ilsp)%flux_l_cs,                                        &
+                              chem_species(ilsp)%diss_l_cs,                                        &
+                              i_omp_start,                                                         &
+                              tn,                                                                  &
+                              bc_dirichlet_l  .OR.  bc_radiation_l  .OR.  decycle_chem_lr,         &
+                              bc_dirichlet_n  .OR.  bc_radiation_n  .OR.  decycle_chem_ns,         &
+                              bc_dirichlet_r  .OR.  bc_radiation_r  .OR.  decycle_chem_lr,         &
+                              bc_dirichlet_s  .OR.  bc_radiation_s  .OR.  decycle_chem_ns,         &
+                              monotonic_limiter_z )
           ELSE
              CALL advec_s_pw( i, j, chem_species(ilsp)%conc )
Index: /palm/trunk/SOURCE/init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/init_grid.f90	(revision 4108)
+++ /palm/trunk/SOURCE/init_grid.f90	(revision 4109)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! - Separate initialization of advection flags for momentum and scalars.
+! - Change subroutine interface for ws_init_flags_scalar to pass boundary flags
 ! 
 ! Former revisions:
@@ -373,5 +374,5 @@
  
     USE advec_ws,                                                              &
-        ONLY:  ws_init_flags
+        ONLY:  ws_init_flags_momentum, ws_init_flags_scalar
 
     USE arrays_3d,                                                             &
@@ -380,4 +381,12 @@
     USE control_parameters,                                                    &
         ONLY:  bc_lr_cyc, bc_ns_cyc,                                           &
+               bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &
                constant_flux_layer, dz, dz_max, dz_stretch_factor,             &
                dz_stretch_factor_array, dz_stretch_level, dz_stretch_level_end,&
@@ -392,5 +401,7 @@
         
     USE indices,                                                               &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz,   &
+        ONLY:  advc_flags_m,                                                   &
+               advc_flags_s,                                                   &
+               nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nz,   &
                nzb, nzb_diff, nzb_diff_s_inner, nzb_diff_s_outer,              &
                nzb_max, nzb_s_inner, nzb_s_outer, nzb_u_inner,                 &
@@ -845,11 +856,25 @@
 !-- Calculate wall flag arrays for the multigrid method.
 !-- Please note, wall flags are only applied in the non-optimized version.
-    IF ( psolver == 'multigrid_noopt' )  CALL poismg_noopt_init 
+    IF ( psolver == 'multigrid_noopt' )  CALL poismg_noopt_init
 
 !
 !-- Init flags for ws-scheme to degrade order of the numerics near walls, i.e. 
-!-- to decrease the numerical stencil appropriately.
-    IF ( momentum_advec == 'ws-scheme'  .OR.  scalar_advec == 'ws-scheme' )    &
-       CALL ws_init_flags
+!-- to decrease the numerical stencil appropriately. The order of the scheme
+!-- is degraded near solid walls as well as near non-cyclic inflow and outflow
+!-- boundaries. Do this separately for momentum and scalars.
+    IF ( momentum_advec == 'ws-scheme' )  THEN
+       ALLOCATE( advc_flags_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       CALL ws_init_flags_momentum
+    ENDIF
+    IF ( scalar_advec == 'ws-scheme'   )  THEN
+       ALLOCATE( advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       advc_flags_s = 0
+       
+       CALL ws_init_flags_scalar( bc_dirichlet_l  .OR.  bc_radiation_l,        &
+                                  bc_dirichlet_n  .OR.  bc_radiation_n,        &
+                                  bc_dirichlet_r  .OR.  bc_radiation_r,        &
+                                  bc_dirichlet_s  .OR.  bc_radiation_s,        &
+                                  advc_flags_s )
+    ENDIF
 
 !
@@ -861,6 +886,5 @@
        DO  j = nys, nyn
           DO  k = nzb, nzt + 1
-             k_top = MAX( k_top, MERGE( k, 0,                                  &
-                                        .NOT. BTEST( topo(k,j,i), 0 ) ) )
+             k_top = MAX( k_top, MERGE( k, 0, .NOT. BTEST( topo(k,j,i), 0 ) ) )
           ENDDO
        ENDDO
@@ -2496,5 +2520,5 @@
     USE control_parameters,                                                    &
         ONLY:  bc_lr_cyc, bc_ns_cyc, constant_flux_layer, land_surface,        &
-               use_surface_fluxes, use_top_fluxes, urban_surface
+               scalar_advec, use_surface_fluxes, use_top_fluxes, urban_surface
 
     USE indices,                                                               &
@@ -2724,4 +2748,32 @@
           wall_flags_0(nzt+1,j,i) = IBSET( wall_flags_0(nzt+1,j,i), 22 )
           wall_flags_0(nzt+1,j,i) = IBSET( wall_flags_0(nzt+1,j,i), 23 )
+!
+!--       Set flags indicating that topography is close by in horizontal 
+!--       direction, i.e. flags that infold the topography. These will be used
+!--       to set advection flags for passive scalars, where due to large 
+!--       gradients near buildings stationary numerical oscillations can produce 
+!--       unrealistically high concentrations. This is only necessary if 
+!--       WS-scheme is applied for scalar advection. Note, these flags will be 
+!--       only used for passive scalars such as chemical species or aerosols.
+          IF ( scalar_advec == 'ws-scheme' )  THEN
+             DO k = nzb, nzt
+                IF ( BTEST( wall_flags_0(k,j,i), 0 )  .AND. (                   &
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i-1), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i-2), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i-3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i+1), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i+2), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3:j+3,i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-1,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-2,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j-3,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j+1,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j+2,i-3:i+3), 0 ) )  .OR.&
+                     ANY( .NOT. BTEST( wall_flags_0(k,j+3,i-3:i+3), 0 ) )      &
+                                                            ) )                &
+                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 31 )
+                     
+             ENDDO
+          ENDIF
        ENDDO
     ENDDO
Index: /palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 4109)
@@ -20,5 +20,9 @@
 ! Current revisions:
 ! -----------------
-! 
+! Relax checks for non-consistent initialization in case static or dynamic 
+! input is provided. For example, soil_temperature or deep_soil_temperature
+! is not mandatory any more if dynamic input is available. Also, improper 
+! settings of x_type in namelist are only checked if no static file is 
+! available. 
 ! 
 ! Former revisions:
@@ -591,5 +595,7 @@
 
     USE netcdf_data_input_mod,                                                 &
-        ONLY :  building_type_f, init_3d, input_pids_static,                   &
+        ONLY :  building_type_f, init_3d,                                      &
+                input_pids_dynamic,                                            &
+                input_pids_static,                                             &
                 netcdf_data_input_interpolate, netcdf_data_input_init_lsm,     &
                 pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f,  &
@@ -727,5 +733,5 @@
                                    soil_temperature = 9999999.9_wp,  & !< NAMELIST soil temperature (K) +1
                                    dz_soil  = 9999999.9_wp,          & !< (NAMELIST) soil layer depths (spacing)
-                                   zs_layer = 9999999.9_wp         !< soil layer depths (edge)
+                                   zs_layer = 9999999.9_wp             !< soil layer depths (edge)
                                  
     TYPE(surf_type_lsm), POINTER ::  t_soil_h,    & !< Soil temperature (K), horizontal surface elements
@@ -1437,6 +1443,5 @@
 !-- Check if soil types are set within a valid range.
     IF ( TRIM( surface_type ) == 'vegetation'  .OR.                            &
-         TRIM( surface_type ) == 'pavement'    .OR.                            &
-         TRIM( surface_type ) == 'netcdf' )  THEN
+         TRIM( surface_type ) == 'pavement' )  THEN
        IF ( soil_type < LBOUND( soil_pars, 2 )  .AND.                          &
             soil_type > UBOUND( soil_pars, 2 ) )  THEN
@@ -1445,4 +1450,6 @@
           CALL message( 'lsm_check_parameters', 'PA0452', 2, 2, 0, 6, 0 )
        ENDIF
+    ENDIF
+    IF ( TRIM( surface_type ) == 'netcdf' )  THEN
        IF ( soil_type_f%from_file )  THEN
           DO  i = nxl, nxr
@@ -1462,6 +1469,5 @@
 !
 !-- Check if vegetation types are set within a valid range.    
-    IF ( TRIM( surface_type ) == 'vegetation'  .OR.                            &
-         TRIM( surface_type ) == 'netcdf' )  THEN
+    IF ( TRIM( surface_type ) == 'vegetation' )  THEN
        IF ( vegetation_type < LBOUND( vegetation_pars, 2 )  .AND.              &
             vegetation_type > UBOUND( vegetation_pars, 2 ) )  THEN
@@ -1470,4 +1476,6 @@
           CALL message( 'lsm_check_parameters', 'PA0526', 2, 2, 0, 6, 0 )
        ENDIF
+    ENDIF
+    IF ( TRIM( surface_type ) == 'netcdf' )  THEN
        IF ( vegetation_type_f%from_file )  THEN
           DO  i = nxl, nxr
@@ -1488,6 +1496,5 @@
 !
 !-- Check if pavement types are set within a valid range.    
-    IF ( TRIM( surface_type ) == 'pavement'  .OR.                              &
-         TRIM( surface_type ) == 'netcdf' )  THEN
+    IF ( TRIM( surface_type ) == 'pavement' )  THEN
        IF ( pavement_type < LBOUND( pavement_pars, 2 )  .AND.                  &
             pavement_type > UBOUND( pavement_pars, 2 ) )  THEN
@@ -1496,4 +1503,6 @@
           CALL message( 'lsm_check_parameters', 'PA0527', 2, 2, 0, 6, 0 )
        ENDIF
+    ENDIF
+    IF ( TRIM( surface_type ) == 'netcdf' )  THEN
        IF ( pavement_type_f%from_file )  THEN
           DO  i = nxl, nxr
@@ -1513,6 +1522,5 @@
 !
 !-- Check if water types are set within a valid range.    
-    IF ( TRIM( surface_type ) == 'water'  .OR.                                 &
-         TRIM( surface_type ) == 'netcdf' )  THEN
+    IF ( TRIM( surface_type ) == 'water' )  THEN
        IF ( water_type < LBOUND( water_pars, 2 )  .AND.                        &
             water_type > UBOUND( water_pars, 2 ) )  THEN
@@ -1521,4 +1529,6 @@
           CALL message( 'lsm_check_parameters', 'PA0528', 2, 2, 0, 6, 0 )
        ENDIF
+    ENDIF
+    IF ( TRIM( surface_type ) == 'netcdf' )  THEN
        IF ( water_type_f%from_file )  THEN
           DO  i = nxl, nxr
@@ -1708,5 +1718,5 @@
 !
 !-- Temporary message as long as NetCDF input is not available
-    IF ( TRIM( surface_type ) == 'netcdf'  .AND.  .NOT.  input_pids_static )   &
+    IF ( TRIM( surface_type ) == 'netcdf'  .AND.  .NOT. input_pids_static )   &
     THEN
        message_string = 'surface_type = netcdf requires static input file.'
@@ -1714,5 +1724,5 @@
     ENDIF
 
-    IF ( soil_type == 0 )  THEN
+    IF ( soil_type == 0  .AND.  .NOT. input_pids_static )  THEN
 
        IF ( alpha_vangenuchten == 9999999.9_wp )  THEN
@@ -1796,16 +1806,19 @@
 !
 !-- Check whether valid soil temperatures are prescribed
-    IF ( COUNT( soil_temperature /= 9999999.9_wp ) /= nzs )  THEN
-       WRITE( message_string, * ) 'number of soil layers (', nzs, ') does not',&
+    IF ( .NOT. input_pids_dynamic )  THEN
+       IF ( COUNT( soil_temperature /= 9999999.9_wp ) /= nzs )  THEN
+          WRITE( message_string, * )                                           &
+                                  'number of soil layers (', nzs, ') does not',&
                                   ' match to the number of layers specified',  &
                                   ' in soil_temperature (', COUNT(             &
-                                   soil_temperature /= 9999999.9_wp ), ')'
-          CALL message( 'lsm_check_parameters', 'PA0471', 1, 2, 0, 6, 0 )
-    ENDIF
-
-    IF ( deep_soil_temperature == 9999999.9_wp ) THEN
-          message_string = 'deep_soil_temperature is not set but must be'//    &
-                           '/= 9999999.9'
-          CALL message( 'lsm_check_parameters', 'PA0472', 1, 2, 0, 6, 0 )
+                                  soil_temperature /= 9999999.9_wp ), ')'
+             CALL message( 'lsm_check_parameters', 'PA0471', 1, 2, 0, 6, 0 )
+       ENDIF
+
+       IF ( deep_soil_temperature == 9999999.9_wp ) THEN
+             message_string = 'deep_soil_temperature is not set but must be'// &
+                              '/= 9999999.9'
+             CALL message( 'lsm_check_parameters', 'PA0472', 1, 2, 0, 6, 0 )
+       ENDIF
     ENDIF
 
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 4108)
+++ /palm/trunk/SOURCE/modules.f90	(revision 4109)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! ------------------
-! 
+! -advc_flags_1, advc_flags_2
+! +advc_flags_m, advc_flags_s
 ! 
 ! Former revisions:
@@ -1744,6 +1745,6 @@
     INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE,  TARGET ::  wall_flags_10  !< topograpyh masking flag on multigrid level 10 
 
-    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_1            !< flags used to degrade order of advection scheme
-    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_2            !< flags used to degrade order of advection scheme
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_m            !< flags used to degrade order of advection scheme for momentum
+    INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  advc_flags_s            !< flags used to degrade order of advection scheme for scalar quantities
     INTEGER(iwp), DIMENSION(:,:,:), ALLOCATABLE ::  wall_flags_0            !< flags to mask topography and surface-bounded grid points
 
Index: /palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- /palm/trunk/SOURCE/ocean_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/ocean_mod.f90	(revision 4109)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Pass integer flag array as well as boundary flags to WS scalar advection 
+! routine
 ! 
 ! Former revisions:
@@ -1582,5 +1583,13 @@
 
     USE control_parameters,                                                    &
-        ONLY:  dt_3d, intermediate_timestep_count,                             &
+        ONLY:  bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &
+               dt_3d, intermediate_timestep_count,                             &
                intermediate_timestep_count_max, scalar_advec, simulated_time,  &
                timestep_scheme, tsc, ws_scheme_sca
@@ -1593,5 +1602,5 @@
 
     USE indices,                                                               &
-        ONLY:  nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0
+        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_0
 
     USE surface_mod,                                                           &
@@ -1647,5 +1656,9 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( sa, 'sa' )
+                CALL advec_s_ws( advc_flags_s, sa, 'sa',                       &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( sa )
@@ -1745,5 +1758,13 @@
 
     USE control_parameters,                                                    &
-        ONLY:  dt_3d, intermediate_timestep_count,                             &
+        ONLY:  bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &
+               dt_3d, intermediate_timestep_count,                             &
                intermediate_timestep_count_max, simulated_time,                &
                timestep_scheme, tsc, ws_scheme_sca
@@ -1753,5 +1774,5 @@
 
     USE indices,                                                               &
-        ONLY:  nzb, nzt, wall_flags_0
+        ONLY:  advc_flags_s, nzb, nzt, wall_flags_0
 
     USE surface_mod,                                                           &
@@ -1790,6 +1811,11 @@
        THEN
           IF ( ws_scheme_sca )  THEN
-             CALL advec_s_ws( i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa,&
-                              diss_l_sa, i_omp_start, tn  )
+             CALL advec_s_ws( advc_flags_s,                                    &
+                              i, j, sa, 'sa', flux_s_sa,  diss_s_sa, flux_l_sa,&
+                              diss_l_sa, i_omp_start, tn,                      &
+                              bc_dirichlet_l  .OR.  bc_radiation_l,            &
+                              bc_dirichlet_n  .OR.  bc_radiation_n,            &
+                              bc_dirichlet_r  .OR.  bc_radiation_r,            &
+                              bc_dirichlet_s  .OR.  bc_radiation_s )
           ELSE
              CALL advec_s_pw( i, j, sa )
Index: /palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4108)
+++ /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4109)
@@ -20,5 +20,7 @@
 ! Current revisions:
 ! ------------------
-! 
+! pass integer flag array to WS scalar advection routine which is now necessary
+! as the flags may differ for scalars, e.g. pt can be cyclic while chemical
+! species may be non-cyclic. Further, pass boundary flags. 
 ! 
 ! Former revisions:
@@ -420,5 +422,13 @@
 
     USE control_parameters,                                                    &
-        ONLY:  constant_diffusion,                                             &
+        ONLY:  bc_dirichlet_l,                                                 &
+               bc_dirichlet_n,                                                 &
+               bc_dirichlet_r,                                                 &
+               bc_dirichlet_s,                                                 &
+               bc_radiation_l,                                                 &
+               bc_radiation_n,                                                 &
+               bc_radiation_r,                                                 &
+               bc_radiation_s,                                                 &
+               constant_diffusion,                                             &
                debug_output_timestep,                                          &
                dp_external, dp_level_ind_b, dp_smooth_factor, dpdxy, dt_3d,    &
@@ -454,5 +464,6 @@
 
     USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
+        ONLY:  advc_flags_s,                                                   &
+               nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
                nzb, nzt, wall_flags_0
 
@@ -805,6 +816,11 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                    IF ( ws_scheme_sca )  THEN
-                      CALL advec_s_ws( i, j, pt, 'pt', flux_s_pt, diss_s_pt,   &
-                                       flux_l_pt, diss_l_pt, i_omp_start, tn )
+                      CALL advec_s_ws( advc_flags_s,                           &
+                                       i, j, pt, 'pt', flux_s_pt, diss_s_pt,   &
+                                       flux_l_pt, diss_l_pt, i_omp_start, tn,  &
+                                       bc_dirichlet_l  .OR.  bc_radiation_l,   &
+                                       bc_dirichlet_n  .OR.  bc_radiation_n,   &
+                                       bc_dirichlet_r  .OR.  bc_radiation_r,   &
+                                       bc_dirichlet_s  .OR.  bc_radiation_s )
                    ELSE
                       CALL advec_s_pw( i, j, pt )
@@ -899,9 +915,15 @@
 !--          Tendency-terms for total water content / scalar
              tend(:,j,i) = 0.0_wp
-             IF ( timestep_scheme(1:5) == 'runge' ) &
+             IF ( timestep_scheme(1:5) == 'runge' )                            &
              THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( i, j, q, 'q', flux_s_q, &
-                                diss_s_q, flux_l_q, diss_l_q, i_omp_start, tn )
+                   CALL advec_s_ws( advc_flags_s,                              &
+                                    i, j, q, 'q', flux_s_q,                    &
+                                    diss_s_q, flux_l_q, diss_l_q,              &
+                                    i_omp_start, tn,                           &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( i, j, q )
@@ -983,5 +1005,5 @@
 !--          Tendency-terms for total water content / scalar
              tend(:,j,i) = 0.0_wp
-             IF ( timestep_scheme(1:5) == 'runge' ) &
+             IF ( timestep_scheme(1:5) == 'runge' )                            &
              THEN
                 IF ( ws_scheme_sca )  THEN
@@ -989,7 +1011,13 @@
 !--                For scalar advection apply monotonic flux limiter near 
 !--                topography.
-                   CALL advec_s_ws( i, j, s, 's', flux_s_s, &
+                   CALL advec_s_ws( advc_flags_s,                              &
+                                    i, j, s, 's', flux_s_s,                    &
                                     diss_s_s, flux_l_s, diss_l_s, i_omp_start, &
-                                    tn, monotonic_limiter_z )
+                                    tn,                                        &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s,      &
+                                    monotonic_limiter_z )
                 ELSE
                    CALL advec_s_pw( i, j, s )
@@ -1437,5 +1465,9 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( pt, 'pt' )
+                CALL advec_s_ws( advc_flags_s, pt, 'pt',                       &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( pt )
@@ -1573,5 +1605,9 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( q, 'q' )
+                CALL advec_s_ws( advc_flags_s, q, 'q',                         &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( q )
@@ -1687,5 +1723,9 @@
           IF ( timestep_scheme(1:5) == 'runge' )  THEN
              IF ( ws_scheme_sca )  THEN
-                CALL advec_s_ws( s, 's' )
+                CALL advec_s_ws( advc_flags_s, s, 's',                         &
+                                 bc_dirichlet_l  .OR.  bc_radiation_l,         &
+                                 bc_dirichlet_n  .OR.  bc_radiation_n,         &
+                                 bc_dirichlet_r  .OR.  bc_radiation_r,         &
+                                 bc_dirichlet_s  .OR.  bc_radiation_s )
              ELSE
                 CALL advec_s_pw( s )
Index: /palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- /palm/trunk/SOURCE/salsa_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/salsa_mod.f90	(revision 4109)
@@ -21,5 +21,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Pass integer flag array as well as boundary flags to WS scalar advection 
+! routine
 ! 
 ! Former revisions:
@@ -7739,5 +7740,5 @@
 
     USE indices,                                                                                   &
-        ONLY:  wall_flags_0
+        ONLY:  advc_flags_s, wall_flags_0
 
     USE pegrid,                                                                                    &
@@ -7782,5 +7783,10 @@
     IF ( timestep_scheme(1:5) == 'runge' )  THEN
        IF ( ws_scheme_sca )  THEN
-          CALL advec_s_ws( i, j, rs, id, flux_s, diss_s, flux_l, diss_l, i_omp_start, tn,          &
+          CALL advec_s_ws( advc_flags_s, i, j, rs, id, flux_s, diss_s, flux_l, diss_l,             &
+                           i_omp_start, tn,                                                        &
+                           bc_dirichlet_l  .OR.  bc_radiation_l,                                   &
+                           bc_dirichlet_n  .OR.  bc_radiation_n,                                   &
+                           bc_dirichlet_r  .OR.  bc_radiation_r,                                   &
+                           bc_dirichlet_s  .OR.  bc_radiation_s,                                   &
                            monotonic_limiter_z )
        ELSE
@@ -7883,5 +7889,5 @@
         ONLY:  diffusion_s
     USE indices,                                                                                   &
-        ONLY:  wall_flags_0
+        ONLY:  advc_flags_s, wall_flags_0
     USE surface_mod,                                                                               &
         ONLY :  surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v
@@ -7914,5 +7920,9 @@
     IF ( timestep_scheme(1:5) == 'runge' )  THEN
        IF ( ws_scheme_sca )  THEN
-          CALL advec_s_ws( rs, id )
+          CALL advec_s_ws( advc_flags_s, rs, id,                                                   &
+                           bc_dirichlet_l  .OR.  bc_radiation_l,                                   &
+                           bc_dirichlet_n  .OR.  bc_radiation_n,                                   &
+                           bc_dirichlet_r  .OR.  bc_radiation_r,                                   &
+                           bc_dirichlet_s  .OR.  bc_radiation_s )
        ELSE
           CALL advec_s_pw( rs )
Index: /palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- /palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 4108)
+++ /palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 4109)
@@ -20,5 +20,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! pass integer flag array as well as boundary flags to WS scalar advection 
+! routine
 ! 
 ! Former revisions:
@@ -248,5 +249,6 @@
 
     USE indices,                                                              &
-        ONLY:  nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,    &
+        ONLY:  advc_flags_s,                                                  &
+               nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,    &
                wall_flags_0
 
@@ -2329,5 +2331,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( e, 'e' )
+                   CALL advec_s_ws( advc_flags_s, e, 'e',                      &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( e )
@@ -2443,5 +2449,9 @@
              IF ( timestep_scheme(1:5) == 'runge' )  THEN
                 IF ( ws_scheme_sca )  THEN
-                   CALL advec_s_ws( diss, 'diss' )
+                   CALL advec_s_ws( advc_flags_s, diss, 'diss',                &
+                                    bc_dirichlet_l  .OR.  bc_radiation_l,      &
+                                    bc_dirichlet_n  .OR.  bc_radiation_n,      &
+                                    bc_dirichlet_r  .OR.  bc_radiation_r,      &
+                                    bc_dirichlet_s  .OR.  bc_radiation_s )
                 ELSE
                    CALL advec_s_pw( diss )
@@ -2549,6 +2559,11 @@
            .AND.  .NOT. use_upstream_for_tke )  THEN
            IF ( ws_scheme_sca )  THEN
-               CALL advec_s_ws( i, j, e, 'e', flux_s_e, diss_s_e, &
-                                flux_l_e, diss_l_e , i_omp, tn )
+               CALL advec_s_ws( advc_flags_s,                                  &
+                                i, j, e, 'e', flux_s_e, diss_s_e,              &
+                                flux_l_e, diss_l_e , i_omp, tn,                &
+                                bc_dirichlet_l  .OR.  bc_radiation_l,          &
+                                bc_dirichlet_n  .OR.  bc_radiation_n,          &
+                                bc_dirichlet_r  .OR.  bc_radiation_r,          &
+                                bc_dirichlet_s  .OR.  bc_radiation_s )
            ELSE
                CALL advec_s_pw( i, j, e )
@@ -2618,6 +2633,11 @@
            .AND.  .NOT. use_upstream_for_tke )  THEN
            IF ( ws_scheme_sca )  THEN
-               CALL advec_s_ws( i, j, diss, 'diss', flux_s_diss, diss_s_diss,  &
-                                flux_l_diss, diss_l_diss, i_omp, tn )
+               CALL advec_s_ws( advc_flags_s,                                  &
+                                i, j, diss, 'diss', flux_s_diss, diss_s_diss,  &
+                                flux_l_diss, diss_l_diss, i_omp, tn,           &
+                                bc_dirichlet_l  .OR.  bc_radiation_l,          &
+                                bc_dirichlet_n  .OR.  bc_radiation_n,          &
+                                bc_dirichlet_r  .OR.  bc_radiation_r,          &
+                                bc_dirichlet_s  .OR.  bc_radiation_s )
            ELSE
                CALL advec_s_pw( i, j, diss )
@@ -3451,5 +3471,5 @@
        dvdy(k) =           ( v(k,j+1,i) - v(k,j,i)     ) * ddy
        dvdz(k) = 0.5_wp  * ( v(k+1,j,i) + v(k+1,j+1,i) -                 &
-                               v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k)
+                             v(k-1,j,i) - v(k-1,j+1,i) ) * dd2zu(k)
 
        dwdx(k) = 0.25_wp * ( w(k,j,i+1) + w(k-1,j,i+1) -                 &
