Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 3870)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 3871)
@@ -267,8 +267,48 @@
 !> the divergence is not sufficiently reduced, resulting in erroneous fluxes 
 !> and could lead to numerical instabilities. 
-!-----------------------------------------------------------------------------!
+!------------------------------------------------------------------------------!
  MODULE advec_ws
 
+    USE arrays_3d,                                                             &
+        ONLY:  ddzu, ddzw, tend, u, v, w,                                      &
+               drho_air, drho_air_zw, rho_air, rho_air_zw,                     &
+               u_stokes_zu, v_stokes_zu,                                       &
+               diss_l_diss, diss_l_e, diss_l_pt, diss_l_q,                     &
+               diss_l_s, diss_l_sa, diss_l_u, diss_l_v, diss_l_w,              &
+               flux_l_diss, flux_l_e, flux_l_pt, flux_l_q, flux_l_s,           &
+               flux_l_sa, flux_l_u, flux_l_v, flux_l_w,                        &
+               diss_s_diss, diss_s_e, diss_s_pt, diss_s_q, diss_s_s,           &
+               diss_s_sa, diss_s_u, diss_s_v, diss_s_w,                        &
+               flux_s_diss, flux_s_e, flux_s_pt, flux_s_q, flux_s_s,           &
+               flux_s_sa, flux_s_u, flux_s_v, flux_s_w
+
+    USE control_parameters,                                                    &
+        ONLY:  humidity, loop_optimization, passive_scalar, ocean_mode,        &
+               rans_tke_e, ws_scheme_mom, ws_scheme_sca,                       &
+               momentum_advec, scalar_advec,                                   &
+               bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,                 &
+               bc_dirichlet_s, bc_radiation_l, bc_radiation_n,                 &
+               bc_radiation_r, bc_radiation_s, intermediate_timestep_count,    &
+               u_gtrans, v_gtrans
+
+    USE indices,                                                               &
+        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
+               nzb, nzb_max, nzt, advc_flags_1, advc_flags_2, wall_flags_0
+
+    USE grid_variables,                                                        &
+        ONLY:  ddx, ddy
+
+    USE pegrid,                                                                &
+           ONLY:  threads_per_task
+
     USE kinds
+
+    USE statistics,                                                            &
+        ONLY:  sums_salsa_ws_l, sums_us2_ws_l, sums_vs2_ws_l, sums_ws2_ws_l,   &
+               sums_wspts_ws_l, sums_wsqs_ws_l, sums_wsss_ws_l,                &
+               sums_wssas_ws_l, sums_wsus_ws_l, sums_wsvs_ws_l,                &
+               sums_wsqcs_ws_l, sums_wsqrs_ws_l,                               &
+               sums_wsncs_ws_l, sums_wsnrs_ws_l,                               &
+               hom, weight_substep
 
     IMPLICIT NONE
@@ -326,39 +366,4 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE ws_init
-
-       USE arrays_3d,                                                          &
-           ONLY:  diss_l_diss, diss_l_e, diss_l_pt,      &
-                  diss_l_q, diss_l_s, diss_l_sa,         &
-                  diss_l_u, diss_l_v, diss_l_w, flux_l_diss, flux_l_e,         & 
-                  flux_l_pt, flux_l_q,      &
-                  flux_l_s, flux_l_sa, flux_l_u, flux_l_v,          &
-                  flux_l_w, diss_s_diss, diss_s_e,      &
-                  diss_s_pt, diss_s_q, diss_s_s,         &
-                  diss_s_sa, diss_s_u, diss_s_v,  diss_s_w, flux_s_diss,       &
-                  flux_s_e, flux_s_pt, flux_s_q,         &
-                  flux_s_s, flux_s_sa, flux_s_u,         &
-                  flux_s_v, flux_s_w
-
-       USE control_parameters,                                                 &
-           ONLY:  humidity, loop_optimization, passive_scalar, ocean_mode,     &
-                  rans_tke_e, ws_scheme_mom, ws_scheme_sca, salsa
-
-       USE indices,                                                            &
-           ONLY:  nyn, nys, nzb, nzt
-
-       USE kinds
-
-       USE pegrid
-
-       USE salsa_util_mod,                                                     &
-           ONLY:  sums_salsa_ws_l
-
-       USE statistics,                                                         &
-           ONLY:  sums_us2_ws_l, sums_vs2_ws_l, sums_ws2_ws_l,&
-                  sums_wspts_ws_l,            &
-                  sums_wsqs_ws_l, sums_wsss_ws_l,             &
-                  sums_wssas_ws_l,  sums_wsss_ws_l, sums_wsus_ws_l,            &
-                  sums_wsvs_ws_l
-
 
 !
@@ -406,9 +411,4 @@
              ALLOCATE( sums_wssas_ws_l(nzb:nzt+1,0:threads_per_task-1) )
              sums_wssas_ws_l = 0.0_wp
-          ENDIF        
-
-          IF ( salsa )  THEN
-             ALLOCATE( sums_salsa_ws_l(nzb:nzt+1,0:threads_per_task-1) )
-             sums_salsa_ws_l = 0.0_wp
           ENDIF
 
@@ -492,16 +492,4 @@
     SUBROUTINE ws_init_flags
 
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, momentum_advec, scalar_advec
-
-       USE indices,                                                            &
-           ONLY:  advc_flags_1, advc_flags_2, nbgp, nxl, nxlg, nxlu, nxr, nxrg,&
-                  nyn, nyng, nys, nysg, nysv, nzb, nzt, wall_flags_0
-
-       USE kinds
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i     !< index variable along x
@@ -1099,24 +1087,7 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE ws_statistics
-    
-       USE control_parameters,                                                 &
-           ONLY:  humidity, passive_scalar, ocean_mode, ws_scheme_mom,         &
-                  ws_scheme_sca, salsa
-
-       USE kinds
-
-       USE salsa_util_mod,                                                     &
-           ONLY:  sums_salsa_ws_l
-
-       USE statistics,                                                         &
-           ONLY:  sums_us2_ws_l, sums_vs2_ws_l, sums_ws2_ws_l, &
-                  sums_wspts_ws_l,           &
-                  sums_wsqs_ws_l, sums_wsss_ws_l,             &
-                  sums_wssas_ws_l, sums_wsus_ws_l, sums_wsvs_ws_l
-                   
-
-       IMPLICIT NONE
-
-!       
+
+
+!
 !--    The arrays needed for statistical evaluation are set to to 0 at the 
 !--    beginning of prognostic_equations.
@@ -1139,5 +1110,4 @@
           IF ( passive_scalar )  sums_wsss_ws_l = 0.0_wp
           IF ( ocean_mode )  sums_wssas_ws_l = 0.0_wp
-          IF ( salsa )       sums_salsa_ws_l = 0.0_wp
 
        ENDIF
@@ -1155,35 +1125,4 @@
                               swap_diss_x_local, i_omp, tn )
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, drho_air, rho_air_zw, tend, u, u_stokes_zu, v,         &
-                  v_stokes_zu, w
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans 
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_max,    &
-                  nzt, advc_flags_1
-
-       USE kinds
-
-       USE pegrid
-
-       USE salsa_util_mod,                                                     &
-           ONLY:  sums_salsa_ws_l
-
-       USE statistics,                                                         &
-           ONLY:  hom, sums_wsncs_ws_l, sums_wsnrs_ws_l, sums_wspts_ws_l,      &
-                  sums_wsqcs_ws_l,  sums_wsqrs_ws_l, sums_wsqs_ws_l,           &
-                  sums_wssas_ws_l, sums_wsss_ws_l, weight_substep
-                  
-
-       IMPLICIT NONE
 
        CHARACTER (LEN = *), INTENT(IN) ::  sk_char !< string identifier, used for assign fluxes to the correct dimension in the analysis array 
@@ -1821,26 +1760,4 @@
     SUBROUTINE advec_u_ws_ij( i, j, i_omp, tn )
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, diss_l_u, diss_s_u, flux_l_u, flux_s_u, tend, u, v, w, &
-                  drho_air, rho_air_zw
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nyn, nys, nxl, nxlu, nxr, nzb, nzb_max, nzt, advc_flags_1
-
-       USE kinds
-
-       USE statistics,                                                         &
-           ONLY:  hom, sums_us2_ws_l, sums_wsus_ws_l, weight_substep
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i         !< grid index along x-direction
@@ -2396,26 +2313,4 @@
    SUBROUTINE advec_v_ws_ij( i, j, i_omp, tn )
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, diss_l_v, diss_s_v, flux_l_v, flux_s_v, tend, u, v, w, &
-                  drho_air, rho_air_zw
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nyn, nys, nysv, nxl, nxr, nzb, nzb_max, nzt, advc_flags_1
-
-       USE kinds
-
-       USE statistics,                                                         &
-           ONLY:  hom, sums_vs2_ws_l, sums_wsvs_ws_l, weight_substep
-
-       IMPLICIT NONE
 
        INTEGER(iwp)  ::  i         !< grid index along x-direction
@@ -2979,27 +2874,4 @@
     SUBROUTINE advec_w_ws_ij( i, j, i_omp, tn )
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzu, diss_l_w, diss_s_w, flux_l_w, flux_s_w, tend, u, v, w, &
-                  drho_air_zw, rho_air
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s,intermediate_timestep_count,  &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nyn, nys, nxl, nxr, nzb, nzb_max, nzt, advc_flags_1,         &
-                  advc_flags_2
-
-       USE kinds
-       
-       USE statistics,                                                         &
-           ONLY:  hom, sums_ws2_ws_l, weight_substep
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i         !< grid index along x-direction
@@ -3535,34 +3407,4 @@
     SUBROUTINE advec_s_ws( sk, sk_char )
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, drho_air, rho_air_zw, tend, u, u_stokes_zu, v,         &
-                  v_stokes_zu, w
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans 
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_max,    &
-                  nzt, advc_flags_1
-
-       USE kinds
-
-       USE salsa_util_mod,                                                     &
-           ONLY:  sums_salsa_ws_l
-
-       USE statistics,                                                         &
-           ONLY:  hom, sums_wspts_ws_l, sums_wsqs_ws_l, sums_wssas_ws_l,       &
-                  sums_wsqcs_ws_l, sums_wsqrs_ws_l, sums_wsncs_ws_l,           &
-                  sums_wsnrs_ws_l, sums_wsss_ws_l, weight_substep  
-
-
-
-       IMPLICIT NONE
 
        CHARACTER (LEN = *), INTENT(IN)    ::  sk_char !< string identifier, used for assign fluxes to the correct dimension in the analysis array 
@@ -4411,25 +4253,4 @@
     SUBROUTINE advec_u_ws
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, drho_air, tend, u, v, w, rho_air_zw
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nxlu, nxr, nyn, nys, nzb, nzb_max, nzt, advc_flags_1
-           
-       USE kinds
-       
-       USE statistics,                                                         &
-           ONLY:  hom, sums_us2_ws_l, sums_wsus_ws_l, weight_substep
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i         !< grid index along x-direction
@@ -5091,26 +4912,4 @@
     SUBROUTINE advec_v_ws
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzw, drho_air, tend, u, v, w, rho_air_zw
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys, nysv, nzb, nzb_max, nzt, advc_flags_1
-
-       USE kinds
-
-       USE statistics,                                                         &
-           ONLY:  hom, sums_vs2_ws_l, sums_wsvs_ws_l, weight_substep
-
-       IMPLICIT NONE
-
 
        INTEGER(iwp) ::  i         !< grid index along x-direction
@@ -5777,26 +5576,4 @@
     SUBROUTINE advec_w_ws
 
-       USE arrays_3d,                                                          &
-           ONLY:  ddzu, drho_air_zw, tend, u, v, w, rho_air
-
-       USE control_parameters,                                                 &
-           ONLY:  bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,              &
-                  bc_dirichlet_s, bc_radiation_l, bc_radiation_n,              &
-                  bc_radiation_r, bc_radiation_s, intermediate_timestep_count, &
-                  u_gtrans, v_gtrans
-
-       USE grid_variables,                                                     &
-           ONLY:  ddx, ddy
-
-       USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys, nzb, nzb_max, nzt, advc_flags_1,         &
-                  advc_flags_2
-
-       USE kinds
-       
-       USE statistics,                                                         &
-           ONLY:  hom, sums_ws2_ws_l, weight_substep
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i         !< grid index along x-direction
