Index: /palm/trunk/SOURCE/boundary_conds.f90
===================================================================
--- /palm/trunk/SOURCE/boundary_conds.f90	(revision 3878)
+++ /palm/trunk/SOURCE/boundary_conds.f90	(revision 3879)
@@ -230,6 +230,6 @@
 
     USE chemistry_model_mod,                                                   &
-        ONLY:  chem_boundary_conds 
-              
+        ONLY:  chem_boundary_conds
+
     USE control_parameters,                                                    &
         ONLY:  air_chemistry, bc_dirichlet_l, bc_dirichlet_n, bc_dirichlet_r,  &
Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3878)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 3879)
@@ -289,5 +289,5 @@
 
     USE indices,                                                                                   &
-         ONLY:  nz, nzb, nzt, nysg, nyng, nxlg, nxrg, nys, nyn, nx, nxl, nxr, ny, wall_flags_0
+         ONLY:  nbgp, nz, nzb, nzt, nysg, nyng, nxlg, nxrg, nys, nyn, nx, nxl, nxr, ny, wall_flags_0
 
     USE pegrid,                                                                                    &
@@ -429,6 +429,9 @@
     INTERFACE chem_boundary_conds
        MODULE PROCEDURE chem_boundary_conds
+    END INTERFACE chem_boundary_conds
+
+    INTERFACE chem_boundary_conds_decycle
        MODULE PROCEDURE chem_boundary_conds_decycle
-    END INTERFACE chem_boundary_conds
+    END INTERFACE chem_boundary_conds_decycle
 
     INTERFACE chem_check_data_output
@@ -585,5 +588,6 @@
 
 
-    PUBLIC chem_3d_data_averaging, chem_boundary_conds, chem_check_data_output, &
+    PUBLIC chem_3d_data_averaging, chem_boundary_conds,                       &
+            chem_boundary_conds_decycle, chem_check_data_output,              &
          chem_check_data_output_pr, chem_check_parameters,                    &
          chem_data_output_2d, chem_data_output_3d, chem_data_output_mask,     &
@@ -871,5 +875,5 @@
 !> x-direction
 !------------------------------------------------------------------------------!
- SUBROUTINE chem_boundary_conds_decycle( cs_3d, cs_pr_init )
+ SUBROUTINE chem_boundary_conds_decycle()
 !
 !-- Decycling of chemistry variables: Dirichlet BCs with cyclic is frequently not
@@ -887,138 +891,163 @@
     INTEGER(iwp) ::  k         !< 
     INTEGER(iwp) ::  ss        !< 
+    INTEGER(iwp) ::  lsp       !<
+    INTEGER(iwp) ::  lsp_usr   !<
     REAL(wp), DIMENSION(nzb:nzt+1) ::  cs_pr_init
     REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  cs_3d
     REAL(wp) ::  flag !< flag to mask topography grid points
 
-    flag = 0.0_wp
-!
-!-- Left and right boundaries
-    IF ( decycle_chem_lr  .AND.  bc_lr_cyc )  THEN
-
-       DO  boundary = 1, 2
-
-          IF ( decycle_method(boundary) == 'dirichlet' )  THEN
-!    
-!--          Initial profile is copied to ghost and first three layers          
-             ss = 1
-             ee = 0
-             IF ( boundary == 1  .AND.  nxl == 0 )  THEN
-                ss = nxlg
-                ee = nxl+2
-             ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
-                ss = nxr-2
-                ee = nxrg
+    CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'start' )
+
+    DO  lsp = 1, nspec
+
+       CALL exchange_horiz( chem_species(lsp)%conc_p, nbgp )
+       lsp_usr = 1
+       DO WHILE ( TRIM( cs_name( lsp_usr ) ) /= 'novalue' )
+          IF ( TRIM(chem_species(lsp)%name) == TRIM(cs_name(lsp_usr)) )  THEN
+
+             cs_3d = chem_species(lsp)%conc_p
+             cs_pr_init = chem_species(lsp)%conc_pr_init
+
+             flag = 0.0_wp
+         !
+         !-- Left and right boundaries
+             IF ( decycle_chem_lr  .AND.  bc_lr_cyc )  THEN
+
+                DO  boundary = 1, 2
+
+                   IF ( decycle_method(boundary) == 'dirichlet' )  THEN
+         !
+         !--          Initial profile is copied to ghost and first three layers
+                      ss = 1
+                      ee = 0
+                      IF ( boundary == 1  .AND.  nxl == 0 )  THEN
+                         ss = nxlg
+                         ee = nxl+2
+                      ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
+                         ss = nxr-2
+                         ee = nxrg
+                      ENDIF
+
+                      DO  i = ss, ee
+                         DO  j = nysg, nyng
+                            DO  k = nzb+1, nzt
+                               flag = MERGE( 1.0_wp, 0.0_wp,                            &
+                                             BTEST( wall_flags_0(k,j,i), 0 ) )
+                               cs_3d(k,j,i) = cs_pr_init(k) * flag
+                            ENDDO
+                         ENDDO
+                      ENDDO
+
+                 ELSEIF ( decycle_method(boundary) == 'neumann' )  THEN
+         !
+         !--          The value at the boundary is copied to the ghost layers to simulate
+         !--          an outlet with zero gradient
+                      ss = 1
+                      ee = 0
+                      IF ( boundary == 1  .AND.  nxl == 0 )  THEN
+                         ss = nxlg
+                         ee = nxl-1
+                         copied = nxl
+                      ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
+                         ss = nxr+1
+                         ee = nxrg
+                         copied = nxr
+                      ENDIF
+
+                       DO  i = ss, ee
+                         DO  j = nysg, nyng
+                            DO  k = nzb+1, nzt
+                               flag = MERGE( 1.0_wp, 0.0_wp,                            &
+                                             BTEST( wall_flags_0(k,j,i), 0 ) )
+                              cs_3d(k,j,i) = cs_3d(k,j,copied) * flag
+                            ENDDO
+                         ENDDO
+                      ENDDO
+
+                   ELSE
+                      WRITE(message_string,*)                                           &
+                                          'unknown decycling method: decycle_method (', &
+                              boundary, ') ="' // TRIM( decycle_method(boundary) ) // '"'
+                      CALL message( 'chem_boundary_conds_decycle', 'CM0431',           &
+                                    1, 2, 0, 6, 0 )
+                   ENDIF
+                ENDDO
              ENDIF
-
-             DO  i = ss, ee
-                DO  j = nysg, nyng
-                   DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_0(k,j,i), 0 ) )
-                      cs_3d(k,j,i) = cs_pr_init(k) * flag
-                   ENDDO
+         !
+         !-- South and north boundaries
+             IF ( decycle_chem_ns  .AND.  bc_ns_cyc )  THEN
+
+                DO  boundary = 3, 4
+
+                   IF ( decycle_method(boundary) == 'dirichlet' )  THEN
+         !
+         !--          Initial profile is copied to ghost and first three layers
+                      ss = 1
+                      ee = 0
+                      IF ( boundary == 3  .AND.  nys == 0 )  THEN
+                         ss = nysg
+                         ee = nys+2
+                      ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
+                         ss = nyn-2
+                         ee = nyng
+                      ENDIF
+
+                      DO  i = nxlg, nxrg
+                         DO  j = ss, ee
+                            DO  k = nzb+1, nzt
+                               flag = MERGE( 1.0_wp, 0.0_wp,                            &
+                                             BTEST( wall_flags_0(k,j,i), 0 ) )
+                               cs_3d(k,j,i) = cs_pr_init(k) * flag
+                            ENDDO
+                         ENDDO
+                      ENDDO
+
+
+                 ELSEIF ( decycle_method(boundary) == 'neumann' )  THEN
+         !
+         !--          The value at the boundary is copied to the ghost layers to simulate
+         !--          an outlet with zero gradient
+                      ss = 1
+                      ee = 0
+                      IF ( boundary == 3  .AND.  nys == 0 )  THEN
+                         ss = nysg
+                         ee = nys-1
+                         copied = nys
+                      ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
+                         ss = nyn+1
+                         ee = nyng
+                         copied = nyn
+                      ENDIF
+
+                       DO  i = nxlg, nxrg
+                         DO  j = ss, ee
+                            DO  k = nzb+1, nzt
+                               flag = MERGE( 1.0_wp, 0.0_wp,                            &
+                                             BTEST( wall_flags_0(k,j,i), 0 ) )
+                               cs_3d(k,j,i) = cs_3d(k,copied,i) * flag
+                            ENDDO
+                         ENDDO
+                      ENDDO
+
+                   ELSE
+                      WRITE(message_string,*)                                           &
+                                          'unknown decycling method: decycle_method (', &
+                              boundary, ') ="' // TRIM( decycle_method(boundary) ) // '"'
+                      CALL message( 'chem_boundary_conds_decycle', 'CM0432',           &
+                                    1, 2, 0, 6, 0 )
+                   ENDIF
                 ENDDO
-             ENDDO
-
-        ELSEIF ( decycle_method(boundary) == 'neumann' )  THEN
-!
-!--          The value at the boundary is copied to the ghost layers to simulate
-!--          an outlet with zero gradient
-             ss = 1
-             ee = 0
-             IF ( boundary == 1  .AND.  nxl == 0 )  THEN
-                ss = nxlg
-                ee = nxl-1
-                copied = nxl
-             ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
-                ss = nxr+1
-                ee = nxrg
-                copied = nxr
              ENDIF
 
-              DO  i = ss, ee
-                DO  j = nysg, nyng
-                   DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_0(k,j,i), 0 ) )
-                     cs_3d(k,j,i) = cs_3d(k,j,copied) * flag
-                   ENDDO
-                ENDDO
-             ENDDO
-
-          ELSE
-             WRITE(message_string,*)                                           &
-                                 'unknown decycling method: decycle_method (', &
-                     boundary, ') ="' // TRIM( decycle_method(boundary) ) // '"'
-             CALL message( 'chem_boundary_conds_decycle', 'CM0431',           &
-                           1, 2, 0, 6, 0 )
           ENDIF
+
+          lsp_usr = lsp_usr + 1
+
        ENDDO
-    ENDIF
-!
-!-- South and north boundaries
-    IF ( decycle_chem_ns  .AND.  bc_ns_cyc )  THEN
-
-       DO  boundary = 3, 4
-
-          IF ( decycle_method(boundary) == 'dirichlet' )  THEN
-!    
-!--          Initial profile is copied to ghost and first three layers          
-             ss = 1
-             ee = 0
-             IF ( boundary == 3  .AND.  nys == 0 )  THEN
-                ss = nysg
-                ee = nys+2
-             ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
-                ss = nyn-2
-                ee = nyng
-             ENDIF
-
-             DO  i = nxlg, nxrg
-                DO  j = ss, ee
-                   DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_0(k,j,i), 0 ) )
-                      cs_3d(k,j,i) = cs_pr_init(k) * flag
-                   ENDDO
-                ENDDO
-             ENDDO
-
-
-        ELSEIF ( decycle_method(boundary) == 'neumann' )  THEN
-!
-!--          The value at the boundary is copied to the ghost layers to simulate
-!--          an outlet with zero gradient
-             ss = 1
-             ee = 0
-             IF ( boundary == 3  .AND.  nys == 0 )  THEN
-                ss = nysg
-                ee = nys-1
-                copied = nys
-             ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
-                ss = nyn+1
-                ee = nyng
-                copied = nyn
-             ENDIF
-
-              DO  i = nxlg, nxrg
-                DO  j = ss, ee
-                   DO  k = nzb+1, nzt
-                      flag = MERGE( 1.0_wp, 0.0_wp,                            &
-                                    BTEST( wall_flags_0(k,j,i), 0 ) )
-                      cs_3d(k,j,i) = cs_3d(k,copied,i) * flag
-                   ENDDO
-                ENDDO
-             ENDDO
-
-          ELSE
-             WRITE(message_string,*)                                           &
-                                 'unknown decycling method: decycle_method (', &
-                     boundary, ') ="' // TRIM( decycle_method(boundary) ) // '"'
-             CALL message( 'chem_boundary_conds_decycle', 'CM0432',           &
-                           1, 2, 0, 6, 0 )
-          ENDIF
-       ENDDO
-    ENDIF
+
+    ENDDO
+
+    CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'stop' )
+
  END SUBROUTINE chem_boundary_conds_decycle
 
Index: /palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- /palm/trunk/SOURCE/prognostic_equations.f90	(revision 3878)
+++ /palm/trunk/SOURCE/prognostic_equations.f90	(revision 3879)
@@ -41,5 +41,5 @@
 ! 
 ! 3840 2019-03-29 10:35:52Z knoop
-! added USE chem_gasphase_mod for nvar, nspec and spc_names
+! added USE chem_gasphase_mod for nspec, nspec and spc_names
 ! 
 ! 3820 2019-03-27 11:53:41Z forkel
@@ -388,12 +388,11 @@
 
     USE chem_modules,                                                          &
-        ONLY:  call_chem_at_all_substeps, chem_gasphase_on, cs_name,           &
-               deposition_dry, chem_species
+        ONLY:  chem_gasphase_on, deposition_dry, chem_species
 
     USE chem_gasphase_mod,                                                     &
-        ONLY:  nspec, nvar, spc_names
+        ONLY:  nspec, spc_names
 
     USE chemistry_model_mod,                                                   &
-        ONLY:  chem_boundary_conds, chem_prognostic_equations
+        ONLY:  chem_boundary_conds_decycle, chem_prognostic_equations
 
     USE control_parameters,                                                    &
@@ -520,5 +519,4 @@
     LOGICAL      ::  loop_start          !<
     INTEGER(iwp) ::  lsp
-    INTEGER(iwp) ::  lsp_usr             !< lsp running index for chem spcs
 
 
@@ -538,26 +536,5 @@
     !$OMP END PARALLEL
 
-    IF ( air_chemistry )  THEN
-!
-!--    Loop over chemical species       
-       CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'start' )
-       DO  lsp = 1, nspec
-          CALL exchange_horiz( chem_species(lsp)%conc, nbgp )    
-          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_p,                                 &
-                                          chem_species(lsp)%conc_pr_init ) 
-             
-             ENDIF
-             lsp_usr = lsp_usr +1
-          ENDDO
-
-
-       ENDDO
-       CALL cpu_log( log_point_s(84), 'chem.exch-horiz', 'stop' )
-
-    ENDIF
+    IF ( air_chemistry )  CALL chem_boundary_conds_decycle
 !
 !-- Run SALSA and aerosol dynamic processes. SALSA is run with a longer time 
@@ -1142,5 +1119,5 @@
 !
 !--          Loop over chemical species
-             DO  lsp = 1, nvar                         
+             DO  lsp = 1, nspec
                 CALL chem_prognostic_equations( chem_species(lsp)%conc_p,      &
                                      chem_species(lsp)%conc,                   &
@@ -1924,5 +1901,5 @@
 !
 !--    Loop over chemical species
-       DO  lsp = 1, nvar                         
+       DO  lsp = 1, nspec
           CALL chem_prognostic_equations( chem_species(lsp)%conc_p,            &
                                           chem_species(lsp)%conc,              &
Index: /palm/trunk/SOURCE/time_integration.f90
===================================================================
--- /palm/trunk/SOURCE/time_integration.f90	(revision 3878)
+++ /palm/trunk/SOURCE/time_integration.f90	(revision 3879)
@@ -38,5 +38,5 @@
 ! 
 ! 3833 2019-03-28 15:04:04Z forkel
-! added USE chem_gasphase_mod, replaced nspec by nvar since fixed compounds are not integrated
+! added USE chem_gasphase_mod, replaced nspec by nspec since fixed compounds are not integrated
 ! 
 ! 3820 2019-03-27 11:53:41Z forkel
@@ -506,11 +506,11 @@
 
     USE chem_gasphase_mod,                                                                         &
-        ONLY:  nvar
+        ONLY:  nspec
 
     USE chem_modules,                                                                              &
-        ONLY:  bc_cs_t_val, cs_name, emissions_anthropogenic, nspec_out, chem_species
+        ONLY:  bc_cs_t_val, emissions_anthropogenic, nspec_out, chem_species
 
     USE chemistry_model_mod,                                                                       &
-        ONLY:  chem_boundary_conds
+        ONLY:  chem_boundary_conds_decycle
 
     USE control_parameters,                                                                        &
@@ -680,6 +680,4 @@
     INTEGER(iwp)      ::  icc       !< additional index for aerosol mass bins
     INTEGER(iwp)      ::  ig        !< index for salsa gases
-    INTEGER(iwp)      ::  lsp
-    INTEGER(iwp)      ::  lsp_usr   !<
     INTEGER(iwp)      ::  n         !< loop counter for chemistry species
 
@@ -859,7 +857,7 @@
            bc_q_t_val  = ( q_init(nzt+1) - q_init(nzt) ) / dzu(nzt+1)
            IF ( air_chemistry )  THEN
-              DO  lsp = 1, nvar
-                 bc_cs_t_val = (  chem_species(lsp)%conc_pr_init(nzt+1)                            &
-                                - chem_species(lsp)%conc_pr_init(nzt) )                            &
+              DO  n = 1, nspec
+                 bc_cs_t_val = (  chem_species(n)%conc_pr_init(nzt+1)                            &
+                                - chem_species(n)%conc_pr_init(nzt) )                            &
                                / dzu(nzt+1)
               ENDDO
@@ -1036,19 +1034,5 @@
           ENDIF
           IF ( passive_scalar )  CALL exchange_horiz( s_p, nbgp )
-          IF ( air_chemistry )  THEN
-             DO  lsp = 1, nvar
-                CALL exchange_horiz( chem_species(lsp)%conc_p, nbgp )
-!
-!--             kanani: Push chem_boundary_conds after CALL boundary_conds
-                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_p,                          &
-                                                chem_species(lsp)%conc_pr_init )
-                   ENDIF
-                   lsp_usr = lsp_usr + 1
-                ENDDO
-             ENDDO
-          ENDIF
+          IF ( air_chemistry  )  CALL chem_boundary_conds_decycle
 
           IF ( salsa  .AND.  time_since_reference_point >= skip_time_do_salsa )  THEN
@@ -1133,5 +1117,5 @@
 
                 IF ( air_chemistry )  THEN
-                   DO  n = 1, nvar     
+                   DO  n = 1, nspec
                       CALL exchange_horiz( chem_species(n)%conc, nbgp ) 
                    ENDDO
