Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 1566)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 1567)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! ------------------
-
+! Bugfixes in monotonic limiter.
 ! 
 ! Former revisions:
@@ -825,15 +825,15 @@
 !
 !--           Calculate empirical limiter function (van Albada2 limiter).
-              phi_l = MIN( 1.0_wp, ( 2.0_wp * rl ) /                          &
+              phi_l = MIN( 1.0_wp, ( 2.0_wp * ABS( rl ) ) /                   &
                                          ( rl**2 + 1.0_wp ) ) 
-              phi_r = MIN( 1.0_wp, ( 2.0_wp * rr ) /                          &
+              phi_r = MIN( 1.0_wp, ( 2.0_wp * ABS( rr ) ) /                   &
                                          ( rr**2 + 1.0_wp ) ) 
-              phi_s = MIN( 1.0_wp, ( 2.0_wp * rs ) /                          &
+              phi_s = MIN( 1.0_wp, ( 2.0_wp * ABS( rs ) ) /                   &
                                          ( rs**2 + 1.0_wp ) ) 
-              phi_n = MIN( 1.0_wp, ( 2.0_wp * rn ) /                          &
+              phi_n = MIN( 1.0_wp, ( 2.0_wp * ABS( rn ) ) /                   &
                                          ( rn**2 + 1.0_wp ) ) 
-              phi_d = MIN( 1.0_wp, ( 2.0_wp * rd ) /                          &
+              phi_d = MIN( 1.0_wp, ( 2.0_wp * ABS( rd ) ) /                   &
                                          ( rd**2 + 1.0_wp ) ) 
-              phi_t = MIN( 1.0_wp, ( 2.0_wp * rt ) /                          &
+              phi_t = MIN( 1.0_wp, ( 2.0_wp * ABS( rt ) ) /                   &
                                          ( rt**2 + 1.0_wp ) ) 
 !
@@ -847,8 +847,8 @@
               flux_n(k)                 = fn_1 - phi_n *                      &
                                         ( fn_1 - flux_n(k)                  )
-              flux_d                    = fd_1  !- phi_d *                      &
-!                                         ( fd_1 - flux_d                     )
-              flux_t(k)                 = ft_1 !- phi_t *                      &
-!                                         ( ft_1 - flux_t(k)                  )
+              flux_d                    = fd_1 - phi_d *                      &
+                                        ( fd_1 - flux_d                     )
+              flux_t(k)                 = ft_1 - phi_t *                      &
+                                        ( ft_1 - flux_t(k)                  )
 !
 !--          Moreover, modify dissipation flux according to the limiter. 
@@ -857,6 +857,6 @@
              swap_diss_y_local(k,tn)   = swap_diss_y_local(k,tn)   * phi_s
              diss_n(k)                 = diss_n(k)                 * phi_n
-             diss_d                    = 0.0 !diss_d                    * phi_d
-             diss_t(k)                 = 0.0 !diss_t(k)                 * phi_t
+             diss_d                    = diss_d                    * phi_d
+             diss_t(k)                 = diss_t(k)                 * phi_t
 
           ENDIF
@@ -1054,15 +1054,15 @@
 !
 !--           Calculate empirical limiter function (van Albada2 limiter).
-              phi_l = MIN( 1.0_wp, ( 2.0_wp * rl ) /                          &
+              phi_l = MIN( 1.0_wp, ( 2.0_wp * ABS( rl ) ) /                   &
                                          ( rl**2 + 1.0_wp ) ) 
-              phi_r = MIN( 1.0_wp, ( 2.0_wp * rr ) /                          &
+              phi_r = MIN( 1.0_wp, ( 2.0_wp * ABS( rr ) ) /                   &
                                          ( rr**2 + 1.0_wp ) ) 
-              phi_s = MIN( 1.0_wp, ( 2.0_wp * rs ) /                          &
+              phi_s = MIN( 1.0_wp, ( 2.0_wp * ABS( rs ) ) /                   &
                                          ( rs**2 + 1.0_wp ) ) 
-              phi_n = MIN( 1.0_wp, ( 2.0_wp * rn ) /                          &
+              phi_n = MIN( 1.0_wp, ( 2.0_wp * ABS( rn ) ) /                   &
                                          ( rn**2 + 1.0_wp ) ) 
-              phi_d = MIN( 1.0_wp, ( 2.0_wp * rd ) /                          &
+              phi_d = MIN( 1.0_wp, ( 2.0_wp * ABS( rd ) ) /                   &
                                          ( rd**2 + 1.0_wp ) ) 
-              phi_t = MIN( 1.0_wp, ( 2.0_wp * rt ) /                          &
+              phi_t = MIN( 1.0_wp, ( 2.0_wp * ABS( rt ) ) /                   &
                                          ( rt**2 + 1.0_wp ) ) 
 !
@@ -1130,5 +1130,5 @@
                                           ( flux_t(k) + diss_t(k) )           &
                                   * weight_substep(intermediate_timestep_count)
-             ENDDO
+                ENDDO
              
              CASE ( 'sa' )
@@ -2961,15 +2961,15 @@
 !
 !--                Calculate empirical limiter function (van Albada2 limiter).
-                   phi_l = MIN( 1.0_wp, ( 2.0_wp * rl ) /                     &
+                   phi_l = MIN( 1.0_wp, ( 2.0_wp * ABS( rl ) ) /              &
                                         ( rl**2 + 1.0_wp ) ) 
-                   phi_r = MIN( 1.0_wp, ( 2.0_wp * rr ) /                     &
+                   phi_r = MIN( 1.0_wp, ( 2.0_wp * ABS( rr ) ) /              &
                                         ( rr**2 + 1.0_wp ) ) 
-                   phi_s = MIN( 1.0_wp, ( 2.0_wp * rs ) /                     &
+                   phi_s = MIN( 1.0_wp, ( 2.0_wp * ABS( rs ) ) /              &
                                         ( rs**2 + 1.0_wp ) ) 
-                   phi_n = MIN( 1.0_wp, ( 2.0_wp * rn ) /                     &
+                   phi_n = MIN( 1.0_wp, ( 2.0_wp * ABS( rn ) ) /              &
                                         ( rn**2 + 1.0_wp ) ) 
-                   phi_d = MIN( 1.0_wp, ( 2.0_wp * rd ) /                     &
+                   phi_d = MIN( 1.0_wp, ( 2.0_wp * ABS( rd ) ) /              &
                                         ( rd**2 + 1.0_wp ) ) 
-                   phi_t = MIN( 1.0_wp, ( 2.0_wp * rt ) /                     &
+                   phi_t = MIN( 1.0_wp, ( 2.0_wp * ABS( rt ) ) /              &
                                         ( rt**2 + 1.0_wp ) ) 
 !
@@ -3186,15 +3186,15 @@
 !
 !--                Calculate empirical limiter function (van Albada2 limiter).
-                   phi_l = MIN( 1.0_wp, ( 2.0_wp * rl ) /                     &
+                   phi_l = MIN( 1.0_wp, ( 2.0_wp * ABS( rl ) ) /              &
                                         ( rl**2 + 1.0_wp ) ) 
-                   phi_r = MIN( 1.0_wp, ( 2.0_wp * rr ) /                     &
+                   phi_r = MIN( 1.0_wp, ( 2.0_wp * ABS( rr ) ) /              &
                                         ( rr**2 + 1.0_wp ) ) 
-                   phi_s = MIN( 1.0_wp, ( 2.0_wp * rs ) /                     &
+                   phi_s = MIN( 1.0_wp, ( 2.0_wp * ABS( rs ) ) /              &
                                         ( rs**2 + 1.0_wp ) ) 
-                   phi_n = MIN( 1.0_wp, ( 2.0_wp * rn ) /                     &
+                   phi_n = MIN( 1.0_wp, ( 2.0_wp * ABS( rn ) ) /              &
                                         ( rn**2 + 1.0_wp ) ) 
-                   phi_d = MIN( 1.0_wp, ( 2.0_wp * rd ) /                     &
+                   phi_d = MIN( 1.0_wp, ( 2.0_wp * ABS( rd ) ) /              &
                                         ( rd**2 + 1.0_wp ) ) 
-                   phi_t = MIN( 1.0_wp, ( 2.0_wp * rt ) /                     &
+                   phi_t = MIN( 1.0_wp, ( 2.0_wp * ABS( rt ) ) /              &
                                         ( rt**2 + 1.0_wp ) ) 
 !
@@ -3699,15 +3699,15 @@
 !
 !--                Calculate empirical limiter function (van Albada2 limiter).
-                   phi_l = MIN( 1.0_wp, ( 2.0_wp * rl ) /                     &
+                   phi_l = MIN( 1.0_wp, ( 2.0_wp * ABS( rl ) ) /              &
                                         ( rl**2 + 1.0_wp ) ) 
-                   phi_r = MIN( 1.0_wp, ( 2.0_wp * rr ) /                     &
+                   phi_r = MIN( 1.0_wp, ( 2.0_wp * ABS( rr ) ) /              &
                                         ( rr**2 + 1.0_wp ) ) 
-                   phi_s = MIN( 1.0_wp, ( 2.0_wp * rs ) /                     &
+                   phi_s = MIN( 1.0_wp, ( 2.0_wp * ABS( rs ) ) /              &
                                         ( rs**2 + 1.0_wp ) ) 
-                   phi_n = MIN( 1.0_wp, ( 2.0_wp * rn ) /                     &
+                   phi_n = MIN( 1.0_wp, ( 2.0_wp * ABS( rn ) ) /              &
                                         ( rn**2 + 1.0_wp ) ) 
-                   phi_d = MIN( 1.0_wp, ( 2.0_wp * rd ) /                     &
+                   phi_d = MIN( 1.0_wp, ( 2.0_wp * ABS( rd ) ) /              &
                                         ( rd**2 + 1.0_wp ) ) 
-                   phi_t = MIN( 1.0_wp, ( 2.0_wp * rt ) /                     &
+                   phi_t = MIN( 1.0_wp, ( 2.0_wp * ABS( rt ) ) /              &
                                         ( rt**2 + 1.0_wp ) ) 
 !
Index: palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- palm/trunk/SOURCE/flow_statistics.f90	(revision 1566)
+++ palm/trunk/SOURCE/flow_statistics.f90	(revision 1567)
@@ -21,5 +21,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Reverse modifications made for monotonic limiter.
 ! 
 ! Former revisions:
@@ -146,6 +146,5 @@
         ONLY:   average_count_pr, cloud_droplets, cloud_physics, do_sum,       &
                 dt_3d, g, humidity, icloud_scheme, kappa, large_scale_forcing, &
-                large_scale_subsidence, max_pr_user, message_string,           &
-                monotonic_adjustment, ocean,                                   &
+                large_scale_subsidence, max_pr_user, message_string, ocean,    &
                 passive_scalar, precipitation, simulated_time,                 &
                 use_subsidence_tendencies, use_surface_fluxes, use_top_fluxes, &
@@ -285,6 +284,5 @@
        ENDIF
 
-       IF ( ws_scheme_sca .AND. .NOT. monotonic_adjustment                    &
-           .AND. sr == 0 )  THEN
+       IF ( ws_scheme_sca .AND. sr == 0 )  THEN
 
           DO  i = 0, threads_per_task-1
@@ -807,6 +805,5 @@
 !--             but so far there is no other suitable place to calculate)
                 IF ( ocean )  THEN
-                   IF( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR.      &
-                             sr /= 0 )  THEN
+                   IF( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
                       pts = 0.5_wp * ( sa(k,j,i)   - hom(k,1,23,sr) +          &
                                        sa(k+1,j,i) - hom(k+1,1,23,sr) )
@@ -859,12 +856,10 @@
                       ENDIF
                    ELSE
-                      IF( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR.   &
-                                sr /= 0 )  THEN
+                      IF( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
                          pts = 0.5_wp * ( vpt(k,j,i)   - hom(k,1,44,sr) +      &
                                           vpt(k+1,j,i) - hom(k+1,1,44,sr) )
                          sums_l(k,46,tn) = sums_l(k,46,tn) + pts * w(k,j,i) *  &
                                                              rmask(j,i,sr)
-                      ELSE IF ( ws_scheme_sca .AND. .NOT. monotonic_adjustment &
-                                .AND. sr == 0 )  THEN
+                      ELSE IF ( ws_scheme_sca .AND. sr == 0 )  THEN
                          sums_l(k,46,tn) = ( 1.0_wp + 0.61_wp *                & 
                                              hom(k,1,41,sr) ) *                &
@@ -878,5 +873,5 @@
 !--             Passive scalar flux
                 IF ( passive_scalar .AND. ( .NOT. ws_scheme_sca                &
-                     .OR. monotonic_adjustment .OR. sr /= 0 ) )  THEN
+                     .OR. sr /= 0 ) )  THEN
                    pts = 0.5_wp * ( q(k,j,i)   - hom(k,1,41,sr) +              &
                                     q(k+1,j,i) - hom(k+1,1,41,sr) )
@@ -922,5 +917,5 @@
 
        ENDIF
-       IF ( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR. sr /= 0 )  THEN
+       IF ( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
          !$OMP DO
          DO  i = nxl, nxr
@@ -1533,6 +1528,5 @@
         ONLY :  average_count_pr, cloud_droplets, cloud_physics, do_sum,       &
                 dt_3d, g, humidity, icloud_scheme, kappa, large_scale_forcing, &
-                large_scale_subsidence, max_pr_user, message_string,           &
-                monotonic_adjustment, ocean,                                   &
+                large_scale_subsidence, max_pr_user, message_string, ocean,    &
                 passive_scalar, precipitation, simulated_time,                 &
                 use_subsidence_tendencies, use_surface_fluxes, use_top_fluxes, &
@@ -1672,5 +1666,5 @@
        ENDIF
 
-       IF ( ws_scheme_sca .AND. .NOT. monotonic_adjustment .AND. sr == 0 )  THEN
+       IF ( ws_scheme_sca .AND. sr == 0 )  THEN
 
           DO  i = 0, threads_per_task-1
@@ -2495,5 +2489,5 @@
        IF ( ocean )  THEN
 
-          IF( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR. sr /= 0 )  THEN
+          IF( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
 
              !$acc parallel loop gang present( hom, rflags_invers, rmask, sa, sums_l, w ) create( s1 )
@@ -2637,5 +2631,5 @@
           ELSE
 
-             IF( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR.  sr /= 0 )  THEN
+             IF( .NOT. ws_scheme_sca  .OR.  sr /= 0 )  THEN
 
                 !$acc parallel loop gang present( hom, rflags_invers, rmask, sums_l, vpt, w ) create( s1 )
@@ -2669,6 +2663,5 @@
 !
 !--    Passive scalar flux
-       IF ( passive_scalar  .AND.  ( .NOT. ws_scheme_sca .OR. monotonic_adjustment &
-                                     .OR.  sr /= 0 ) )  THEN
+       IF ( passive_scalar  .AND.  ( .NOT. ws_scheme_sca  .OR.  sr /= 0 ) )  THEN
 
           !$acc parallel loop gang present( hom, q, rflags_invers, rmask, sums_l, w ) create( s1 )
@@ -2724,5 +2717,5 @@
        ENDIF
 
-       IF ( .NOT. ws_scheme_sca .OR. monotonic_adjustment .OR.  sr /= 0 )  THEN
+       IF ( .NOT. ws_scheme_sca  .OR.  sr /= 0 )  THEN
 
           !$OMP DO
