Index: palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4336)
+++ palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4346)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Introduction of wall_flags_total_0, which currently sets bits based on static
+! topography information used in wall_flags_static_0
+! 
+! 4336 2019-12-13 10:12:05Z raasch
 ! bugfix: wrong header output of particle group features (density ratio) in case
 ! of restarts corrected
@@ -152,5 +156,5 @@
                nzb_max, nzt,nbgp, ngp_2dh_outer,                               &
                topo_top_ind,                                                   &
-               wall_flags_static_0
+               wall_flags_total_0
 
     USE kinds
@@ -1354,5 +1358,5 @@
 !--                               of overhanging structures.
                                   IF ( kp > nzt  .OR.                          &
-                                 .NOT. BTEST( wall_flags_static_0(kp,jp,ip), 0 ) )  THEN
+                                 .NOT. BTEST( wall_flags_total_0(kp,jp,ip), 0 ) )  THEN
                                      pos_x = pos_x + pdx(i)
                                      CYCLE xloop
@@ -1364,5 +1368,5 @@
                                ELSEIF ( .NOT. seed_follows_topography .AND.    &
                                          tmp_particle%z <= zw(k_surf)  .OR.    &
-                                        .NOT. BTEST( wall_flags_static_0(kp,jp,ip), 0 ) )&
+                                        .NOT. BTEST( wall_flags_total_0(kp,jp,ip), 0 ) )&
                                THEN
                                   pos_x = pos_x + pdx(i)
@@ -1520,5 +1524,5 @@
 !
 !--                Check if particle is within topography
-                   IF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 0 ) )  THEN
+                   IF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 0 ) )  THEN
                       particles(n)%particle_mask = .FALSE.
                       deleted_particles = deleted_particles + 1
@@ -1763,22 +1767,22 @@
           DO  k = nzb, nzt+1
 
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 0 )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i+1), 0 ) )                    &
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 0 )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i+1), 0 ) )              &
              THEN
                 de_dx(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i+1) - e(k,j,i) ) * ddx
-             ELSEIF ( BTEST( wall_flags_static_0(k,j,i-1), 0 )  .AND.                 &
-                      BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.                 &
-                .NOT. BTEST( wall_flags_static_0(k,j,i+1), 0 ) )                      &
+             ELSEIF ( BTEST( wall_flags_total_0(k,j,i-1), 0 )  .AND.           &
+                      BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.           &
+                .NOT. BTEST( wall_flags_total_0(k,j,i+1), 0 ) )                &
              THEN
                 de_dx(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i) - e(k,j,i-1) ) * ddx
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 22   )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i+1), 22 ) )               &   
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 22   )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i+1), 22 ) )         &   
              THEN
                 de_dx(k,j,i) = 0.0_wp
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i-1), 22 )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i), 22   ) )               &
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i-1), 22 )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i), 22   ) )         &
              THEN
                 de_dx(k,j,i) = 0.0_wp
@@ -1787,22 +1791,22 @@
              ENDIF
 
-             IF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 0 )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.               &
-                        BTEST( wall_flags_static_0(k,j+1,i), 0 ) )                    &
+             IF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 0 )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.         &
+                        BTEST( wall_flags_total_0(k,j+1,i), 0 ) )              &
              THEN
                 de_dy(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j+1,i) - e(k,j,i) ) * ddy
-             ELSEIF ( BTEST( wall_flags_static_0(k,j-1,i), 0 )  .AND.                 &
-                      BTEST( wall_flags_static_0(k,j,i), 0   )  .AND.                 &
-                .NOT. BTEST( wall_flags_static_0(k,j+1,i), 0 ) )                      &
+             ELSEIF ( BTEST( wall_flags_total_0(k,j-1,i), 0 )  .AND.           &
+                      BTEST( wall_flags_total_0(k,j,i), 0   )  .AND.           &
+                .NOT. BTEST( wall_flags_total_0(k,j+1,i), 0 ) )                &
              THEN
                 de_dy(k,j,i) = 2.0_wp * sgs_wf_part *                          &
                                ( e(k,j,i) - e(k,j-1,i) ) * ddy
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j,i), 22   )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j+1,i), 22 ) )               &   
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j,i), 22   )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j+1,i), 22 ) )         &   
              THEN
                 de_dy(k,j,i) = 0.0_wp
-             ELSEIF ( .NOT. BTEST( wall_flags_static_0(k,j-1,i), 22 )  .AND.          &
-                      .NOT. BTEST( wall_flags_static_0(k,j,i), 22   ) )               &
+             ELSEIF ( .NOT. BTEST( wall_flags_total_0(k,j-1,i), 22 )  .AND.    &
+                      .NOT. BTEST( wall_flags_total_0(k,j,i), 22   ) )         &
              THEN
                 de_dy(k,j,i) = 0.0_wp
@@ -1822,5 +1826,5 @@
 !
 !--          Flag to mask topography
-             flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0  ) )
+             flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0  ) )
 
              de_dz(k,j,i) = 2.0_wp * sgs_wf_part *                             &
@@ -1897,5 +1901,5 @@
 !
 !--             Flag indicating vicinity of wall
-                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 24 ) )
+                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 24 ) )
 
                 sums_l(k,1,0)  = sums_l(k,1,0)  + u(k,j,i) * flag1
@@ -1937,5 +1941,5 @@
 !
 !--             Flag indicating vicinity of wall
-                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 24 ) )
+                flag1 = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 24 ) )
 
                 sums_l(k,8,0)  = sums_l(k,8,0)  + e(k,j,i)                       * flag1
@@ -3645,5 +3649,5 @@
                                ( gg-dd ) * w(k+1,j+1,i+1) &
                              ) / ( 3.0_wp * gg )
-                   w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) *               &
+                   w_int(n) = w_int_l + ( zv(n) - zw(k) ) / dzw(k+1) *            &
                               ( w_int_u - w_int_l )
                 ENDIF
@@ -3668,7 +3672,7 @@
              j = jp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 1 ) )
              k = kp + MERGE( -1_iwp , 1_iwp, BTEST( nb, 0 ) )
-             IF ( .NOT. BTEST(wall_flags_static_0(k,  jp, ip), 0) .OR.                &
-                  .NOT. BTEST(wall_flags_static_0(kp, j,  ip), 0) .OR.                &
-                  .NOT. BTEST(wall_flags_static_0(kp, jp, i ), 0) )                   &
+             IF ( .NOT. BTEST(wall_flags_total_0(k,  jp, ip), 0) .OR.             &
+                  .NOT. BTEST(wall_flags_total_0(kp, j,  ip), 0) .OR.             &
+                  .NOT. BTEST(wall_flags_total_0(kp, jp, i ), 0) )                &
              THEN
                 subbox_at_wall = .TRUE.
@@ -4765,5 +4769,5 @@
                 IF ( reach_x(t_index)                      .AND.               & 
                      ABS( pos_x - xwall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_x )  THEN
 ! 
@@ -4805,5 +4809,5 @@
                 IF ( reach_y(t_index)                      .AND.               & 
                      ABS( pos_y - ywall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_y )  THEN
 ! 
@@ -4845,5 +4849,5 @@
                 IF ( reach_z(t_index)                      .AND.               & 
                      ABS( pos_z - zwall ) < eps            .AND.               &
-                     .NOT. BTEST(wall_flags_static_0(k3,j3,i3),0) .AND.               &
+                     .NOT. BTEST(wall_flags_total_0(k3,j3,i3),0) .AND.         &
                      .NOT. reflect_z )  THEN
 ! 
@@ -5203,5 +5207,5 @@
 !
 !--          Predetermine flag to mask topography
-             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+             flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
              q(k,j,i)  = q_p(k,j,i)  - ql_c(k,j,i) * flag
@@ -5233,5 +5237,5 @@
 !
 !--    Predetermine flag to mask topography
-       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_static_0(k,j,i), 0 ) )
+       flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) )
 
        q(k,j,i)  = q(k,j,i)  - ql_c(k,j,i) * flag
