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
Index: palm/trunk/SOURCE/module_interface.f90
===================================================================
--- palm/trunk/SOURCE/module_interface.f90	(revision 3870)
+++ palm/trunk/SOURCE/module_interface.f90	(revision 3871)
@@ -285,4 +285,5 @@
                salsa_init,                                                     &
                salsa_header,                                                   &
+               salsa_actions,                                                  &
                salsa_prognostic_equations,                                     &
                salsa_swap_timelevel,                                           &
@@ -880,4 +881,5 @@
     IF ( bulk_cloud_model    )  CALL bcm_actions( location )
     IF ( gust_module_enabled )  CALL gust_actions( location )
+    IF ( salsa               )  CALL salsa_actions( location )
     IF ( user_module_enabled )  CALL user_actions( location )
 
@@ -901,4 +903,5 @@
     IF ( bulk_cloud_model    )  CALL bcm_actions( i, j, location )
     IF ( gust_module_enabled )  CALL gust_actions( i, j, location )
+    IF ( salsa               )  CALL salsa_actions( i, j, location )
     IF ( user_module_enabled )  CALL user_actions( i, j, location )
 
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 3870)
+++ palm/trunk/SOURCE/modules.f90	(revision 3871)
@@ -2111,4 +2111,5 @@
     
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums             !< global sum array for the various output quantities
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_salsa_ws_l  !< subdomain sum of vertical salsa flux w's' (5th-order advection scheme only)
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_wsts_bc_l   !< subdomain sum of sensible heat flux in Bott-Chlond scheme
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  ts_value         !< timeseries output array for the various output quantities
Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 3870)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 3871)
@@ -150,4 +150,7 @@
     USE salsa_util_mod
 
+    USE statistics,                                                            &
+        ONLY:  sums_salsa_ws_l
+
     IMPLICIT NONE
 !
@@ -727,4 +730,10 @@
        MODULE PROCEDURE salsa_driver
     END INTERFACE salsa_driver
+
+!-- Actions salsa variables
+    INTERFACE salsa_actions
+       MODULE PROCEDURE salsa_actions
+       MODULE PROCEDURE salsa_actions_ij
+    END INTERFACE salsa_actions
 !
 !-- Prognostics equations for salsa variables
@@ -750,5 +759,6 @@
            salsa_data_output_mask, salsa_define_netcdf_grid, salsa_diagnostics, salsa_driver,      &
            salsa_emission_update, salsa_header, salsa_init, salsa_init_arrays, salsa_parin,        &
-           salsa_rrd_local, salsa_swap_timelevel, salsa_prognostic_equations, salsa_wrd_local
+           salsa_rrd_local, salsa_swap_timelevel, salsa_prognostic_equations, salsa_wrd_local,     &
+           salsa_actions
 !
 !-- Public parameters, constants and initial values
@@ -1249,4 +1259,13 @@
           surf_usm_v(l)%gtsws = 0.0_wp
        ENDDO
+    ENDIF
+
+    IF ( ws_scheme_sca )  THEN
+
+       IF ( salsa )  THEN
+          ALLOCATE( sums_salsa_ws_l(nzb:nzt+1,0:threads_per_task-1) )
+          sums_salsa_ws_l = 0.0_wp
+       ENDIF
+
     ENDIF
 
@@ -7084,4 +7103,59 @@
  END SUBROUTINE salsa_diagnostics
 
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Call for all grid points
+!------------------------------------------------------------------------------!
+ SUBROUTINE salsa_actions( location )
+
+
+    CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+    SELECT CASE ( location )
+
+       CASE ( 'before_timestep' )
+
+          IF ( ws_scheme_sca )  sums_salsa_ws_l = 0.0_wp
+
+       CASE DEFAULT
+          CONTINUE
+
+    END SELECT
+
+ END SUBROUTINE salsa_actions
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Call for grid points i,j
+!------------------------------------------------------------------------------!
+
+ SUBROUTINE salsa_actions_ij( i, j, location )
+
+
+    INTEGER(iwp),      INTENT(IN) ::  i         !< grid index in x-direction
+    INTEGER(iwp),      INTENT(IN) ::  j         !< grid index in y-direction
+    CHARACTER (LEN=*), INTENT(IN) ::  location  !< call location string
+    INTEGER(iwp)  ::  dummy  !< call location string
+
+    IF ( bulk_cloud_model    )   dummy = i + j
+
+    SELECT CASE ( location )
+
+       CASE ( 'before_timestep' )
+
+          IF ( ws_scheme_sca )  sums_salsa_ws_l = 0.0_wp
+
+       CASE DEFAULT
+          CONTINUE
+
+    END SELECT
+
+
+ END SUBROUTINE salsa_actions_ij
+
 !
 !------------------------------------------------------------------------------!
@@ -7095,7 +7169,4 @@
     USE control_parameters,                                                                        &
         ONLY:  time_since_reference_point
-
-    USE salsa_util_mod,                                                                            &
-        ONLY:  sums_salsa_ws_l
 
     IMPLICIT NONE
@@ -7167,7 +7238,4 @@
     USE control_parameters,                                                                        &
         ONLY:  time_since_reference_point
-
-    USE salsa_util_mod,                                                                            &
-        ONLY:  sums_salsa_ws_l
 
     IMPLICIT NONE
Index: palm/trunk/SOURCE/salsa_util_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_util_mod.f90	(revision 3870)
+++ palm/trunk/SOURCE/salsa_util_mod.f90	(revision 3871)
@@ -51,8 +51,4 @@
 
     IMPLICIT NONE
-
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  sums_salsa_ws_l !< subdomain sum of vertical salsa 
-                                                              !< flux w's' (5th-order advection 
-                                                              !< scheme only)
 !
 !-- Component index
@@ -78,5 +74,5 @@
 
     PRIVATE
-    PUBLIC component_index, component_index_constructor, get_index, is_used, sums_salsa_ws_l
+    PUBLIC component_index, component_index_constructor, get_index, is_used
 
  CONTAINS
