Index: palm/trunk/SOURCE/advec_ws.f90
===================================================================
--- palm/trunk/SOURCE/advec_ws.f90	(revision 3302)
+++ palm/trunk/SOURCE/advec_ws.f90	(revision 3467)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Implementation of a new aerosol module salsa.
+! 
+! 3302 2018-10-03 02:39:40Z raasch
 ! Stokes drift velocity added in scalar advection
 ! 
@@ -47,5 +50,5 @@
 ! 2731 2018-01-09 17:44:02Z suehring
 ! Enable loop vectorization by splitting the k-loop
-! 
+!
 ! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
@@ -315,4 +318,7 @@
        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_wsncs_ws_l,& 
@@ -381,5 +387,9 @@
              ALLOCATE( sums_wssas_ws_l(nzb:nzt+1,0:threads_per_task-1) )
              sums_wssas_ws_l = 0.0_wp
-          ENDIF
+          ENDIF        
+!          
+!--       Mona: Now always allocated
+          ALLOCATE( sums_salsa_ws_l(nzb:nzt+1,0:threads_per_task-1) )
+          sums_salsa_ws_l = 0.0_wp         
 
        ENDIF
@@ -1096,14 +1106,17 @@
                   ws_scheme_sca
 
-       USE kinds
+       USE kinds  
 
        USE bulk_cloud_model_mod,                                               &
            ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert
 
+       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_wsncs_ws_l,&
                   sums_wsnrs_ws_l, sums_wspts_ws_l, sums_wsqcs_ws_l,           &
                   sums_wsqrs_ws_l, sums_wsqs_ws_l, sums_wsss_ws_l,             &
-                  sums_wssas_ws_l, sums_wsus_ws_l, sums_wsvs_ws_l      
+                  sums_wssas_ws_l, sums_wsus_ws_l, sums_wsvs_ws_l
                    
 
@@ -1134,5 +1147,8 @@
           ENDIF
           IF ( ocean_mode )  sums_wssas_ws_l = 0.0_wp
-
+       
+          sums_salsa_ws_l = 0.0_wp
+         
+          
        ENDIF
 
@@ -1167,8 +1183,11 @@
        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    
+                  sums_wssas_ws_l, sums_wsss_ws_l, weight_substep
                   
 
@@ -1704,4 +1723,15 @@
                     ) * weight_substep(intermediate_timestep_count)
              ENDDO
+                  
+         CASE ( 'aerosol_mass', 'aerosol_number', 'salsa_gas' )
+         
+             DO  k = nzb, nzt
+                sums_salsa_ws_l(k,tn)  = sums_salsa_ws_l(k,tn) +               &
+                    ( flux_t(k) / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
+                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
+                    + diss_t(k) / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
+                                *   ABS( w(k,j,i) - hom(k,1,3,0)            )  &
+                    ) * weight_substep(intermediate_timestep_count)
+             ENDDO             
 
 !          CASE ( 'kc' )
@@ -3211,4 +3241,7 @@
            
        USE kinds
+       
+       USE salsa_util_mod,                                                     &
+           ONLY:  sums_salsa_ws_l      
        
        USE statistics,                                                         &
@@ -3731,5 +3764,17 @@
                                 *   ABS(w(k,j,i) - hom(k,1,3,0)             )  &
                             ) * weight_substep(intermediate_timestep_count)
-                    ENDDO   
+                    ENDDO  
+     
+                 CASE ( 'aerosol_mass', 'aerosol_number', 'salsa_gas' )
+                     DO  k = nzb, nzt
+                        sums_salsa_ws_l(k,tn)  = sums_salsa_ws_l(k,tn)         &
+                          + ( flux_t(k)                                        &
+                                / ( w(k,j,i) + SIGN( 1.0E-20_wp, w(k,j,i) ) )  &
+                                * ( w(k,j,i) - hom(k,1,3,0)                 )  &
+                            + diss_t(k)                                        &
+                                / ( ABS(w(k,j,i)) + 1.0E-20_wp              )  &
+                                *   ABS(w(k,j,i) - hom(k,1,3,0)             )  &
+                            ) * weight_substep(intermediate_timestep_count)
+                     ENDDO                    
                                    
 
