Index: /palm/trunk/SOURCE/bulk_cloud_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/bulk_cloud_model_mod.f90	(revision 4731)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
 ! 
@@ -1470,34 +1473,72 @@
 ! Description:
 ! ------------
-!> Control of microphysics for all grid points
-!--------------------------------------------------------------------------------------------------!
-    SUBROUTINE bcm_exchange_horiz
+!> Exchange ghostpoints
+!--------------------------------------------------------------------------------------------------!
+    SUBROUTINE bcm_exchange_horiz( location )
 
        USE exchange_horiz_mod,                                                                     &
            ONLY:  exchange_horiz
 
-
-       IF ( .NOT. microphysics_sat_adjust  .AND.  ( intermediate_timestep_count == 1  .OR.         &
-            call_microphysics_at_all_substeps ) )                                                  &
-       THEN
-          IF ( microphysics_morrison )  THEN
-             CALL exchange_horiz( nc, nbgp )
-             CALL exchange_horiz( qc, nbgp )
-          ENDIF
-          IF ( microphysics_seifert ) THEN
-             CALL exchange_horiz( qr, nbgp )
-             CALL exchange_horiz( nr, nbgp )
-          ENDIF
-          IF ( microphysics_ice_phase ) THEN
-             CALL exchange_horiz( qi, nbgp )
-             CALL exchange_horiz( ni, nbgp )
-          ENDIF
-          CALL exchange_horiz( q, nbgp )
-          CALL exchange_horiz( pt, nbgp )
-       ENDIF
-
+       CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+       SELECT CASE ( location )
+
+          CASE ( 'before_prognostic_equation' )
+
+             IF ( .NOT. microphysics_sat_adjust  .AND.  ( intermediate_timestep_count == 1  .OR.   &
+                  call_microphysics_at_all_substeps ) )                                            &
+             THEN
+                IF ( microphysics_morrison )  THEN
+                   CALL exchange_horiz( nc, nbgp )
+                   CALL exchange_horiz( qc, nbgp )
+                ENDIF
+                IF ( microphysics_seifert ) THEN
+                   CALL exchange_horiz( qr, nbgp )
+                   CALL exchange_horiz( nr, nbgp )
+                ENDIF
+                IF ( microphysics_ice_phase ) THEN
+                   CALL exchange_horiz( qi, nbgp )
+                   CALL exchange_horiz( ni, nbgp )
+                ENDIF
+                CALL exchange_horiz( q, nbgp )
+                CALL exchange_horiz( pt, nbgp )
+             ENDIF
+
+          CASE ( 'after_prognostic_equation' )
+
+             IF ( collision_turbulence )  THEN
+                CALL exchange_horiz( diss, nbgp )
+             ENDIF
+             IF ( microphysics_morrison )  THEN
+                CALL exchange_horiz( qc_p, nbgp )
+                CALL exchange_horiz( nc_p, nbgp )
+             ENDIF
+             IF ( microphysics_seifert )  THEN
+                CALL exchange_horiz( qr_p, nbgp )
+                CALL exchange_horiz( nr_p, nbgp )
+             ENDIF
+             IF ( microphysics_ice_phase )  THEN
+                CALL exchange_horiz( qi_p, nbgp )
+                CALL exchange_horiz( ni_p, nbgp )
+             ENDIF
+
+          CASE ( 'after_anterpolation' )
+
+             IF ( microphysics_morrison )  THEN
+                CALL exchange_horiz( qc, nbgp )
+                CALL exchange_horiz( nc, nbgp )
+             ENDIF
+             IF ( microphysics_seifert )  THEN
+                CALL exchange_horiz( qr, nbgp )
+                CALL exchange_horiz( nr, nbgp )
+             ENDIF
+             IF ( microphysics_ice_phase )  THEN
+                CALL exchange_horiz( qi, nbgp )
+                CALL exchange_horiz( ni, nbgp )
+             ENDIF
+
+       END SELECT
 
     END SUBROUTINE bcm_exchange_horiz
-
 
 
Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4731)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
 !
@@ -2934,5 +2937,5 @@
 !> routine for exchange horiz of chemical quantities
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE chem_exchange_horiz_bounds
+ SUBROUTINE chem_exchange_horiz_bounds( location )
 
     USE exchange_horiz_mod,                                                                        &
@@ -2940,17 +2943,42 @@
 
    INTEGER(iwp) ::  lsp       !<
-
-!
-!--    Loop over chemical species
-       CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'start' )
-       DO  lsp = 1, nvar
-          CALL exchange_horiz( chem_species(lsp)%conc, nbgp,                                       &
-                               alternative_communicator = communicator_chem )
-       ENDDO
-
-       CALL chem_boundary_conditions( horizontal_conditions_only = .TRUE. )
-
-       CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'stop' )
-
+   INTEGER(iwp) ::  n
+
+   CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+   SELECT CASE ( location )
+
+       CASE ( 'before_prognostic_equation' )
+!
+!--       Loop over chemical species
+          CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'start' )
+          DO  lsp = 1, nvar
+             CALL exchange_horiz( chem_species(lsp)%conc, nbgp,                                    &
+                                  alternative_communicator = communicator_chem )
+          ENDDO
+
+          CALL chem_boundary_conditions( horizontal_conditions_only = .TRUE. )
+
+          CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'stop' )
+
+       CASE ( 'after_prognostic_equation' )
+
+          IF ( air_chemistry )  THEN
+             DO  n = 1, nvar
+                CALL exchange_horiz( chem_species(n)%conc_p, nbgp,                                 &
+                                     alternative_communicator = communicator_chem )
+             ENDDO
+          ENDIF
+
+       CASE ( 'after_anterpolation' )
+
+          IF ( air_chemistry )  THEN
+             DO  n = 1, nvar
+                CALL exchange_horiz( chem_species(n)%conc, nbgp,                                   &
+                                     alternative_communicator = communicator_chem )
+             ENDDO
+          ENDIF
+
+    END SELECT
 
  END SUBROUTINE chem_exchange_horiz_bounds
Index: /palm/trunk/SOURCE/dynamics_mod.f90
===================================================================
--- /palm/trunk/SOURCE/dynamics_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/dynamics_mod.f90	(revision 4731)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4627 2020-07-26 10:14:44Z raasch
 ! bugfix for r4626
 !
@@ -67,5 +70,9 @@
     USE arrays_3d,                                                                                 &
         ONLY:  c_u, c_u_m, c_u_m_l, c_v, c_v_m, c_v_m_l, c_w, c_w_m, c_w_m_l,                      &
+               diss,                                                                               &
+               diss_p,                                                                             &
                dzu,                                                                                &
+               e,                                                                                  &
+               e_p,                                                                                &
                exner,                                                                              &
                hyp,                                                                                &
@@ -94,4 +101,5 @@
                child_domain,                                                                       &
                coupling_mode,                                                                      &
+               constant_diffusion,                                                                 &
                dt_3d,                                                                              &
                humidity,                                                                           &
@@ -113,6 +121,12 @@
                passive_scalar,                                                                     &
                restart_string,                                                                     &
+               rans_mode,                                                                          &
+               rans_tke_e,                                                                         &
                tsc,                                                                                &
                use_cmax
+
+    USE exchange_horiz_mod,                                                                        &
+        ONLY:  exchange_horiz
+
 
     USE grid_variables,                                                                            &
@@ -764,7 +778,37 @@
 !> Perform module-specific horizontal boundary exchange
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE dynamics_exchange_horiz
-
-
+ SUBROUTINE dynamics_exchange_horiz( location )
+
+       CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+       SELECT CASE ( location )
+
+          CASE ( 'before_prognostic_equation' )
+
+          CASE ( 'after_prognostic_equation' )
+
+             CALL exchange_horiz( u_p, nbgp )
+             CALL exchange_horiz( v_p, nbgp )
+             CALL exchange_horiz( w_p, nbgp )
+             CALL exchange_horiz( pt_p, nbgp )
+             IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e_p, nbgp )
+             IF ( rans_tke_e  )               CALL exchange_horiz( diss_p, nbgp )
+             IF ( humidity )                  CALL exchange_horiz( q_p, nbgp )
+             IF ( passive_scalar )            CALL exchange_horiz( s_p, nbgp )
+
+          CASE ( 'after_anterpolation' )
+
+             CALL exchange_horiz( u, nbgp )
+             CALL exchange_horiz( v, nbgp )
+             CALL exchange_horiz( w, nbgp )
+             IF ( .NOT. neutral )             CALL exchange_horiz( pt, nbgp )
+             IF ( humidity )                  CALL exchange_horiz( q, nbgp )
+             IF ( passive_scalar )            CALL exchange_horiz( s, nbgp )
+             IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e, nbgp )
+             IF ( .NOT. constant_diffusion  .AND.  rans_mode  .AND.  rans_tke_e )  THEN
+                CALL exchange_horiz( diss, nbgp )
+             ENDIF
+
+       END SELECT
 
  END SUBROUTINE dynamics_exchange_horiz
Index: /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/lagrangian_particle_model_mod.f90	(revision 4731)
@@ -24,4 +24,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4673 2020-09-10 07:56:36Z schwenkel
 ! bugfix in case of mpi-restarts
 !
@@ -413,4 +416,5 @@
            lpm_actions,                                                                            &
            lpm_data_output_ptseries,                                                               &
+           lpm_exchange_horiz_bounds,                                                              &
            lpm_interaction_droplets_ptq,                                                           &
            lpm_rrd_local_particles,                                                                &
@@ -513,4 +517,8 @@
        MODULE PROCEDURE lpm_exchange_horiz
     END INTERFACE lpm_exchange_horiz
+
+    INTERFACE lpm_exchange_horiz_bounds
+       MODULE PROCEDURE lpm_exchange_horiz_bounds
+    END INTERFACE lpm_exchange_horiz_bounds
 
     INTERFACE lpm_move_particle
@@ -7764,4 +7772,32 @@
  END SUBROUTINE lpm_exchange_horiz
 
+
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Exchange ghostpoints
+!--------------------------------------------------------------------------------------------------!
+    SUBROUTINE lpm_exchange_horiz_bounds( location )
+
+    USE exchange_horiz_mod,                                                                        &
+        ONLY:  exchange_horiz
+
+       CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+       SELECT CASE ( location )
+
+          CASE ( 'before_prognostic_equation' )
+
+          CASE ( 'after_prognostic_equation' )
+
+             IF ( wang_kernel  .OR.  use_sgs_for_particles )  THEN
+                CALL exchange_horiz( diss, nbgp )
+             ENDIF
+
+       END SELECT
+
+    END SUBROUTINE lpm_exchange_horiz_bounds
+
+
 #if defined( __parallel )
 !--------------------------------------------------------------------------------------------------!
Index: /palm/trunk/SOURCE/module_interface.f90
===================================================================
--- /palm/trunk/SOURCE/module_interface.f90	(revision 4730)
+++ /palm/trunk/SOURCE/module_interface.f90	(revision 4731)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4708 2020-09-28 17:42:58Z suehring
 ! pass fillvalue attribute to radiation output
 !
@@ -390,4 +393,5 @@
                lpm_header,                                                     &
                lpm_check_parameters,                                           &
+               lpm_exchange_horiz_bounds,                                      &
                lpm_init_arrays,                                                &
                lpm_init,                                                       &
@@ -432,4 +436,5 @@
                ocean_check_data_output_pr,                                     &
                ocean_check_data_output,                                        &
+               ocean_exchange_horiz,                                           &
                ocean_init_arrays,                                              &
                ocean_init,                                                     &
@@ -1350,14 +1355,17 @@
 !> Exchange horiz for module-specific quantities
 !------------------------------------------------------------------------------!
- SUBROUTINE module_interface_exchange_horiz
-
+ SUBROUTINE module_interface_exchange_horiz( location )
+
+    CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
 
     IF ( debug_output_timestep )  CALL debug_message( 'module-specific exchange_horiz', 'start' )
 
-    CALL dynamics_exchange_horiz
-
-    IF ( bulk_cloud_model    )  CALL bcm_exchange_horiz
-    IF ( air_chemistry       )  CALL chem_exchange_horiz_bounds
-    IF ( salsa               )  CALL salsa_exchange_horiz_bounds
+    CALL dynamics_exchange_horiz( location )
+
+    IF ( bulk_cloud_model    )  CALL bcm_exchange_horiz( location )
+    IF ( air_chemistry       )  CALL chem_exchange_horiz_bounds( location )
+    IF ( ocean_mode          )  CALL ocean_exchange_horiz( location )
+    IF ( particle_advection  )  CALL lpm_exchange_horiz_bounds ( location )
+    IF ( salsa               )  CALL salsa_exchange_horiz_bounds( location )
 
     IF ( debug_output_timestep )  CALL debug_message( 'module-specific exchange_horiz', 'end' )
Index: /palm/trunk/SOURCE/ocean_mod.f90
===================================================================
--- /palm/trunk/SOURCE/ocean_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/ocean_mod.f90	(revision 4731)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
 ! 
@@ -96,5 +99,5 @@
     USE control_parameters,                                                    &
         ONLY:  atmos_ocean_sign, bottom_salinityflux,                          &
-               constant_top_salinityflux, restart_data_format_output, ocean_mode, top_salinityflux, &
+               constant_top_salinityflux, restart_data_format_output, ocean_mode, top_salinityflux,&
                wall_salinityflux, loop_optimization, ws_scheme_sca
 
@@ -108,5 +111,5 @@
 
     USE indices,                                                               &
-        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0
+        ONLY:  advc_flags_s, nxl, nxr, nyn, nys, nzb, nzt, wall_flags_total_0, nbgp
 
     USE restart_data_mpi_io_mod,                                                                   &
@@ -117,4 +120,8 @@
         ONLY:  bc_h, surf_def_v, surf_def_h, surf_lsm_h, surf_lsm_v,           &
                surf_usm_h, surf_usm_v
+
+       USE exchange_horiz_mod,                                                                     &
+           ONLY:  exchange_horiz
+
 
     IMPLICIT NONE
@@ -202,4 +209,8 @@
     END INTERFACE ocean_data_output_3d
 
+    INTERFACE ocean_exchange_horiz
+       MODULE PROCEDURE ocean_exchange_horiz
+    END INTERFACE ocean_exchange_horiz
+
     INTERFACE ocean_header
        MODULE PROCEDURE ocean_header
@@ -273,5 +284,5 @@
     PUBLIC eqn_state_seawater, ocean_actions, ocean_check_data_output,         &
            ocean_check_data_output_pr, ocean_check_parameters,                 &
-           ocean_data_output_2d, ocean_data_output_3d,                         &
+           ocean_data_output_2d, ocean_data_output_3d, ocean_exchange_horiz,   &
            ocean_define_netcdf_grid, ocean_header, ocean_init,                 &
            ocean_init_arrays, ocean_parin, ocean_prognostic_equations,         &
@@ -1165,4 +1176,29 @@
 
  END SUBROUTINE ocean_data_output_3d
+
+
+!--------------------------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Exchange ghostpoints
+!--------------------------------------------------------------------------------------------------!
+    SUBROUTINE ocean_exchange_horiz( location )
+
+       CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+       SELECT CASE ( location )
+
+          CASE ( 'before_prognostic_equation' )
+
+          CASE ( 'after_prognostic_equation' )
+
+             CALL exchange_horiz( sa_p, nbgp )
+             CALL exchange_horiz( rho_ocean, nbgp )
+             CALL exchange_horiz( prho, nbgp )
+
+       END SELECT
+
+    END SUBROUTINE ocean_exchange_horiz
+
 
 
Index: /palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4730)
+++ /palm/trunk/SOURCE/prognostic_equations.f90	(revision 4731)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4717 2020-09-30 22:27:40Z pavelkrc
 ! Fixes and optimizations of OpenMP parallelization, formatting of OpenMP
 ! directives (J. Resler)
@@ -411,5 +414,5 @@
 !-- Module Inferface for exchange horiz after non_advective_processes but before advection.
 !-- Therefore, non_advective_processes must not run for ghost points.
-    CALL module_interface_exchange_horiz()
+    CALL module_interface_exchange_horiz( 'before_prognostic_equation' )
 !
 !-- Loop over all prognostic equations
@@ -917,5 +920,5 @@
 !-- Module Inferface for exchange horiz after non_advective_processes but before advection.
 !-- Therefore, non_advective_processes must not run for ghost points.
-    CALL module_interface_exchange_horiz()
+    CALL module_interface_exchange_horiz( 'before_prognostic_equation' )
 !
 !-- u-velocity component
Index: /palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- /palm/trunk/SOURCE/salsa_mod.f90	(revision 4730)
+++ /palm/trunk/SOURCE/salsa_mod.f90	(revision 4731)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
 ! 
@@ -8332,5 +8335,5 @@
 !> Routine for exchange horiz of salsa variables.
 !------------------------------------------------------------------------------!
- SUBROUTINE salsa_exchange_horiz_bounds
+ SUBROUTINE salsa_exchange_horiz_bounds ( location )
 
     USE cpulog,                                                                &
@@ -8347,36 +8350,85 @@
     INTEGER(iwp) ::  ig   !<
 
-    IF ( time_since_reference_point >= skip_time_do_salsa )  THEN
-       IF ( ( time_since_reference_point - last_salsa_time ) >= dt_salsa )  THEN
-
-          CALL cpu_log( log_point_s(91), 'salsa exch-horiz ', 'start' )
-!
-!--       Exchange ghost points
-          DO  ib = 1, nbins_aerosol
-             CALL exchange_horiz( aerosol_number(ib)%conc, nbgp,                                   &
-                                  alternative_communicator = communicator_salsa )
-             DO  ic = 1, ncomponents_mass
-                icc = ( ic - 1 ) * nbins_aerosol + ib
-                CALL exchange_horiz( aerosol_mass(icc)%conc, nbgp,                                 &
+    CHARACTER (LEN=*), INTENT(IN) ::  location !< call location string
+
+    SELECT CASE ( location )
+
+       CASE ( 'before_prognostic_equation' )
+
+          IF ( time_since_reference_point >= skip_time_do_salsa )  THEN
+             IF ( ( time_since_reference_point - last_salsa_time ) >= dt_salsa )  THEN
+
+                CALL cpu_log( log_point_s(91), 'salsa exch-horiz ', 'start' )
+!
+!--             Exchange ghost points
+                DO  ib = 1, nbins_aerosol
+                   CALL exchange_horiz( aerosol_number(ib)%conc, nbgp,                             &
+                                        alternative_communicator = communicator_salsa )
+                   DO  ic = 1, ncomponents_mass
+                      icc = ( ic - 1 ) * nbins_aerosol + ib
+                      CALL exchange_horiz( aerosol_mass(icc)%conc, nbgp,                           &
+                                           alternative_communicator = communicator_salsa )
+                   ENDDO
+                ENDDO
+                IF ( .NOT. salsa_gases_from_chem )  THEN
+                   DO  ig = 1, ngases_salsa
+                      CALL exchange_horiz( salsa_gas(ig)%conc, nbgp,                               &
+                                           alternative_communicator = communicator_salsa )
+                   ENDDO
+                ENDIF
+!
+!--             Apply only horizontal boundary conditions
+                CALL salsa_boundary_conditions( horizontal_conditions_only = .TRUE. )
+                CALL cpu_log( log_point_s(91), 'salsa exch-horiz ', 'stop' )
+!
+!--             Update last_salsa_time
+                last_salsa_time = time_since_reference_point
+             ENDIF
+          ENDIF
+
+       CASE ( 'after_prognostic_equation' )
+
+          IF ( salsa  .AND.  time_since_reference_point >= skip_time_do_salsa )  THEN
+             DO  ib = 1, nbins_aerosol
+                CALL exchange_horiz( aerosol_number(ib)%conc_p, nbgp,                              &
                                      alternative_communicator = communicator_salsa )
+                DO  ic = 1, ncomponents_mass
+                   icc = ( ic - 1 ) * nbins_aerosol + ib
+                   CALL exchange_horiz( aerosol_mass(icc)%conc_p, nbgp,                            &
+                                        alternative_communicator = communicator_salsa )
+                ENDDO
              ENDDO
-          ENDDO
-          IF ( .NOT. salsa_gases_from_chem )  THEN
-             DO  ig = 1, ngases_salsa
-                CALL exchange_horiz( salsa_gas(ig)%conc, nbgp,                                     &
+             IF ( .NOT. salsa_gases_from_chem )  THEN
+                DO  ig = 1, ngases_salsa
+                   CALL exchange_horiz( salsa_gas(ig)%conc_p, nbgp,                                &
+                                        alternative_communicator = communicator_salsa )
+                ENDDO
+             ENDIF
+          ENDIF
+
+       CASE ( 'after_anterpolation' )
+
+          IF ( salsa  .AND. time_since_reference_point >= skip_time_do_salsa )  THEN
+             DO  ib = 1, nbins_aerosol
+                CALL exchange_horiz( aerosol_number(ib)%conc, nbgp,                                &
                                      alternative_communicator = communicator_salsa )
+                DO  ic = 1, ncomponents_mass
+                   icc = ( ic - 1 ) * nbins_aerosol + ib
+                   CALL exchange_horiz( aerosol_mass(icc)%conc, nbgp,                              &
+                                        alternative_communicator = communicator_salsa )
+                ENDDO
              ENDDO
+             IF ( .NOT. salsa_gases_from_chem )  THEN
+                DO  ig = 1, ngases_salsa
+                   CALL exchange_horiz( salsa_gas(ig)%conc, nbgp,                                  &
+                                        alternative_communicator = communicator_salsa )
+                ENDDO
+             ENDIF
           ENDIF
-!
-!--       Apply only horizontal boundary conditions
-          CALL salsa_boundary_conditions( horizontal_conditions_only = .TRUE. )
-          CALL cpu_log( log_point_s(91), 'salsa exch-horiz ', 'stop' )
-!
-!--       Update last_salsa_time
-          last_salsa_time = time_since_reference_point
-       ENDIF
-    ENDIF
+
+    END SELECT
 
  END SUBROUTINE salsa_exchange_horiz_bounds
+
 
 !------------------------------------------------------------------------------!
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 4730)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 4731)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move exchange_horiz from time_integration to modules
+!
+! 4671 2020-09-09 20:27:58Z pavelkrc
 ! Implementation of downward facing USM and LSM surfaces
 !
@@ -252,11 +255,6 @@
 
     USE arrays_3d,                                                                                 &
-        ONLY:  diss, diss_p, dzu, e_p, nc_p, ni_p, nr_p, prho, pt, pt_p, pt_init, q, qc_p, qr_p,   &
-               q_init, q_p, qi_p, ref_state, rho_ocean, sa_p, s_p, tend, u, u_p, v, vpt, v_p, w_p
-
-#if defined( __parallel )  &&  ! defined( _OPENACC )
-    USE arrays_3d,                                                                                 &
-        ONLY:  e, nc, ni, nr, qc, qi, qr, s, w
-#endif
+        ONLY:  dzu, prho, pt, pt_init, q,                                                          &
+               q_init, ref_state, rho_ocean, tend, u, v, vpt
 
     USE biometeorology_mod,                                                                        &
@@ -265,6 +263,5 @@
 
     USE bulk_cloud_model_mod,                                                                      &
-        ONLY: bulk_cloud_model, calc_liquid_water_content, collision_turbulence,                   &
-              microphysics_ice_phase, microphysics_morrison, microphysics_seifert
+        ONLY: bulk_cloud_model, calc_liquid_water_content
 
     USE calc_mean_profile_mod,                                                                     &
@@ -278,5 +275,5 @@
 
     USE chem_modules,                                                                              &
-        ONLY:  bc_cs_t_val, chem_species, communicator_chem, emissions_anthropogenic,              &
+        ONLY:  bc_cs_t_val, chem_species, emissions_anthropogenic,                                 &
                emiss_read_legacy_mode, n_matched_vars
 
@@ -296,7 +293,7 @@
                land_surface, large_scale_forcing, loop_optimization, lsf_surf, lsf_vert, masks,    &
                multi_agent_system_end, multi_agent_system_start, nesting_offline, neutral,         &
-               nr_timesteps_this_run, nudging, ocean_mode, passive_scalar, pt_reference,           &
+               nr_timesteps_this_run, nudging, ocean_mode, pt_reference,                           &
                pt_slope_offset, pt_surface_heating_rate,                                           &
-               random_heatflux, rans_tke_e, run_coupled, salsa,                                    &
+               random_heatflux, run_coupled, salsa,                                                &
                simulated_time, simulated_time_chr, skip_time_do2d_xy, skip_time_do2d_xz,           &
                skip_time_do2d_yz, skip_time_do3d, skip_time_domask, skip_time_dopr,                &
@@ -310,9 +307,4 @@
                virtual_flight, virtual_measurement, ws_scheme_mom, ws_scheme_sca
 
-#if defined( __parallel )
-    USE control_parameters,                                                                        &
-        ONLY:  rans_mode
-#endif
-
     USE cpulog,                                                                                    &
         ONLY:  cpu_log, log_point, log_point_s
@@ -332,5 +324,5 @@
 
     USE indices,                                                                                   &
-        ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, nzb, nzt
+        ONLY:  nx, nxl, nxlg, nxr, nxrg, nzb, nzt
 
     USE indoor_model_mod,                                                                          &
@@ -352,5 +344,5 @@
     USE module_interface,                                                                          &
         ONLY:  module_interface_actions, module_interface_swap_timelevel,                          &
-               module_interface_boundary_conditions
+               module_interface_boundary_conditions, module_interface_exchange_horiz
 
     USE multi_agent_system_mod,                                                                    &
@@ -373,5 +365,5 @@
 
     USE particle_attributes,                                                                       &
-        ONLY:  particle_advection, particle_advection_start, use_sgs_for_particles, wang_kernel
+        ONLY:  particle_advection, particle_advection_start
 
     USE pegrid
@@ -396,5 +388,5 @@
     USE salsa_mod,                                                                                 &
         ONLY: aerosol_number, aerosol_mass, bc_am_t_val, bc_an_t_val, bc_gt_t_val,                 &
-              communicator_salsa, nbins_aerosol, ncomponents_mass, ngases_salsa,                   &
+              nbins_aerosol, ncomponents_mass, ngases_salsa,                                       &
               salsa_boundary_conditions, salsa_emission_update, salsa_gas, salsa_gases_from_chem,  &
               skip_time_do_salsa
@@ -769,5 +761,5 @@
           ENDIF
 !
-!--       Execute all other module actions routunes
+!--       Execute all other module actions routines
           CALL module_interface_actions( 'before_prognostic_equations' )
 !
@@ -797,62 +789,5 @@
           CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'start' )
 
-          CALL exchange_horiz( u_p, nbgp )
-          CALL exchange_horiz( v_p, nbgp )
-          CALL exchange_horiz( w_p, nbgp )
-          CALL exchange_horiz( pt_p, nbgp )
-          IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e_p, nbgp )
-          IF ( rans_tke_e  .OR.  wang_kernel  .OR.  collision_turbulence                           &
-               .OR.  use_sgs_for_particles )  THEN
-             IF ( rans_tke_e )  THEN
-                CALL exchange_horiz( diss_p, nbgp )
-             ELSE
-                CALL exchange_horiz( diss, nbgp )
-             ENDIF
-          ENDIF
-          IF ( ocean_mode )  THEN
-             CALL exchange_horiz( sa_p, nbgp )
-             CALL exchange_horiz( rho_ocean, nbgp )
-             CALL exchange_horiz( prho, nbgp )
-          ENDIF
-          IF ( humidity )  THEN
-             CALL exchange_horiz( q_p, nbgp )
-             IF ( bulk_cloud_model .AND. microphysics_morrison )  THEN
-                CALL exchange_horiz( qc_p, nbgp )
-                CALL exchange_horiz( nc_p, nbgp )
-             ENDIF
-             IF ( bulk_cloud_model .AND. microphysics_seifert )  THEN
-                CALL exchange_horiz( qr_p, nbgp )
-                CALL exchange_horiz( nr_p, nbgp )
-             ENDIF
-             IF ( bulk_cloud_model .AND. microphysics_ice_phase )  THEN
-                CALL exchange_horiz( qi_p, nbgp )
-                CALL exchange_horiz( ni_p, nbgp )
-             ENDIF
-          ENDIF
-          IF ( passive_scalar )  CALL exchange_horiz( s_p, nbgp )
-          IF ( air_chemistry )  THEN
-             DO  n = 1, nvar
-                CALL exchange_horiz( chem_species(n)%conc_p, nbgp,                                 &
-                                     alternative_communicator = communicator_chem )
-             ENDDO
-          ENDIF
-
-          IF ( salsa  .AND.  time_since_reference_point >= skip_time_do_salsa )  THEN
-             DO  ib = 1, nbins_aerosol
-                CALL exchange_horiz( aerosol_number(ib)%conc_p, nbgp,                              &
-                                     alternative_communicator = communicator_salsa )
-                DO  ic = 1, ncomponents_mass
-                   icc = ( ic - 1 ) * nbins_aerosol + ib
-                   CALL exchange_horiz( aerosol_mass(icc)%conc_p, nbgp,                            &
-                                        alternative_communicator = communicator_salsa )
-                ENDDO
-             ENDDO
-             IF ( .NOT. salsa_gases_from_chem )  THEN
-                DO  ig = 1, ngases_salsa
-                   CALL exchange_horiz( salsa_gas(ig)%conc_p, nbgp,                                &
-                                        alternative_communicator = communicator_salsa )
-                ENDDO
-             ENDIF
-          ENDIF
+          CALL module_interface_exchange_horiz( 'after_prognostic_equation' )
 
           CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' )
@@ -899,60 +834,6 @@
 !--             Exchange_horiz is needed for all parent-domains after the
 !--             anterpolation
-                CALL exchange_horiz( u, nbgp )
-                CALL exchange_horiz( v, nbgp )
-                CALL exchange_horiz( w, nbgp )
-                IF ( .NOT. neutral )  CALL exchange_horiz( pt, nbgp )
-
-                IF ( humidity )  THEN
-
-                   CALL exchange_horiz( q, nbgp )
-
-                   IF ( bulk_cloud_model  .AND.  microphysics_morrison )  THEN
-                       CALL exchange_horiz( qc, nbgp )
-                       CALL exchange_horiz( nc, nbgp )
-                   ENDIF
-                   IF ( bulk_cloud_model  .AND.  microphysics_seifert )  THEN
-                       CALL exchange_horiz( qr, nbgp )
-                       CALL exchange_horiz( nr, nbgp )
-                   ENDIF
-                   IF ( bulk_cloud_model  .AND.  microphysics_ice_phase )  THEN
-                      CALL exchange_horiz( qi, nbgp )
-                      CALL exchange_horiz( ni, nbgp )
-                   ENDIF
-
-                ENDIF
-
-                IF ( passive_scalar )  CALL exchange_horiz( s, nbgp )
-
-                IF ( .NOT. constant_diffusion )  CALL exchange_horiz( e, nbgp )
-
-                IF ( .NOT. constant_diffusion  .AND.  rans_mode  .AND.  rans_tke_e )  THEN
-                   CALL exchange_horiz( diss, nbgp )
-                ENDIF
-
-                IF ( air_chemistry )  THEN
-                   DO  n = 1, nvar
-                      CALL exchange_horiz( chem_species(n)%conc, nbgp,                             &
-                                           alternative_communicator = communicator_chem )
-                   ENDDO
-                ENDIF
-
-                IF ( salsa  .AND. time_since_reference_point >= skip_time_do_salsa )  THEN
-                   DO  ib = 1, nbins_aerosol
-                      CALL exchange_horiz( aerosol_number(ib)%conc, nbgp,                          &
-                                           alternative_communicator = communicator_salsa )
-                      DO  ic = 1, ncomponents_mass
-                         icc = ( ic - 1 ) * nbins_aerosol + ib
-                         CALL exchange_horiz( aerosol_mass(icc)%conc, nbgp,                        &
-                                              alternative_communicator = communicator_salsa )
-                      ENDDO
-                   ENDDO
-                   IF ( .NOT. salsa_gases_from_chem )  THEN
-                      DO  ig = 1, ngases_salsa
-                         CALL exchange_horiz( salsa_gas(ig)%conc, nbgp,                            &
-                                              alternative_communicator = communicator_salsa )
-                      ENDDO
-                   ENDIF
-                ENDIF
+                CALL module_interface_exchange_horiz( 'after_anterpolation' )
+
                 CALL cpu_log( log_point_s(92), 'exchange-horiz-nest', 'stop' )
 
