Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 4342)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 4346)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4342 2019-12-16 13:49:14Z Giersch
 ! cdc replaced by canopy_drag_coeff
 ! 
@@ -259,5 +263,6 @@
 
     USE indices,                                                                                   &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, nz, nzt, wall_flags_static_0
+        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, nzb, nz, nzt,             &
+               wall_flags_total_0
 
     USE kinds
@@ -1655,8 +1660,8 @@
        ALLOCATE( salsa_advc_flags_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
 !
-!--    In case of decycling, set Neuman boundary conditions for wall_flags_static_0 bit 31 instead of
+!--    In case of decycling, set Neuman boundary conditions for wall_flags_total_0 bit 31 instead of
 !--    cyclic boundary conditions. Bit 31 is used to identify extended degradation zones (please see
 !--    the following comment). Note, since several also other modules may access this bit but may
-!--    have other boundary conditions, the original value of wall_flags_static_0 bit 31 must not be
+!--    have other boundary conditions, the original value of wall_flags_total_0 bit 31 must not be
 !--    modified. Hence, store the boundary conditions directly on salsa_advc_flags_s.
 !--    salsa_advc_flags_s will be later overwritten in ws_init_flags_scalar and bit 31 won't be used
@@ -1664,5 +1669,5 @@
 !--    Initialize with flag 31 only.
        salsa_advc_flags_s = 0
-       salsa_advc_flags_s = MERGE( IBSET( salsa_advc_flags_s, 31 ), 0, BTEST( wall_flags_static_0, 31 ) )
+       salsa_advc_flags_s = MERGE( IBSET( salsa_advc_flags_s, 31 ), 0, BTEST( wall_flags_total_0, 31 ) )
 
        IF ( decycle_salsa_ns )  THEN
@@ -1784,5 +1789,6 @@
        DO  j = nys, nyn
 
-          k_topo_top(j,i) = MAXLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,j,i), 12 ) ), DIM = 1 ) - 1
+          k_topo_top(j,i) = MAXLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,j,i), 12 ) ), &
+                                       DIM = 1 ) - 1
 
           CALL salsa_driver( i, j, 1 )
@@ -2310,5 +2316,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--          a) Number concentrations
@@ -2521,5 +2527,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
 !
 !--          Regime 2a:
@@ -3068,5 +3074,5 @@
 !
 !--    Predetermine flag to mask topography
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 !
 !--    Wind velocity for dry depositon on vegetation
@@ -7443,5 +7449,5 @@
 !
 !-- Predetermine flag to mask topography
-    flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(:,j,i), 0 ) )
+    flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(:,j,i), 0 ) )
 
     DO  ib = 1, nbins_aerosol   ! aerosol size bins
@@ -7859,5 +7865,5 @@
 
     USE indices,                                                                                   &
-        ONLY:  wall_flags_static_0
+        ONLY:  wall_flags_total_0
 
     USE surface_mod,                                                                               &
@@ -7951,8 +7957,8 @@
           tend(k,j,i) = tend(k,j,i) - MAX( 0.0_wp, ( rs(k+1,j,i) * sedim_vd(k+1,j,i,ib) -          &
                                                      rs(k,j,i) * sedim_vd(k,j,i,ib) ) * ddzu(k) )  &
-                                    * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k-1,j,i), 0 ) )
+                                    * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k-1,j,i), 0 ) )
           rs_p(k,j,i) = rs(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )     &
                                       - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) ) )          &
-                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
        ENDDO
@@ -7964,5 +7970,5 @@
           rs_p(k,j,i) = rs(k,j,i) + ( dt_3d * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )     &
                                                 - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) ) )&
-                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                  * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
           IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
        ENDDO
@@ -8003,5 +8009,5 @@
         ONLY:  diffusion_s
     USE indices,                                                                                   &
-        ONLY:  wall_flags_static_0
+        ONLY:  wall_flags_total_0
     USE surface_mod,                                                                               &
         ONLY :  surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, surf_usm_v
@@ -8088,10 +8094,10 @@
                                    sedim_vd(nzb+2:nzt+1,j,i,ib) - rs(nzb+1:nzt,j,i) *              &
                                    sedim_vd(nzb+1:nzt,j,i,ib) ) * ddzu(nzb+1:nzt) ) *              &
-                                   MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(nzb:nzt-1,j,i), 0 ) )
+                                   MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(nzb:nzt-1,j,i), 0 ) )
           ENDIF
           DO  k = nzb+1, nzt
              rs_p(k,j,i) = rs(k,j,i) +  ( dt_3d  * ( tsc(2) * tend(k,j,i) + tsc(3) * trs_m(k,j,i) )&
                                                   - tsc(5) * rdf_sc(k) * ( rs(k,j,i) - rs_init(k) )&
-                                        ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                        ) * MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
              IF ( rs_p(k,j,i) < 0.0_wp )  rs_p(k,j,i) = 0.1_wp * rs(k,j,i)
           ENDDO
@@ -8424,5 +8430,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq_init(k) * flag
                    ENDDO
@@ -8449,5 +8455,5 @@
                 DO  j = nysg, nyng
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq(k,j,copied) * flag
                    ENDDO
@@ -8485,5 +8491,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq_init(k) * flag
                    ENDDO
@@ -8510,5 +8516,5 @@
                 DO  j = ss, ee
                    DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                      flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       sq(k,j,i) = sq(k,copied,i) * flag
                    ENDDO
@@ -10006,5 +10012,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10021,5 +10028,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10035,5 +10043,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10053,5 +10062,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10071,5 +10081,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10089,5 +10100,6 @@
                          ENDDO
                          sums_l(k,ind,tn) = sums_l(k,ind,tn) + temp_bin * rmask(j,i,sr)  *         &
-                                           MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 22 ) )
+                                           MERGE( 1.0_wp, 0.0_wp,                                  &
+                                           BTEST( wall_flags_total_0(k,j,i), 22 ) )
                       ENDDO
                    ENDDO
@@ -10704,5 +10716,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( aerosol_number(ib)%conc(k,j,i), REAL( fill_value,   &
-                                               KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10713,5 +10725,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( nbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10736,5 +10748,5 @@
                       ENDDO
                       local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),            &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10745,5 +10757,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( mbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -10770,5 +10782,5 @@
                          local_pf(i,j,k) = MERGE( salsa_gas(found_index)%conc(k,j,i),              &
                                                   REAL( fill_value,  KIND = wp ),                  &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10784,5 +10796,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10814,5 +10826,5 @@
 
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10823,5 +10835,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ldsa_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10844,5 +10856,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10853,5 +10865,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( nufp_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10872,5 +10884,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10881,5 +10893,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ntot_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10903,5 +10915,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10912,5 +10924,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm01_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10934,5 +10946,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10943,5 +10955,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm25_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10965,5 +10977,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin,  REAL( fill_value, KIND = wp ),        &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10974,5 +10986,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm10_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -10995,5 +11007,5 @@
                             ENDDO
                             local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),      &
-                                                     BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11011,5 +11023,5 @@
                          DO  k = nzb_do, nzt_do
                             local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,      &
-                                                     KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11033,5 +11045,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11043,5 +11055,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                              KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11114,5 +11126,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( aerosol_number(ib)%conc(k,j,i), REAL( fill_value,   &
-                                               KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -11123,5 +11135,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( nbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                    ENDDO
                 ENDDO
@@ -11144,5 +11156,5 @@
                       ENDDO
                       local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),            &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) )
                    ENDDO
                 ENDDO
@@ -11153,5 +11165,5 @@
                    DO  k = nzb_do, nzt_do
                       local_pf(i,j,k) = MERGE( mbins_av(k,j,i,ib), REAL( fill_value, KIND = wp ),  &
-                                               BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                               BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                    ENDDO
                 ENDDO
@@ -11176,5 +11188,5 @@
                          local_pf(i,j,k) = MERGE( salsa_gas(found_index)%conc(k,j,i),              &
                                                   REAL( fill_value, KIND = wp ),                   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11192,5 +11204,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11219,5 +11231,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11228,5 +11240,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ldsa_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11246,5 +11258,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11255,5 +11267,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( nufp_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11271,5 +11283,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11280,5 +11292,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( ntot_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11300,5 +11312,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11309,5 +11321,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm01_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11329,5 +11341,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11338,5 +11350,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm25_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11358,5 +11370,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11367,5 +11379,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( pm10_av(k,j,i), REAL( fill_value, KIND = wp ),   &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11385,5 +11397,5 @@
                             ENDDO
                             local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),      &
-                                                     BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                     BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                          ENDDO
                       ENDDO
@@ -11403,5 +11415,5 @@
                          DO  k = nzb_do, nzt_do
                             local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,      &
-                                                     KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                                     KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                          ENDDO
                       ENDDO
@@ -11421,5 +11433,5 @@
                          ENDDO
                          local_pf(i,j,k) = MERGE( temp_bin, REAL( fill_value, KIND = wp ),         &
-                                                  BTEST( wall_flags_static_0(k,j,i), 0 ) ) 
+                                                  BTEST( wall_flags_total_0(k,j,i), 0 ) ) 
                       ENDDO
                    ENDDO
@@ -11431,5 +11443,5 @@
                       DO  k = nzb_do, nzt_do
                          local_pf(i,j,k) = MERGE( to_be_resorted(k,j,i), REAL( fill_value,         &
-                                                  KIND = wp ), BTEST( wall_flags_static_0(k,j,i), 0 ) )
+                                               KIND = wp ), BTEST( wall_flags_total_0(k,j,i), 0 ) )
                       ENDDO
                    ENDDO
@@ -11521,10 +11533,11 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                    DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -11575,10 +11588,11 @@
                       im = mask_i(mid,i)
                       jm = mask_j(mid,j)
-                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                      ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                    DIM = 1 ) - 1
                       DO  k = 1, mask_size_l(mid,3)
                          kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                      Set value if not in building
-                         IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                         IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                             local_pf(i,j,k) = fill_value
                          ELSE
@@ -11654,10 +11668,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11703,10 +11718,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11750,10 +11766,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11801,10 +11818,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11852,10 +11870,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11903,10 +11922,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -11955,10 +11975,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                                       DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -12011,10 +12032,11 @@
                          im = mask_i(mid,i)
                          jm = mask_j(mid,j)
-                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                         ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                          DIM = 1 ) - 1
                          DO  k = 1, mask_size_l(mid,3)
                             kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !
 !--                         Set value if not in building
-                            IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                            IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                                local_pf(i,j,k) = fill_value
                             ELSE
@@ -12055,9 +12077,10 @@
                 im = mask_i(mid,i)
                 jm = mask_j(mid,j)
-                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_static_0(:,jm,im), 5 )), DIM = 1 ) - 1
+                ktt = MINLOC( MERGE( 1, 0, BTEST( wall_flags_total_0(:,jm,im), 5 )), &
+                                 DIM = 1 ) - 1
                 DO  k = 1, mask_size_l(mid,3)
                    kk = MIN( ktt+mask_k(mid,k), nzt+1 )
 !--                Set value if not in building
-                   IF ( BTEST( wall_flags_static_0(kk,jm,im), 6 ) )  THEN
+                   IF ( BTEST( wall_flags_total_0(kk,jm,im), 6 ) )  THEN
                       local_pf(i,j,k) = fill_value
                    ELSE
