Index: palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- palm/trunk/SOURCE/flow_statistics.f90	(revision 1657)
+++ palm/trunk/SOURCE/flow_statistics.f90	(revision 1658)
@@ -21,5 +21,5 @@
 ! Current revisions:
 ! -----------------
-!
+! bugfix: reduction variables in the openacc branch are now initialzed to zero
 !
 ! Former revisions:
@@ -1781,4 +1781,7 @@
        !$acc parallel loop gang present( pt, rflags_invers, rmask, sums_l, u, v ) create( s1, s2, s3 )
        DO  k = nzb, nzt+1
+          s1 = 0
+          s2 = 0
+          s3 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3 )
           DO  i = nxl, nxr
@@ -1803,4 +1806,5 @@
           !$acc parallel loop gang present( rflags_invers, rmask, sums_l, sa ) create( s1 )
           DO  k = nzb, nzt+1
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -1823,4 +1827,6 @@
           !$acc parallel loop gang present( q, rflags_invers, rmask, sums_l, vpt ) create( s1, s2 )
           DO  k = nzb, nzt+1
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -1839,4 +1845,6 @@
              !$acc parallel loop gang present( pt, q, ql, rflags_invers, rmask, sums_l ) create( s1, s2 )
              DO  k = nzb, nzt+1
+                s1 = 0
+                s2 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
                 DO  i = nxl, nxr
@@ -1861,4 +1869,5 @@
           !$acc parallel loop gang present( q, rflags_invers, rmask, sums_l ) create( s1 )
           DO  k = nzb, nzt+1
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2048,4 +2057,11 @@
        !$acc parallel loop gang present( e, hom, kh, km, p, pt, w, rflags_invers, rmask, sums_l ) create( s1, s2, s3, s4, s5, s6, s7 )
        DO  k = nzb, nzt+1
+          s1 = 0
+          s2 = 0
+          s3 = 0
+          s4 = 0
+          s5 = 0
+          s6 = 0
+          s7 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3, s4, s5, s6, s7 )
           DO  i = nxl, nxr
@@ -2080,4 +2096,5 @@
           !$acc parallel loop gang present( hom, q, rflags_invers, rmask, sums_l ) create( s1 )
           DO  k = nzb, nzt+1
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2095,4 +2112,5 @@
 !--    Total and perturbation energy for the total domain (being
 !--    collected in the last column of sums_l).
+       s1 = 0
        !$OMP DO
        !$acc parallel loop collapse(3) present( rflags_invers, rmask, u, v, w ) reduction(+:s1)
@@ -2113,4 +2131,8 @@
        !$OMP DO
        !$acc parallel present( rmask, sums_l, us, usws, vsws, ts ) create( s1, s2, s3, s4 )
+       s1 = 0
+       s2 = 0
+       s3 = 0
+       s4 = 0
        !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3, s4 )
        DO  i = nxl, nxr
@@ -2132,4 +2154,5 @@
        IF ( humidity )  THEN
           !$acc parallel present( qs, rmask, sums_l ) create( s1 )
+          s1 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1 )
           DO  i = nxl, nxr
@@ -2150,4 +2173,8 @@
           !$acc parallel loop gang present( u, v, w, rflags_invers, rmask, sums_l ) create( s1, s2, s3, s4, ust2, vst2, w2 )
           DO  k = nzb, nzt+1
+             s1 = 0
+             s2 = 0
+             s3 = 0
+             s4 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3, s4 )
              DO  i = nxl, nxr
@@ -2176,4 +2203,5 @@
           !$OMP DO
           !$acc parallel present( sums_l ) create( s1 )
+          s1 = 0
           !$acc loop reduction( +: s1 )
           DO  k = nzb, nzt+1
@@ -2203,4 +2231,7 @@
        !$acc parallel loop gang present( ddzu, kh, km, pt, u, v, w, rflags_invers, rmask, sums_l ) create( s1, s2, s3 )
        DO  k = nzb, nzt_diff
+          s1 = 0
+          s2 = 0
+          s3 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3 )
           DO  i = nxl, nxr
@@ -2244,4 +2275,5 @@
           !$acc parallel loop gang present( ddzu, kh, sa, rflags_invers, rmask, sums_l ) create( s1 )
           DO  k = nzb, nzt_diff
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2264,4 +2296,6 @@
           !$acc parallel loop gang present( ddzu, kh, q, vpt, rflags_invers, rmask, sums_l ) create( s1, s2 )
           DO  k = nzb, nzt_diff
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -2286,4 +2320,5 @@
              !$acc parallel loop gang present( ddzu, kh, q, ql, rflags_invers, rmask, sums_l ) create( s1 )
              DO  k = nzb, nzt_diff
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2309,4 +2344,5 @@
           !$acc parallel loop gang present( ddzu, kh, q, rflags_invers, rmask, sums_l ) create( s1 )
           DO  k = nzb, nzt_diff
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2328,4 +2364,9 @@
           !$OMP DO
           !$acc parallel present( rmask, shf, sums_l, usws, vsws ) create( s1, s2, s3, s4, s5 )
+          s1 = 0
+          s2 = 0
+          s3 = 0
+          s4 = 0
+          s5 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3, s4, s5 )
           DO  i = nxl, nxr
@@ -2351,4 +2392,5 @@
              !$OMP DO
              !$acc parallel present( rmask, saswsb, sums_l ) create( s1 )
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2366,4 +2408,6 @@
              !$OMP DO
              !$acc parallel present( pt, q, qsws, rmask, shf, sums_l ) create( s1, s2 )
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -2382,4 +2426,5 @@
                 !$OMP DO
                 !$acc parallel present( pt, q, ql, qsws, rmask, shf, sums_l ) create( s1 )
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2399,4 +2444,5 @@
                 !$OMP DO
                 !$acc parallel present( qsws, rmask, sums_l ) create( s1 )
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2418,4 +2464,5 @@
              !$OMP DO
              !$acc parallel present( qsws, rmask, sums_l ) create( s1 )
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2437,4 +2484,9 @@
           !$OMP DO
           !$acc parallel present( rmask, sums_l, tswst, uswst, vswst ) create( s1, s2, s3, s4, s5 )
+          s1 = 0
+          s2 = 0
+          s3 = 0
+          s4 = 0
+          s5 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3, s4, s5 )
           DO  i = nxl, nxr
@@ -2458,4 +2510,5 @@
              !$OMP DO
              !$acc parallel present( rmask, saswst, sums_l ) create( s1 )
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2473,4 +2526,6 @@
              !$OMP DO
              !$acc parallel present( pt, q, qswst, rmask, tswst, sums_l ) create( s1, s2 )
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -2489,4 +2544,5 @@
                 !$OMP DO
                 !$acc parallel present( pt, q, ql, qswst, rmask, tswst, sums_l ) create( s1 )
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2507,4 +2563,5 @@
                 !$OMP DO
                 !$acc parallel present( qswst, rmask, sums_l ) create( s1 )
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2526,4 +2583,5 @@
              !$OMP DO
              !$acc parallel present( qswst, rmask, sums_l ) create( s1 )
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2546,4 +2604,7 @@
        !$acc parallel loop gang present( hom, pt, rflags_invers, rmask, sums_l, u, v, w ) create( s1, s2, s3 )
        DO  k = nzb, nzt_diff
+          s1 = 0
+          s2 = 0
+          s3 = 0
           !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3 )
           DO  i = nxl, nxr
@@ -2580,4 +2641,5 @@
              !$acc parallel loop gang present( hom, rflags_invers, rmask, sa, sums_l, w ) create( s1 )
              DO  k = nzb, nzt_diff
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2597,4 +2659,6 @@
           !$acc parallel loop gang present( rflags_invers, rho, prho, rmask, sums_l ) create( s1, s2 )
           DO  k = nzb, nzt_diff
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -2620,4 +2684,5 @@
              !$acc parallel loop gang present( hom, rflags_invers, rmask, sums_l, vpt, w ) create( s1 )
              DO  k = nzb, nzt_diff
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
@@ -2636,4 +2701,5 @@
                 !$acc parallel loop gang present( hom, q, ql, rflags_invers, rmask, sums_l, w ) create( s1 )
                 DO  k = nzb, nzt_diff
+                   s1 = 0
                    !$acc loop vector collapse( 2 ) reduction( +: s1 )
                    DO  i = nxl, nxr
@@ -2652,4 +2718,5 @@
                    !$acc parallel loop gang present( qc, ql, rflags_invers, rmask, sums_l ) create( s1, s2 )
                    DO  k = nzb, nzt_diff
+                      s1 = 0
                       !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
                       DO  i = nxl, nxr
@@ -2668,4 +2735,7 @@
                       !$acc parallel loop gang present( nr, qr, prr, rflags_invers, rmask, sums_l ) create( s1, s2, s3 )
                       DO  k = nzb, nzt_diff
+                         s1 = 0
+                         s2 = 0
+                         s3 = 0
                          !$acc loop vector collapse( 2 ) reduction( +: s1, s2, s3 )
                          DO  i = nxl, nxr
@@ -2688,4 +2758,5 @@
                    !$acc parallel loop gang present( ql, rflags_invers, rmask, sums_l ) create( s1 )
                    DO  k = nzb, nzt_diff
+                      s1 = 0
                       !$acc loop vector collapse( 2 ) reduction( +: s1 )
                       DO  i = nxl, nxr
@@ -2704,4 +2775,5 @@
                 !$acc parallel loop gang present( ql, rflags_invers, rmask, sums_l ) create( s1 )
                 DO  k = nzb, nzt_diff
+                   s1 = 0
                    !$acc loop vector collapse( 2 ) reduction( +: s1 )
                    DO  i = nxl, nxr
@@ -2722,4 +2794,5 @@
                 !$acc parallel loop gang present( hom, rflags_invers, rmask, sums_l, vpt, w ) create( s1 )
                 DO  k = nzb, nzt_diff
+                   s1 = 0
                    !$acc loop vector collapse( 2 ) reduction( +: s1 )
                    DO  i = nxl, nxr
@@ -2754,4 +2827,5 @@
           !$acc parallel loop gang present( hom, q, rflags_invers, rmask, sums_l, w ) create( s1 )
           DO  k = nzb, nzt_diff
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2778,4 +2852,6 @@
           !$acc parallel loop gang present( hom, rflags_invers, rmask, sums_l, u, v, w ) create( s1, s2 )
           DO  k = nzb, nzt_diff
+             s1 = 0
+             s2 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1, s2 )
              DO  i = nxl, nxr
@@ -2809,4 +2885,5 @@
           !$acc parallel loop gang present( hom, pt, rflags_invers, rmask, sums_l, w ) create( s1 )
           DO  k = nzb, nzt_diff
+             s1 = 0
              !$acc loop vector collapse( 2 ) reduction( +: s1 )
              DO  i = nxl, nxr
@@ -2828,4 +2905,5 @@
              !$acc parallel loop gang present( hom, q, rflags_invers, rmask, sums_l, w ) create( s1 )
              DO  k = nzb, nzt_diff
+                s1 = 0
                 !$acc loop vector collapse( 2 ) reduction( +: s1 )
                 DO  i = nxl, nxr
