Index: /palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- /palm/trunk/SOURCE/advec_ws.f90	(revision 742)
+++ /palm/trunk/SOURCE/advec_ws.f90	(revision 743)
@@ -4,4 +4,7 @@
 ! Current revisions:
 ! ------------------
+! Evaluation of turbulent fluxes with WS-scheme only for the whole model 
+! domain. Therefor dimension of arrays needed for statistical evaluation 
+! decreased.
 !
 ! Former revisions:
@@ -130,9 +133,7 @@
        IF ( ws_scheme_mom )  THEN
 
-          ALLOCATE( sums_wsus_ws_l(nzb:nzt+1,0:statistic_regions),  &
-                    sums_wsvs_ws_l(nzb:nzt+1,0:statistic_regions),  &
-                    sums_us2_ws_l(nzb:nzt+1,0:statistic_regions),   &
-                    sums_vs2_ws_l(nzb:nzt+1,0:statistic_regions),   &
-                    sums_ws2_ws_l(nzb:nzt+1,0:statistic_regions))
+          ALLOCATE( sums_wsus_ws_l(nzb:nzt+1), sums_wsvs_ws_l(nzb:nzt+1),  &
+                    sums_us2_ws_l(nzb:nzt+1),  sums_vs2_ws_l(nzb:nzt+1),   &
+                    sums_ws2_ws_l(nzb:nzt+1) )
 
           sums_wsus_ws_l = 0.0
@@ -146,14 +147,14 @@
        IF ( ws_scheme_sca )  THEN
 
-          ALLOCATE( sums_wspts_ws_l(nzb:nzt+1,0:statistic_regions) )
+          ALLOCATE( sums_wspts_ws_l(nzb:nzt+1) )
           sums_wspts_ws_l = 0.0
 
           IF ( humidity .OR. passive_scalar )  THEN
-             ALLOCATE( sums_wsqs_ws_l(nzb:nzt+1,0:statistic_regions) )
+             ALLOCATE( sums_wsqs_ws_l(nzb:nzt+1) )
              sums_wsqs_ws_l = 0.0
           ENDIF
 
           IF ( ocean )  THEN
-             ALLOCATE( sums_wssas_ws_l(nzb:nzt+1,0:statistic_regions) )
+             ALLOCATE( sums_wssas_ws_l(nzb:nzt+1) )
              sums_wssas_ws_l = 0.0
           ENDIF
@@ -640,8 +641,7 @@
 
              DO  k = nzb_s_inner(j,i), nzt
-                sums_wspts_ws_l(k,:) = sums_wspts_ws_l(k,:) +                  &
+                sums_wspts_ws_l(k) = sums_wspts_ws_l(k) +                      &
                                        ( flux_t(k) + diss_t(k) )               &
-                                 * weight_substep(intermediate_timestep_count) &
-                                       * rmask(j,i,:)
+                                 * weight_substep(intermediate_timestep_count)
              ENDDO
              
@@ -649,8 +649,7 @@
 
              DO  k = nzb_s_inner(j,i), nzt
-                sums_wssas_ws_l(k,:) = sums_wssas_ws_l(k,:) +                  &
+                sums_wssas_ws_l(k) = sums_wssas_ws_l(k) +                      &
                                        ( flux_t(k) + diss_t(k) )               &
-                                 * weight_substep(intermediate_timestep_count) &
-                                       * rmask(j,i,:)
+                                 * weight_substep(intermediate_timestep_count)
              ENDDO
              
@@ -658,8 +657,7 @@
 
              DO  k = nzb_s_inner(j,i), nzt
-                sums_wsqs_ws_l(k,:)  = sums_wsqs_ws_l(k,:) +                   &
+                sums_wsqs_ws_l(k)  = sums_wsqs_ws_l(k) +                       &
                                       ( flux_t(k) + diss_t(k) )                &
-                                 * weight_substep(intermediate_timestep_count) &
-                                      * rmask(j,i,:)
+                                 * weight_substep(intermediate_timestep_count)
              ENDDO
 
@@ -905,14 +903,14 @@
 !--        Statistical Evaluation of u'u'. The factor has to be applied for 
 !--        right evaluation when gallilei_trans = .T. .
-           sums_us2_ws_l(k,:) = sums_us2_ws_l(k,:)                            &
+           sums_us2_ws_l(k) = sums_us2_ws_l(k)                                &
              + ( flux_r(k) *                                                  &
-               ( u_comp(k) - 2.0 * hom(k,1,1,:) )                             &
+               ( u_comp(k) - 2.0 * hom(k,1,1,0) )                             &
              / ( u_comp(k) - gu + 1.0E-20      )                              &
              +   diss_r(k) *                                                  &
-                 ABS( u_comp(k) - 2.0 * hom(k,1,1,:) )                        &
+                 ABS( u_comp(k) - 2.0 * hom(k,1,1,0) )                        &
              / ( ABS( u_comp(k) - gu ) + 1.0E-20 ) )                          &
-             *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+             *   weight_substep(intermediate_timestep_count)
        ENDDO 
-       sums_us2_ws_l(nzb_u_inner(j,i),:) = sums_us2_ws_l(nzb_u_inner(j,i)+1,:)
+       sums_us2_ws_l(nzb_u_inner(j,i)) = sums_us2_ws_l(nzb_u_inner(j,i)+1)
                                            
 
@@ -1000,7 +998,7 @@
 !--    sum up the vertical momentum fluxes
        DO  k = nzb_u_inner(j,i), nzt
-          sums_wsus_ws_l(k,:) = sums_wsus_ws_l(k,:)                           &
+          sums_wsus_ws_l(k) = sums_wsus_ws_l(k)                               &
               + ( flux_t(k) + diss_t(k) )                                     &
-              *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+              *   weight_substep(intermediate_timestep_count)
        ENDDO
 
@@ -1243,15 +1241,15 @@
 !--        right evaluation when gallilei_trans = .T. .
 
-           sums_vs2_ws_l(k,:) = sums_vs2_ws_l(k,:)                            &
+           sums_vs2_ws_l(k) = sums_vs2_ws_l(k)                                &
              + ( flux_n(k)                                                    &
-             * ( v_comp(k) - 2.0 * hom(k,1,2,:) )                             &
+             * ( v_comp(k) - 2.0 * hom(k,1,2,0) )                             &
              / ( v_comp(k) - gv + 1.0E-20 )                                   &
              +   diss_n(k)                                                    &
-             *   ABS( v_comp(k) - 2.0 * hom(k,1,2,:) )                        &
+             *   ABS( v_comp(k) - 2.0 * hom(k,1,2,0) )                        &
              / ( ABS( v_comp(k) - gv ) +1.0E-20 ) )                           &
-             *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+             *   weight_substep(intermediate_timestep_count)
 
        ENDDO
-       sums_vs2_ws_l(nzb_v_inner(j,i),:) = sums_vs2_ws_l(nzb_v_inner(j,i)+1,:)  
+       sums_vs2_ws_l(nzb_v_inner(j,i)) = sums_vs2_ws_l(nzb_v_inner(j,i)+1)  
                                            
 !
@@ -1335,7 +1333,7 @@
               
        DO  k = nzb_v_inner(j,i), nzt
-          sums_wsvs_ws_l(k,:) = sums_wsvs_ws_l(k,:)                           &
+          sums_wsvs_ws_l(k) = sums_wsvs_ws_l(k)                               &
                  + ( flux_t(k) + diss_t(k) )                                  &
-                 *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+                 *   weight_substep(intermediate_timestep_count) 
        ENDDO
 
@@ -1667,7 +1665,7 @@
        
        DO  k = nzb_w_inner(j,i), nzt
-           sums_ws2_ws_l(k,:)  = sums_ws2_ws_l(k,:)                           &
+           sums_ws2_ws_l(k)  = sums_ws2_ws_l(k)                               &
                  + ( flux_t(k) + diss_t(k) )                                  &
-                 *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+                 *   weight_substep(intermediate_timestep_count)
        ENDDO
 
@@ -2039,22 +2037,19 @@
                CASE ( 'pt' )
                  DO  k = nzb_s_inner(j,i), nzt
-                   sums_wspts_ws_l(k,:) = sums_wspts_ws_l(k,:)                &
+                   sums_wspts_ws_l(k) = sums_wspts_ws_l(k)                    &
                       + ( flux_t(k) + diss_t(k) )                             &
-                      *   weight_substep(intermediate_timestep_count)         &
-                      *   rmask(j,i,:)
+                      *   weight_substep(intermediate_timestep_count)
                  ENDDO
                CASE ( 'sa' )
                  DO  k = nzb_s_inner(j,i), nzt
-                   sums_wssas_ws_l(k,:) = sums_wssas_ws_l(k,:)                &
+                   sums_wssas_ws_l(k) = sums_wssas_ws_l(k)                    &
                       + ( flux_t(k) + diss_t(k) )                             &
-                      *   weight_substep(intermediate_timestep_count)         &
-                      *   rmask(j,i,:)
+                      *   weight_substep(intermediate_timestep_count)
                  ENDDO
                CASE ( 'q' )
                  DO  k = nzb_s_inner(j,i), nzt
-                   sums_wsqs_ws_l(k,:) = sums_wsqs_ws_l(k,:)                  &
+                   sums_wsqs_ws_l(k) = sums_wsqs_ws_l(k)                      &
                       + ( flux_t(k) + diss_t(k) )                             &
-                      *   weight_substep(intermediate_timestep_count)         &
-                      *   rmask(j,i,:)
+                      *   weight_substep(intermediate_timestep_count)
                  ENDDO
 
@@ -2335,15 +2330,14 @@
                swap_diss_y_local_u(k)   = diss_n(k)
                       
-               sums_us2_ws_l(k,:)  = sums_us2_ws_l(k,:)                        &
+               sums_us2_ws_l(k)  = sums_us2_ws_l(k)                            &
                  + ( flux_r(k)                                                 &
-                 * ( u_comp(k) - 2.0 * hom(k,1,1,:) )                          &
+                 * ( u_comp(k) - 2.0 * hom(k,1,1,0) )                          &
                  / ( u_comp(k) - gu + 1.0E-20 )                                & 
                  +   diss_r(k)                                                 &
-                 *   ABS( u_comp(k) - 2.0 * hom(k,1,1,:) )                     &
+                 *   ABS( u_comp(k) - 2.0 * hom(k,1,1,0) )                     &
                  / ( ABS( u_comp(k) - gu) + 1.0E-20) )                         &
-                 *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+                 *   weight_substep(intermediate_timestep_count)
             ENDDO
-            sums_us2_ws_l(nzb_u_inner(j,i),:) =                                &
-                                           sums_us2_ws_l(nzb_u_inner(j,i)+1,:)
+            sums_us2_ws_l(nzb_u_inner(j,i)) = sums_us2_ws_l(nzb_u_inner(j,i)+1)
          ENDDO
        ENDDO
@@ -2438,8 +2432,7 @@
 !-- at last vertical momentum flux is accumulated
             DO  k = nzb_u_inner(j,i), nzt
-               sums_wsus_ws_l(k,:) = sums_wsus_ws_l(k,:)                       &
+               sums_wsus_ws_l(k) = sums_wsus_ws_l(k)                           &
                               + ( flux_t(k) + diss_t(k) )                      &
-                              *   weight_substep(intermediate_timestep_count)  &
-                              *   rmask(j,i,:)
+                              *   weight_substep(intermediate_timestep_count)
             ENDDO
           ENDDO
@@ -2716,13 +2709,12 @@
                swap_diss_y_local_v(k)   = diss_n(k)   
 
-               sums_vs2_ws_l(k,:) = sums_vs2_ws_l(k,:)                         &
-                  + ( flux_n(k) * ( v_comp(k) - 2.0 * hom(k,1,2,:) )           &
+               sums_vs2_ws_l(k) = sums_vs2_ws_l(k)                             &
+                  + ( flux_n(k) * ( v_comp(k) - 2.0 * hom(k,1,2,0) )           &
                   / ( v_comp(k) - gv + 1.0E-20 )                               &
-                  +   diss_n(k) * ABS( v_comp(k) - 2.0 * hom(k,1,2,:) )        &
+                  +   diss_n(k) * ABS( v_comp(k) - 2.0 * hom(k,1,2,0) )        &
                   / ( ABS( v_comp(k) - gv ) + 1.0E-20 ) )                      &
-                  *   weight_substep(intermediate_timestep_count) * rmask(j,i,:)
+                  *   weight_substep(intermediate_timestep_count)
             ENDDO
-            sums_vs2_ws_l(nzb_v_inner(j,i),:) =                                &  
-                                           sums_vs2_ws_l(nzb_v_inner(j,i)+1,:)
+            sums_vs2_ws_l(nzb_v_inner(j,i)) = sums_vs2_ws_l(nzb_v_inner(j,i)+1)
          ENDDO
        ENDDO
@@ -2814,11 +2806,9 @@
 !-          At last vertical momentum flux is accumulated.
             DO  k = nzb_v_inner(j,i), nzt
-               sums_wsvs_ws_l(k,:) = sums_wsvs_ws_l(k,:)                       &
+               sums_wsvs_ws_l(k) = sums_wsvs_ws_l(k)                           &
                                + ( flux_t(k) + diss_t(k) )                     &
-                               *   weight_substep(intermediate_timestep_count) &
-                               *   rmask(j,i,:)
+                               *   weight_substep(intermediate_timestep_count)
             ENDDO
-            sums_vs2_ws_l(nzb_v_inner(j,i),:) =                                &
-                                             sums_vs2_ws_l(nzb_v_inner(j,i)+1,:)
+            sums_vs2_ws_l(nzb_v_inner(j,i)) = sums_vs2_ws_l(nzb_v_inner(j,i)+1)
           ENDDO
        ENDDO
@@ -3192,8 +3182,7 @@
 !--         at last vertical momentum flux is accumulated
             DO  k = nzb_w_inner(j,i), nzt
-               sums_ws2_ws_l(k,:)  = sums_ws2_ws_l(k,:)                        &
+               sums_ws2_ws_l(k)  = sums_ws2_ws_l(k)                            &
                                + ( flux_t(k) + diss_t(k) )                     &
-                               *   weight_substep(intermediate_timestep_count) &
-                               *   rmask(j,i,:)
+                               *   weight_substep(intermediate_timestep_count)
             ENDDO
 
Index: /palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/flow_statistics.f90	(revision 742)
+++ /palm/trunk/SOURCE/flow_statistics.f90	(revision 743)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Calculation of turbulent fluxes with WS-scheme only for the whole model
+! domain, not for user-defined subregions. 
 !
 ! Former revisions:
@@ -168,5 +169,5 @@
 !--    Copy the turbulent quantities, evaluated in the advection routines to 
 !--    the local array sums_l() for further computations
-       IF ( ws_scheme_mom )  THEN
+       IF ( ws_scheme_mom .AND. sr == 0 )  THEN
 
 !       
@@ -174,6 +175,6 @@
 !--       the corresponding fluxes has to satisfiy the same bc.
           IF ( ocean )  THEN
-             sums_us2_ws_l(nzt+1,sr) = sums_us2_ws_l(nzt,sr)
-             sums_vs2_ws_l(nzt+1,sr) = sums_vs2_ws_l(nzt,sr)    
+             sums_us2_ws_l(nzt+1) = sums_us2_ws_l(nzt)
+             sums_vs2_ws_l(nzt+1) = sums_vs2_ws_l(nzt)    
           ENDIF
 
@@ -181,17 +182,17 @@
 !          
 !--          Swap the turbulent quantities evaluated in advec_ws.
-             sums_l(:,13,i) = sums_wsus_ws_l(:,sr)       ! w*u* 
-             sums_l(:,15,i) = sums_wsvs_ws_l(:,sr)       ! w*v* 
-             sums_l(:,30,i) = sums_us2_ws_l(:,sr)        ! u*2 
-             sums_l(:,31,i) = sums_vs2_ws_l(:,sr)        ! v*2 
-             sums_l(:,32,i) = sums_ws2_ws_l(:,sr)        ! w*2 
+             sums_l(:,13,i) = sums_wsus_ws_l(:)       ! w*u* 
+             sums_l(:,15,i) = sums_wsvs_ws_l(:)       ! w*v* 
+             sums_l(:,30,i) = sums_us2_ws_l(:)        ! u*2 
+             sums_l(:,31,i) = sums_vs2_ws_l(:)        ! v*2 
+             sums_l(:,32,i) = sums_ws2_ws_l(:)        ! w*2 
              sums_l(:,34,i) = sums_l(:,34,i) + 0.5 *                        & 
-                              ( sums_us2_ws_l(:,sr) + sums_vs2_ws_l(:,sr) + &
-                                sums_ws2_ws_l(:,sr) )    ! e*
+                              ( sums_us2_ws_l(:) + sums_vs2_ws_l(:) +       &
+                                sums_ws2_ws_l(:) )    ! e*
              DO  k = nzb, nzt
                 sums_l(nzb+5,pr_palm,i) = sums_l(nzb+5,pr_palm,i) + 0.5 * (  &
-                                                      sums_us2_ws_l(k,sr) +  &
-                                                      sums_vs2_ws_l(k,sr) +  &
-                                                      sums_ws2_ws_l(k,sr) )
+                                                      sums_us2_ws_l(k) +     &
+                                                      sums_vs2_ws_l(k) +     &
+                                                      sums_ws2_ws_l(k) )
              ENDDO
           ENDDO
@@ -199,11 +200,11 @@
        ENDIF
 
-       IF ( ws_scheme_sca )  THEN
+       IF ( ws_scheme_sca .AND. sr == 0 )  THEN
 
           DO  i = 0, threads_per_task-1
-             sums_l(:,17,i) = sums_wspts_ws_l(:,sr)      ! w*pt* from advec_s_ws
-             IF ( ocean ) sums_l(:,66,i) = sums_wssas_ws_l(:,sr) ! w*sa*
+             sums_l(:,17,i) = sums_wspts_ws_l(:)      ! w*pt* from advec_s_ws
+             IF ( ocean ) sums_l(:,66,i) = sums_wssas_ws_l(:) ! w*sa*
              IF ( humidity .OR. passive_scalar ) sums_l(:,49,i) =              &
-                                                   sums_wsqs_ws_l(:,sr) !w*q*
+                                                   sums_wsqs_ws_l(:) !w*q*
           ENDDO
 
@@ -483,5 +484,5 @@
 !--    Computation of statistics when ws-scheme is not used. Else these 
 !--    quantities are evaluated in the advection routines.
-       IF ( .NOT. ws_scheme_mom )  THEN
+       IF ( .NOT. ws_scheme_mom .OR. sr /= 0 )  THEN
           !$OMP DO
           DO  i = nxl, nxr
@@ -692,5 +693,5 @@
 !--             but so far there is no other suitable place to calculate)
                 IF ( ocean )  THEN
-                   IF( .NOT. ws_scheme_sca )  THEN
+                   IF( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
                       pts = 0.5 * ( sa(k,j,i)   - hom(k,1,23,sr) + &
                                  sa(k+1,j,i) - hom(k+1,1,23,sr) )
@@ -726,5 +727,6 @@
 !
 !--             Passive scalar flux
-                IF ( passive_scalar .AND. ( .NOT. ws_scheme_sca ))  THEN
+                IF ( passive_scalar .AND. ( .NOT. ws_scheme_sca   &
+                     .OR. sr /= 0 ) )  THEN
                    pts = 0.5 * ( q(k,j,i)   - hom(k,1,41,sr) + &
                                  q(k+1,j,i) - hom(k+1,1,41,sr) )
@@ -746,5 +748,5 @@
 !--    inside the WS advection routines are treated seperatly
 !--    Momentum fluxes first:
-       IF ( .NOT. ws_scheme_mom )  THEN
+       IF ( .NOT. ws_scheme_mom .OR. sr /= 0  )  THEN
          !$OMP DO
          DO  i = nxl, nxr
@@ -770,5 +772,5 @@
 
        ENDIF
-       IF ( .NOT. ws_scheme_sca )  THEN
+       IF ( .NOT. ws_scheme_sca .OR. sr /= 0 )  THEN
          !$OMP DO
          DO  i = nxl, nxr
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 742)
+++ /palm/trunk/SOURCE/modules.f90	(revision 743)
@@ -5,4 +5,7 @@
 ! Current revisions:
 ! -----------------
+! Dimension of sums_wsus_ws_l, sums_wsvs_ws_l, sums_us2_ws_l, sums_vs2_ws_l, 
+! sums_ws2_ws_l, sums_wspts_ws_l, sums_wssas_ws_l,sums_wsqs_ws_l needed for 
+! statistical evaluation of turbulent fluxes in WS-scheme decreased.
 !
 ! Former revisions:
@@ -1406,12 +1409,12 @@
     LOGICAL ::  flow_statistics_called = .FALSE.
     REAL ::     u_max, v_max, w_max
-    REAL, DIMENSION(:), ALLOCATABLE       ::  sums_divnew_l, sums_divold_l, &
+    REAL, DIMENSION(:), ALLOCATABLE       ::  sums_divnew_l, sums_divold_l,   &
+                                              sums_wsus_ws_l, sums_wsvs_ws_l, &
+                                              sums_us2_ws_l, sums_vs2_ws_l,   &
+                                              sums_ws2_ws_l,                  &
+                                              sums_wspts_ws_l,                &
+                                              sums_wssas_ws_l,sums_wsqs_ws_l, &                 
                                               weight_substep, weight_pres
-    REAL, DIMENSION(:,:), ALLOCATABLE     ::  sums, sums_wsts_bc_l,        &
-                                              sums_wsus_ws_l, sums_wsvs_ws_l,&
-                                              sums_us2_ws_l, sums_vs2_ws_l, &
-                                              sums_ws2_ws_l,                 &
-                                              sums_wspts_ws_l, sums_wssas_ws_l, &
-                                              sums_wsqs_ws_l, ts_value
+    REAL, DIMENSION(:,:), ALLOCATABLE     ::  sums, sums_wsts_bc_l, ts_value
     REAL, DIMENSION(:,:,:), ALLOCATABLE   ::  hom_sum, rmask, spectrum_x, &
                                               spectrum_y, sums_l, sums_l_l, &
