Index: palm/trunk/SOURCE/sum_up_3d_data.f90
===================================================================
--- palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2292)
+++ palm/trunk/SOURCE/sum_up_3d_data.f90	(revision 2696)
@@ -1,5 +1,5 @@
 !> @file sum_up_3d_data.f90
 !------------------------------------------------------------------------------!
-! This file is part of PALM.
+! This file is part of the PALM model system.
 !
 ! PALM is free software: you can redistribute it and/or modify it under the
@@ -25,4 +25,11 @@
 ! -----------------
 ! $Id$
+! - Implementation of uv exposure model (FK)
+! - output of diss_av, kh_av, km_av (turbulence_closure_mod) (TG)
+! - Implementation of chemistry module (FK)
+! - Workaround for sum-up usm arrays in case of restart runs, to avoid program 
+!   crash (MS)
+! 
+! 2292 2017-06-20 09:51:42Z schwenkel
 ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' 
 ! includes two more prognostic equations for cloud drop concentration (nc)  
@@ -144,9 +151,13 @@
 
     USE averaging,                                                             &
-        ONLY:  e_av, lpt_av, lwp_av, nc_av, nr_av, ol_av, p_av, pc_av, pr_av,  &
-               prr_av, precipitation_rate_av, pt_av, q_av, qc_av, ql_av,       &
-               ql_c_av, ql_v_av, ql_vp_av, qr_av, qsws_av, qv_av, rho_ocean_av,&
-               s_av, sa_av, shf_av, ssws_av, ts_av, u_av, us_av, v_av, vpt_av, &
-               w_av, z0_av, z0h_av, z0q_av
+        ONLY:  diss_av, e_av, kh_av, km_av, lpt_av, lwp_av, nc_av, nr_av,      &
+               ol_av, p_av, pc_av, pr_av, prr_av, precipitation_rate_av, pt_av,&
+               q_av, qc_av, ql_av, ql_c_av, ql_v_av, ql_vp_av, qr_av, qsws_av, &
+               qv_av, rho_ocean_av, s_av, sa_av, shf_av, ssws_av, ts_av, u_av, &
+               us_av, v_av, vpt_av, w_av, z0_av, z0h_av, z0q_av
+#if defined( __chem )
+    USE chemistry_model_mod,                                                   &
+        ONLY:  chem_3d_data_averaging, chem_integrate, chem_species, nspec                                   
+#endif
 
     USE cloud_parameters,                                                      &
@@ -154,6 +165,7 @@
 
     USE control_parameters,                                                    &
-        ONLY:  average_count_3d, cloud_physics, doav, doav_n, land_surface,    &
-               rho_surface, urban_surface, varnamelength
+        ONLY:  air_chemistry, average_count_3d, cloud_physics, doav, doav_n,   &
+               land_surface, rho_surface, urban_surface, uv_exposure,          &
+               varnamelength
 
     USE cpulog,                                                                &
@@ -177,6 +189,12 @@
         ONLY:  surf_def_h, surf_lsm_h, surf_usm_h
 
+    USE turbulence_closure_mod,                                                &
+        ONLY:  tcm_3d_data_averaging
+
     USE urban_surface_mod,                                                     &
         ONLY:  usm_average_3d_data
+
+    USE uv_exposure_model_mod,                                                &
+        ONLY:  uvem_3d_data_averaging
 
 
@@ -436,4 +454,8 @@
 
 !
+!--             Turbulence closure module
+                CALL tcm_3d_data_averaging( 'allocate', doav(ii) )
+
+!
 !--             Land surface quantity
                 IF ( land_surface )  THEN
@@ -445,4 +467,18 @@
                 IF ( radiation )  THEN
                    CALL radiation_3d_data_averaging( 'allocate', doav(ii) )
+                ENDIF
+
+!
+!--             Chemical quantity                                           
+#if defined( __chem )                
+                IF ( air_chemistry  .AND.  trimvar(1:3) == 'kc_')  THEN
+                   CALL chem_3d_data_averaging( 'allocate', doav(ii) )
+                ENDIF
+#endif
+
+!
+!--             UV exposure quantity
+                IF ( uv_exposure  .AND.  trimvar(1:5) == 'uvem_')  THEN
+                   CALL uvem_3d_data_averaging( 'allocate', doav(ii) )
                 ENDIF
 
@@ -889,9 +925,17 @@
              ENDDO
 !             
-!--       Block of urban surface model outputs 
+!--       Block of urban surface model outputs. 
+!--       In case of urban surface variables it should be always checked
+!--       if respective arrays are allocated, at least in case of a restart 
+!--       run, as usm arrays are not read from file at the moment. 
           CASE ( 'usm_output' )
+             CALL usm_average_3d_data( 'allocate', doav(ii) )
              CALL usm_average_3d_data( 'sum', doav(ii) )
 
           CASE DEFAULT
+!
+!--          Turbulence closure module
+             CALL tcm_3d_data_averaging( 'sum', doav(ii) )
+
 !
 !--          Land surface quantity
@@ -907,4 +951,18 @@
 
 !
+!--          Chemical quantity
+#if defined( __chem )                
+             IF ( air_chemistry  .AND.  trimvar(1:3) == 'kc_')  THEN
+                CALL chem_3d_data_averaging( 'sum',doav(ii) )
+             ENDIF
+#endif
+
+!
+!--          UV exposure quantity
+             IF ( uv_exposure )  THEN
+                CALL uvem_3d_data_averaging( 'sum', doav(ii) )
+             ENDIF
+
+!
 !--          User-defined quantity
              CALL user_3d_data_averaging( 'sum', doav(ii) )
