Index: palm/trunk/SOURCE/time_integration.f90
===================================================================
--- palm/trunk/SOURCE/time_integration.f90	(revision 4022)
+++ palm/trunk/SOURCE/time_integration.f90	(revision 4029)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! exchange of ghost points and boundary conditions separated for chemical species and SALSA module,
+! bugfix: decycling of chemistry species after nesting data transfer
+! 
+! 4022 2019-06-12 11:52:39Z suehring
 ! Call synthetic turbulence generator at last RK3 substep right after boundary
 ! conditions are updated in offline nesting in order to assure that 
@@ -1068,9 +1072,37 @@
              DO  lsp = 1, nvar
                 CALL exchange_horiz( chem_species(lsp)%conc_p, nbgp )
-!
-!--             kanani: Push chem_boundary_conds after CALL boundary_conds
+             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 )
+                DO  ic = 1, ncomponents_mass
+                   icc = ( ic - 1 ) * nbins_aerosol + ib
+                   CALL exchange_horiz( aerosol_mass(icc)%conc_p, nbgp )
+                ENDDO
+             ENDDO
+             IF ( .NOT. salsa_gases_from_chem )  THEN
+                DO  ig = 1, ngases_salsa
+                   CALL exchange_horiz( salsa_gas(ig)%conc_p, nbgp )
+                ENDDO
+             ENDIF
+          ENDIF
+          CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' )
+
+!
+!--       Boundary conditions for the prognostic quantities (except of the
+!--       velocities at the outflow in case of a non-cyclic lateral wall)
+          CALL boundary_conds
+
+!
+!--       Boundary conditions for prognostic quantitites of other modules:
+!--       Here, only decycling is carried out
+          IF ( air_chemistry )  THEN
+
+             DO  lsp = 1, nvar
                 lsp_usr = 1
                 DO WHILE ( TRIM( cs_name( lsp_usr ) ) /= 'novalue' )
-                   IF ( TRIM(chem_species(lsp)%name) == TRIM(cs_name(lsp_usr)) )  THEN
+                   IF ( TRIM( chem_species(lsp)%name ) == TRIM( cs_name(lsp_usr) ) )  THEN
                       CALL chem_boundary_conds( chem_species(lsp)%conc_p,                          &
                                                 chem_species(lsp)%conc_pr_init )
@@ -1079,15 +1111,13 @@
                 ENDDO
              ENDDO
+
           ENDIF
 
           IF ( salsa  .AND.  time_since_reference_point >= skip_time_do_salsa )  THEN
-!
-!--          Exchange ghost points and decycle boundary concentrations if needed
+
              DO  ib = 1, nbins_aerosol
-                CALL exchange_horiz( aerosol_number(ib)%conc_p, nbgp )
                 CALL salsa_boundary_conds( aerosol_number(ib)%conc_p, aerosol_number(ib)%init )
                 DO  ic = 1, ncomponents_mass
                    icc = ( ic - 1 ) * nbins_aerosol + ib
-                   CALL exchange_horiz( aerosol_mass(icc)%conc_p, nbgp )
                    CALL salsa_boundary_conds( aerosol_mass(icc)%conc_p, aerosol_mass(icc)%init )
                 ENDDO
@@ -1095,15 +1125,10 @@
              IF ( .NOT. salsa_gases_from_chem )  THEN
                 DO  ig = 1, ngases_salsa
-                   CALL exchange_horiz( salsa_gas(ig)%conc_p, nbgp )
                    CALL salsa_boundary_conds( salsa_gas(ig)%conc_p, salsa_gas(ig)%init )
                 ENDDO
              ENDIF
-          ENDIF
-          CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' )
-
-!
-!--       Boundary conditions for the prognostic quantities (except of the
-!--       velocities at the outflow in case of a non-cyclic lateral wall)
-          CALL boundary_conds
+
+          ENDIF
+
 !
 !--       Swap the time levels in preparation for the next time step.
@@ -1130,4 +1155,6 @@
 
              IF ( TRIM( nesting_mode ) == 'two-way' .OR.  nesting_mode == 'vertical' )  THEN
+
+                CALL cpu_log( log_point_s(92), 'exchange-horiz-nest', 'start' )
 !
 !--             Exchange_horiz is needed for all parent-domains after the
@@ -1170,9 +1197,7 @@
                    DO  ib = 1, nbins_aerosol
                       CALL exchange_horiz( aerosol_number(ib)%conc, nbgp )
-                      CALL salsa_boundary_conds( aerosol_number(ib)%conc, aerosol_number(ib)%init )
                       DO  ic = 1, ncomponents_mass
                          icc = ( ic - 1 ) * nbins_aerosol + ib
                          CALL exchange_horiz( aerosol_mass(icc)%conc, nbgp )
-                         CALL salsa_boundary_conds( aerosol_mass(icc)%conc, aerosol_mass(icc)%init )
                       ENDDO
                    ENDDO
@@ -1180,14 +1205,46 @@
                       DO  ig = 1, ngases_salsa
                          CALL exchange_horiz( salsa_gas(ig)%conc, nbgp )
-                         CALL salsa_boundary_conds( salsa_gas(ig)%conc, salsa_gas(ig)%init )
                       ENDDO
                    ENDIF
                 ENDIF
-                CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' )
-
-             ENDIF
+                CALL cpu_log( log_point_s(92), 'exchange-horiz-nest', 'stop' )
+
+             ENDIF
+
 !
 !--          Set boundary conditions again after interpolation and anterpolation.
              CALL pmci_boundary_conds
+
+!
+!--          Set chemistry boundary conditions (decycling)
+             IF ( air_chemistry )  THEN
+                DO  lsp = 1, nvar
+                   lsp_usr = 1
+                   DO WHILE ( TRIM( cs_name( lsp_usr ) ) /= 'novalue' )
+                      IF ( TRIM( chem_species(lsp)%name ) == TRIM( cs_name(lsp_usr) ) )  THEN
+                         CALL chem_boundary_conds( chem_species(lsp)%conc,                         &
+                                                   chem_species(lsp)%conc_pr_init )
+                      ENDIF
+                      lsp_usr = lsp_usr + 1
+                   ENDDO
+                ENDDO
+             ENDIF
+
+!
+!--          Set SALSA boundary conditions (decycling)
+             IF ( salsa  .AND. time_since_reference_point >= skip_time_do_salsa )  THEN
+                DO  ib = 1, nbins_aerosol
+                   CALL salsa_boundary_conds( aerosol_number(ib)%conc, aerosol_number(ib)%init )
+                   DO  ic = 1, ncomponents_mass
+                      icc = ( ic - 1 ) * nbins_aerosol + ib
+                      CALL salsa_boundary_conds( aerosol_mass(icc)%conc, aerosol_mass(icc)%init )
+                   ENDDO
+                ENDDO
+                IF ( .NOT. salsa_gases_from_chem )  THEN
+                   DO  ig = 1, ngases_salsa
+                      CALL salsa_boundary_conds( salsa_gas(ig)%conc, salsa_gas(ig)%init )
+                   ENDDO
+                ENDIF
+             ENDIF
 
              CALL cpu_log( log_point(60), 'nesting', 'stop' )
