Index: palm/trunk/SOURCE/chem_modules.f90
===================================================================
--- palm/trunk/SOURCE/chem_modules.f90	(revision 4543)
+++ palm/trunk/SOURCE/chem_modules.f90	(revision 4544)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! conc_av changed from pointer to allocatable array
+! 
+! 4511 2020-04-30 12:20:40Z raasch
 ! new variables for explicit settings of lateral boundary conditions introduced
 !
@@ -231,5 +234,5 @@
        CHARACTER(LEN=15)                            ::  unit         !< unit (ppm for gases, kg m^-3 for aerosol tracers)
        REAL(kind=wp), POINTER, DIMENSION(:,:,:)     ::  conc         !< concentrations of trace gases
-       REAL(kind=wp), POINTER, DIMENSION(:,:,:)     ::  conc_av      !< averaged concentrations
+       REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:) ::  conc_av      !< averaged concentrations
        REAL(kind=wp), POINTER, DIMENSION(:,:,:)     ::  conc_p       !< conc at prognostic time level
        REAL(kind=wp), POINTER, DIMENSION(:,:,:)     ::  tconc_m      !< weighted tendency of conc for previous sub-timestep (Runge-Kutta)
Index: palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4543)
+++ palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4544)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! conc_av changed from pointer to allocatable array, array spec_conc_av removed
+! 
+! 4542 2020-05-19 15:45:12Z raasch
 ! redundant if statement removed
 ! 
@@ -341,5 +344,5 @@
 
     USE restart_data_mpi_io_mod,                                                                   &
-        ONLY:  rrd_mpi_io, wrd_mpi_io
+        ONLY:  rrd_mpi_io, rd_mpi_io_check_array, wrd_mpi_io
 
     USE statistics
@@ -356,5 +359,4 @@
     REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET ::  spec_conc_2  !< pointer for swapping of timelevels for conc
     REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET ::  spec_conc_3  !< pointer for swapping of timelevels for conc
-    REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET ::  spec_conc_av !< averaged concentrations of chemical species       
     REAL(kind=wp), ALLOCATABLE, DIMENSION(:,:,:,:), TARGET ::  freq_1       !< pointer for phtolysis frequncies 
                                                                             !< (only 1 timelevel required)
@@ -646,5 +648,8 @@
              IF ( TRIM( variable(1:3) ) == 'kc_' .AND. &
                   TRIM( variable(4:) ) == TRIM( chem_species(lsp)%name ) )  THEN
-                chem_species(lsp)%conc_av = 0.0_wp
+                IF ( .NOT. ALLOCATED( chem_species(lsp)%conc_av ) )  THEN
+                   ALLOCATE( chem_species(lsp)%conc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+                   chem_species(lsp)%conc_av = 0.0_wp
+                ENDIF
              ENDIF
           ENDDO
@@ -1951,5 +1956,4 @@
     ALLOCATE( spec_conc_2 (nzb:nzt+1,nysg:nyng,nxlg:nxrg,nspec) )
     ALLOCATE( spec_conc_3 (nzb:nzt+1,nysg:nyng,nxlg:nxrg,nspec) )
-    ALLOCATE( spec_conc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg,nspec) ) 
     ALLOCATE( phot_frequen(nphot) ) 
     ALLOCATE( freq_1(nzb:nzt+1,nysg:nyng,nxlg:nxrg,nphot) )
@@ -1960,5 +1964,4 @@
     spec_conc_2 (:,:,:,:) = 0.0_wp
     spec_conc_3 (:,:,:,:) = 0.0_wp
-    spec_conc_av(:,:,:,:) = 0.0_wp
 
 
@@ -1969,5 +1972,4 @@
        chem_species(lsp)%conc_p (nzb:nzt+1,nysg:nyng,nxlg:nxrg)       => spec_conc_2 (:,:,:,lsp)
        chem_species(lsp)%tconc_m(nzb:nzt+1,nysg:nyng,nxlg:nxrg)       => spec_conc_3 (:,:,:,lsp)
-       chem_species(lsp)%conc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg)       => spec_conc_av(:,:,:,lsp)     
 
        ALLOCATE (chem_species(lsp)%cssws_av(nysg:nyng,nxlg:nxrg))                   
@@ -3099,4 +3101,7 @@
        ELSEIF (restart_string(1:length) == TRIM( chem_species(lsp)%name ) // '_av' )  THEN
 
+          IF ( .NOT. ALLOCATED( chem_species(lsp)%conc_av ) )  THEN
+             ALLOCATE( chem_species(lsp)%conc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg ) )
+          ENDIF
           IF ( k == 1 )  READ ( 13 )  tmp_3d
           chem_species(lsp)%conc_av(:,nysc-nbgp:nync+nbgp,nxlc-nbgp:nxrc+nbgp) =                   &
@@ -3123,9 +3128,18 @@
     INTEGER(iwp) ::  lsp  !<
 
+    LOGICAL      ::  array_found  !<
+
 
     DO  lsp = 1, nspec
 
        CALL rrd_mpi_io( TRIM( chem_species(lsp)%name ), chem_species(lsp)%conc )
-       CALL rrd_mpi_io( TRIM( chem_species(lsp)%name )//'_av', chem_species(lsp)%conc_av )
+
+       CALL rd_mpi_io_check_array( TRIM( chem_species(lsp)%name )//'_av' , found = array_found )
+       IF ( array_found )  THEN
+          IF ( .NOT. ALLOCATED( chem_species(lsp)%conc_av ) )  THEN
+             ALLOCATE( chem_species(lsp)%conc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+          CALL rrd_mpi_io( TRIM( chem_species(lsp)%name )//'_av', chem_species(lsp)%conc_av )
+       ENDIF
 
     ENDDO
@@ -3239,6 +3253,8 @@
           CALL wrd_write_string( TRIM( chem_species(lsp)%name ) )
           WRITE ( 14 )  chem_species(lsp)%conc
-          CALL wrd_write_string( TRIM( chem_species(lsp)%name )//'_av' )
-          WRITE ( 14 )  chem_species(lsp)%conc_av
+          IF ( ALLOCATED( chem_species(lsp)%conc_av ) )  THEN
+             CALL wrd_write_string( TRIM( chem_species(lsp)%name )//'_av' )
+             WRITE ( 14 )  chem_species(lsp)%conc_av
+          ENDIF
        ENDDO
 
@@ -3247,5 +3263,7 @@
        DO  lsp = 1, nspec
           CALL wrd_mpi_io( TRIM( chem_species(lsp)%name ), chem_species(lsp)%conc )
-          CALL wrd_mpi_io( TRIM( chem_species(lsp)%name ) // '_av', chem_species(lsp)%conc_av )
+          IF ( ALLOCATED( chem_species(lsp)%conc_av ) )  THEN
+             CALL wrd_mpi_io( TRIM( chem_species(lsp)%name ) // '_av', chem_species(lsp)%conc_av )
+          ENDIF
        ENDDO
 
