Index: /palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- /palm/trunk/SOURCE/advec_ws.f90	(revision 887)
+++ /palm/trunk/SOURCE/advec_ws.f90	(revision 888)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! ------------------
+! Number of IBITS() calls with identical arguments is reduced.
 !
 ! Former revisions:
@@ -274,5 +275,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, i_omp, j, k, k_mm, k_pp, k_ppp,  tn
+       INTEGER ::  i, ibit0, ibit1, ibit2, ibit3, ibit4, ibit5, ibit6,        &
+                   ibit7, ibit8, i_omp, j, k, k_mm, k_pp, k_ppp,  tn
        REAL    ::  diss_d, div, flux_d, u_comp, v_comp
        REAL, DIMENSION(:,:,:), POINTER    :: sk
@@ -293,33 +295,37 @@
           DO  k = nzb+1, nzb_max
 
+             ibit5 = IBITS(wall_flags_0(k,j,i),5,1)
+             ibit4 = IBITS(wall_flags_0(k,j,i),4,1)
+             ibit3 = IBITS(wall_flags_0(k,j,i),3,1)
+
              v_comp                  = v(k,j,i) - v_gtrans
              swap_flux_y_local(k,tn) = v_comp * (                             &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)  + sk(k,j-1,i)     )         &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j+1,i) + sk(k,j-2,i)    )         &
-                  +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j+2,i) + sk(k,j-3,i)    )         &
+                                                  ( 37.0 * ibit5 * adv_sca_5  &
+                                               +     7.0 * ibit4 * adv_sca_3  &
+                                               +           ibit3 * adv_sca_1  &
+                                                  ) *                         &
+                                           ( sk(k,j,i)  + sk(k,j-1,i)     )   &
+                                            -     (  8.0 * ibit5 * adv_sca_5  &
+                                               +           ibit4 * adv_sca_3  &
+                                                   ) *                        &
+                                           ( sk(k,j+1,i) + sk(k,j-2,i)    )   &
+                                           +      (        ibit5 * adv_sca_5  &
+                                                  ) *                         &
+                                           ( sk(k,j+2,i) + sk(k,j-3,i)    )   &
                                                 )
 
              swap_diss_y_local(k,tn) = -ABS( v_comp ) * (                     &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   - sk(k,j-1,i)    )         &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j+1,i) - sk(k,j-2,i)  )           &
-                  +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j+2,i) - sk(k,j-3,i) )            &
+                                                  ( 10.0 * ibit5 * adv_sca_5  &
+                                               +     3.0 * ibit4 * adv_sca_3  &
+                                               +           ibit3 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   - sk(k,j-1,i)    )  &
+                                           -      (  5.0 * ibit5 * adv_sca_5  &
+                                               +           ibit4 * adv_sca_3  &
+                                            ) *                               &
+                                            ( sk(k,j+1,i) - sk(k,j-2,i)  )    &
+                                           +      (        ibit5 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j+2,i) - sk(k,j-3,i) )     &
                                                         )
 
@@ -329,5 +335,5 @@
           DO  k = nzb_max+1, nzt
 
-             v_comp               = v(k,j,i) - v_gtrans
+             v_comp                  = v(k,j,i) - v_gtrans
              swap_flux_y_local(k,tn) = v_comp * (                            &
                                     37.0 * ( sk(k,j,i)   + sk(k,j-1,i) )     &
@@ -350,32 +356,37 @@
           DO  k = nzb+1, nzb_max
 
-             u_comp                 = u(k,j,i) - u_gtrans
+             ibit2 = IBITS(wall_flags_0(k,j,i),2,1)
+             ibit1 = IBITS(wall_flags_0(k,j,i),1,1)
+             ibit0 = IBITS(wall_flags_0(k,j,i),0,1)
+
+             u_comp                     = u(k,j,i) - u_gtrans
              swap_flux_x_local(k,j,tn) = u_comp * (                           &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   + sk(k,j,i-1)    )         &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+1) + sk(k,j,i-2)    )         &
-                  +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                         ) *         ( sk(k,j,i+2) + sk(k,j,i-3)    )         &
+                                                  ( 37.0 * ibit2 * adv_sca_5  &
+                                               +     7.0 * ibit1 * adv_sca_3  &
+                                               +           ibit0 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   + sk(k,j,i-1)    )  &
+                                           -      (  8.0 * ibit2 * adv_sca_5  &
+                                               +           ibit1 * adv_sca_3  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+1) + sk(k,j,i-2)    )  &
+                                           +      (        ibit2 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+2) + sk(k,j,i-3)    )  &
                                                   )
 
               swap_diss_x_local(k,j,tn) = -ABS( u_comp ) * (                  &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   - sk(k,j,i-1)    )         &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+1) - sk(k,j,i-2)  )           &
-                  +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+2) - sk(k,j,i-3) )            &
+                                                  ( 10.0 * ibit2 * adv_sca_5  &
+                                               +     3.0 * ibit1 * adv_sca_3  &
+                                               +           ibit0 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   - sk(k,j,i-1)    )  &
+                                           -      (  5.0 * ibit2 * adv_sca_5  &
+                                               +           ibit1 * adv_sca_3  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+1) - sk(k,j,i-2)  )    &
+                                           +      (        ibit2 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+2) - sk(k,j,i-3) )     &
                                                            )
 
@@ -412,49 +423,57 @@
 !--       Note: It is faster to conduct all multiplications explicitly, e.g.
 !--       * adv_sca_5 ... than to determine a factor and multiplicate the
-!--       flux at the end. Indeed, per loop the first requires 6
-!--       multiplications more, but the the second requires 9 more internal
-!--       calls of IBITS(). 
+!--       flux at the end. 
+
+          ibit2 = IBITS(wall_flags_0(k,j,i),2,1)
+          ibit1 = IBITS(wall_flags_0(k,j,i),1,1)
+          ibit0 = IBITS(wall_flags_0(k,j,i),0,1)
+
           u_comp    = u(k,j,i+1) - u_gtrans
           flux_r(k) = u_comp * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1    &
+                     ( 37.0 * ibit2 * adv_sca_5                             &
+                  +     7.0 * ibit1 * adv_sca_3                             &
+                  +           ibit0 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k,j,i+1) + sk(k,j,i)   )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
+              -      (  8.0 * ibit2 * adv_sca_5                             &
+                  +           ibit1 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k,j,i+2) + sk(k,j,i-1) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                     ) *     ( sk(k,j,i+3) + sk(k,j,i-2) )                  &
+              +      (        ibit2 * adv_sca_5                             &
+                     ) *                                                    &
+                             ( sk(k,j,i+3) + sk(k,j,i-2) )                  &
                                )
 
           diss_r(k) = -ABS( u_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1    &
+                     ( 10.0 * ibit2 * adv_sca_5                             &
+                  +     3.0 * ibit1 * adv_sca_3                             &
+                  +           ibit0 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k,j,i+1) - sk(k,j,i)  )                   &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
+              -      (  5.0 * ibit2 * adv_sca_5                             &
+                  +           ibit1 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k,j,i+2) - sk(k,j,i-1) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
+              +      (        ibit2 * adv_sca_5                             &
                      ) *                                                    &
                              ( sk(k,j,i+3) - sk(k,j,i-2) )                  &
                                        )
 
+          ibit5 = IBITS(wall_flags_0(k,j,i),5,1)
+          ibit4 = IBITS(wall_flags_0(k,j,i),4,1)
+          ibit3 = IBITS(wall_flags_0(k,j,i),3,1)
+
           v_comp    = v(k,j+1,i) - v_gtrans
           flux_n(k) = v_comp * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1    &
+                     ( 37.0 * ibit5 * adv_sca_5                             &
+                  +     7.0 * ibit4 * adv_sca_3                             &
+                  +           ibit3 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k,j+1,i) + sk(k,j,i)   )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
+              -      (  8.0 * ibit5 * adv_sca_5                             &
+                  +           ibit4 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k,j+2,i) + sk(k,j-1,i) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
+              +      (        ibit5 * adv_sca_5                             &
                      ) *                                                    &
                              ( sk(k,j+3,i) + sk(k,j-2,i) )                  &
@@ -462,14 +481,14 @@
 
           diss_n(k) = -ABS( v_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1    &
+                     ( 10.0 * ibit5 * adv_sca_5                             &
+                  +     3.0 * ibit4 * adv_sca_3                             &
+                  +           ibit3 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k,j+1,i) - sk(k,j,i)    )                 &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
+              -      (  5.0 * ibit5 * adv_sca_5                             &
+                  +           ibit4 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k,j+2,i) - sk(k,j-1,i)  )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
+              +      (        ibit5 * adv_sca_5                             &
                      ) *                                                    &
                              ( sk(k,j+3,i) - sk(k,j-2,i) )                  &
@@ -478,34 +497,38 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),8,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),6,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),8,1)
+          ibit8 = IBITS(wall_flags_0(k,j,i),8,1)
+          ibit7 = IBITS(wall_flags_0(k,j,i),7,1)
+          ibit6 = IBITS(wall_flags_0(k,j,i),6,1)
+
+          k_ppp = k + 3 * ibit8
+          k_pp  = k + 2 * ( 1 - ibit6  )
+          k_mm  = k - 2 * ibit8
 
 
           flux_t(k) = w(k,j,i) * (                                          &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
+                     ( 37.0 * ibit8 * adv_sca_5                             &
+                  +     7.0 * ibit7 * adv_sca_3                             &
+                  +           ibit6 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k+1,j,i)  + sk(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
+              -      (  8.0 * ibit8 * adv_sca_5                             &
+                  +           ibit7 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k_pp,j,i) + sk(k-1,j,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
+              +      (        ibit8 * adv_sca_5                             &
                      ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )                &
                                  )
 
           diss_t(k) = -ABS( w(k,j,i) ) * (                                  &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
+                     ( 10.0 * ibit8 * adv_sca_5                             &
+                  +     3.0 * ibit7 * adv_sca_3                             &
+                  +           ibit6 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k+1,j,i)   - sk(k,j,i)    )               &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
+              -      (  5.0 * ibit8 * adv_sca_5                             &
+                  +           ibit7 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k_pp,j,i)  - sk(k-1,j,i)  )               &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
+              +      (        ibit8 * adv_sca_5                             &
                      ) *                                                    &
                              ( sk(k_ppp,j,i) - sk(k_mm,j,i) )               &
@@ -564,33 +587,38 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),8,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),6,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),8,1)
+          ibit8 = IBITS(wall_flags_0(k,j,i),8,1)
+          ibit7 = IBITS(wall_flags_0(k,j,i),7,1)
+          ibit6 = IBITS(wall_flags_0(k,j,i),6,1)
+
+          k_ppp = k + 3 * ibit8
+          k_pp  = k + 2 * ( 1 - ibit6  )
+          k_mm  = k - 2 * ibit8
+
 
           flux_t(k) = w(k,j,i) * (                                          &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
+                     ( 37.0 * ibit8 * adv_sca_5                             &
+                  +     7.0 * ibit7 * adv_sca_3                             &
+                  +           ibit6 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k+1,j,i)  + sk(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
+              -      (  8.0 * ibit8 * adv_sca_5                             &
+                  +           ibit7 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k_pp,j,i) + sk(k-1,j,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
+              +      (        ibit8 * adv_sca_5                             &
                      ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )                &
                                  )
 
           diss_t(k) = -ABS( w(k,j,i) ) * (                                  &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
+                     ( 10.0 * ibit8 * adv_sca_5                             &
+                  +     3.0 * ibit7 * adv_sca_3                             &
+                  +           ibit6 * adv_sca_1                             &
                      ) *                                                    &
                              ( sk(k+1,j,i)   - sk(k,j,i)    )               &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
+              -      (  5.0 * ibit8 * adv_sca_5                             &
+                  +           ibit7 * adv_sca_3                             &
                      ) *                                                    &
                              ( sk(k_pp,j,i)  - sk(k-1,j,i)  )               &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
+              +      (        ibit8 * adv_sca_5                             &
                      ) *                                                    &
                              ( sk(k_ppp,j,i) - sk(k_mm,j,i) )               &
@@ -671,5 +699,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, i_omp, j, k, k_mm, k_pp, k_ppp, tn
+       INTEGER ::  i, ibit9, ibit10, ibit11, ibit12, ibit13, ibit14, ibit15,  &
+                   ibit16, ibit17, i_omp, j, k, k_mm, k_pp, k_ppp, tn
        REAL    ::  diss_d, div, flux_d, gu, gv, u_comp_l, v_comp, w_comp
        REAL, DIMENSION(nzb:nzt+1) :: diss_n, diss_r, diss_t, flux_n, flux_r,  &
@@ -684,32 +713,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit14 = IBITS(wall_flags_0(k,j,i),14,1)
+             ibit13 = IBITS(wall_flags_0(k,j,i),13,1)
+             ibit12 = IBITS(wall_flags_0(k,j,i),12,1)
+
              v_comp      = v(k,j,i) + v(k,j,i-1) - gv
              flux_s_u(k,tn) = v_comp * (                                      &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 37.0 * ibit14 * adv_mom_5                       &
+                         +     7.0 * ibit13 * adv_mom_3                       &
+                         +           ibit12 * adv_mom_1                       &
+                            ) *                                               &
                                      ( u(k,j,i)   + u(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  8.0 * ibit14 * adv_mom_5                       &
+                         +           ibit13 * adv_mom_3                       &
+                            ) *                                               &
                                      ( u(k,j+1,i) + u(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit14 * adv_mom_5                       &
+                            ) *                                               &
                                      ( u(k,j+2,i) + u(k,j-3,i) )              &
                                        )
 
              diss_s_u(k,tn) = - ABS ( v_comp ) * (                            &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 10.0 * ibit14 * adv_mom_5                       &
+                         +     3.0 * ibit13 * adv_mom_3                       &
+                         +           ibit12 * adv_mom_1                       &
+                            ) *                                               &
                                      ( u(k,j,i)   - u(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  5.0 * ibit14 * adv_mom_5                       &
+                         +           ibit13 * adv_mom_3                       &
+                            ) *                                               &
                                      ( u(k,j+1,i) - u(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit14 * adv_mom_5                       &
+                            ) *                                               &
                                      ( u(k,j+2,i) - u(k,j-3,i) )              &
                                                  )
@@ -738,32 +771,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit11 = IBITS(wall_flags_0(k,j,i),11,1)
+             ibit10 = IBITS(wall_flags_0(k,j,i),10,1)
+             ibit9  = IBITS(wall_flags_0(k,j,i),9,1)
+
              u_comp_l         = u(k,j,i) + u(k,j,i-1) - gu
              flux_l_u(k,j,tn) = u_comp_l * (                                   &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1 &
-                          ) *                                                  &
+                              ( 37.0 * ibit11 * adv_mom_5                      &
+                           +     7.0 * ibit10 * adv_mom_3                      &
+                           +           ibit9  * adv_mom_1                      &
+                              ) *                                              &
                                      ( u(k,j,i)   + u(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                          ) *                                                  &
+                       -      (  8.0 * ibit11 * adv_mom_5                      &
+                           +           ibit10 * adv_mom_3                      &
+                              ) *                                              &
                                      ( u(k,j,i+1) + u(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                          ) *                                                  &
+                       +      (        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 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1 &
-                          ) *                                                  &
+                              ( 10.0 * ibit11 * adv_mom_5                      &
+                           +     3.0 * ibit10 * adv_mom_3                      &
+                           +           ibit9  * adv_mom_1                      &
+                              ) *                                              &
                                      ( u(k,j,i)   - u(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                          ) *                                                  &
+                       -      (  5.0 * ibit11 * adv_mom_5                      &
+                           +           ibit10 * adv_mom_3                      &
+                              ) *                                              &
                                      ( u(k,j,i+1) - u(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                          ) *                                                  &
+                       +      (        ibit11 * adv_mom_5                      &
+                              ) *                                              &
                                      ( u(k,j,i+2) - u(k,j,i-3) )               &
                                                      )
@@ -796,16 +833,20 @@
        DO  k = nzb+1, nzb_max
 
+          ibit11 = IBITS(wall_flags_0(k,j,i),11,1)
+          ibit10 = IBITS(wall_flags_0(k,j,i),10,1)
+          ibit9  = IBITS(wall_flags_0(k,j,i),9,1)
+
           u_comp(k) = u(k,j,i+1) + u(k,j,i)
           flux_r(k) = ( u_comp(k) - gu ) * (                                 &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1    &
+                     ( 37.0 * ibit11 * adv_mom_5                             &
+                  +     7.0 * ibit10 * adv_mom_3                             &
+                  +           ibit9  * adv_mom_1                             &
                      ) *                                                     &
                                  ( u(k,j,i+1) + u(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
+              -      (  8.0 * ibit11 * adv_mom_5                             &
+                  +           ibit10 * adv_mom_3                             &
                      ) *                                                     &
                                  ( u(k,j,i+2) + u(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
+              +      (        ibit11 * adv_mom_5                             &
                      ) *                                                     &
                                  ( u(k,j,i+3) + u(k,j,i-2) )                 &
@@ -813,67 +854,75 @@
 
           diss_r(k) = - ABS( u_comp(k) - gu ) * (                            &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1    &
+                     ( 10.0 * ibit11 * adv_mom_5                             &
+                  +     3.0 * ibit10 * adv_mom_3                             &
+                  +           ibit9  * adv_mom_1                             &
                      ) *                                                     &
                                  ( u(k,j,i+1) - u(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
+              -      (  5.0 * ibit11 * adv_mom_5                             &
+                  +           ibit10 * adv_mom_3                             &
                      ) *                                                     &
                                  ( u(k,j,i+2) - u(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
+              +      (        ibit11 * adv_mom_5                             &
                      ) *                                                     &
                                  ( u(k,j,i+3) - u(k,j,i-2) )                 &
                                                 )
 
+          ibit14 = IBITS(wall_flags_0(k,j,i),14,1)
+          ibit13 = IBITS(wall_flags_0(k,j,i),13,1)
+          ibit12 = IBITS(wall_flags_0(k,j,i),12,1)
+
           v_comp    = v(k,j+1,i) + v(k,j+1,i-1) - gv
           flux_n(k) = v_comp * (                                             &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1    &
+                     ( 37.0 * ibit14 * adv_mom_5                             &
+                  +     7.0 * ibit13 * adv_mom_3                             &
+                  +           ibit12 * adv_mom_1                             &
                      ) *                                                     &
                                  ( u(k,j+1,i) + u(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
+              -      (  8.0 * ibit14 * adv_mom_5                             &
+                  +           ibit13 * adv_mom_3                             &
                      ) *                                                     &
                                  ( u(k,j+2,i) + u(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
+              +      (        ibit14 * adv_mom_5                             &
                      ) *                                                     &
                                  ( u(k,j+3,i) + u(k,j-2,i) )                 &
-                                           )
+                               )
 
           diss_n(k) = - ABS ( v_comp ) * (                                   &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1    &
+                     ( 10.0 * ibit14 * adv_mom_5                             &
+                  +     3.0 * ibit13 * adv_mom_3                             &
+                  +           ibit12 * adv_mom_1                             &
                      ) *                                                     &
                                  ( u(k,j+1,i) - u(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
+              -      (  5.0 * ibit14 * adv_mom_5                             &
+                  +           ibit13 * adv_mom_3                             &
                      ) *                                                     &
                                  ( u(k,j+2,i) - u(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
+              +      (        ibit14 * adv_mom_5                             &
                      ) *                                                     &
                                  ( u(k,j+3,i) - u(k,j-2,i) )                 &
-                                                )
+                                         )
 !
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),17,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),15,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),17,1)
+          ibit17 = IBITS(wall_flags_0(k,j,i),17,1)
+          ibit16 = IBITS(wall_flags_0(k,j,i),16,1)
+          ibit15 = IBITS(wall_flags_0(k,j,i),15,1)
+
+          k_ppp = k + 3 * ibit17
+          k_pp  = k + 2 * ( 1 - ibit15 )
+          k_mm  = k - 2 * ibit17
 
           w_comp    = w(k,j,i) + w(k,j,i-1)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
+                     ( 37.0 * ibit17 * adv_mom_5                             &
+                  +     7.0 * ibit16 * adv_mom_3                             &
+                  +           ibit15 * adv_mom_1                             &
                      ) *                                                     &
                              ( u(k+1,j,i)  + u(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
+              -      (  8.0 * ibit17 * adv_mom_5                             &
+                  +           ibit16 * adv_mom_3                             &
                      ) *                                                     &
                              ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
+              +      (        ibit17 * adv_mom_5                             &
                      ) *                                                     &
                              ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
@@ -881,14 +930,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
+                     ( 10.0 * ibit17 * adv_mom_5                             &
+                  +     3.0 * ibit16 * adv_mom_3                             &
+                  +           ibit15 * adv_mom_1                             &
                      ) *                                                     &
                              ( u(k+1,j,i)   - u(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
+              -      (  5.0 * ibit17 * adv_mom_5                             &
+                  +           ibit16 * adv_mom_3                             &
                      ) *                                                     &
                              ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
+              +      (        ibit17 * adv_mom_5                             &
                      ) *                                                     &
                              ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
@@ -960,20 +1009,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),17,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),15,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),17,1)
+          ibit17 = IBITS(wall_flags_0(k,j,i),17,1)
+          ibit16 = IBITS(wall_flags_0(k,j,i),16,1)
+          ibit15 = IBITS(wall_flags_0(k,j,i),15,1)
+
+          k_ppp = k + 3 * ibit17
+          k_pp  = k + 2 * ( 1 - ibit15 )
+          k_mm  = k - 2 * ibit17
 
           w_comp    = w(k,j,i) + w(k,j,i-1)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
+                     ( 37.0 * ibit17 * adv_mom_5                             &
+                  +     7.0 * ibit16 * adv_mom_3                             &
+                  +           ibit15 * adv_mom_1                             &
                      ) *                                                     &
                              ( u(k+1,j,i)  + u(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
+              -      (  8.0 * ibit17 * adv_mom_5                             &
+                  +           ibit16 * adv_mom_3                             &
                      ) *                                                     &
                              ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
+              +      (        ibit17 * adv_mom_5                             &
                      ) *                                                     &
                              ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
@@ -981,14 +1034,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
+                     ( 10.0 * ibit17 * adv_mom_5                             &
+                  +     3.0 * ibit16 * adv_mom_3                             &
+                  +           ibit15 * adv_mom_1                             &
                      ) *                                                     &
                              ( u(k+1,j,i)   - u(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
+              -      (  5.0 * ibit17 * adv_mom_5                             &
+                  +           ibit16 * adv_mom_3                             &
                      ) *                                                     &
                              ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
+              +      (        ibit17 * adv_mom_5                             &
                      ) *                                                     &
                              ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
@@ -1058,5 +1111,6 @@
        IMPLICIT NONE
 
-       INTEGER  ::  i, i_omp, j, k, k_mm, k_pp, k_ppp, tn
+       INTEGER  ::  i, ibit18, ibit19, ibit20, ibit21, ibit22, ibit23, ibit24, &
+                    ibit25, ibit26, i_omp, j, k, k_mm, k_pp, k_ppp, tn
        REAL     ::  diss_d, div, flux_d, gu, gv, u_comp, v_comp_l, w_comp
        REAL, DIMENSION(nzb:nzt+1)  :: diss_n, diss_r, diss_t, flux_n, flux_r,  &
@@ -1072,32 +1126,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit20 = IBITS(wall_flags_0(k,j,i),20,1)
+             ibit19 = IBITS(wall_flags_0(k,j,i),19,1)
+             ibit18 = IBITS(wall_flags_0(k,j,i),18,1)
+
              u_comp           = u(k,j-1,i) + u(k,j,i) - gu
              flux_l_v(k,j,tn) = u_comp * (                                     &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1 &
-                          ) *                                                  &
+                              ( 37.0 * ibit20 * adv_mom_5                      &
+                           +     7.0 * ibit19 * adv_mom_3                      &
+                           +           ibit18 * adv_mom_1                      &
+                              ) *                                              &
                                      ( v(k,j,i)   + v(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                          ) *                                                  &
+                       -      (  8.0 * ibit20 * adv_mom_5                      &
+                           +           ibit19 * adv_mom_3                      &
+                              ) *                                              &
                                      ( v(k,j,i+1) + v(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                          ) *                                                  &
+                       +      (        ibit20 * adv_mom_5                      &
+                              ) *                                              &
                                      ( v(k,j,i+2) + v(k,j,i-3) )               &
                                          )
 
               diss_l_v(k,j,tn) = - ABS( u_comp ) * (                           &
-                          ( 10.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1 &
-                          ) *                                                  &
+                              ( 10.0 * ibit20 * adv_mom_5                      &
+                           +     3.0 * ibit19 * adv_mom_3                      &
+                           +           ibit18 * adv_mom_1                      &
+                              ) *                                              &
                                      ( v(k,j,i)   - v(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                          ) *                                                  &
+                       -      (  5.0 * ibit20 * adv_mom_5                      &
+                           +           ibit19 * adv_mom_3                      &
+                              ) *                                              &
                                      ( v(k,j,i+1) - v(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                          ) *                                                  &
+                       +      (        ibit20 * adv_mom_5                      &
+                              ) *                                              &
                                      ( v(k,j,i+2) - v(k,j,i-3) )               &
                                                    )
@@ -1126,32 +1184,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit23 = IBITS(wall_flags_0(k,j,i),23,1)
+             ibit22 = IBITS(wall_flags_0(k,j,i),22,1)
+             ibit21 = IBITS(wall_flags_0(k,j,i),21,1)
+
              v_comp_l       = v(k,j,i) + v(k,j-1,i) - gv
              flux_s_v(k,tn) = v_comp_l * (                                    &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 37.0 * ibit23 * adv_mom_5                       &
+                         +     7.0 * ibit22 * adv_mom_3                       &
+                         +           ibit21 * adv_mom_1                       &
+                            ) *                                               &
                                      ( v(k,j,i)   + v(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  8.0 * ibit23 * adv_mom_5                       &
+                         +           ibit22 * adv_mom_3                       &
+                            ) *                                               &
                                      ( v(k,j+1,i) + v(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit23 * adv_mom_5                       &
+                            ) *                                               &
                                      ( v(k,j+2,i) + v(k,j-3,i) )              &
                                          )
 
              diss_s_v(k,tn) = - ABS( v_comp_l ) * (                           &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 10.0 * ibit23 * adv_mom_5                       &
+                         +     3.0 * ibit22 * adv_mom_3                       &
+                         +           ibit21 * adv_mom_1                       &
+                            ) *                                               &
                                      ( v(k,j,i)   - v(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  5.0 * ibit23 * adv_mom_5                       &
+                         +           ibit22 * adv_mom_3                       &
+                            ) *                                               &
                                      ( v(k,j+1,i) - v(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit23 * adv_mom_5                       &
+                            ) *                                               &
                                      ( v(k,j+2,i) - v(k,j-3,i) )              &
                                                  )
@@ -1184,16 +1246,20 @@
        DO  k = nzb+1, nzb_max
 
+          ibit20 = IBITS(wall_flags_0(k,j,i),20,1)
+          ibit19 = IBITS(wall_flags_0(k,j,i),19,1)
+          ibit18 = IBITS(wall_flags_0(k,j,i),18,1)
+ 
           u_comp    = u(k,j-1,i+1) + u(k,j,i+1) - gu
           flux_r(k) = u_comp * (                                             &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1    &
+                     ( 37.0 * ibit20 * adv_mom_5                             &
+                  +     7.0 * ibit19 * adv_mom_3                             &
+                  +           ibit18 * adv_mom_1                             &
                      ) *                                                     &
                                  ( v(k,j,i+1) + v(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
+              -      (  8.0 * ibit20 * adv_mom_5                             &
+                  +           ibit19 * adv_mom_3                             &
                      ) *                                                     &
                                  ( v(k,j,i+2) + v(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
+              +      (        ibit20 * adv_mom_5                             &
                      ) *                                                     &
                                  ( v(k,j,i+3) + v(k,j,i-2) )                 &
@@ -1201,30 +1267,35 @@
 
           diss_r(k) = - ABS( u_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1    &
+                     ( 10.0 * ibit20 * adv_mom_5                             &
+                  +     3.0 * ibit19 * adv_mom_3                             &
+                  +           ibit18 * adv_mom_1                             &
                      ) *                                                     &
                                  ( v(k,j,i+1) - v(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
+              -      (  5.0 * ibit20 * adv_mom_5                             &
+                  +           ibit19 * adv_mom_3                             &
                      ) *                                                     &
                                  ( v(k,j,i+2) - v(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
+              +      (        ibit20 * adv_mom_5                             &
                      ) *                                                     &
                                  ( v(k,j,i+3) - v(k,j,i-2) )                 &
                                         )
 
+          ibit23 = IBITS(wall_flags_0(k,j,i),23,1)
+          ibit22 = IBITS(wall_flags_0(k,j,i),22,1)
+          ibit21 = IBITS(wall_flags_0(k,j,i),21,1)
+
+
           v_comp(k) = v(k,j+1,i) + v(k,j,i)
           flux_n(k) = ( v_comp(k) - gv ) * (                                 &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1    &
+                     ( 37.0 * ibit23 * adv_mom_5                             &
+                  +     7.0 * ibit22 * adv_mom_3                             &
+                  +           ibit21 * adv_mom_1                             &
                      ) *                                                     &
                                  ( v(k,j+1,i) + v(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
+              -      (  8.0 * ibit23 * adv_mom_5                             &
+                  +           ibit22 * adv_mom_3                             &
                      ) *                                                     &
                                  ( v(k,j+2,i) + v(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
+              +      (        ibit23 * adv_mom_5                             &
                      ) *                                                     &
                                  ( v(k,j+3,i) + v(k,j-2,i) )                 &
@@ -1232,14 +1303,14 @@
 
           diss_n(k) = - ABS( v_comp(k) - gv ) * (                            &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1    &
+                     ( 10.0 * ibit23 * adv_mom_5                             &
+                  +     3.0 * ibit22 * adv_mom_3                             &
+                  +           ibit21 * adv_mom_1                             &
                      ) *                                                     &
                                  ( v(k,j+1,i) - v(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
+              -      (  5.0 * ibit23 * adv_mom_5                             &
+                  +           ibit22 * adv_mom_3                             &
                      ) *                                                     &
                                  ( v(k,j+2,i) - v(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
+              +      (        ibit23 * adv_mom_5                             &
                      ) *                                                     &
                                  ( v(k,j+3,i) - v(k,j-2,i) )                 &
@@ -1248,20 +1319,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),26,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),24,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),26,1)
+          ibit26 = IBITS(wall_flags_0(k,j,i),26,1)
+          ibit25 = IBITS(wall_flags_0(k,j,i),25,1)
+          ibit24 = IBITS(wall_flags_0(k,j,i),24,1)
+
+          k_ppp = k + 3 * ibit26
+          k_pp  = k + 2 * ( 1 - ibit24  )
+          k_mm  = k - 2 * ibit26
 
           w_comp    = w(k,j-1,i) + w(k,j,i)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
+                     ( 37.0 * ibit26 * adv_mom_5                             &
+                  +     7.0 * ibit25 * adv_mom_3                             &
+                  +           ibit24 * adv_mom_1                             &
                      ) *                                                     &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
+              -      (  8.0 * ibit26 * adv_mom_5                             &
+                  +           ibit25 * adv_mom_3                             &
                      ) *                                                     &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
+              +      (        ibit26 * adv_mom_5                             &
                      ) *                                                     &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
@@ -1269,14 +1344,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
+                     ( 10.0 * ibit26 * adv_mom_5                             &
+                  +     3.0 * ibit25 * adv_mom_3                             &
+                  +           ibit24 * adv_mom_1                             &
                      ) *                                                     &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
+              -      (  5.0 * ibit26 * adv_mom_5                             &
+                  +           ibit25 * adv_mom_3                             &
                      ) *                                                     &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
+              +      (        ibit26 * adv_mom_5                             &
                      ) *                                                     &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
@@ -1353,20 +1428,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),26,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),24,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),26,1)
+          ibit26 = IBITS(wall_flags_0(k,j,i),26,1)
+          ibit25 = IBITS(wall_flags_0(k,j,i),25,1)
+          ibit24 = IBITS(wall_flags_0(k,j,i),24,1)
+
+          k_ppp = k + 3 * ibit26
+          k_pp  = k + 2 * ( 1 - ibit24  )
+          k_mm  = k - 2 * ibit26
 
           w_comp    = w(k,j-1,i) + w(k,j,i)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
+                     ( 37.0 * ibit26 * adv_mom_5                             &
+                  +     7.0 * ibit25 * adv_mom_3                             &
+                  +           ibit24 * adv_mom_1                             &
                      ) *                                                     &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
+              -      (  8.0 * ibit26 * adv_mom_5                             &
+                  +           ibit25 * adv_mom_3                             &
                      ) *                                                     &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
+              +      (        ibit26 * adv_mom_5                             &
                      ) *                                                     &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
@@ -1374,14 +1453,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
+                     ( 10.0 * ibit26 * adv_mom_5                             &
+                  +     3.0 * ibit25 * adv_mom_3                             &
+                  +           ibit24 * adv_mom_1                             &
                      ) *                                                     &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
+              -      (  5.0 * ibit26 * adv_mom_5                             &
+                  +           ibit25 * adv_mom_3                             &
                      ) *                                                     &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
+              +      (        ibit26 * adv_mom_5                             &
                      ) *                                                     &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
@@ -1451,5 +1530,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, i_omp, j, k, k_mm, k_pp, k_ppp, tn
+       INTEGER ::  i, ibit27, ibit28, ibit29, ibit30, ibit31, ibit32, ibit33, &
+                   ibit34, ibit35, i_omp, j, k, k_mm, k_pp, k_ppp, tn
        REAL    ::  diss_d, div, flux_d, gu, gv, u_comp, v_comp, w_comp
        REAL, DIMENSION(nzb:nzt+1)  :: diss_n, diss_r, diss_t, flux_n, flux_r, &
@@ -1464,33 +1544,36 @@
 
           DO  k = nzb+1, nzb_max
+             ibit32 = IBITS(wall_flags_0(k,j,i),32,1)
+             ibit31 = IBITS(wall_flags_0(k,j,i),31,1)
+             ibit30 = IBITS(wall_flags_0(k,j,i),30,1)
 
              v_comp         = v(k+1,j,i) + v(k,j,i) - gv
              flux_s_w(k,tn) = v_comp * (                                      &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 37.0 * ibit32 * adv_mom_5                       &
+                         +     7.0 * ibit31 * adv_mom_3                       &
+                         +           ibit30 * adv_mom_1                       &
+                            ) *                                               &
                                      ( w(k,j,i)   + w(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  8.0 * ibit32 * adv_mom_5                       &
+                         +           ibit31 * adv_mom_3                       &
+                            ) *                                               &
                                      ( w(k,j+1,i) + w(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit32 * adv_mom_5                       &
+                            ) *                                               &
                                      ( w(k,j+2,i) + w(k,j-3,i) )              &
                                          )
 
              diss_s_w(k,tn) = - ABS( v_comp ) * (                             &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1 &
-                         ) *                                                  &
+                            ( 10.0 * ibit32 * adv_mom_5                       &
+                         +     3.0 * ibit31 * adv_mom_3                       &
+                         +           ibit30 * adv_mom_1                       &
+                            ) *                                               &
                                      ( w(k,j,i)   - w(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                         ) *                                                  &
+                     -      (  5.0 * ibit32 * adv_mom_5                       &
+                         +           ibit31 * adv_mom_3                       &
+                            ) *                                               &
                                      ( w(k,j+1,i) - w(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                         ) *                                                  &
+                     +      (        ibit32 * adv_mom_5                       &
+                            ) *                                               &
                                      ( w(k,j+2,i) - w(k,j-3,i) )              &
                                                  )
@@ -1519,32 +1602,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit29 = IBITS(wall_flags_0(k,j,i),29,1)
+             ibit28 = IBITS(wall_flags_0(k,j,i),28,1)
+             ibit27 = IBITS(wall_flags_0(k,j,i),27,1)
+
              u_comp           = u(k+1,j,i) + u(k,j,i) - gu
              flux_l_w(k,j,tn) = u_comp * (                                     &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1 &
-                          ) *                                                  &
+                             ( 37.0 * ibit29 * adv_mom_5                       &
+                          +     7.0 * ibit28 * adv_mom_3                       &
+                          +           ibit27 * adv_mom_1                       &
+                             ) *                                               &
                                      ( w(k,j,i)   + w(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                          ) *                                                  &
+                      -      (  8.0 * ibit29 * adv_mom_5                       &
+                          +           ibit28 * adv_mom_3                       &
+                             ) *                                               &
                                      ( w(k,j,i+1) + w(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                          ) *                                                  &
+                      +      (        ibit29 * adv_mom_5                       &
+                             ) *                                               &
                                      ( w(k,j,i+2) + w(k,j,i-3) )               &
                                          )
 
                diss_l_w(k,j,tn) = - ABS( u_comp ) * (                          &
-                          ( 10.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1 &
-                          ) *                                                  &
+                             ( 10.0 * ibit29 * adv_mom_5                       &
+                          +     3.0 * ibit28 * adv_mom_3                       &
+                          +           ibit27 * adv_mom_1                       &
+                             ) *                                               &
                                      ( w(k,j,i)   - w(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                          ) *                                                  &
+                      -      (  5.0 * ibit29 * adv_mom_5                       &
+                          +           ibit28 * adv_mom_3                       &
+                             ) *                                               &
                                      ( w(k,j,i+1) - w(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                          ) *                                                  &
+                      +      (        ibit29 * adv_mom_5                       &
+                             ) *                                               &
                                      ( w(k,j,i+2) - w(k,j,i-3) )               &
                                                     )
@@ -1582,47 +1669,55 @@
        DO  k = nzb+1, nzb_max
 
+          ibit29 = IBITS(wall_flags_0(k,j,i),29,1)
+          ibit28 = IBITS(wall_flags_0(k,j,i),28,1)
+          ibit27 = IBITS(wall_flags_0(k,j,i),27,1)
+
           u_comp    = u(k+1,j,i+1) + u(k,j,i+1) - gu
           flux_r(k) = u_comp * (                                             &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1    &
+                     ( 37.0 * ibit29 * adv_mom_5                             &
+                  +     7.0 * ibit28 * adv_mom_3                             &
+                  +           ibit27 * adv_mom_1                             &
                      ) *                                                     &
                                  ( w(k,j,i+1) + w(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
+              -      (  8.0 * ibit29 * adv_mom_5                             &
+                  +           ibit28 * adv_mom_3                             &
                      ) *                                                     &
                                  ( w(k,j,i+2) + w(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
+              +      (        ibit29 * adv_mom_5                             &
                      ) *                                                     &
                                  ( w(k,j,i+3) + w(k,j,i-2) )                 &
-                               )
+                                )
 
           diss_r(k) = - ABS( u_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1    &
+                     ( 10.0 * ibit29 * adv_mom_5                             &
+                  +     3.0 * ibit28 * adv_mom_3                             &
+                  +           ibit27 * adv_mom_1                             &
                      ) *                                                     &
                                  ( w(k,j,i+1) - w(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
+              -      (  5.0 * ibit29 * adv_mom_5                             &
+                  +           ibit28 * adv_mom_3                             &
                      ) *                                                     &
                                  ( w(k,j,i+2) - w(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
+              +      (        ibit29 * adv_mom_5                             &
                      ) *                                                     &
                                  ( w(k,j,i+3) - w(k,j,i-2) )                 &
                                         )
 
+          ibit32 = IBITS(wall_flags_0(k,j,i),32,1)
+          ibit31 = IBITS(wall_flags_0(k,j,i),31,1)
+          ibit30 = IBITS(wall_flags_0(k,j,i),30,1)
+
           v_comp    = v(k+1,j+1,i) + v(k,j+1,i) - gv
           flux_n(k) = v_comp * (                                             &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1    &
+                     ( 37.0 * ibit32 * adv_mom_5                             &
+                  +     7.0 * ibit31 * adv_mom_3                             &
+                  +           ibit30 * adv_mom_1                             &
                      ) *                                                     &
                                  ( w(k,j+1,i) + w(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
+              -      (  8.0 * ibit32 * adv_mom_5                             &
+                  +           ibit31 * adv_mom_3                             &
                      ) *                                                     &
                                  ( w(k,j+2,i) + w(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
+              +      (        ibit32 * adv_mom_5                             &
                      ) *                                                     &
                                  ( w(k,j+3,i) + w(k,j-2,i) )                 &
@@ -1630,14 +1725,14 @@
 
           diss_n(k) = - ABS( v_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1    &
+                     ( 10.0 * ibit32 * adv_mom_5                             &
+                  +     3.0 * ibit31 * adv_mom_3                             &
+                  +           ibit30 * adv_mom_1                             &
                      ) *                                                     &
                                  ( w(k,j+1,i) - w(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
+              -      (  5.0 * ibit32 * adv_mom_5                             &
+                  +           ibit31 * adv_mom_3                             &
                      ) *                                                     &
                                  ( w(k,j+2,i) - w(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
+              +      (        ibit32 * adv_mom_5                             &
                      ) *                                                     &
                                  ( w(k,j+3,i) - w(k,j-2,i) )                 &
@@ -1646,20 +1741,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),35,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),33,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),35,1)
+          ibit35 = IBITS(wall_flags_0(k,j,i),35,1)
+          ibit34 = IBITS(wall_flags_0(k,j,i),34,1)
+          ibit33 = IBITS(wall_flags_0(k,j,i),33,1)
+
+          k_ppp = k + 3 * ibit35
+          k_pp  = k + 2 * ( 1 - ibit33  )
+          k_mm  = k - 2 * ibit35
 
           w_comp    = w(k+1,j,i) + w(k,j,i)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
+                     ( 37.0 * ibit35 * adv_mom_5                             &
+                  +     7.0 * ibit34 * adv_mom_3                             &
+                  +           ibit33 * adv_mom_1                             &
                      ) *                                                     &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
+              -      (  8.0 * ibit35 * adv_mom_5                             &
+                  +           ibit34 * adv_mom_3                             &
                      ) *                                                     &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
+              +      (        ibit35 * adv_mom_5                             &
                      ) *                                                     &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
@@ -1667,14 +1766,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
+                     ( 10.0 * ibit35 * adv_mom_5                             &
+                  +     3.0 * ibit34 * adv_mom_3                             &
+                  +           ibit33 * adv_mom_1                             &
                      ) *                                                     &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
+              -      (  5.0 * ibit35 * adv_mom_5                             &
+                  +           ibit34 * adv_mom_3                             &
                      ) *                                                     &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
+              +      (        ibit35 * adv_mom_5                             &
                      ) *                                                     &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
@@ -1739,20 +1838,24 @@
 !--       k index has to be modified near bottom and top, else array
 !--       subscripts will be exceeded.
-          k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),35,1)
-          k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),33,1)  )
-          k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),35,1)
+          ibit35 = IBITS(wall_flags_0(k,j,i),35,1)
+          ibit34 = IBITS(wall_flags_0(k,j,i),34,1)
+          ibit33 = IBITS(wall_flags_0(k,j,i),33,1)
+
+          k_ppp = k + 3 * ibit35
+          k_pp  = k + 2 * ( 1 - ibit33  )
+          k_mm  = k - 2 * ibit35
 
           w_comp    = w(k+1,j,i) + w(k,j,i)
           flux_t(k) = w_comp  * (                                            &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
+                     ( 37.0 * ibit35 * adv_mom_5                             &
+                  +     7.0 * ibit34 * adv_mom_3                             &
+                  +           ibit33 * adv_mom_1                             &
                      ) *                                                     &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
+              -      (  8.0 * ibit35 * adv_mom_5                             &
+                  +           ibit34 * adv_mom_3                             &
                      ) *                                                     &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
+              +      (        ibit35 * adv_mom_5                             &
                      ) *                                                     &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
@@ -1760,14 +1863,14 @@
 
           diss_t(k) = - ABS( w_comp ) * (                                    &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
+                     ( 10.0 * ibit35 * adv_mom_5                             &
+                  +     3.0 * ibit34 * adv_mom_3                             &
+                  +           ibit33 * adv_mom_1                             &
                      ) *                                                     &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
+              -      (  5.0 * ibit35 * adv_mom_5                             &
+                  +           ibit34 * adv_mom_3                             &
                      ) *                                                     &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
+              +      (        ibit35 * adv_mom_5                             &
                      ) *                                                     &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
@@ -1823,5 +1926,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, j, k, k_mm, k_pp, k_ppp, tn = 0
+       INTEGER ::  i, ibit0, ibit1, ibit2, ibit3, ibit4, ibit5, ibit6,        &
+                   ibit7, ibit8, j, k, k_mm, k_pp, k_ppp, tn = 0
        REAL, DIMENSION(:,:,:), POINTER ::  sk
        REAL    :: diss_d, div, flux_d, u_comp, v_comp
@@ -1840,33 +1944,38 @@
           DO  k = nzb+1, nzb_max
 
+             ibit2 = IBITS(wall_flags_0(k,j,i),2,1)
+             ibit1 = IBITS(wall_flags_0(k,j,i),1,1)
+             ibit0 = IBITS(wall_flags_0(k,j,i),0,1)
+
              u_comp                 = u(k,j,i) - u_gtrans
              swap_flux_x_local(k,j) = u_comp * (                              &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   + sk(k,j,i-1)    )         &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+1) + sk(k,j,i-2)    )         &
-                  +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                         ) *         ( sk(k,j,i+2) + sk(k,j,i-3)    )         &
-                                                  )
+                                                  ( 37.0 * ibit2 * adv_sca_5  &
+                                               +     7.0 * ibit1 * adv_sca_3  &
+                                               +           ibit0 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   + sk(k,j,i-1)    )  &
+                                           -      (  8.0 * ibit2 * adv_sca_5  &
+                                               +           ibit1 * adv_sca_3  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+1) + sk(k,j,i-2)    )  &
+                                           +      (        ibit2 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+2) + sk(k,j,i-3)    )  &
+                                               )
 
               swap_diss_x_local(k,j) = -ABS( u_comp ) * (                     &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   - sk(k,j,i-1)    )         &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+1) - sk(k,j,i-2)  )           &
-                  +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j,i+2) - sk(k,j,i-3) )            &
-                                                           )
+                                                  ( 10.0 * ibit2 * adv_sca_5  &
+                                               +     3.0 * ibit1 * adv_sca_3  &
+                                               +           ibit0 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   - sk(k,j,i-1)    )  &
+                                           -      (  5.0 * ibit2 * adv_sca_5  &
+                                               +           ibit1 * adv_sca_3  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+1) - sk(k,j,i-2)  )    &
+                                           +      (        ibit2 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j,i+2) - sk(k,j,i-3) )     &
+                                                        )
 
           ENDDO
@@ -1879,5 +1988,5 @@
                                     -  8.0 * ( sk(k,j,i+1) + sk(k,j,i-2) )   &
                                     +        ( sk(k,j,i+2) + sk(k,j,i-3) )   &
-                                                  ) * adv_sca_5
+                                               ) * adv_sca_5
 
              swap_diss_x_local(k,j) = -ABS( u_comp ) * (                     &
@@ -1885,5 +1994,5 @@
                                     -  5.0 * ( sk(k,j,i+1) - sk(k,j,i-2) )   &
                                     +        ( sk(k,j,i+2) - sk(k,j,i-3) )   &
-                                                          ) * adv_sca_5
+                                                       ) * adv_sca_5
 
           ENDDO
@@ -1896,33 +2005,37 @@
           DO  k = nzb+1, nzb_max
 
-             v_comp                  = v(k,j,i) - v_gtrans
+             ibit5 = IBITS(wall_flags_0(k,j,i),5,1)
+             ibit4 = IBITS(wall_flags_0(k,j,i),4,1)
+             ibit3 = IBITS(wall_flags_0(k,j,i),3,1)
+
+             v_comp               = v(k,j,i) - v_gtrans
              swap_flux_y_local(k) = v_comp * (                                &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)  + sk(k,j-1,i)     )         &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j+1,i) + sk(k,j-2,i)    )         &
-                  +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j+2,i) + sk(k,j-3,i)    )         &
+                                                  ( 37.0 * ibit5 * adv_sca_5  &
+                                               +     7.0 * ibit4 * adv_sca_3  &
+                                               +           ibit3 * adv_sca_1  &
+                                                  ) *                         &
+                                           ( sk(k,j,i)  + sk(k,j-1,i)     )   &
+                                            -     (  8.0 * ibit5 * adv_sca_5  &
+                                               +           ibit4 * adv_sca_3  &
+                                                   ) *                        &
+                                           ( sk(k,j+1,i) + sk(k,j-2,i)    )   &
+                                           +      (        ibit5 * adv_sca_5  &
+                                                  ) *                         &
+                                           ( sk(k,j+2,i) + sk(k,j-3,i)    )   &
                                              )
 
              swap_diss_y_local(k) = -ABS( v_comp ) * (                        &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                      +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1  &
-                         ) *                                                  &
-                                     ( sk(k,j,i)   - sk(k,j-1,i)    )         &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                      +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3  &
-                         ) *                                                  &
-                                     ( sk(k,j+1,i) - sk(k,j-2,i)  )           &
-                  +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5  &
-                         ) *                                                  &
-                                     ( sk(k,j+2,i) - sk(k,j-3,i) )            &
+                                                  ( 10.0 * ibit5 * adv_sca_5  &
+                                               +     3.0 * ibit4 * adv_sca_3  &
+                                               +           ibit3 * adv_sca_1  &
+                                                  ) *                         &
+                                            ( sk(k,j,i)   - sk(k,j-1,i)    )  &
+                                           -      (  5.0 * ibit5 * adv_sca_5  &
+                                               +           ibit4 * adv_sca_3  &
+                                            ) *                               &
+                                            ( sk(k,j+1,i) - sk(k,j-2,i)  )    &
+                                           +      (        ibit5 * adv_sca_5  &
+                                                  ) *                         &
+                                            ( sk(k,j+2,i) - sk(k,j-3,i) )     &
                                                      )
 
@@ -1955,62 +2068,71 @@
              DO  k = nzb+1, nzb_max
 
+                ibit2 = IBITS(wall_flags_0(k,j,i),2,1)
+                ibit1 = IBITS(wall_flags_0(k,j,i),1,1)
+                ibit0 = IBITS(wall_flags_0(k,j,i),0,1)
+
                 u_comp    = u(k,j,i+1) - u_gtrans
                 flux_r(k) = u_comp * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1    &
-                     ) *                                                    &
+                          ( 37.0 * ibit2 * adv_sca_5                        &
+                      +      7.0 * ibit1 * adv_sca_3                        &
+                      +           ibit0 * adv_sca_1                         &
+                          ) *                                               &
                              ( sk(k,j,i+1) + sk(k,j,i)   )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                     ) *                                                    &
+                   -      (  8.0 * ibit2 * adv_sca_5                        &
+                       +           ibit1 * adv_sca_3                        &
+                          ) *                                               &
                              ( sk(k,j,i+2) + sk(k,j,i-1) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                     ) *     ( sk(k,j,i+3) + sk(k,j,i-2) )                  &
+                   +      (        ibit2 * adv_sca_5                        &
+                          ) *                                               &
+                             ( sk(k,j,i+3) + sk(k,j,i-2) )                  &
                                      )
 
                 diss_r(k) = -ABS( u_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),0,1) * adv_sca_1    &
-                     ) *                                                    &
+                          ( 10.0 * ibit2 * adv_sca_5                        &
+                       +     3.0 * ibit1 * adv_sca_3                        &
+                       +           ibit0 * adv_sca_1                        &
+                          ) *                                               &
                              ( sk(k,j,i+1) - sk(k,j,i)  )                   &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),1,1) * adv_sca_3    &
-                     ) *                                                    &
+                   -      (  5.0 * ibit2 * adv_sca_5                        &
+                       +           ibit1 * adv_sca_3                        &
+                          ) *                                               &
                              ( sk(k,j,i+2) - sk(k,j,i-1) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),2,1) * adv_sca_5    &
-                     ) *                                                    &
+                   +      (        ibit2 * adv_sca_5                        &
+                          ) *                                               &
                              ( sk(k,j,i+3) - sk(k,j,i-2) )                  &
                                              )
 
+                ibit5 = IBITS(wall_flags_0(k,j,i),5,1)
+                ibit4 = IBITS(wall_flags_0(k,j,i),4,1)
+                ibit3 = IBITS(wall_flags_0(k,j,i),3,1)
+
                 v_comp    = v(k,j+1,i) - v_gtrans
                 flux_n(k) = v_comp * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1    &
-                     ) *                                                    &
+                          ( 37.0 * ibit5 * adv_sca_5                        &
+                       +     7.0 * ibit4 * adv_sca_3                        &
+                       +           ibit3 * adv_sca_1                        &
+                          ) *                                               &
                              ( sk(k,j+1,i) + sk(k,j,i)   )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                     ) *                                                    &
+                   -      (  8.0 * ibit5 * adv_sca_5                        &
+                       +           ibit4 * adv_sca_3                        &
+                          ) *                                               &
                              ( sk(k,j+2,i) + sk(k,j-1,i) )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                     ) *                                                    &
+                   +      (        ibit5 * adv_sca_5                        &
+                          ) *                                               &
                              ( sk(k,j+3,i) + sk(k,j-2,i) )                  &
                                      )
 
                 diss_n(k) = -ABS( v_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),3,1) * adv_sca_1    &
-                     ) *                                                    &
+                          ( 10.0 * ibit5 * adv_sca_5                        &
+                       +     3.0 * ibit4 * adv_sca_3                        &
+                       +           ibit3 * adv_sca_1                        &
+                          ) *                                               &
                              ( sk(k,j+1,i) - sk(k,j,i)    )                 &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),4,1) * adv_sca_3    &
-                     ) *                                                    &
+                   -      (  5.0 * ibit5 * adv_sca_5                        &
+                       +           ibit4 * adv_sca_3                        &
+                          ) *                                               &
                              ( sk(k,j+2,i) - sk(k,j-1,i)  )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),5,1) * adv_sca_5    &
-                     ) *                                                    &
+                   +      (        ibit5 * adv_sca_5                        &
+                          ) *                                               &
                              ( sk(k,j+3,i) - sk(k,j-2,i) )                  &
                                              )
@@ -2018,37 +2140,41 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),8,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),6,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),8,1)
-
-
-                flux_t(k) = w(k,j,i) * (                                    &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
-                     ) *                                                    &
-                             ( sk(k+1,j,i)  + sk(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                     ) *                                                    &
-                             ( sk(k_pp,j,i) + sk(k-1,j,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                     ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )                &
+                ibit8 = IBITS(wall_flags_0(k,j,i),8,1)
+                ibit7 = IBITS(wall_flags_0(k,j,i),7,1)
+                ibit6 = IBITS(wall_flags_0(k,j,i),6,1)
+
+                k_ppp = k + 3 * ibit8
+                k_pp  = k + 2 * ( 1 - ibit6  )
+                k_mm  = k - 2 * ibit8
+
+
+                flux_t(k) = w(k,j,i) * (                                      &
+                           ( 37.0 * ibit8 * adv_sca_5                         &
+                        +     7.0 * ibit7 * adv_sca_3                         &
+                        +           ibit6 * adv_sca_1                         &
+                           ) *                                                &
+                                   ( sk(k+1,j,i)  + sk(k,j,i)   )             &
+                          -      (  8.0 * ibit8 * adv_sca_5                   &
+                        +           ibit7 * adv_sca_3                         &
+                           ) *                                                &
+                                   ( sk(k_pp,j,i) + sk(k-1,j,i) )             &
+                    +      (        ibit8 * adv_sca_5                         &
+                           ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )            &
                                        )
 
-                diss_t(k) = -ABS( w(k,j,i) ) * (                            &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
-                     ) *                                                    &
-                             ( sk(k+1,j,i)   - sk(k,j,i)    )               &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                     ) *                                                    &
-                             ( sk(k_pp,j,i)  - sk(k-1,j,i)  )               &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                     ) *                                                    &
-                             ( sk(k_ppp,j,i) - sk(k_mm,j,i) )               &
-                                               )
+                diss_t(k) = -ABS( w(k,j,i) ) * (                              &
+                           ( 10.0 * ibit8 * adv_sca_5                         &
+                        +     3.0 * ibit7 * adv_sca_3                         &
+                        +           ibit6 * adv_sca_1                         &
+                           ) *                                                &
+                                   ( sk(k+1,j,i)   - sk(k,j,i)    )           &
+                    -      (  5.0 * ibit8 * adv_sca_5                         &
+                        +           ibit7 * adv_sca_3                         &
+                           ) *                                                &
+                                   ( sk(k_pp,j,i)  - sk(k-1,j,i)  )           &
+                    +      (        ibit8 * adv_sca_5                         &
+                           ) *                                                &
+                                   ( sk(k_ppp,j,i) - sk(k_mm,j,i) )           &
+                                         )
 !
 !--             Calculate the divergence of the velocity field. A respective
@@ -2101,36 +2227,41 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),8,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),6,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),8,1)
-
-                flux_t(k) = w(k,j,i) * (                                    &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
-                     ) *                                                    &
-                             ( sk(k+1,j,i)  + sk(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                     ) *                                                    &
-                             ( sk(k_pp,j,i) + sk(k-1,j,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                     ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )                &
+                ibit8 = IBITS(wall_flags_0(k,j,i),8,1)
+                ibit7 = IBITS(wall_flags_0(k,j,i),7,1)
+                ibit6 = IBITS(wall_flags_0(k,j,i),6,1)
+
+                k_ppp = k + 3 * ibit8
+                k_pp  = k + 2 * ( 1 - ibit6  )
+                k_mm  = k - 2 * ibit8
+
+
+                flux_t(k) = w(k,j,i) * (                                      &
+                           ( 37.0 * ibit8 * adv_sca_5                         &
+                        +     7.0 * ibit7 * adv_sca_3                         &
+                        +           ibit6 * adv_sca_1                         &
+                           ) *                                                &
+                                   ( sk(k+1,j,i)  + sk(k,j,i)   )             &
+                          -      (  8.0 * ibit8 * adv_sca_5                   &
+                        +           ibit7 * adv_sca_3                         &
+                           ) *                                                &
+                                   ( sk(k_pp,j,i) + sk(k-1,j,i) )             &
+                    +      (        ibit8 * adv_sca_5                         &
+                           ) *     ( sk(k_ppp,j,i)+ sk(k_mm,j,i) )            &
                                        )
 
-                diss_t(k) = -ABS( w(k,j,i) ) * (                            &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                  +           IBITS(wall_flags_0(k,j,i),6,1) * adv_sca_1    &
-                     ) *                                                    &
-                             ( sk(k+1,j,i)   - sk(k,j,i)    )               &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                  +           IBITS(wall_flags_0(k,j,i),7,1) * adv_sca_3    &
-                     ) *                                                    &
-                             ( sk(k_pp,j,i)  - sk(k-1,j,i)  )               &
-              +      (        IBITS(wall_flags_0(k,j,i),8,1) * adv_sca_5    &
-                     ) *                                                    &
-                             ( sk(k_ppp,j,i) - sk(k_mm,j,i) )               &
-                                               )
+                diss_t(k) = -ABS( w(k,j,i) ) * (                              &
+                           ( 10.0 * ibit8 * adv_sca_5                         &
+                        +     3.0 * ibit7 * adv_sca_3                         &
+                        +           ibit6 * adv_sca_1                         &
+                           ) *                                                &
+                                   ( sk(k+1,j,i)   - sk(k,j,i)    )           &
+                    -      (  5.0 * ibit8 * adv_sca_5                         &
+                        +           ibit7 * adv_sca_3                         &
+                           ) *                                                &
+                                   ( sk(k_pp,j,i)  - sk(k-1,j,i)  )           &
+                    +      (        ibit8 * adv_sca_5                         &
+                           ) *                                                &
+                                   ( sk(k_ppp,j,i) - sk(k_mm,j,i) )           &
+                                         )
 !
 !--             Calculate the divergence of the velocity field. A respective
@@ -2203,5 +2334,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, j, k, k_mm, k_pp, k_ppp, tn = 0
+       INTEGER ::  i, ibit9, ibit10, ibit11, ibit12, ibit13, ibit14, ibit15,   &
+                   ibit16, ibit17, j, k, k_mm, k_pp, k_ppp, tn = 0
        REAL    ::  diss_d, div, flux_d, gu, gv, v_comp, w_comp
        REAL, DIMENSION(nzb+1:nzt) :: swap_diss_y_local_u, swap_flux_y_local_u
@@ -2220,32 +2352,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit11 = IBITS(wall_flags_0(k,j,i),11,1)
+             ibit10 = IBITS(wall_flags_0(k,j,i),10,1)
+             ibit9  = IBITS(wall_flags_0(k,j,i),9,1)
+
              u_comp(k)                = u(k,j,i) + u(k,j,i-1) - gu
              swap_flux_x_local_u(k,j) = u_comp(k) * (                          &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1 &
-                          ) *                                                  &
+                                       ( 37.0 * ibit11 * adv_mom_5             &
+                                    +     7.0 * ibit10 * adv_mom_3             &
+                                    +           ibit9  * adv_mom_1             &
+                                       ) *                                     &
                                      ( u(k,j,i)   + u(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                          ) *                                                  &
+                                -      (  8.0 * ibit11 * adv_mom_5             &
+                                    +           ibit10 * adv_mom_3             &
+                                       ) *                                     &
                                      ( u(k,j,i+1) + u(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                          ) *                                                  &
+                                +      (        ibit11 * adv_mom_5             &
+                                       ) *                                     &
                                      ( u(k,j,i+2) + u(k,j,i-3) )               &
                                                    )
 
               swap_diss_x_local_u(k,j) = - ABS( u_comp(k) ) * (                &
-                          ( 10.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1 &
-                          ) *                                                  &
+                                       ( 10.0 * ibit11 * adv_mom_5             &
+                                    +     3.0 * ibit10 * adv_mom_3             &
+                                    +           ibit9  * adv_mom_1             &
+                                       ) *                                     &
                                      ( u(k,j,i)   - u(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3 &
-                          ) *                                                  &
+                                -      (  5.0 * ibit11 * adv_mom_5             &
+                                    +           ibit10 * adv_mom_3             &
+                                       ) *                                     &
                                      ( u(k,j,i+1) - u(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5 &
-                          ) *                                                  &
+                                +      (        ibit11 * adv_mom_5             &
+                                       ) *                                     &
                                      ( u(k,j,i+2) - u(k,j,i-3) )               &
                                                              )
@@ -2274,32 +2410,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit14 = IBITS(wall_flags_0(k,j,i),14,1)
+             ibit13 = IBITS(wall_flags_0(k,j,i),13,1)
+             ibit12 = IBITS(wall_flags_0(k,j,i),12,1)
+
              v_comp                 = v(k,j,i) + v(k,j,i-1) - gv
              swap_flux_y_local_u(k) = v_comp * (                              &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1 &
-                         ) *                                                  &
+                                   ( 37.0 * ibit14 * adv_mom_5                &
+                                +     7.0 * ibit13 * adv_mom_3                &
+                                +           ibit12 * adv_mom_1                &
+                                   ) *                                        &
                                      ( u(k,j,i)   + u(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                         ) *                                                  &
+                            -      (  8.0 * ibit14 * adv_mom_5                &
+                            +           ibit13 * adv_mom_3                    &
+                                   ) *                                        &
                                      ( u(k,j+1,i) + u(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                         ) *                                                  &
+                        +      (        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 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1 &
-                         ) *                                                  &
+                                   ( 10.0 * ibit14 * adv_mom_5                &
+                                +     3.0 * ibit13 * adv_mom_3                &
+                                +           ibit12 * adv_mom_1                &
+                                   ) *                                        &
                                      ( u(k,j,i)   - u(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3 &
-                         ) *                                                  &
+                            -      (  5.0 * ibit14 * adv_mom_5                &
+                                +           ibit13 * adv_mom_3                &
+                                   ) *                                        &
                                      ( u(k,j+1,i) - u(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5 &
-                         ) *                                                  &
+                            +      (        ibit14 * adv_mom_5                &
+                                   ) *                                        &
                                      ( u(k,j+2,i) - u(k,j-3,i) )              &
                                                          )
@@ -2331,63 +2471,71 @@
              DO  k = nzb+1, nzb_max
 
+                ibit11 = IBITS(wall_flags_0(k,j,i),11,1)
+                ibit10 = IBITS(wall_flags_0(k,j,i),10,1)
+                ibit9  = IBITS(wall_flags_0(k,j,i),9,1)
+
                 u_comp(k) = u(k,j,i+1) + u(k,j,i)
                 flux_r(k) = ( u_comp(k) - gu ) * (                           &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit11 * adv_mom_5                        &
+                       +     7.0 * ibit10 * adv_mom_3                        &
+                       +           ibit9  * adv_mom_1                        &
+                          ) *                                                &
                                  ( u(k,j,i+1) + u(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit11 * adv_mom_5                        &
+                       +           ibit10 * adv_mom_3                        &
+                          ) *                                                &
                                  ( u(k,j,i+2) + u(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit11 * adv_mom_5                        &
+                          ) *                                                &
                                  ( u(k,j,i+3) + u(k,j,i-2) )                 &
                                                  )
 
                 diss_r(k) = - ABS( u_comp(k) - gu ) * (                      &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),9,1)  * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit11 * adv_mom_5                        &
+                       +     3.0 * ibit10 * adv_mom_3                        & 
+                       +           ibit9  * adv_mom_1                        &
+                          ) *                                                &
                                  ( u(k,j,i+1) - u(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),10,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit11 * adv_mom_5                        &
+                       +           ibit10 * adv_mom_3                        &
+                          ) *                                                &
                                  ( u(k,j,i+2) - u(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),11,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit11 * adv_mom_5                        &
+                          ) *                                                &
                                  ( u(k,j,i+3) - u(k,j,i-2) )                 &
                                                      )
 
+                ibit14 = IBITS(wall_flags_0(k,j,i),14,1)
+                ibit13 = IBITS(wall_flags_0(k,j,i),13,1)
+                ibit12 = IBITS(wall_flags_0(k,j,i),12,1)
+
                 v_comp    = v(k,j+1,i) + v(k,j+1,i-1) - gv
                 flux_n(k) = v_comp * (                                       &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit14 * adv_mom_5                        &
+                       +     7.0 * ibit13 * adv_mom_3                        &
+                       +           ibit12 * adv_mom_1                        &
+                          ) *                                                &
                                  ( u(k,j+1,i) + u(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit14 * adv_mom_5                        &
+                       +           ibit13 * adv_mom_3                        &
+                          ) *                                                &
                                  ( u(k,j+2,i) + u(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit14 * adv_mom_5                        & 
+                          ) *                                                &
                                  ( u(k,j+3,i) + u(k,j-2,i) )                 &
                                                  )
 
                 diss_n(k) = - ABS ( v_comp ) * (                             &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),12,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit14 * adv_mom_5                        &
+                       +     3.0 * ibit13 * adv_mom_3                        &
+                       +           ibit12 * adv_mom_1                        &
+                          ) *                                                &
                                  ( u(k,j+1,i) - u(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),13,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit14 * adv_mom_5                        &
+                       +           ibit13 * adv_mom_3                        &
+                          ) *                                                &
                                  ( u(k,j+2,i) - u(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),14,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit14 * adv_mom_5                        &
+                          ) *                                                &
                                  ( u(k,j+3,i) - u(k,j-2,i) )                 &
                                                       )
@@ -2395,36 +2543,40 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),17,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),15,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),17,1)
+                ibit17 = IBITS(wall_flags_0(k,j,i),17,1)
+                ibit16 = IBITS(wall_flags_0(k,j,i),16,1)
+                ibit15 = IBITS(wall_flags_0(k,j,i),15,1)
+
+                k_ppp = k + 3 * ibit17
+                k_pp  = k + 2 * ( 1 - ibit15  )
+                k_mm  = k - 2 * ibit17
 
                 w_comp    = w(k,j,i) + w(k,j,i-1)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit17 * adv_mom_5                        &
+                       +     7.0 * ibit16 * adv_mom_3                        &
+                       +           ibit15 * adv_mom_1                        & 
+                          ) *                                                &
                              ( u(k+1,j,i)  + u(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit17 * adv_mom_5                        &
+                       +           ibit16 * adv_mom_3                        &
+                          ) *                                                &
                              ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit17 * adv_mom_5                        &
+                          ) *                                                &
                              ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
                                       )
 
                 diss_t(k) = - ABS( w_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit17 * adv_mom_5                        &
+                       +     3.0 * ibit16 * adv_mom_3                        &
+                       +           ibit15 * adv_mom_1                        &
+                          ) *                                                &
                              ( u(k+1,j,i)   - u(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit17 * adv_mom_5                        &
+                       +           ibit16 * adv_mom_3                        &
+                          ) *                                                &
                              ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit17 * adv_mom_5                        &
+                           ) *                                               &
                              ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
                                               )
@@ -2497,38 +2649,42 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),17,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),15,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),17,1)
+                ibit17 = IBITS(wall_flags_0(k,j,i),17,1)
+                ibit16 = IBITS(wall_flags_0(k,j,i),16,1)
+                ibit15 = IBITS(wall_flags_0(k,j,i),15,1)
+
+                k_ppp = k + 3 * ibit17
+                k_pp  = k + 2 * ( 1 - ibit15  )
+                k_mm  = k - 2 * ibit17
 
                 w_comp    = w(k,j,i) + w(k,j,i-1)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit17 * adv_mom_5                        &
+                       +     7.0 * ibit16 * adv_mom_3                        &
+                       +           ibit15 * adv_mom_1                        &
+                          ) *                                                &
                              ( u(k+1,j,i)  + u(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit17 * adv_mom_5                        &
+                       +           ibit16 * adv_mom_3                        &
+                          ) *                                                &
                              ( u(k_pp,j,i) + u(k-1,j,i)   )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit17 * adv_mom_5                        &
+                          ) *                                                &
                              ( u(k_ppp,j,i) + u(k_mm,j,i) )                  &
                                       )
 
-                 diss_t(k) = - ABS( w_comp ) * (                             &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),15,1) * adv_mom_1    &
-                     ) *                                                     &
+                diss_t(k) = - ABS( w_comp ) * (                              &
+                          ( 10.0 * ibit17 * adv_mom_5                        &
+                       +     3.0 * ibit16 * adv_mom_3                        &
+                       +           ibit15 * adv_mom_1                        &
+                          ) *                                                &
                              ( u(k+1,j,i)   - u(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),16,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit17 * adv_mom_5                        &
+                       +           ibit16 * adv_mom_3                        &
+                          ) *                                                &
                              ( u(k_pp,j,i)  - u(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),17,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit17 * adv_mom_5                        &
+                           ) *                                               &
                              ( u(k_ppp,j,i) - u(k_mm,j,i) )                  &
-                                               )
+                                              )
 !
 !--             Calculate the divergence of the velocity field. A respective
@@ -2597,5 +2753,6 @@
 
 
-       INTEGER ::  i, j, k, k_mm, k_pp, k_ppp, tn = 0
+       INTEGER ::  i, ibit18, ibit19, ibit20, ibit21, ibit22, ibit23, ibit24, &
+                    ibit25, ibit26, j, k, k_mm, k_pp, k_ppp, tn = 0
        REAL    ::  diss_d, div, flux_d, gu, gv, u_comp, w_comp
        REAL, DIMENSION(nzb+1:nzt) :: swap_diss_y_local_v, swap_flux_y_local_v
@@ -2613,32 +2770,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit20 = IBITS(wall_flags_0(k,j,i),20,1)
+             ibit19 = IBITS(wall_flags_0(k,j,i),19,1)
+             ibit18 = IBITS(wall_flags_0(k,j,i),18,1)
+
              u_comp                   = u(k,j-1,i) + u(k,j,i) - gu
              swap_flux_x_local_v(k,j) = u_comp * (                             &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1 &
-                          ) *                                                  &
+                                      ( 37.0 * ibit20 * adv_mom_5              &
+                                   +     7.0 * ibit19 * adv_mom_3              &
+                                   +           ibit18 * adv_mom_1              &
+                                      ) *                                      &
                                      ( v(k,j,i)   + v(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                          ) *                                                  &
+                               -      (  8.0 * ibit20 * adv_mom_5              &
+                                   +           ibit19 * adv_mom_3              &
+                                      ) *                                      &
                                      ( v(k,j,i+1) + v(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                          ) *                                                  &
+                               +      (        ibit20 * adv_mom_5              &
+                                      ) *                                      &
                                      ( v(k,j,i+2) + v(k,j,i-3) )               &
                                                  )
 
               swap_diss_x_local_v(k,j) = - ABS( u_comp ) * (                   &
-                          ( 10.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1 &
-                          ) *                                                  &
+                                      ( 10.0 * ibit20 * adv_mom_5              &
+                                   +     3.0 * ibit19 * adv_mom_3              &
+                                   +           ibit18 * adv_mom_1              &
+                                      ) *                                      &
                                      ( v(k,j,i)   - v(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3 &
-                          ) *                                                  &
+                               -      (  5.0 * ibit20 * adv_mom_5              &
+                                   +           ibit19 * adv_mom_3              &
+                                      ) *                                      &
                                      ( v(k,j,i+1) - v(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5 &
-                          ) *                                                  &
+                               +      (        ibit20 * adv_mom_5              &
+                                      ) *                                      &
                                      ( v(k,j,i+2) - v(k,j,i-3) )               &
                                                            )
@@ -2667,32 +2828,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit23 = IBITS(wall_flags_0(k,j,i),23,1)
+             ibit22 = IBITS(wall_flags_0(k,j,i),22,1)
+             ibit21 = IBITS(wall_flags_0(k,j,i),21,1)
+
              v_comp(k)              = v(k,j,i) + v(k,j-1,i) - gv
              swap_flux_y_local_v(k) = v_comp(k) * (                           &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1 &
-                         ) *                                                  &
+                                   ( 37.0 * ibit23 * adv_mom_5                &
+                                +     7.0 * ibit22 * adv_mom_3                &
+                                +           ibit21 * adv_mom_1                &
+                                   ) *                                        &
                                      ( v(k,j,i)   + v(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                         ) *                                                  &
+                            -      (  8.0 * ibit23 * adv_mom_5                &
+                                +           ibit22 * adv_mom_3                &
+                                   ) *                                        &
                                      ( v(k,j+1,i) + v(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                         ) *                                                  &
+                            +      (        ibit23 * adv_mom_5                &
+                                   ) *                                        &
                                      ( v(k,j+2,i) + v(k,j-3,i) )              &
                                                  )
 
              swap_diss_y_local_v(k) = - ABS( v_comp(k) ) * (                  &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1 &
-                         ) *                                                  &
+                                   ( 10.0 * ibit23 * adv_mom_5                &
+                                +     3.0 * ibit22 * adv_mom_3                &
+                                +           ibit21 * adv_mom_1                &
+                                   ) *                                        &
                                      ( v(k,j,i)   - v(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3 &
-                         ) *                                                  &
+                            -      (  5.0 * ibit23 * adv_mom_5                &
+                                +           ibit22 * adv_mom_3                &
+                                   ) *                                        &
                                      ( v(k,j+1,i) - v(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5 &
-                         ) *                                                  &
+                            +      (        ibit23 * adv_mom_5                &
+                                   ) *                                        &
                                      ( v(k,j+2,i) - v(k,j-3,i) )              &
                                                           )
@@ -2723,63 +2888,71 @@
              DO  k = nzb+1, nzb_max
 
+                ibit20 = IBITS(wall_flags_0(k,j,i),20,1)
+                ibit19 = IBITS(wall_flags_0(k,j,i),19,1)
+                ibit18 = IBITS(wall_flags_0(k,j,i),18,1)
+
                 u_comp    = u(k,j-1,i+1) + u(k,j,i+1) - gu
                 flux_r(k) = u_comp * (                                       &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit20 * adv_mom_5                        &
+                       +     7.0 * ibit19 * adv_mom_3                        &
+                       +           ibit18 * adv_mom_1                        &
+                          ) *                                                &
                                  ( v(k,j,i+1) + v(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit20 * adv_mom_5                        &
+                       +           ibit19 * adv_mom_3                        &
+                          ) *                                                &
                                  ( v(k,j,i+2) + v(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit20 * adv_mom_5                        &
+                          ) *                                                &
                                  ( v(k,j,i+3) + v(k,j,i-2) )                 &
                                      )
 
                 diss_r(k) = - ABS( u_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),18,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit20 * adv_mom_5                        &
+                       +     3.0 * ibit19 * adv_mom_3                        &
+                       +           ibit18 * adv_mom_1                        &
+                          ) *                                                &
                                  ( v(k,j,i+1) - v(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),19,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit20 * adv_mom_5                        &
+                       +           ibit19 * adv_mom_3                        &
+                          ) *                                                &
                                  ( v(k,j,i+2) - v(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),20,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit20 * adv_mom_5                        &
+                          ) *                                                &
                                  ( v(k,j,i+3) - v(k,j,i-2) )                 &
                                               )
 
+                ibit23 = IBITS(wall_flags_0(k,j,i),23,1)
+                ibit22 = IBITS(wall_flags_0(k,j,i),22,1)
+                ibit21 = IBITS(wall_flags_0(k,j,i),21,1)
+
                 v_comp(k) = v(k,j+1,i) + v(k,j,i)
                 flux_n(k) = ( v_comp(k) - gv ) * (                           &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit23 * adv_mom_5                        &
+                       +     7.0 * ibit22 * adv_mom_3                        &
+                       +           ibit21 * adv_mom_1                        &
+                          ) *                                                &
                                  ( v(k,j+1,i) + v(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit23 * adv_mom_5                        &
+                       +           ibit22 * adv_mom_3                        &
+                          ) *                                                &
                                  ( v(k,j+2,i) + v(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit23 * adv_mom_5                        &
+                          ) *                                                &
                                  ( v(k,j+3,i) + v(k,j-2,i) )                 &
                                      )
 
                 diss_n(k) = - ABS( v_comp(k) - gv ) * (                      &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),21,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit23 * adv_mom_5                        &
+                       +     3.0 * ibit22 * adv_mom_3                        &
+                       +           ibit21 * adv_mom_1                        &
+                          ) *                                                &
                                  ( v(k,j+1,i) - v(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),22,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit23 * adv_mom_5                        &
+                       +           ibit22 * adv_mom_3                        &
+                          ) *                                                &
                                  ( v(k,j+2,i) - v(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),23,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit23 * adv_mom_5                        &
+                          ) *                                                &
                                  ( v(k,j+3,i) - v(k,j-2,i) )                 &
                                                       )
@@ -2787,36 +2960,40 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),26,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),24,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),26,1)
+                ibit26 = IBITS(wall_flags_0(k,j,i),26,1)
+                ibit25 = IBITS(wall_flags_0(k,j,i),25,1)
+                ibit24 = IBITS(wall_flags_0(k,j,i),24,1)
+
+                k_ppp = k + 3 * ibit26
+                k_pp  = k + 2 * ( 1 - ibit24  )
+                k_mm  = k - 2 * ibit26
 
                 w_comp    = w(k,j-1,i) + w(k,j,i)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit26 * adv_mom_5                        &
+                       +     7.0 * ibit25 * adv_mom_3                        &
+                       +           ibit24 * adv_mom_1                        &
+                          ) *                                                &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit26 * adv_mom_5                        &
+                       +           ibit25 * adv_mom_3                        &
+                          ) *                                                &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit26 * adv_mom_5                        &
+                          ) *                                                &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
                                       )
 
                 diss_t(k) = - ABS( w_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit26 * adv_mom_5                        &
+                       +     3.0 * ibit25 * adv_mom_3                        &
+                       +           ibit24 * adv_mom_1                        &
+                          ) *                                                &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit26 * adv_mom_5                        &
+                       +           ibit25 * adv_mom_3                        &
+                          ) *                                                &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit26 * adv_mom_5                        &
+                          ) *                                                &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
                                                )
@@ -2896,38 +3073,42 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),26,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),24,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),26,1)
+                ibit26 = IBITS(wall_flags_0(k,j,i),26,1)
+                ibit25 = IBITS(wall_flags_0(k,j,i),25,1)
+                ibit24 = IBITS(wall_flags_0(k,j,i),24,1)
+
+                k_ppp = k + 3 * ibit26
+                k_pp  = k + 2 * ( 1 - ibit24  )
+                k_mm  = k - 2 * ibit26
 
                 w_comp    = w(k,j-1,i) + w(k,j,i)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit26 * adv_mom_5                        &
+                       +     7.0 * ibit25 * adv_mom_3                        &
+                       +           ibit24 * adv_mom_1                        &
+                          ) *                                                &
                              ( v(k+1,j,i)   + v(k,j,i)    )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit26 * adv_mom_5                        &
+                       +           ibit25 * adv_mom_3                        &
+                          ) *                                                &
                              ( v(k_pp,j,i)  + v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit26 * adv_mom_5                        &
+                          ) *                                                &
                              ( v(k_ppp,j,i) + v(k_mm,j,i) )                  &
-                                 )
+                                      )
 
                 diss_t(k) = - ABS( w_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),24,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit26 * adv_mom_5                        &
+                       +     3.0 * ibit25 * adv_mom_3                        &
+                       +           ibit24 * adv_mom_1                        &
+                          ) *                                                &
                              ( v(k+1,j,i)   - v(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),25,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit26 * adv_mom_5                        &
+                       +           ibit25 * adv_mom_3                        &
+                          ) *                                                &
                              ( v(k_pp,j,i)  - v(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),26,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit26 * adv_mom_5                        &
+                          ) *                                                &
                              ( v(k_ppp,j,i) - v(k_mm,j,i) )                  &
-                                         )
+                                               )
 !
 !--             Calculate the divergence of the velocity field. A respective
@@ -2999,5 +3180,6 @@
        IMPLICIT NONE
 
-       INTEGER ::  i, j, k, k_mm, k_pp, k_ppp, tn = 0
+       INTEGER ::  i, ibit27, ibit28, ibit29, ibit30, ibit31, ibit32, ibit33, &
+                   ibit34, ibit35, j, k, k_mm, k_pp, k_ppp, tn = 0
        REAL    ::  diss_d, div, flux_d, gu, gv, u_comp, v_comp, w_comp
        REAL, DIMENSION(nzb:nzt)    ::  diss_t, flux_t
@@ -3016,32 +3198,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit29 = IBITS(wall_flags_0(k,j,i),29,1)
+             ibit28 = IBITS(wall_flags_0(k,j,i),28,1)
+             ibit27 = IBITS(wall_flags_0(k,j,i),27,1)
+
              u_comp                   = u(k+1,j,i) + u(k,j,i) - gu
              swap_flux_x_local_w(k,j) = u_comp * (                             &
-                          ( 37.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +     7.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1 &
-                          ) *                                                  &
+                                      ( 37.0 * ibit29 * adv_mom_5              &
+                                   +     7.0 * ibit28 * adv_mom_3              &
+                                   +           ibit27 * adv_mom_1              &
+                                      ) *                                      &
                                      ( w(k,j,i)   + w(k,j,i-1) )               &
-                   -      (  8.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                          ) *                                                  &
+                               -      (  8.0 * ibit29 * adv_mom_5              &
+                                   +           ibit28 * adv_mom_3              &
+                                      ) *                                      &
                                      ( w(k,j,i+1) + w(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                          ) *                                                  &
+                               +      (        ibit29 * adv_mom_5              &
+                                      ) *                                      &
                                      ( w(k,j,i+2) + w(k,j,i-3) )               &
                                                  )
 
                swap_diss_x_local_w(k,j) = - ABS( u_comp ) * (                  &
-                          ( 10.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +     3.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                       +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1 &
-                          ) *                                                  &
+                                        ( 10.0 * ibit29 * adv_mom_5            &
+                                     +     3.0 * ibit28 * adv_mom_3            &
+                                     +           ibit27 * adv_mom_1            &
+                                        ) *                                    &
                                      ( w(k,j,i)   - w(k,j,i-1) )               &
-                   -      (  5.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                       +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3 &
-                          ) *                                                  &
+                                 -      (  5.0 * ibit29 * adv_mom_5            &
+                                     +           ibit28 * adv_mom_3            &
+                                        ) *                                    &
                                      ( w(k,j,i+1) - w(k,j,i-2) )               &
-                   +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5 &
-                          ) *                                                  &
+                                 +      (        ibit29 * adv_mom_5            &
+                                        ) *                                    &
                                      ( w(k,j,i+2) - w(k,j,i-3) )               &
                                                             )
@@ -3070,32 +3256,36 @@
           DO  k = nzb+1, nzb_max
 
+             ibit32 = IBITS(wall_flags_0(k,j,i),32,1)
+             ibit31 = IBITS(wall_flags_0(k,j,i),31,1)
+             ibit30 = IBITS(wall_flags_0(k,j,i),30,1)
+
              v_comp                 = v(k+1,j,i) + v(k,j,i) - gv
              swap_flux_y_local_w(k) = v_comp * (                              &
-                         ( 37.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +     7.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1 &
-                         ) *                                                  &
+                                    ( 37.0 * ibit32 * adv_mom_5               &
+                                 +     7.0 * ibit31 * adv_mom_3               &
+                                 +           ibit30 * adv_mom_1               &
+                                    ) *                                       &
                                      ( w(k,j,i)   + w(k,j-1,i) )              &
-                  -      (  8.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                         ) *                                                  &
+                             -      (  8.0 * ibit32 * adv_mom_5               &
+                                 +           ibit31 * adv_mom_3               &
+                                    ) *                                       &
                                      ( w(k,j+1,i) + w(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                         ) *                                                  &
+                             +      (        ibit32 * adv_mom_5               &
+                                    ) *                                       &
                                      ( w(k,j+2,i) + w(k,j-3,i) )              &
                                                )
 
              swap_diss_y_local_w(k) = - ABS( v_comp ) * (                     &
-                         ( 10.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +     3.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                      +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1 &
-                         ) *                                                  &
+                                    ( 10.0 * ibit32 * adv_mom_5               &
+                                 +     3.0 * ibit31 * adv_mom_3               &
+                                 +           ibit30 * adv_mom_1               &
+                                    ) *                                       &
                                      ( w(k,j,i)   - w(k,j-1,i) )              &
-                  -      (  5.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                      +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3 &
-                         ) *                                                  &
+                             -      (  5.0 * ibit32 * adv_mom_5               &
+                                 +           ibit31 * adv_mom_3               &
+                                    ) *                                       &
                                      ( w(k,j+1,i) - w(k,j-2,i) )              &
-                  +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5 &
-                         ) *                                                  &
+                             +      (        ibit32 * adv_mom_5               &
+                                    ) *                                       &
                                      ( w(k,j+2,i) - w(k,j-3,i) )              &
                                                         )
@@ -3132,63 +3322,71 @@
              DO  k = nzb+1, nzb_max
 
+                ibit29 = IBITS(wall_flags_0(k,j,i),29,1)
+                ibit28 = IBITS(wall_flags_0(k,j,i),28,1)
+                ibit27 = IBITS(wall_flags_0(k,j,i),27,1)
+
                 u_comp    = u(k+1,j,i+1) + u(k,j,i+1) - gu
                 flux_r(k) = u_comp * (                                       &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit29 * adv_mom_5                        &
+                       +     7.0 * ibit28 * adv_mom_3                        &
+                       +           ibit27 * adv_mom_1                        &
+                          ) *                                                &
                                  ( w(k,j,i+1) + w(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit29 * adv_mom_5                        &
+                       +           ibit28 * adv_mom_3                        &
+                          ) *                                                &
                                  ( w(k,j,i+2) + w(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit29 * adv_mom_5                        &
+                          ) *                                                &
                                  ( w(k,j,i+3) + w(k,j,i-2) )                 &
                                      )
 
                 diss_r(k) = - ABS( u_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),27,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit29 * adv_mom_5                        &
+                       +     3.0 * ibit28 * adv_mom_3                        &
+                       +           ibit27 * adv_mom_1                        &
+                          ) *                                                &
                                  ( w(k,j,i+1) - w(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),28,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit29 * adv_mom_5                        &
+                       +           ibit28 * adv_mom_3                        &
+                          ) *                                                &
                                  ( w(k,j,i+2) - w(k,j,i-1) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),29,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit29 * adv_mom_5                        &
+                          ) *                                                &
                                  ( w(k,j,i+3) - w(k,j,i-2) )                 &
                                               )
 
+                ibit32 = IBITS(wall_flags_0(k,j,i),32,1)
+                ibit31 = IBITS(wall_flags_0(k,j,i),31,1)
+                ibit30 = IBITS(wall_flags_0(k,j,i),30,1)
+
                 v_comp    = v(k+1,j+1,i) + v(k,j+1,i) - gv
                 flux_n(k) = v_comp * (                                       &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit32 * adv_mom_5                        &
+                       +     7.0 * ibit31 * adv_mom_3                        &
+                       +           ibit30 * adv_mom_1                        &
+                          ) *                                                &
                                  ( w(k,j+1,i) + w(k,j,i)   )                 &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit32 * adv_mom_5                        &
+                       +           ibit31 * adv_mom_3                        &
+                          ) *                                                &
                                  ( w(k,j+2,i) + w(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit32 * adv_mom_5                        &
+                          ) *                                                &
                                  ( w(k,j+3,i) + w(k,j-2,i) )                 &
                                      )
 
                 diss_n(k) = - ABS( v_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),30,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit32 * adv_mom_5                        &
+                       +     3.0 * ibit31 * adv_mom_3                        &
+                       +           ibit30 * adv_mom_1                        &
+                          ) *                                                &
                                  ( w(k,j+1,i) - w(k,j,i)  )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),31,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit32 * adv_mom_5                        &
+                       +           ibit31 * adv_mom_3                        &
+                          ) *                                                &
                                  ( w(k,j+2,i) - w(k,j-1,i) )                 &
-              +      (        IBITS(wall_flags_0(k,j,i),32,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit32 * adv_mom_5                        &
+                          ) *                                                &
                                  ( w(k,j+3,i) - w(k,j-2,i) )                 &
                                               )
@@ -3196,36 +3394,40 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),35,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),33,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),35,1)
+                ibit35 = IBITS(wall_flags_0(k,j,i),35,1)
+                ibit34 = IBITS(wall_flags_0(k,j,i),34,1)
+                ibit33 = IBITS(wall_flags_0(k,j,i),33,1)
+
+                k_ppp = k + 3 * ibit35
+                k_pp  = k + 2 * ( 1 - ibit33  )
+                k_mm  = k - 2 * ibit35
 
                 w_comp    = w(k+1,j,i) + w(k,j,i)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit35 * adv_mom_5                        &
+                       +     7.0 * ibit34 * adv_mom_3                        &
+                       +           ibit33 * adv_mom_1                        &
+                          ) *                                                &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit35 * adv_mom_5                        &
+                       +           ibit34 * adv_mom_3                        &
+                          ) *                                                &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit35 * adv_mom_5                        &
+                          ) *                                                &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
                                        )
 
                 diss_t(k) = - ABS( w_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit35 * adv_mom_5                        &
+                       +     3.0 * ibit34 * adv_mom_3                        &
+                       +           ibit33 * adv_mom_1                        &
+                          ) *                                                &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit35 * adv_mom_5                        &
+                       +           ibit34 * adv_mom_3                        &
+                          ) *                                                &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit35 * adv_mom_5                        &
+                          ) *                                                &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
                                                )
@@ -3291,38 +3493,42 @@
 !--             k index has to be modified near bottom and top, else array
 !--             subscripts will be exceeded.
-                k_ppp = k + 3 * IBITS(wall_flags_0(k,j,i),35,1)
-                k_pp  = k + 2 * ( 1 - IBITS(wall_flags_0(k,j,i),33,1)  )
-                k_mm  = k - 2 * IBITS(wall_flags_0(k,j,i),35,1)
+                ibit35 = IBITS(wall_flags_0(k,j,i),35,1)
+                ibit34 = IBITS(wall_flags_0(k,j,i),34,1)
+                ibit33 = IBITS(wall_flags_0(k,j,i),33,1)
+
+                k_ppp = k + 3 * ibit35
+                k_pp  = k + 2 * ( 1 - ibit33  )
+                k_mm  = k - 2 * ibit35
 
                 w_comp    = w(k+1,j,i) + w(k,j,i)
                 flux_t(k) = w_comp  * (                                      &
-                     ( 37.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     7.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 37.0 * ibit35 * adv_mom_5                        &
+                       +     7.0 * ibit34 * adv_mom_3                        &
+                       +           ibit33 * adv_mom_1                        &
+                          ) *                                                &
                              ( w(k+1,j,i)  + w(k,j,i)     )                  &
-              -      (  8.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  8.0 * ibit35 * adv_mom_5                        &
+                       +           ibit34 * adv_mom_3                        &
+                          ) *                                                &
                              ( w(k_pp,j,i)  + w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit35 * adv_mom_5                        &
+                          ) *                                                &
                              ( w(k_ppp,j,i) + w(k_mm,j,i) )                  &
-                                      )
+                                       )
 
                 diss_t(k) = - ABS( w_comp ) * (                              &
-                     ( 10.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +     3.0 * IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                  +           IBITS(wall_flags_0(k,j,i),33,1) * adv_mom_1    &
-                     ) *                                                     &
+                          ( 10.0 * ibit35 * adv_mom_5                        &
+                       +     3.0 * ibit34 * adv_mom_3                        &
+                       +           ibit33 * adv_mom_1                        &
+                          ) *                                                &
                              ( w(k+1,j,i)   - w(k,j,i)    )                  &
-              -      (  5.0 * IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                  +           IBITS(wall_flags_0(k,j,i),34,1) * adv_mom_3    &
-                     ) *                                                     &
+                   -      (  5.0 * ibit35 * adv_mom_5                        &
+                       +           ibit34 * adv_mom_3                        &
+                          ) *                                                &
                              ( w(k_pp,j,i)  - w(k-1,j,i)  )                  &
-              +      (        IBITS(wall_flags_0(k,j,i),35,1) * adv_mom_5    &
-                     ) *                                                     &
+                   +      (        ibit35 * adv_mom_5                        &
+                          ) *                                                &
                              ( w(k_ppp,j,i) - w(k_mm,j,i) )                  &
-                                              )
+                                               )
 !
 !--             Calculate the divergence of the velocity field. A respective
