Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 1576)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 1580)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-! 
+! Bugfix: statistical evaluation of scalar fluxes in case of monotonic limiter.
 ! 
 ! Former revisions:
@@ -1121,53 +1121,49 @@
 
 !
-!--    Evaluation of statistics. Please note, in case of using monotone limiter
-!--    vertical fluxes will be not calculated by the advective fluxes.
-       IF ( .NOT. monotonic_adjustment )  THEN
-
-          SELECT CASE ( sk_char )
-
-             CASE ( 'pt' )
-
-                DO  k = nzb, nzt
-                   sums_wspts_ws_l(k,tn) = sums_wspts_ws_l(k,tn) +            &
-                                          ( flux_t(k) + diss_t(k) )           &
-                                  * weight_substep(intermediate_timestep_count)
-                ENDDO
-             
-             CASE ( 'sa' )
-
-                DO  k = nzb, nzt
-                   sums_wssas_ws_l(k,tn) = sums_wssas_ws_l(k,tn) +            &
-                                          ( flux_t(k) + diss_t(k) )           &
-                                  * weight_substep(intermediate_timestep_count)
-                ENDDO
-             
-             CASE ( 'q' )
-
-                DO  k = nzb, nzt
-                   sums_wsqs_ws_l(k,tn)  = sums_wsqs_ws_l(k,tn) +             &
-                                         ( flux_t(k) + diss_t(k) )            &
-                                  * weight_substep(intermediate_timestep_count)
-                ENDDO
-
-             CASE ( 'qr' )
-
-                DO  k = nzb, nzt
-                   sums_wsqrs_ws_l(k,tn)  = sums_wsqrs_ws_l(k,tn) +           &
-                                         ( flux_t(k) + diss_t(k) )            &
-                                  * weight_substep(intermediate_timestep_count)
-                ENDDO
-
-             CASE ( 'nr' )
-
-                DO  k = nzb, nzt
-                   sums_wsnrs_ws_l(k,tn)  = sums_wsnrs_ws_l(k,tn) +           &
-                                         ( flux_t(k) + diss_t(k) )            &
-                                  * weight_substep(intermediate_timestep_count)
-                ENDDO
-
-            END SELECT
-         ENDIF
-
+!--    Evaluation of statistics.
+       SELECT CASE ( sk_char )
+
+          CASE ( 'pt' )
+
+             DO  k = nzb, nzt
+                sums_wspts_ws_l(k,tn) = sums_wspts_ws_l(k,tn) +               &
+                                       ( flux_t(k) + diss_t(k) )              &
+                               * weight_substep(intermediate_timestep_count)
+             ENDDO
+            
+          CASE ( 'sa' )
+
+             DO  k = nzb, nzt
+                sums_wssas_ws_l(k,tn) = sums_wssas_ws_l(k,tn) +               &
+                                       ( flux_t(k) + diss_t(k) )              &
+                               * weight_substep(intermediate_timestep_count)
+             ENDDO
+            
+          CASE ( 'q' )
+
+             DO  k = nzb, nzt
+                sums_wsqs_ws_l(k,tn)  = sums_wsqs_ws_l(k,tn) +                &
+                                      ( flux_t(k) + diss_t(k) )               &
+                               * weight_substep(intermediate_timestep_count)
+             ENDDO
+
+          CASE ( 'qr' )
+
+             DO  k = nzb, nzt
+                sums_wsqrs_ws_l(k,tn)  = sums_wsqrs_ws_l(k,tn) +              &
+                                      ( flux_t(k) + diss_t(k) )               &
+                               * weight_substep(intermediate_timestep_count)
+             ENDDO
+
+          CASE ( 'nr' )
+
+             DO  k = nzb, nzt
+                sums_wsnrs_ws_l(k,tn)  = sums_wsnrs_ws_l(k,tn) +              &
+                                      ( flux_t(k) + diss_t(k) )               &
+                               * weight_substep(intermediate_timestep_count)
+             ENDDO
+
+         END SELECT
+         
     END SUBROUTINE advec_s_ws_ij
 
@@ -3251,45 +3247,39 @@
              ENDDO
 !
-!--          Evaluation of statistics. Please note, in case of using monotone
-!--          limiter vertical fluxes will be not calculated by the advective 
-!--          fluxes.
-             IF ( .NOT. monotonic_adjustment )  THEN
-
-                SELECT CASE ( sk_char )
-
-                    CASE ( 'pt' )
-                       DO  k = nzb, nzt
-                          sums_wspts_ws_l(k,tn) = sums_wspts_ws_l(k,tn)       &
-                           + ( flux_t(k) + diss_t(k) )                        &
-                           *   weight_substep(intermediate_timestep_count)
-                       ENDDO
-                    CASE ( 'sa' )
-                       DO  k = nzb, nzt
-                          sums_wssas_ws_l(k,tn) = sums_wssas_ws_l(k,tn)       &
-                           + ( flux_t(k) + diss_t(k) )                        &
-                           *   weight_substep(intermediate_timestep_count)
-                       ENDDO
-                    CASE ( 'q' )
-                       DO  k = nzb, nzt
-                          sums_wsqs_ws_l(k,tn) = sums_wsqs_ws_l(k,tn)         &
-                           + ( flux_t(k) + diss_t(k) )                        &
-                           *   weight_substep(intermediate_timestep_count)
-                       ENDDO
-                    CASE ( 'qr' )
-                       DO  k = nzb, nzt
-                          sums_wsqrs_ws_l(k,tn) = sums_wsqrs_ws_l(k,tn)       &
-                           + ( flux_t(k) + diss_t(k) )                        &
-                           *   weight_substep(intermediate_timestep_count)
-                       ENDDO
-                    CASE ( 'nr' )
-                       DO  k = nzb, nzt
-                          sums_wsnrs_ws_l(k,tn) = sums_wsnrs_ws_l(k,tn)       &
-                           + ( flux_t(k) + diss_t(k) )                        &
-                           *   weight_substep(intermediate_timestep_count)
-                       ENDDO
-
-                 END SELECT
-
-              ENDIF
+!--          Evaluation of statistics. 
+             SELECT CASE ( sk_char )
+
+                 CASE ( 'pt' )
+                    DO  k = nzb, nzt
+                       sums_wspts_ws_l(k,tn) = sums_wspts_ws_l(k,tn)          &
+                        + ( flux_t(k) + diss_t(k) )                           &
+                        *   weight_substep(intermediate_timestep_count)
+                    ENDDO
+                 CASE ( 'sa' )
+                    DO  k = nzb, nzt
+                       sums_wssas_ws_l(k,tn) = sums_wssas_ws_l(k,tn)          &
+                        + ( flux_t(k) + diss_t(k) )                           &
+                        *   weight_substep(intermediate_timestep_count)
+                    ENDDO
+                 CASE ( 'q' )
+                    DO  k = nzb, nzt
+                       sums_wsqs_ws_l(k,tn) = sums_wsqs_ws_l(k,tn)            &
+                        + ( flux_t(k) + diss_t(k) )                           &
+                        *   weight_substep(intermediate_timestep_count)
+                    ENDDO
+                 CASE ( 'qr' )
+                    DO  k = nzb, nzt
+                       sums_wsqrs_ws_l(k,tn) = sums_wsqrs_ws_l(k,tn)          &
+                        + ( flux_t(k) + diss_t(k) )                           &
+                        *   weight_substep(intermediate_timestep_count)
+                    ENDDO
+                 CASE ( 'nr' )
+                    DO  k = nzb, nzt
+                       sums_wsnrs_ws_l(k,tn) = sums_wsnrs_ws_l(k,tn)          &
+                        + ( flux_t(k) + diss_t(k) )                           &
+                        *   weight_substep(intermediate_timestep_count)
+                    ENDDO
+
+              END SELECT
 
          ENDDO
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 1576)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 1580)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: setting flags for 5th order scheme near buildings.
 !
 ! Former revisions:
@@ -1243,5 +1243,12 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             DO  k = nzb_u_inner(j,i)+1, nzt
+             DO  k = nzb+1, nzt
+!
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+!--             near vertical walls. 
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 )
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 )
 !
 !--             u component - x-direction
@@ -1251,5 +1258,5 @@
                      .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr  )     &
                    )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 )
+                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 )
                 ELSEIF ( k <= nzb_u_inner(j,i+2) .OR. k <= nzb_u_inner(j,i-1) &
                          .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 )&
@@ -1257,8 +1264,13 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 10 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 11 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 )
                 ENDIF
-
 !
 !--             u component - y-direction
@@ -1267,5 +1279,5 @@
                      .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n )       &
                      .AND. j == nyn ) )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 )
+                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 )
                 ELSEIF ( k <= nzb_u_inner(j+2,i) .OR. k <= nzb_u_inner(j-1,i)  &
                          .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv  ) &
@@ -1273,6 +1285,12 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 13 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 14 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 )
                 ENDIF
 !
@@ -1296,5 +1314,11 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             DO  k = nzb_v_inner(j,i)+1, nzt
+             DO  k = nzb+1, nzt
+!
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 )
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 )
 !
 !--             v component - x-direction
@@ -1303,5 +1327,5 @@
                      .AND. i == nxl ) .OR. (( inflow_r .OR. outflow_r )        &
                      .AND. i == nxr ) )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 )
+                     wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 )
 !--             WS3
                 ELSEIF ( k <= nzb_v_inner(j,i+2) .OR. k <= nzb_v_inner(j,i-1)  &
@@ -1310,6 +1334,12 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 19 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 20 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 )
                 ENDIF
 !
@@ -1320,5 +1350,5 @@
                      .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn  )      &
                    )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 )
+                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 )
                 ELSEIF ( k <= nzb_v_inner(j+2,i) .OR. k <= nzb_v_inner(j-1,i)  &
                          .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv+1 )&
@@ -1326,6 +1356,12 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 22 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 23 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 )
                 ENDIF
 !
@@ -1348,5 +1384,11 @@
        DO  i = nxl, nxr
           DO  j = nys, nyn
-             DO  k = nzb_w_inner(j,i), nzt
+             DO  k = nzb+1, nzt
+!
+!--             At first, set flags to WS1. 
+!--             Since fluxes are swapped in advec_ws.f90, this is necessary to 
+!--             in order to handle the left/south flux.
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 )
+                wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 )
 !
 !--             w component - x-direction
@@ -1355,5 +1397,5 @@
                      .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r )       &
                      .AND. i == nxr ) )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 )
+                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 )
                 ELSEIF ( k <= nzb_w_inner(j,i+2) .OR. k <= nzb_w_inner(j,i-1)  &
                          .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) &
@@ -1361,6 +1403,12 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 28 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 )
                 ELSE
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i),29 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 )
                 ENDIF
 !
@@ -1370,5 +1418,5 @@
                      .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n )       &
                      .AND. j == nyn ) )  THEN
-                   wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 )
+                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 )
                 ELSEIF ( k <= nzb_w_inner(j+2,i) .OR. k <= nzb_w_inner(j-1,i)  &
                          .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv  ) &
@@ -1376,6 +1424,12 @@
                        )  THEN
                    wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 31 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 )
                 ELSE
                    wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 0 )
+!
+!--                Clear flag for WS1
+                   wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 )
                 ENDIF
 !
