Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4600)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4601)
@@ -21,9 +21,13 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! - Bugfix in variable name separation in profile-output initialization
+! - Bugfix in counting the number of chemistry profiles
+! 
+! 4581 2020-06-29 08:49:58Z suehring
 ! Enable output of resolved-scale vertical fluxes of chemical species.
 ! 
@@ -1109,10 +1113,11 @@
                 cs_pr_count_sp                 = cs_pr_count_sp + 1
                 cs_pr_index_sp(cs_pr_count_sp) = lsp
-                dopr_index(var_count)          = pr_palm + cs_pr_count_sp + cs_pr_count_fl_sgs + cs_pr_count_fl_res
+                dopr_index(var_count)          = pr_palm + cs_pr_count_sp +                        &
+                                                 cs_pr_count_fl_sgs + cs_pr_count_fl_res
                 dopr_unit                      = 'ppm'
                 IF ( spec_name(1:2) == 'PM')  THEN
                    dopr_unit = 'kg m-3'
                 ENDIF
-                hom(:,2, dopr_index(var_count),:) = SPREAD( zu, 2, statistic_regions+1 )
+                hom(:,2,dopr_index(var_count),:) = SPREAD( zu, 2, statistic_regions+1 )
                 unit                              = dopr_unit
 
@@ -1125,23 +1130,21 @@
           IF ( TRIM( variable(1:5) ) == 'kc_w"' )  THEN
              DO  lsp = 1, nspec
-                index_start = INDEX( TRIM( variable ), TRIM( chem_species(lsp)%name ) )
                 index_end   = LEN( TRIM( variable ) ) - 1
-                IF ( index_start /= 0 )  THEN
-                   spec_name = TRIM( variable(index_start:index_end) )
-                   IF ( TRIM( spec_name ) == TRIM( chem_species(lsp)%name ) )  THEN
-                      cs_pr_count_fl_sgs                     = cs_pr_count_fl_sgs + 1
-                      cs_pr_index_fl_sgs(cs_pr_count_fl_sgs) = lsp
-                      dopr_index(var_count)                  = pr_palm + cs_pr_count_sp +          &
-                                                               cs_pr_count_fl_sgs +                &
-                                                               cs_pr_count_fl_res
-                      dopr_unit                              = 'm ppm s-1'
-                      IF ( spec_name(1:2) == 'PM')  THEN
-                         dopr_unit = 'kg m-2 s-1'
-                      ENDIF
-                      hom(:,2, dopr_index(var_count),:)    = SPREAD( zu, 2, statistic_regions+1 )
-                      unit                                 = dopr_unit
-
-                      hom_index_fl_sgs(cs_pr_count_fl_sgs) = dopr_index(var_count)
+                index_start = 6
+                spec_name = TRIM( variable(index_start:index_end) )
+                IF ( TRIM( spec_name ) == TRIM( chem_species(lsp)%name ) )  THEN
+                   cs_pr_count_fl_sgs                     = cs_pr_count_fl_sgs + 1
+                   cs_pr_index_fl_sgs(cs_pr_count_fl_sgs) = lsp
+                   dopr_index(var_count)                  = pr_palm + cs_pr_count_sp +          &
+                                                            cs_pr_count_fl_sgs +                &
+                                                            cs_pr_count_fl_res
+                   dopr_unit                              = 'm ppm s-1'
+                   IF ( spec_name(1:2) == 'PM')  THEN
+                      dopr_unit = 'kg m-2 s-1'
                    ENDIF
+                   hom(:,2,dopr_index(var_count),:)     = SPREAD( zu, 2, statistic_regions+1 )
+                   unit                                 = dopr_unit
+
+                   hom_index_fl_sgs(cs_pr_count_fl_sgs) = dopr_index(var_count)
                 ENDIF
              ENDDO
@@ -1152,23 +1155,21 @@
              spec_name = TRIM( variable(6:) )
              DO  lsp = 1, nspec
-                index_start = INDEX( TRIM( variable ), TRIM( chem_species(lsp)%name ) )
+                index_start = 6
                 index_end   = LEN( TRIM( variable ) ) - 1
-                IF ( index_start /= 0 )  THEN
-                   spec_name = TRIM( variable(index_start:index_end) )
-                   IF ( TRIM( spec_name ) == TRIM( chem_species(lsp)%name ) )  THEN
-                      cs_pr_count_fl_res                     = cs_pr_count_fl_res + 1
-                      cs_pr_index_fl_res(cs_pr_count_fl_res) = lsp
-                      dopr_index(var_count)                  = pr_palm + cs_pr_count_sp +          &
-                                                               cs_pr_count_fl_sgs +                &
-                                                               cs_pr_count_fl_res
-                      dopr_unit                              = 'm ppm s-1'
-                      IF ( spec_name(1:2) == 'PM')  THEN
-                         dopr_unit = 'kg m-2 s-1'
-                      ENDIF
-                      hom(:,2, dopr_index(var_count),:)    = SPREAD( zu, 2, statistic_regions+1 )
-                      unit                                 = dopr_unit
-
-                      hom_index_fl_res(cs_pr_count_fl_res) = dopr_index(var_count)
+                spec_name = TRIM( variable(index_start:index_end) )
+                IF ( TRIM( spec_name ) == TRIM( chem_species(lsp)%name ) )  THEN
+                   cs_pr_count_fl_res                     = cs_pr_count_fl_res + 1
+                   cs_pr_index_fl_res(cs_pr_count_fl_res) = lsp
+                   dopr_index(var_count)                  = pr_palm + cs_pr_count_sp +             &
+                                                            cs_pr_count_fl_sgs +                   &
+                                                            cs_pr_count_fl_res
+                   dopr_unit                              = 'm ppm s-1'
+                   IF ( spec_name(1:2) == 'PM')  THEN
+                      dopr_unit = 'kg m-2 s-1'
                    ENDIF
+                   hom(:,2, dopr_index(var_count),:)    = SPREAD( zu, 2, statistic_regions+1 )
+                   unit                                 = dopr_unit
+
+                   hom_index_fl_res(cs_pr_count_fl_res) = dopr_index(var_count)
                 ENDIF
              ENDDO
@@ -2710,6 +2711,5 @@
     i = 1
 
-    DO  WHILE ( data_output_pr(i)  /= ' '  .AND.  i <= 100 )
-
+    DO  WHILE ( data_output_pr(i)  /= ' '  .AND.  i <= SIZE( data_output_pr ) )
        IF ( TRIM( data_output_pr(i)(1:3) ) == 'kc_' )  THEN
           max_pr_cs_tmp = max_pr_cs_tmp+1
Index: /palm/trunk/SOURCE/init_grid.f90
===================================================================
--- /palm/trunk/SOURCE/init_grid.f90	(revision 4600)
+++ /palm/trunk/SOURCE/init_grid.f90	(revision 4601)
@@ -20,9 +20,12 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Minor formatting adjustments
+! 
+! 4564 2020-06-12 14:03:36Z raasch
 ! Vertical nesting method of Huq et al. (2019) removed
 ! 
@@ -281,5 +284,5 @@
                                    'dz_stretch_level_end + 1 = ',              &
                                    number_stretch_level_end+1
-          CALL message( 'init_grid', 'PA0156', 1, 2, 0, 6, 0 )
+       CALL message( 'init_grid', 'PA0156', 1, 2, 0, 6, 0 )
     ENDIF
     
@@ -294,5 +297,5 @@
                                    'dz_stretch_level_start = ',                &
                                    number_stretch_level_start
-          CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 )
+       CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 )
     ENDIF
     
@@ -307,5 +310,5 @@
                                    'values for dz_stretch_level_end = ',       &
                                    number_stretch_level_end
-          CALL message( 'init_grid', 'PA0216', 1, 2, 0, 6, 0 )
+       CALL message( 'init_grid', 'PA0216', 1, 2, 0, 6, 0 )
     ENDIF
 
@@ -345,9 +348,9 @@
        IF ( ANY( min_dz_stretch_level_end(1:number_stretch_level_start) >      &
                  dz_stretch_level_end(1:number_stretch_level_start) ) ) THEN
-             message_string= 'Each dz_stretch_level_end has to be larger ' //  &
-                             'than its corresponding value for &' //           &
-                             'dz_stretch_level_start + 4*MAX(dz(n),dz(n+1)) '//&
-                             'to allow for smooth grid stretching'
-             CALL message( 'init_grid', 'PA0224', 1, 2, 0, 6, 0 )
+          message_string= 'Each dz_stretch_level_end has to be larger ' //     &
+                          'than its corresponding value for &' //              &
+                          'dz_stretch_level_start + 4*MAX(dz(n),dz(n+1)) '//   &
+                          'to allow for smooth grid stretching'
+          CALL message( 'init_grid', 'PA0224', 1, 2, 0, 6, 0 )
        ENDIF
        
@@ -359,5 +362,5 @@
           WRITE( message_string, * ) 'Each dz_stretch_level_start has to be ',&
                                      'larger than ', dz(1) * 1.5
-             CALL message( 'init_grid', 'PA0226', 1, 2, 0, 6, 0 )
+          CALL message( 'init_grid', 'PA0226', 1, 2, 0, 6, 0 )
        ENDIF
 
Index: /palm/trunk/SOURCE/surface_data_output_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4600)
+++ /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 4601)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Minor simplification in name creation for IO variables in restart files.
+!
+! 4600 2020-07-13 18:50:12Z suehring
 ! - Change: adjustmens for mpi-io - surface data is transformed to a 2D-based surface array
 !   before writing.
@@ -4701,7 +4704,5 @@
 
     DO  nv = 1, dosurf_no(1)
-       IF ( nv < 10                     )  WRITE( dum, '(I1)') nv
-       IF ( nv < 100   .AND.  nv >= 10  )  WRITE( dum, '(I2)') nv
-       IF ( nv < 1000  .AND.  nv >= 100 )  WRITE( dum, '(I3)') nv
+       WRITE( dum, '(I3.3)' )  nv
 
        CALL rd_mpi_io_check_array( 'surfaces%var_av' // TRIM( dum ), found = array_found )
@@ -4954,7 +4955,5 @@
              ENDDO
 
-             IF ( nv < 10                     )  WRITE( dum, '(I1)') nv
-             IF ( nv < 100   .AND.  nv >= 10  )  WRITE( dum, '(I2)') nv
-             IF ( nv < 1000  .AND.  nv >= 100 )  WRITE( dum, '(I3)') nv
+             WRITE( dum, '(I3.3)' )  nv
 
              CALL wrd_mpi_io_surface( 'surfaces%var_av' // TRIM( dum ), surf_out )
