Index: palm/trunk/SOURCE/chem_modules.f90
===================================================================
--- palm/trunk/SOURCE/chem_modules.f90	(revision 4272)
+++ palm/trunk/SOURCE/chem_modules.f90	(revision 4273)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Add logical switches nesting_chem and nesting_offline_chem (both .TRUE.
+! by default)
+! 
+! 4182 2019-08-22 15:20:23Z scharf
 ! Corrected "Former revisions" section
 ! 
@@ -134,4 +138,6 @@
     LOGICAL ::  emissions_anthropogenic   = .FALSE.  !< namelist parameter: flag for turning on anthropogenic emissions
     LOGICAL ::  emission_output_required  = .TRUE.   !< internal flag for requiring emission outputs
+    LOGICAL ::  nesting_chem              = .TRUE.   !< apply self-nesting for the chemistry model
+    LOGICAL ::  nesting_offline_chem      = .TRUE.   !< apply offline nesting for the chemistry model
 
     REAL(wp) ::  cs_surface_initial_change(99)     = 0.0_wp        !< namelist parameter: ...???
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4272)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4273)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Add logical switches nesting_chem and nesting_offline_chem (both .TRUE.
+! by default)
+! 
+! 4272 2019-10-23 15:18:57Z schwenkel
 ! Further modularization of boundary conditions: moved boundary conditions to
 ! respective modules
@@ -859,148 +863,149 @@
  SUBROUTINE chem_boundary_conds_decycle( cs_3d, cs_pr_init )
 
-
-   INTEGER(iwp) ::  boundary  !< 
-   INTEGER(iwp) ::  ee        !<
-   INTEGER(iwp) ::  copied    !< 
-   INTEGER(iwp) ::  i         !< 
-   INTEGER(iwp) ::  j         !< 
-   INTEGER(iwp) ::  k         !< 
-   INTEGER(iwp) ::  ss        !<
-
-   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-1
-            ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
-               ss = nxr+1
-               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
-   !
-   !-- 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-1
-            ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
-               ss = nyn+1
-               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
+    USE control_parameters,                                                                         &
+        ONLY:  nesting_offline
+
+    INTEGER(iwp) ::  boundary  !< 
+    INTEGER(iwp) ::  ee        !<
+    INTEGER(iwp) ::  copied    !< 
+    INTEGER(iwp) ::  i         !< 
+    INTEGER(iwp) ::  j         !< 
+    INTEGER(iwp) ::  k         !< 
+    INTEGER(iwp) ::  ss        !<
+
+    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
+!
+!-- Skip input if forcing from a larger-scale model is applied
+    IF ( nesting_offline  .AND.  nesting_offline_chem )  RETURN
+!
+!-- 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-1
+             ELSEIF ( boundary == 2  .AND.  nxr == nx )  THEN
+                ss = nxr+1
+                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
+!
+!-- 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-1
+             ELSEIF ( boundary == 4  .AND.  nyn == ny )  THEN
+                ss = nyn+1
+                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
 
 
@@ -1175,4 +1180,10 @@
        message_string = 'Incorrect chemistry mechanism selected, check spelling in namelist and/or chem_gasphase_mod'
        CALL message( 'chem_check_parameters', 'CM0462', 1, 2, 0, 6, 0 )
+    ENDIF
+!
+!-- If nesting_chem = .F., set top boundary condition to its default value
+    IF ( .NOT. nesting_chem  .AND.  ibc_cs_t == 3  )  THEN
+       ibc_cs_t = 2
+       bc_cs_t = 'initial_gradient'
     ENDIF
 !
@@ -1681,4 +1692,7 @@
        WRITE ( io, 11 )  docsinit_chr
     ENDIF
+
+    IF ( nesting_chem )  WRITE( io, 12 )  nesting_chem
+    IF ( nesting_offline_chem )  WRITE( io, 13 )  nesting_offline_chem
 !
 !-- number of variable and fix chemical species and number of reactions
@@ -1703,4 +1717,6 @@
 10  FORMAT (/'    ',A)  
 11  FORMAT (/'    ',A) 
+12  FORMAT (/'   Nesting for chemistry variables: ', L1 )
+13  FORMAT (/'   Offline nesting for chemistry variables: ', L1 )
 !
 !
@@ -2267,4 +2283,6 @@
          mode_emis,                        &
          my_steps,                         &
+         nesting_chem,                     &
+         nesting_offline_chem,             &
          rcntrl,                           &
          side_street_id,                   &
Index: palm/trunk/SOURCE/nesting_offl_mod.f90
===================================================================
--- palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4272)
+++ palm/trunk/SOURCE/nesting_offl_mod.f90	(revision 4273)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Add a logical switch nesting_offline_chem
+! 
+! 4270 2019-10-23 10:46:20Z monakurppa
 ! Implement offline nesting for salsa variables.
 ! 
@@ -139,7 +142,7 @@
            ONLY:  g,                                                           &
                   pi
-                 
+
     USE chem_modules,                                                          &
-        ONLY:  chem_species
+        ONLY:  chem_species, nesting_offline_chem
 
     USE control_parameters,                                                    &
@@ -170,5 +173,5 @@
                time_since_reference_point,                                     &
                volume_flow
-               
+
     USE cpulog,                                                                &
         ONLY:  cpu_log,                                                        &
@@ -520,9 +523,9 @@
                              .TRUE. )
        ENDIF
-       
-       IF ( air_chemistry )  THEN
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND(nest_offl%var_names_chem_l, 1)
              IF ( check_existence( nest_offl%var_names,                        &
-                                   nest_offl%var_names_chem_l(n) ) )  THEN  
+                                   nest_offl%var_names_chem_l(n) ) )  THEN
                 CALL get_variable( pids_id,                                    &
                            TRIM( nest_offl%var_names_chem_l(n) ),              &
@@ -594,9 +597,9 @@
                              .TRUE. )
        ENDIF
-       
-       IF ( air_chemistry )  THEN
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND(nest_offl%var_names_chem_r, 1)
              IF ( check_existence( nest_offl%var_names,                        &
-                                   nest_offl%var_names_chem_r(n) ) )  THEN     
+                                   nest_offl%var_names_chem_r(n) ) )  THEN
                 CALL get_variable( pids_id,                                    &
                            TRIM( nest_offl%var_names_chem_r(n) ),              &
@@ -623,6 +626,6 @@
                           MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
+                          .TRUE. )
+
        CALL get_variable( pids_id, 'ls_forcing_north_v',                       & ! array to be read
                           nest_offl%v_north,                                   & ! start index x direction
@@ -633,6 +636,6 @@
                           MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
+                          .TRUE. )
+
        CALL get_variable( pids_id, 'ls_forcing_north_w',                       & ! array to be read
                           nest_offl%w_north,                                   & ! start index x direction
@@ -643,7 +646,7 @@
                           MERGE( nest_offl%nzw, 0, bc_dirichlet_n ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_n ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
-       IF ( .NOT. neutral )  THEN                                              
+                          .TRUE. )
+
+       IF ( .NOT. neutral )  THEN
           CALL get_variable( pids_id, 'ls_forcing_north_pt',                   & ! array to be read
                              nest_offl%pt_north,                               & ! start index x direction
@@ -654,7 +657,7 @@
                              MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),        & ! number of time steps (2 or 0)
                              MERGE( 2, 0, bc_dirichlet_n ),                    & ! parallel IO when compiled accordingly
-                             .TRUE. )                                             
-       ENDIF                                                                   
-       IF ( humidity )  THEN                                                   
+                             .TRUE. )
+       ENDIF
+       IF ( humidity )  THEN
           CALL get_variable( pids_id, 'ls_forcing_north_qv',                   & ! array to be read
                              nest_offl%q_north,                                & ! start index x direction
@@ -665,11 +668,11 @@
                              MERGE( nest_offl%nzu, 0, bc_dirichlet_n ),        & ! number of time steps (2 or 0)
                              MERGE( 2, 0, bc_dirichlet_n ),                    & ! parallel IO when compiled accordingly
-                             .TRUE. )                                             
-       ENDIF                                                                   
-                                                                               
-       IF ( air_chemistry )  THEN                                              
-          DO  n = 1, UBOUND(nest_offl%var_names_chem_n, 1)                     
+                             .TRUE. )
+       ENDIF
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_n, 1)
              IF ( check_existence( nest_offl%var_names,                        &
-                                   nest_offl%var_names_chem_n(n) ) )  THEN     
+                                   nest_offl%var_names_chem_n(n) ) )  THEN
                 CALL get_variable( pids_id,                                    &
                            TRIM( nest_offl%var_names_chem_n(n) ),              &
@@ -696,6 +699,6 @@
                           MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
+                          .TRUE. )
+
        CALL get_variable( pids_id, 'ls_forcing_south_v',                       & ! array to be read
                           nest_offl%v_south,                                   & ! start index x direction
@@ -706,6 +709,6 @@
                           MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
+                          .TRUE. )
+
        CALL get_variable( pids_id, 'ls_forcing_south_w',                       & ! array to be read
                           nest_offl%w_south,                                   & ! start index x direction
@@ -716,7 +719,7 @@
                           MERGE( nest_offl%nzw, 0, bc_dirichlet_s ),           & ! number of time steps (2 or 0)
                           MERGE( 2, 0, bc_dirichlet_s ),                       & ! parallel IO when compiled accordingly
-                          .TRUE. )                                             
-                                                                               
-       IF ( .NOT. neutral )  THEN                                              
+                          .TRUE. )
+
+       IF ( .NOT. neutral )  THEN
           CALL get_variable( pids_id, 'ls_forcing_south_pt',                   & ! array to be read
                              nest_offl%pt_south,                               & ! start index x direction
@@ -727,7 +730,7 @@
                              MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),        & ! number of time steps (2 or 0)
                              MERGE( 2, 0, bc_dirichlet_s ),                    & ! parallel IO when compiled accordingly
-                             .TRUE. )                                             
-       ENDIF                                                                   
-       IF ( humidity )  THEN                                                   
+                             .TRUE. )
+       ENDIF
+       IF ( humidity )  THEN
           CALL get_variable( pids_id, 'ls_forcing_south_qv',                   & ! array to be read
                              nest_offl%q_south,                                & ! start index x direction
@@ -738,11 +741,11 @@
                              MERGE( nest_offl%nzu, 0, bc_dirichlet_s ),        & ! number of time steps (2 or 0)
                              MERGE( 2, 0, bc_dirichlet_s ),                    & ! parallel IO when compiled accordingly
-                             .TRUE. )                                             
-       ENDIF                                                                   
-                                                                               
-       IF ( air_chemistry )  THEN                                              
-          DO  n = 1, UBOUND(nest_offl%var_names_chem_s, 1)                     
+                             .TRUE. )
+       ENDIF
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
+          DO  n = 1, UBOUND(nest_offl%var_names_chem_s, 1)
              IF ( check_existence( nest_offl%var_names,                        &
-                                   nest_offl%var_names_chem_s(n) ) )  THEN     
+                                   nest_offl%var_names_chem_s(n) ) )  THEN
                 CALL get_variable( pids_id,                                    &
                            TRIM( nest_offl%var_names_chem_s(n) ),              &
@@ -770,10 +773,10 @@
                              nxl+1, nysv, nest_offl%tind+1,                    &
                              nxr-nxl+1, nyn-nysv+1, 2, .TRUE. )
-                             
+
        CALL get_variable( pids_id, 'ls_forcing_top_w',                         &
                              nest_offl%w_top(0:1,nys:nyn,nxl:nxr),             &
                              nxl+1, nys+1, nest_offl%tind+1,                   &
                              nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
-                             
+
        IF ( .NOT. neutral )  THEN
           CALL get_variable( pids_id, 'ls_forcing_top_pt',                     &
@@ -788,9 +791,9 @@
                                 nxr-nxl+1, nyn-nys+1, 2, .TRUE. )
        ENDIF
-       
-       IF ( air_chemistry )  THEN
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND(nest_offl%var_names_chem_t, 1)
              IF ( check_existence( nest_offl%var_names,                        &
-                                   nest_offl%var_names_chem_t(n) ) )  THEN      
+                                   nest_offl%var_names_chem_t(n) ) )  THEN
                 CALL get_variable( pids_id,                                    &
                               TRIM( nest_offl%var_names_chem_t(n) ),           &
@@ -961,5 +964,5 @@
        u_ref    = 0.0_wp
        v_ref    = 0.0_wp
-       
+
        pt_ref_l = 0.0_wp
        q_ref_l  = 0.0_wp
@@ -968,5 +971,5 @@
 !
 !--    If required, allocate temporary arrays to compute chemistry mean profiles
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           ALLOCATE( ref_chem(nzb:nzt+1,1:UBOUND( chem_species, 1 ) )   )
           ALLOCATE( ref_chem_l(nzb:nzt+1,1:UBOUND( chem_species, 1 ) ) )
@@ -1043,8 +1046,8 @@
              ENDDO
           ENDIF
-          
-          IF ( air_chemistry )  THEN
+
+          IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
              DO  n = 1, UBOUND( chem_species, 1 )
-                IF ( nest_offl%chem_from_file_l(n) )  THEN                   
+                IF ( nest_offl%chem_from_file_l(n) )  THEN
                    DO  j = nys, nyn
                       DO  k = nzb+1, nzt
@@ -1121,8 +1124,8 @@
              ENDDO
           ENDIF
-          
-          IF ( air_chemistry )  THEN
+
+          IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
              DO  n = 1, UBOUND( chem_species, 1 )
-                IF ( nest_offl%chem_from_file_r(n) )  THEN  
+                IF ( nest_offl%chem_from_file_r(n) )  THEN
                    DO  j = nys, nyn
                       DO  k = nzb+1, nzt
@@ -1202,8 +1205,8 @@
              ENDDO
           ENDIF
-          
-          IF ( air_chemistry )  THEN
+
+          IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
              DO  n = 1, UBOUND( chem_species, 1 )
-                IF ( nest_offl%chem_from_file_s(n) )  THEN  
+                IF ( nest_offl%chem_from_file_s(n) )  THEN
                    DO  i = nxl, nxr
                       DO  k = nzb+1, nzt
@@ -1282,8 +1285,8 @@
              ENDDO
           ENDIF
-          
-          IF ( air_chemistry )  THEN
+
+          IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
              DO  n = 1, UBOUND( chem_species, 1 )
-                IF ( nest_offl%chem_from_file_n(n) )  THEN  
+                IF ( nest_offl%chem_from_file_n(n) )  THEN
                    DO  i = nxl, nxr
                       DO  k = nzb+1, nzt
@@ -1368,8 +1371,8 @@
           ENDDO
        ENDIF
-       
-       IF ( air_chemistry )  THEN
+
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND( chem_species, 1 )
-             IF ( nest_offl%chem_from_file_t(n) )  THEN  
+             IF ( nest_offl%chem_from_file_t(n) )  THEN
                 DO  i = nxl, nxr
                    DO  j = nys, nyn
@@ -1413,5 +1416,5 @@
        IF ( .NOT. neutral )  CALL exchange_horiz( pt, nbgp )
        IF ( humidity      )  CALL exchange_horiz( q,  nbgp )
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND( chem_species, 1 )
 !
@@ -1447,5 +1450,5 @@
                               comm2d, ierr )
        ENDIF
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           CALL MPI_ALLREDUCE( ref_chem_l, ref_chem,                            &
                               ( nzt+1-nzb+1 ) * SIZE( ref_chem(nzb,:) ),       &
@@ -1457,5 +1460,5 @@
        IF ( humidity )       q_ref    = q_ref_l
        IF ( .NOT. neutral )  pt_ref   = pt_ref_l
-       IF ( air_chemistry )  ref_chem = ref_chem_l
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  ref_chem = ref_chem_l
 #endif
 !
@@ -1476,5 +1479,5 @@
                                                           ( ny + 1 + nx + 1 ), &
                                               KIND = wp )
-       IF ( air_chemistry )                                                    &
+       IF ( air_chemistry  .AND.  nesting_offline_chem )                       &
           ref_chem(nzb:nzt,:) = ref_chem(nzb:nzt,:) / REAL( 2.0_wp *           &
                                                           ( ny + 1 + nx + 1 ), &
@@ -1490,5 +1493,5 @@
           pt_ref(nzt+1) = pt_ref(nzt+1) / REAL( ( ny + 1 ) * ( nx + 1 ),       &
                                                 KIND = wp )
-       IF ( air_chemistry )                                                    &
+       IF ( air_chemistry  .AND.  nesting_offline_chem )                       &
           ref_chem(nzt+1,:) = ref_chem(nzt+1,:) /                              &
                               REAL( ( ny + 1 ) * ( nx + 1 ),KIND = wp )
@@ -1508,5 +1511,5 @@
        ENDIF
 
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           DO  n = 1, UBOUND( chem_species, 1 )
              IF ( nest_offl%chem_from_file_t(n) )  THEN 
@@ -1519,5 +1522,5 @@
 
        IF ( ALLOCATED( ref_chem   ) )  DEALLOCATE( ref_chem   )
-       IF ( ALLOCATED( ref_chem_l ) )  DEALLOCATE( ref_chem_l )     
+       IF ( ALLOCATED( ref_chem_l ) )  DEALLOCATE( ref_chem_l )
 !
 !--    Further, adjust Rayleigh damping height in case of time-changing conditions.
@@ -1525,5 +1528,5 @@
        CALL nesting_offl_calc_zi
        CALL adjust_sponge_layer 
-       
+
        CALL  cpu_log( log_point(58), 'offline nesting', 'stop' )
 
@@ -1893,6 +1896,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_left(0:1,nzb+1:nzt,nys:nyn)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_left(0:1,nzb+1:nzt,nys:nyn) )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_left(0:1,nzb+1:nzt,nys:nyn,&
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_left(0:1,nzb+1:nzt,nys:nyn,1:UBOUND( chem_species, 1 )) )
        ELSE
           ALLOCATE( nest_offl%u_left(1:1,1:1,1:1)  )
@@ -1901,6 +1904,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_left(1:1,1:1,1:1)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_left(1:1,1:1,1:1)  )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_left(1:1,1:1,1:1,     &
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_left(1:1,1:1,1:1,1:UBOUND( chem_species, 1 )) )
        ENDIF
        IF ( bc_dirichlet_r )  THEN
@@ -1910,6 +1913,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_right(0:1,nzb+1:nzt,nys:nyn)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_right(0:1,nzb+1:nzt,nys:nyn) )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_right(0:1,nzb+1:nzt,nys:nyn,&
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_right(0:1,nzb+1:nzt,nys:nyn,1:UBOUND( chem_species, 1 )) )
        ELSE
           ALLOCATE( nest_offl%u_right(1:1,1:1,1:1)  )
@@ -1918,6 +1921,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_right(1:1,1:1,1:1)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_right(1:1,1:1,1:1)  )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_right(1:1,1:1,1:1,    &
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_right(1:1,1:1,1:1,1:UBOUND( chem_species, 1 )) )
        ENDIF
 !
@@ -1932,6 +1935,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_north(0:1,nzb+1:nzt,nxl:nxr)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_north(0:1,nzb+1:nzt,nxl:nxr) )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_north(0:1,nzb+1:nzt,nxl:nxr,&
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_north(0:1,nzb+1:nzt,nxl:nxr,1:UBOUND( chem_species, 1 )) )
        ELSE
           ALLOCATE( nest_offl%u_north(1:1,1:1,1:1)  )
@@ -1940,6 +1943,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_north(1:1,1:1,1:1)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_north(1:1,1:1,1:1)  )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_north(1:1,1:1,1:1,    &
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_north(1:1,1:1,1:1,1:UBOUND( chem_species, 1 )) )
        ENDIF
        IF ( bc_dirichlet_s )  THEN
@@ -1949,6 +1952,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_south(0:1,nzb+1:nzt,nxl:nxr)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_south(0:1,nzb+1:nzt,nxl:nxr) )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_south(0:1,nzb+1:nzt,nxl:nxr,&
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_south(0:1,nzb+1:nzt,nxl:nxr,1:UBOUND( chem_species, 1 )) )
        ELSE
           ALLOCATE( nest_offl%u_south(1:1,1:1,1:1)  )
@@ -1957,6 +1960,6 @@
           IF ( humidity )       ALLOCATE( nest_offl%q_south(1:1,1:1,1:1)  )
           IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_south(1:1,1:1,1:1)  )
-          IF ( air_chemistry )  ALLOCATE( nest_offl%chem_south(1:1,1:1,1:1,    &
-                                          1:UBOUND( chem_species, 1 )) )
+          IF ( air_chemistry  .AND.  nesting_offline_chem )                                        &
+             ALLOCATE( nest_offl%chem_south(1:1,1:1,1:1,1:UBOUND( chem_species, 1 )) )
        ENDIF
 !
@@ -1969,11 +1972,11 @@
        IF ( humidity )       ALLOCATE( nest_offl%q_top(0:1,nys:nyn,nxl:nxr)  )
        IF ( .NOT. neutral )  ALLOCATE( nest_offl%pt_top(0:1,nys:nyn,nxl:nxr) )
-       IF ( air_chemistry )  ALLOCATE( nest_offl%chem_top(0:1,nys:nyn,nxl:nxr, &
-                                       1:UBOUND( chem_species, 1 )) )
+       IF ( air_chemistry  .AND.  nesting_offline_chem )                                           &
+          ALLOCATE( nest_offl%chem_top(0:1,nys:nyn,nxl:nxr,1:UBOUND( chem_species, 1 )) )
 !
 !--    For chemical species, create the names of the variables. This is necessary
 !--    to identify the respective variable and write it onto the correct array 
 !--    in the chem_species datatype.
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
           ALLOCATE( nest_offl%chem_from_file_l(1:UBOUND( chem_species, 1 )) )
           ALLOCATE( nest_offl%chem_from_file_n(1:UBOUND( chem_species, 1 )) )
@@ -1981,5 +1984,5 @@
           ALLOCATE( nest_offl%chem_from_file_s(1:UBOUND( chem_species, 1 )) )
           ALLOCATE( nest_offl%chem_from_file_t(1:UBOUND( chem_species, 1 )) )
-          
+
           ALLOCATE( nest_offl%var_names_chem_l(1:UBOUND( chem_species, 1 )) )
           ALLOCATE( nest_offl%var_names_chem_n(1:UBOUND( chem_species, 1 )) )
@@ -1995,5 +1998,5 @@
           nest_offl%chem_from_file_s(:) = .FALSE.
           nest_offl%chem_from_file_t(:) = .FALSE.
-          
+
           DO  n = 1, UBOUND( chem_species, 1 )
              nest_offl%var_names_chem_l(n) = nest_offl%char_l //               &
@@ -2054,5 +2057,5 @@
              IF ( humidity      )  q(nzb+1:nzt,nys:nyn,-1)  =                  &
                                       nest_offl%q_left(0,nzb+1:nzt,nys:nyn)
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
                 DO  n = 1, UBOUND( chem_species, 1 )
                    IF( nest_offl%chem_from_file_l(n) )  THEN
@@ -2071,5 +2074,5 @@
              IF ( humidity      )  q(nzb+1:nzt,nys:nyn,nxr+1)  =               &
                                       nest_offl%q_right(0,nzb+1:nzt,nys:nyn)
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
                 DO  n = 1, UBOUND( chem_species, 1 )
                    IF( nest_offl%chem_from_file_r(n) )  THEN
@@ -2088,5 +2091,5 @@
              IF ( humidity      )  q(nzb+1:nzt,-1,nxl:nxr)  =                  &
                                       nest_offl%q_south(0,nzb+1:nzt,nxl:nxr) 
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
                 DO  n = 1, UBOUND( chem_species, 1 )
                    IF( nest_offl%chem_from_file_s(n) )  THEN
@@ -2105,5 +2108,5 @@
              IF ( humidity      )  q(nzb+1:nzt,nyn+1,nxl:nxr)  =               &
                                       nest_offl%q_north(0,nzb+1:nzt,nxl:nxr)
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_offline_chem )  THEN
                 DO  n = 1, UBOUND( chem_species, 1 )
                    IF( nest_offl%chem_from_file_n(n) )  THEN
@@ -2114,5 +2117,5 @@
              ENDIF
           ENDIF
-!         
+!
 !--       Initialize geostrophic wind components. Actually this is already done in
 !--       init_3d_model when initializing_action = 'inifor', however, in speical 
@@ -2121,5 +2124,5 @@
           ug(nzb+1:nzt) = nest_offl%ug(0,nzb+1:nzt)
           vg(nzb+1:nzt) = nest_offl%vg(0,nzb+1:nzt)
-!         
+!
 !--       Set bottom and top boundary condition for geostrophic wind components
           ug(nzt+1) = ug(nzt)
@@ -2127,5 +2130,5 @@
           ug(nzb)   = ug(nzb+1)
           vg(nzb)   = vg(nzb+1)
-       ENDIF      
+       ENDIF
 !
 !--    After boundary data is initialized, mask topography at the 
Index: palm/trunk/SOURCE/pmc_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4272)
+++ palm/trunk/SOURCE/pmc_interface_mod.f90	(revision 4273)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Add a logical switch nesting_chem and rename nest_salsa to nesting_salsa
+! 
+! 4260 2019-10-09 14:04:03Z hellstea
 ! Rest of the possibly round-off-error sensitive grid-line matching tests
 ! changed to round-off-error tolerant forms throughout the module.
@@ -189,5 +192,5 @@
 
     USE chem_modules,                                                          &
-        ONLY:  chem_species
+        ONLY:  chem_species, nesting_chem
 
     USE chemistry_model_mod,                                                   &
@@ -248,6 +251,6 @@
     USE salsa_mod,                                                             &
         ONLY:  aerosol_mass, aerosol_number, gconc_2, mconc_2, nbins_aerosol,  &
-               ncomponents_mass, nconc_2, nest_salsa, ngases_salsa, salsa_gas, &
-               salsa_gases_from_chem
+               ncomponents_mass, nconc_2, nesting_salsa, ngases_salsa,         &
+               salsa_gas, salsa_gases_from_chem
 
     USE surface_mod,                                                           &
@@ -1166,5 +1169,5 @@
        ENDIF
        
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_chem )  THEN
           DO n = 1, nspec
              CALL pmc_set_dataarray_name( 'parent', 'chem_' // TRIM( chem_species(n)%name ),        &
@@ -1173,5 +1176,5 @@
        ENDIF
 
-       IF ( salsa  .AND.  nest_salsa )  THEN
+       IF ( salsa  .AND.  nesting_salsa )  THEN
           DO  lb = 1, nbins_aerosol
              WRITE(salsa_char,'(i0)') lb
@@ -2310,10 +2313,10 @@
 !
 !-- Chemistry, depends on number of species
-    IF ( air_chemistry )  pmc_max_array = pmc_max_array + nspec
+    IF ( air_chemistry  .AND.  nesting_chem )  pmc_max_array = pmc_max_array + nspec
 !
 !-- SALSA, depens on the number aerosol size bins and chemical components + 
 !-- the number of default gases
-    IF ( salsa  .AND.  nest_salsa )  pmc_max_array = pmc_max_array + nbins_aerosol +                &
-         nbins_aerosol * ncomponents_mass
+    IF ( salsa  .AND.  nesting_salsa )  pmc_max_array = pmc_max_array + nbins_aerosol +            &
+                                                        nbins_aerosol * ncomponents_mass
     IF ( .NOT. salsa_gases_from_chem )  pmc_max_array = pmc_max_array + ngases_salsa
 
@@ -2717,5 +2720,5 @@
        ENDIF
 
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_chem )  THEN
           DO  n = 1, nspec
              CALL pmci_interp_1sto_all ( chem_species(n)%conc, chem_spec_c(:,:,:,n),                &
@@ -2724,5 +2727,5 @@
        ENDIF
 
-       IF ( salsa  .AND.  nest_salsa )  THEN
+       IF ( salsa  .AND.  nesting_salsa )  THEN
           DO  lb = 1, nbins_aerosol
              CALL pmci_interp_1sto_all ( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),       &
@@ -3394,5 +3397,5 @@
              ENDIF
 
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_chem )  THEN
                 DO  n = 1, nspec
                    CALL pmci_interp_1sto_lr( chem_species(n)%conc, chem_spec_c(:,:,:,n),            &
@@ -3401,5 +3404,5 @@
              ENDIF
 
-             IF ( salsa  .AND.  nest_salsa )  THEN
+             IF ( salsa  .AND.  nesting_salsa )  THEN
                 DO  lb = 1, nbins_aerosol
                    CALL pmci_interp_1sto_lr( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),   &
@@ -3465,5 +3468,5 @@
              ENDIF
 
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_chem )  THEN
                 DO  n = 1, nspec
                    CALL pmci_interp_1sto_lr( chem_species(n)%conc, chem_spec_c(:,:,:,n),            &
@@ -3472,5 +3475,5 @@
              ENDIF
 
-             IF ( salsa  .AND.  nest_salsa )  THEN
+             IF ( salsa  .AND.  nesting_salsa )  THEN
                 DO  lb = 1, nbins_aerosol
                    CALL pmci_interp_1sto_lr( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),   &
@@ -3536,5 +3539,5 @@
              ENDIF
 
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_chem )  THEN
                 DO  n = 1, nspec
                    CALL pmci_interp_1sto_sn( chem_species(n)%conc, chem_spec_c(:,:,:,n),            &
@@ -3543,5 +3546,5 @@
              ENDIF
              
-             IF ( salsa  .AND.  nest_salsa )  THEN
+             IF ( salsa  .AND.  nesting_salsa )  THEN
                 DO  lb = 1, nbins_aerosol
                    CALL pmci_interp_1sto_sn( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),   &
@@ -3607,5 +3610,5 @@
              ENDIF
 
-             IF ( air_chemistry )  THEN
+             IF ( air_chemistry  .AND.  nesting_chem )  THEN
                 DO  n = 1, nspec
                    CALL pmci_interp_1sto_sn( chem_species(n)%conc, chem_spec_c(:,:,:,n),            &
@@ -3614,5 +3617,5 @@
              ENDIF
              
-             IF ( salsa  .AND.  nest_salsa )  THEN
+             IF ( salsa  .AND.  nesting_salsa )  THEN
                 DO  lb = 1, nbins_aerosol
                    CALL pmci_interp_1sto_sn( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),   &
@@ -3673,5 +3676,5 @@
        ENDIF
 
-       IF ( air_chemistry )  THEN
+       IF ( air_chemistry  .AND.  nesting_chem )  THEN
           DO  n = 1, nspec
              CALL pmci_interp_1sto_t( chem_species(n)%conc, chem_spec_c(:,:,:,n),                   &
@@ -3680,5 +3683,5 @@
        ENDIF 
        
-       IF ( salsa  .AND.  nest_salsa )  THEN
+       IF ( salsa  .AND.  nesting_salsa )  THEN
           DO  lb = 1, nbins_aerosol
              CALL pmci_interp_1sto_t( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),          &
@@ -3764,5 +3767,5 @@
       ENDIF
 
-      IF ( air_chemistry )  THEN
+      IF ( air_chemistry  .AND.  nesting_chem )  THEN
          DO  n = 1, nspec
             CALL pmci_anterp_tophat( chem_species(n)%conc, chem_spec_c(:,:,:,n),                    &
@@ -3770,6 +3773,6 @@
          ENDDO
       ENDIF
-      
-      IF ( salsa  .AND.  nest_salsa )  THEN
+
+      IF ( salsa  .AND.  nesting_salsa )  THEN
          DO  lb = 1, nbins_aerosol
             CALL pmci_anterp_tophat( aerosol_number(lb)%conc, aerosol_number_c(:,:,:,lb),           &
@@ -4816,5 +4819,5 @@
 !
 !-- Set Neumann boundary conditions for chemical species
-    IF ( air_chemistry )  THEN
+    IF ( air_chemistry  .AND.  nesting_chem )  THEN
        IF ( ibc_cs_b == 1 )  THEN
           DO  n = 1, nspec
@@ -4836,5 +4839,5 @@
 !
 !-- Set Neumann boundary conditions for aerosols and salsa gases
-    IF ( salsa  .AND.  nest_salsa )  THEN
+    IF ( salsa  .AND.  nesting_salsa )  THEN
        IF ( ibc_salsa_b == 1 )  THEN
           DO  m = 1, bc_h(0)%ns
Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 4272)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 4273)
@@ -26,4 +26,11 @@
 ! -----------------
 ! $Id$
+! - Rename nest_salsa to nesting_salsa
+! - Correct some errors in boundary condition flags
+! - Add a check for not trying to output gas concentrations in salsa if the
+!   chemistry module is applied
+! - Set the default value of nesting_salsa and nesting_offline_salsa to .TRUE.
+! 
+! 4272 2019-10-23 15:18:57Z schwenkel
 ! Further modularization of boundary conditions: moved boundary conditions to
 ! respective modules
@@ -454,6 +461,6 @@
     LOGICAL ::  include_emission        = .FALSE.  !< Include or not emissions
     LOGICAL ::  feedback_to_palm        = .FALSE.  !< Allow feedback due to condensation of H2O
-    LOGICAL ::  nest_salsa              = .FALSE.  !< Apply nesting for salsa
-    LOGICAL ::  nesting_offline_salsa   = .FALSE.  !< Apply offline nesting for salsa
+    LOGICAL ::  nesting_salsa           = .TRUE.   !< Apply nesting for salsa
+    LOGICAL ::  nesting_offline_salsa   = .TRUE.   !< Apply offline nesting for salsa
     LOGICAL ::  no_insoluble            = .FALSE.  !< Exclude insoluble chemical components
     LOGICAL ::  read_restart_data_salsa = .FALSE.  !< Read restart data for salsa
@@ -652,5 +659,5 @@
        CHARACTER(LEN=15) ::  char_t = 'ls_forcing_top_'   !< leading substring at top boundary
 
-       CHARACTER(LEN=5), DIMENSION(1:ngases_salsa) ::  gas_name = (/'h2so4','hno3 ','nh3  ','ocnv ','ocsv '/)
+       CHARACTER(LEN=5), DIMENSION(1:ngases_salsa) ::  gas_name = (/'H2SO4','HNO3 ','NH3  ','OCNV ','OCSV '/)
 
        CHARACTER(LEN=25),  DIMENSION(:), ALLOCATABLE ::  cc_name    !< chemical component name
@@ -973,5 +980,5 @@
            init_aerosol_type,     &
            init_gases_type,       &
-           nest_salsa,            &
+           nesting_salsa,         &
            nesting_offline_salsa, &
            salsa_gases_from_chem, &
@@ -1037,5 +1044,5 @@
                                      n_lognorm,                                &
                                      nbin,                                     &
-                                     nest_salsa,                               &
+                                     nesting_salsa,                            &
                                      nesting_offline_salsa,                    &
                                      nf2a,                                     &
@@ -1102,5 +1109,5 @@
 
     USE control_parameters,                                                                        &
-        ONLY:  humidity, initializing_actions
+        ONLY:  child_domain, humidity, initializing_actions, nesting_offline
 
     IMPLICIT NONE
@@ -1111,4 +1118,16 @@
        WRITE( message_string, * ) 'salsa = ', salsa, ' is not allowed with humidity = ', humidity
        CALL message( 'salsa_check_parameters', 'PA0594', 1, 2, 0, 6, 0 )
+    ENDIF
+!
+!-- For nested runs, explicitly set nesting boundary conditions.
+    IF ( nesting_salsa  .AND. child_domain )  bc_salsa_t = 'nested'
+!
+!-- Set boundary conditions also in case the model is offline-nested in larger-scale models.
+    IF ( nesting_offline )  THEN
+       IF ( nesting_offline_salsa )  THEN
+          bc_salsa_t = 'nesting_offline'
+       ELSE
+          bc_salsa_t = 'neumann'
+       ENDIF
     ENDIF
 !
@@ -1128,15 +1147,11 @@
     ELSEIF ( bc_salsa_t == 'neumann' )  THEN
        ibc_salsa_t = 1
-    ELSEIF ( bc_salsa_t == 'nested' )  THEN
+    ELSEIF ( bc_salsa_t == 'initial_gradient' )  THEN
        ibc_salsa_t = 2
+    ELSEIF ( bc_salsa_t == 'nested'  .OR.  bc_salsa_t == 'nesting_offline' )  THEN
+       ibc_salsa_t = 3
     ELSE
        message_string = 'unknown boundary condition: bc_salsa_t = "' // TRIM( bc_salsa_t ) // '"'
        CALL message( 'salsa_check_parameters', 'PA0596', 1, 2, 0, 6, 0 )
-    ENDIF
-!
-!-- If nest_salsa = .F., set top boundary to dirichlet
-    IF ( .NOT. nest_salsa  .AND.  ibc_salsa_t == 2  )  THEN
-       ibc_salsa_t = 0
-       bc_salsa_t = 'dirichlet'
     ENDIF
 !
@@ -1246,13 +1261,14 @@
        WRITE( io, 19 )
     ENDIF
-    IF ( nest_salsa )  WRITE( io, 20 )  nest_salsa
-    WRITE( io, 21 ) salsa_emission_mode
+    IF ( nesting_salsa )  WRITE( io, 20 )  nesting_salsa
+    IF ( nesting_offline_salsa )  WRITE( io, 21 )  nesting_offline_salsa
+    WRITE( io, 22 ) salsa_emission_mode
     IF ( salsa_emission_mode == 'uniform' )  THEN
-       WRITE( io, 22 ) surface_aerosol_flux, aerosol_flux_dpg, aerosol_flux_sigmag,                &
+       WRITE( io, 23 ) surface_aerosol_flux, aerosol_flux_dpg, aerosol_flux_sigmag,                &
                        aerosol_flux_mass_fracs_a
     ENDIF
     IF ( SUM( aerosol_flux_mass_fracs_b ) > 0.0_wp  .OR. salsa_emission_mode == 'read_from_file' ) &
     THEN
-       WRITE( io, 23 )
+       WRITE( io, 24 )
     ENDIF
 
@@ -1297,10 +1313,11 @@
 19   FORMAT (/'      Size distribution read from a file.')
 20   FORMAT (/'   Nesting for salsa variables: ', L1 )
-21   FORMAT (/'   Emissions: salsa_emission_mode = ', A )
-22   FORMAT (/'      surface_aerosol_flux = ', ES12.4E3, ' #/m**2/s', /                            &
+21   FORMAT (/'   Offline nesting for salsa variables: ', L1 )
+22   FORMAT (/'   Emissions: salsa_emission_mode = ', A )
+23   FORMAT (/'      surface_aerosol_flux = ', ES12.4E3, ' #/m**2/s', /                            &
               '      aerosol_flux_dpg     =  ', 7(F7.3), ' (m)', /                                 &
               '      aerosol_flux_sigmag  =  ', 7(F7.2), /                                         &
               '      aerosol_mass_fracs_a =  ', 7(ES12.4E3) )
-23   FORMAT (/'      (currently all emissions are soluble!)')
+24   FORMAT (/'      (currently all emissions are soluble!)')
 
  END SUBROUTINE salsa_header
@@ -2209,9 +2226,9 @@
 !
 !--       Read vertical profiles of gases:
-          CALL get_variable( id_dyn, 'init_atmosphere_h2so4', salsa_gas(1)%init(nzb+1:nzt) )
-          CALL get_variable( id_dyn, 'init_atmosphere_hno3',  salsa_gas(2)%init(nzb+1:nzt) )
-          CALL get_variable( id_dyn, 'init_atmosphere_nh3',   salsa_gas(3)%init(nzb+1:nzt) )
-          CALL get_variable( id_dyn, 'init_atmosphere_ocnv',  salsa_gas(4)%init(nzb+1:nzt) )
-          CALL get_variable( id_dyn, 'init_atmosphere_ocsv',  salsa_gas(5)%init(nzb+1:nzt) )
+          CALL get_variable( id_dyn, 'init_atmosphere_H2SO4', salsa_gas(1)%init(nzb+1:nzt) )
+          CALL get_variable( id_dyn, 'init_atmosphere_HNO3',  salsa_gas(2)%init(nzb+1:nzt) )
+          CALL get_variable( id_dyn, 'init_atmosphere_NH3',   salsa_gas(3)%init(nzb+1:nzt) )
+          CALL get_variable( id_dyn, 'init_atmosphere_OCNV',  salsa_gas(4)%init(nzb+1:nzt) )
+          CALL get_variable( id_dyn, 'init_atmosphere_OCSV',  salsa_gas(5)%init(nzb+1:nzt) )
 !
 !--       Set Neumann top and surface boundary condition for initial + initialise concentrations
@@ -8146,5 +8163,4 @@
 
     IF ( time_since_reference_point >= skip_time_do_salsa )  THEN
-
 !
 !--    Surface conditions:
@@ -8247,5 +8263,5 @@
           ENDIF
 
-       ELSEIF ( ibc_salsa_t == 2 )  THEN   ! nested
+       ELSEIF ( ibc_salsa_t == 2 )  THEN   ! Initial gradient
 
           DO  ib = 1, nbins_aerosol
@@ -8358,5 +8374,5 @@
     flag = 0.0_wp
 !
-!-- Skip input if forcing from larger-scale models is applied.
+!-- Skip input if forcing from a larger-scale models is applied.
     IF ( nesting_offline  .AND.  nesting_offline_salsa )  RETURN
 !
@@ -9778,5 +9794,5 @@
 
           CASE ( 'g_H2SO4', 'g_HNO3', 'g_NH3', 'g_OCNV',  'g_OCSV' )
-             IF (  salsa_gases_from_chem )  THEN
+             IF (  air_chemistry )  THEN
                 message_string = 'gases are imported from the chemistry module and thus output '// &
                                  'of "' // TRIM( var ) // '" is not allowed'
Index: palm/trunk/TESTS/cases/urban_environment_salsa/INPUT/urban_environment_salsa_p3d
===================================================================
--- palm/trunk/TESTS/cases/urban_environment_salsa/INPUT/urban_environment_salsa_p3d	(revision 4272)
+++ palm/trunk/TESTS/cases/urban_environment_salsa/INPUT/urban_environment_salsa_p3d	(revision 4273)
@@ -272,5 +272,5 @@
     advect_particle_water   = .T.,   ! particle water: advect or calculate at each dt_salsa 
     feedback_to_palm        = .F.,   ! feedback to flow due to condensation of water
-    nest_salsa              = .F.,   ! apply self-nesting for salsa variables
+    nesting_salsa           = .F.,   ! apply self-nesting for salsa variables
     read_restart_data_salsa = .F.,   ! skip reading restart data even if it's done for the flow
     write_binary_salsa      = .F.,   ! skip writing restart data even if it's done for the flow
