Index: palm/trunk/SOURCE/chem_emissions_mod.f90
===================================================================
--- palm/trunk/SOURCE/chem_emissions_mod.f90	(revision 4218)
+++ palm/trunk/SOURCE/chem_emissions_mod.f90	(revision 4227)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! implement new palm_date_time_mod
+! 
+! 4223 2019-09-10 09:20:47Z gronemeier
 ! Unused routine chem_emissions_check_parameters commented out due to uninitialized content
 ! 
@@ -118,10 +121,4 @@
         ONLY: chem_emis_att_type, chem_emis_val_type
 
-    USE date_and_time_mod,                                                   &
-        ONLY: day_of_month, hour_of_day,                                     &
-             index_mm, index_dd, index_hh,                                   &
-             month_of_year, hour_of_day,                                     &
-             time_default_indices, time_preprocessed_indices
-    
     USE chem_gasphase_mod,                                                   &
         ONLY: nvar, spc_names
@@ -905,5 +902,9 @@
 ! Description:
 ! ------------
-!> Routine for Update of Emission values at each timestep 
+!> Routine for Update of Emission values at each timestep.
+!>
+!> @todo Clarify the correct usage of index_dd, index_hh and index_mm. Consider
+!>       renaming of these variables.
+!> @todo Clarify time used in emis_lod=2 mode. ATM, the used time seems strange.
 !-------------------------------------------------------------------------------!
 
@@ -919,4 +920,9 @@
        ONLY: hyp, pt 
 
+    USE control_parameters, &
+        ONLY: time_since_reference_point
+
+    USE palm_date_time_mod, &
+        ONLY: days_per_week, get_date_time, hours_per_day, months_per_year, seconds_per_day
    
  IMPLICIT NONE
@@ -940,8 +946,19 @@
     INTEGER(iwp) ::  m                                                          !< running index for horizontal surfaces
 
+    INTEGER(iwp) ::  day_of_month                                               !< day of the month
+    INTEGER(iwp) ::  day_of_week                                                !< day of the week
+    INTEGER(iwp) ::  day_of_year                                                !< day of the year
+    INTEGER(iwp) ::  days_since_reference_point                                 !< days since reference point
+    INTEGER(iwp) ::  hour_of_day                                                !< hour of the day
+    INTEGER(iwp) ::  month_of_year                                              !< month of the year
+    INTEGER(iwp) ::  index_dd                                                   !< index day
+    INTEGER(iwp) ::  index_hh                                                   !< index hour
+    INTEGER(iwp) ::  index_mm                                                   !< index month
+
+    REAL(wp) ::  time_utc_init                                                  !< second of day of initial date
+
     !
     !-- CONVERSION FACTORS: TIME  
     REAL(wp), PARAMETER ::  hour_per_year =  8760.0_wp  !< number of hours in a year of 365 days  
-    REAL(wp), PARAMETER ::  hour_per_day  =    24.0_wp  !< number of hours in a day
     REAL(wp), PARAMETER ::  s_per_hour    =  3600.0_wp  !< number of sec per hour (s)/(hour)    
     REAL(wp), PARAMETER ::  s_per_day     = 86400.0_wp  !< number of sec per day (s)/(day)  
@@ -1073,6 +1090,11 @@
 !-- Update time indices
 
-          CALL time_preprocessed_indices( index_hh )
-
+          CALL get_date_time( 0.0_wp, second_of_day=time_utc_init )
+          CALL get_date_time( time_since_reference_point, hour=hour_of_day )
+
+          days_since_reference_point = INT( FLOOR( ( time_utc_init + time_since_reference_point ) &
+                                                   / seconds_per_day ) )
+
+          index_hh = days_since_reference_point * hours_per_day + hour_of_day
 
 !
@@ -1102,5 +1124,7 @@
 !-- Update time indices
 
-             CALL time_default_indices( month_of_year, day_of_month, hour_of_day, index_hh )
+             CALL get_date_time( time_since_reference_point, &
+                                 day_of_year=day_of_year, hour=hour_of_day )
+             index_hh = ( day_of_year - 1_iwp ) * hour_of_day
 
 !
@@ -1132,7 +1156,23 @@
 !
 !-- Update time indices
-             CALL time_default_indices( daytype_mdh, month_of_year, day_of_month,  &
-                  hour_of_day, index_mm, index_dd,index_hh )
-
+             CALL get_date_time( time_since_reference_point, &
+                                 month=month_of_year,        &
+                                 day=day_of_month,           &
+                                 hour=hour_of_day,           &
+                                 day_of_week=day_of_week     )
+             index_mm = month_of_year
+             index_dd = months_per_year + day_of_week
+             SELECT CASE(TRIM(daytype_mdh))
+
+                CASE ("workday")
+                   index_hh = months_per_year + days_per_week + hour_of_day
+
+                CASE ("weekend")
+                   index_hh = months_per_year + days_per_week + hours_per_day + hour_of_day
+
+                CASE ("holiday")
+                   index_hh = months_per_year + days_per_week + 2*hours_per_day + hour_of_day
+
+             END SELECT
 !
 !-- Check if the index is less or equal to the temporal dimension of MDH emission files
@@ -1189,5 +1229,6 @@
 
 !
-!-- Get time-factor for specific hour
+!--       Get time-factor for specific hour
+          CALL get_date_time( time_since_reference_point, hour=hour_of_day )
 
           index_hh = hour_of_day
@@ -1196,5 +1237,5 @@
        ENDIF  ! emiss_lod
 
-       
+
 !
 !--  Emission distribution calculation
@@ -1257,5 +1298,5 @@
                                                  time_factor(icat) *           &
                                                  emt_att%nox_comp(icat,1) *    &
-                                                 conversion_factor * hour_per_day
+                                                 conversion_factor * hours_per_day
 
                    emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                &
@@ -1270,5 +1311,5 @@
                                                  time_factor(icat) *           &
                                                  emt_att%nox_comp(icat,2) *    &
-                                                 conversion_factor * hour_per_day
+                                                 conversion_factor * hours_per_day
 
                    emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                &
@@ -1283,5 +1324,5 @@
                                                  time_factor(icat) *           &
                                                  emt_att%sox_comp(icat,1) *    &
-                                                 conversion_factor * hour_per_day
+                                                 conversion_factor * hours_per_day
 
                    emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                &
@@ -1298,5 +1339,5 @@
                                                  time_factor(icat) *           &
                                                  emt_att%sox_comp(icat,2) *    &
-                                                 conversion_factor * hour_per_day
+                                                 conversion_factor * hours_per_day
 
                    emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                &
@@ -1315,5 +1356,5 @@
                                                     time_factor(icat) *                  &
                                                     emt_att%pm_comp(icat,i_pm_comp,1) *  &
-                                                    conversion_factor * hour_per_day 
+                                                    conversion_factor * hours_per_day 
 
                       emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                       &
@@ -1333,5 +1374,5 @@
                                                     time_factor(icat) *                  &
                                                     emt_att%pm_comp(icat,i_pm_comp,2) *  &
-                                                    conversion_factor * hour_per_day 
+                                                    conversion_factor * hours_per_day 
 
                       emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                       &
@@ -1351,5 +1392,5 @@
                                                     time_factor(icat)     *              &
                                                     emt_att%pm_comp(icat,i_pm_comp,3) *  &
-                                                    conversion_factor * hour_per_day 
+                                                    conversion_factor * hours_per_day 
 
                       emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                       &
@@ -1372,5 +1413,5 @@
                                                        time_factor(icat) *               &
                                                        emt_att%voc_comp(icat,match_spec_voc_input(ivoc)) *   &
-                                                       conversion_factor * hour_per_day
+                                                       conversion_factor * hours_per_day
 
                          emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                    &
@@ -1389,5 +1430,5 @@
                    delta_emis(nys:nyn,nxl:nxr) = emis(nys:nyn,nxl:nxr) *                 &
                                                  time_factor(icat) *                     &
-                                                 conversion_factor * hour_per_day
+                                                 conversion_factor * hours_per_day
  
                    emis_distribution(1,nys:nyn,nxl:nxr,ispec) =                          &
