Index: /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90
===================================================================
--- /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90	(revision 4559)
+++ /palm/trunk/SOURCE/diagnostic_output_quantities_mod.f90	(revision 4560)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! - Bugfix in calculation of vertical momentum and scalar fluxes
+! - remove averaged output variables from PUBLIC list
+! 
+! 4535 2020-05-15 12:07:23Z raasch
 ! bugfix for restart data format query
 ! 
@@ -208,15 +212,5 @@
            initialized_diagnostic_output_quantities,                           &
            prepared_diagnostic_output_quantities,                              &
-           timestep_number_at_prev_calc,                                       &
-           pt_2m_av,                                                           &
-           ti_av,                                                              &
-           u_center_av,                                                        &
-           uu_av,                                                              &
-           uv_10m_av,                                                          &
-           v_center_av,                                                        &
-           vv_av,                                                              &
-           wdir_av,                                                            &
-           wspeed_av,                                                          &
-           ww_av
+           timestep_number_at_prev_calc
 !
 !-- Public routines
@@ -765,37 +759,37 @@
        CASE ( 'ti', 'ti_xy', 'ti_xz', 'ti_yz',                                 &
               'wspeed', 'wspeed_xy', 'wspeed_xz', 'wspeed_yz',                 &
-              'wdir', 'wdir_xy', 'wdir_xz', 'wdir_yz',                         &
+              'wdir', 'wdir_xy', 'wdir_xz', 'wdir_yz' )
+
+          grid_x = 'x'
+          grid_y = 'y'
+          grid_z = 'zu'
+!
+!--    s grid surface variables
+       CASE ( 'theta_2m*_xy', 'wspeed_10m*' )
+
+          grid_x = 'x'
+          grid_y = 'y'
+          grid_z = 'zu'
+!
+!--    u grid
+       CASE ( 'uu', 'uu_xy', 'uu_xz', 'uu_yz' )
+
+          grid_x = 'xu'
+          grid_y = 'y'
+          grid_z = 'zu'
+!
+!--    v grid
+       CASE ( 'vv', 'vv_xy', 'vv_xz', 'vv_yz'  )
+
+          grid_x = 'x'
+          grid_y = 'yv'
+          grid_z = 'zu'
+!
+!--    w grid
+       CASE ( 'ww', 'ww_xy', 'ww_xz', 'ww_yz',                                 &
               'wu', 'wu_xy', 'wu_xz', 'wu_yz',                                 &
               'wv', 'wv_xy', 'wv_xz', 'wv_yz',                                 &
               'wtheta', 'wtheta_xy', 'wtheta_xz', 'wtheta_yz',                 &
-              'wq', 'wq_xy', 'wq_xz', 'wq_yz')
-
-          grid_x = 'x'
-          grid_y = 'y'
-          grid_z = 'zu'
-!
-!--    s grid surface variables
-       CASE ( 'theta_2m*_xy', 'wspeed_10m*' )
-
-          grid_x = 'x'
-          grid_y = 'y'
-          grid_z = 'zu'
-!
-!--    u grid
-       CASE ( 'uu', 'uu_xy', 'uu_xz', 'uu_yz' )
-
-          grid_x = 'xu'
-          grid_y = 'y'
-          grid_z = 'zu'
-!
-!--    v grid
-       CASE ( 'vv', 'vv_xy', 'vv_xz', 'vv_yz'  )
-
-          grid_x = 'x'
-          grid_y = 'yv'
-          grid_z = 'zu'
-!
-!--    w grid
-       CASE ( 'ww', 'ww_xy', 'ww_xz', 'ww_yz'  )
+              'wq', 'wq_xy', 'wq_xz', 'wq_yz'  )
 
           grid_x = 'x'
@@ -1645,5 +1639,7 @@
                 DO  j = nys, nyn
                    DO  k = nzb+1, nzt-1
-                      wu(k,j,i) = w(k,j,i) * u(k,j,i)                          &
+                      wu(k,j,i) = w(k,j,i)                                     &
+                       * 0.25_wp * ( u(k,j,i)   + u(k,j,i+1)                   &
+                                   + u(k+1,j,i) + u(k+1,j,i+1) )               &
                        * MERGE( 1.0_wp, 0.0_wp,                                &
                                 BTEST( wall_flags_total_0(k,j,i), 0) )
@@ -1657,5 +1653,7 @@
                 DO  j = nys, nyn
                    DO  k = nzb+1, nzt-1
-                      wv(k,j,i) = w(k,j,i) * v(k,j,i)                          &
+                      wv(k,j,i) = w(k,j,i)                                     &
+                       * 0.25_wp * ( v(k,j,i)   + v(k,j+1,i)                   &
+                                   + v(k+1,j,i) + v(k+1,j+1,i) )               &
                        * MERGE( 1.0_wp, 0.0_wp,                                &
                                 BTEST( wall_flags_total_0(k,j,i), 0) )
@@ -1669,7 +1667,8 @@
                 DO  j = nys, nyn
                    DO  k = nzb+1, nzt-1
-                      wtheta(k,j,i) = w(k,j,i) * pt(k,j,i)                     &
+                      wtheta(k,j,i) = w(k,j,i)                                 &
+                       *  0.5_wp  * ( pt(k,j,i) + pt(k+1,j,i) )                &
                        * MERGE( 1.0_wp, 0.0_wp,                                &
-                                BTEST( wall_flags_total_0(k,j,i), 0) )
+                                BTEST( wall_flags_total_0(k,j,i), 3) )
                    ENDDO
                 ENDDO
@@ -1681,7 +1680,7 @@
                 DO  j = nys, nyn
                    DO  k = nzb+1, nzt-1
-                      wq(k,j,i) = w(k,j,i) * q(k,j,i)                          &
+                      wq(k,j,i) = w(k,j,i) * 0.5_wp * ( q(k,j,i) + q(k+1,j,i) )&
                        * MERGE( 1.0_wp, 0.0_wp,                                &
-                                BTEST( wall_flags_total_0(k,j,i), 0) )
+                                BTEST( wall_flags_total_0(k,j,i), 3) )
                    ENDDO
                 ENDDO
