Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 2543)
+++ palm/trunk/SOURCE/Makefile	(revision 2544)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Added date_and_time_mod 
+# 
+# 2371 2017-08-24 13:01:17Z kanani
 # Corrected dependencies for vertical_nesting_mod
 # 
@@ -370,4 +373,5 @@
 	data_output_ptseries.f90 data_output_spectra.f90 data_output_flight.f90\
 	data_output_tseries.f90 data_output_2d.f90 data_output_3d.f90 \
+	date_and_time_mod.f90 \
 	diffusion_e.f90 diffusion_s.f90 diffusion_u.f90 diffusion_v.f90 \
 	diffusion_w.f90 diffusivities.f90 disturb_field.f90 \
@@ -497,4 +501,5 @@
 data_output_3d.o: modules.o cpulog_mod.o mod_kinds.o mod_particle_attributes.o \
    netcdf_interface_mod.o land_surface_model_mod.o urban_surface_mod.o
+date_and_time_mod.o: modules.o mod_kinds.o 
 diffusion_e.o: modules.o mod_kinds.o microphysics_mod.o \
    mod_particle_attributes.o surface_mod.o
@@ -514,5 +519,5 @@
                    large_scale_forcing_nudging_mod.o netcdf_interface_mod.o radiation_model_mod.o surface_mod.o
 global_min_max.o: modules.o mod_kinds.o
-header.o: modules.o cpulog_mod.o mod_kinds.o large_scale_forcing_nudging_mod.o netcdf_interface_mod.o \
+header.o: modules.o cpulog_mod.o mod_kinds.o date_and_time_mod.o large_scale_forcing_nudging_mod.o netcdf_interface_mod.o \
    land_surface_model_mod.o microphysics_mod.o model_1d_mod.o plant_canopy_model_mod.o pmc_handle_communicator_mod.o \
    pmc_interface_mod.o radiation_model_mod.o spectra_mod.o subsidence_mod.o surface_mod.o virtual_flight_mod.o
@@ -583,5 +588,5 @@
 palm.o: modules.o cpulog_mod.o land_surface_model_mod.o mod_kinds.o \
 	pmc_interface_mod.o surface_layer_fluxes_mod.o
-parin.o: modules.o cpulog_mod.o land_surface_model_mod.o mod_kinds.o model_1d_mod.o netcdf_interface_mod.o \
+parin.o: modules.o cpulog_mod.o date_and_time_mod.o land_surface_model_mod.o mod_kinds.o model_1d_mod.o netcdf_interface_mod.o \
    plant_canopy_model_mod.o pmc_interface_mod.o progress_bar_mod.o spectra_mod.o \
    synthetic_turbulence_generator_mod.o radiation_model_mod.o microphysics_mod.o \
@@ -613,5 +618,5 @@
 	subsidence_mod.o surface_mod.o user_actions.o wind_turbine_model_mod.o
 progress_bar_mod.o: modules.o mod_kinds.o
-radiation_model_mod.o: modules.o mod_particle_attributes.o microphysics_mod.o surface_mod.o
+radiation_model_mod.o: modules.o mod_particle_attributes.o date_and_time_mod.o microphysics_mod.o surface_mod.o
 random_function_mod.o: mod_kinds.o
 random_gauss.o: mod_kinds.o random_function_mod.o random_generator_parallel_mod.o
@@ -645,5 +650,5 @@
         surface_layer_fluxes_mod.o surface_mod.o \
 	urban_surface_mod.o vertical_nesting_mod.o virtual_flight_mod.o wind_turbine_model_mod.o
-time_integration_spinup.o: cpulog_mod.o modules.o land_surface_model_mod.o mod_kinds.o radiation_model_mod.o surface_layer_fluxes_mod.o urban_surface_mod.o 
+time_integration_spinup.o: cpulog_mod.o modules.o date_and_time_mod.o land_surface_model_mod.o mod_kinds.o radiation_model_mod.o surface_layer_fluxes_mod.o urban_surface_mod.o 
 time_to_string.o: mod_kinds.o
 timestep.o: modules.o cpulog_mod.o mod_kinds.o microphysics_mod.o \
@@ -652,5 +657,5 @@
 transpose.o: modules.o cpulog_mod.o mod_kinds.o
 tridia_solver_mod.o: modules.o mod_kinds.o
-urban_surface_mod.o: modules.o mod_kinds.o radiation_model_mod.o plant_canopy_model_mod.o surface_mod.o
+urban_surface_mod.o: modules.o mod_kinds.o date_and_time_mod.o radiation_model_mod.o plant_canopy_model_mod.o surface_mod.o
 user_3d_data_averaging.o: modules.o mod_kinds.o user_module.o
 user_actions.o: modules.o cpulog_mod.o mod_kinds.o user_module.o
Index: palm/trunk/SOURCE/date_and_time_mod.f90
===================================================================
--- palm/trunk/SOURCE/date_and_time_mod.f90	(revision 2544)
+++ palm/trunk/SOURCE/date_and_time_mod.f90	(revision 2544)
@@ -0,0 +1,89 @@
+!> @file date_and_time_mod.f90
+!------------------------------------------------------------------------------!
+! This file is part of PALM.
+!
+! PALM is free software: you can redistribute it and/or modify it under the
+! terms of the GNU General Public License as published by the Free Software
+! Foundation, either version 3 of the License, or (at your option) any later
+! version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2017 Leibniz Universitaet Hannover
+!------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
+! Initial revision
+! 
+! 
+
+!
+! Description:
+! ------------
+!> This routine calculates all needed information on date and time used by
+!> other modules
+!------------------------------------------------------------------------------!
+ MODULE date_and_time_mod
+ 
+    USE control_parameters,                                                    &
+        ONLY: time_since_reference_point 
+ 
+    USE kinds
+
+    IMPLICIT NONE
+
+    PRIVATE
+    
+    PUBLIC   calc_date_and_time, d_hours_day, d_seconds_hour, d_seconds_year,  &
+             day_of_year, day_of_year_init, time_utc, time_utc_init
+
+
+    INTEGER(iwp) ::  day_of_year              !< day of the year (DOY)
+    INTEGER(iwp) ::  day_of_year_init = 172   !< DOY at model start (default: 21 June)
+
+    REAL(wp) ::  time_utc                     !< current model time in UTC
+    REAL(wp) ::  time_utc_init = 43200.0_wp   !< UTC time at model start
+
+    REAL(wp), PARAMETER ::  d_hours_day    = 0.0416666666667_wp    !< inverse of hours per day (1/24)
+    REAL(wp), PARAMETER ::  d_seconds_hour = 0.000277777777778_wp   !< inverse of seconds per hour (1/3600)
+    REAL(wp), PARAMETER ::  d_seconds_year = 31536000.0_wp          !< inverse of the seconds per year (1/(365*86400))
+    
+    SAVE
+
+ CONTAINS
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculate current day of the year and time in UTC
+!------------------------------------------------------------------------------!
+ 
+    SUBROUTINE calc_date_and_time
+
+       IMPLICIT NONE
+
+!
+!--    Calculate current day of the year 
+       day_of_year = day_of_year_init + INT(FLOOR( (time_utc_init + time_since_reference_point)&
+                               / 86400.0_wp ), KIND=iwp)
+                        
+       time_utc = MOD((time_utc_init + time_since_reference_point), 86400.0_wp)
+       
+       
+
+    END SUBROUTINE calc_date_and_time
+
+
+
+ END MODULE date_and_time_mod
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 2543)
+++ palm/trunk/SOURCE/header.f90	(revision 2544)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Moved initial day of year and time to inipar. 
+! 
+! 2339 2017-08-07 13:55:26Z gronemeier
 ! corrected timestamp in header
 ! 
@@ -333,5 +336,8 @@
     USE cpulog,                                                                &
         ONLY:  log_point_s
-        
+            
+    USE date_and_time_mod,                                                     &
+        ONLY:  day_of_year_init, time_utc_init
+
     USE dvrp_variables,                                                        &
         ONLY:  use_seperate_pe_for_dvrp_output
@@ -1746,4 +1752,8 @@
     WRITE ( io, 410 )  phi, omega, f, fs
 
+ !
+!-- Geostrophic parameters
+    WRITE ( io, 456 )  day_of_year_init, time_utc_init
+    
 !
 !-- Other quantities
@@ -2253,4 +2263,6 @@
 454 FORMAT ('    TKE is not allowed to fall below ',E9.2,' (m/s)**2')
 455 FORMAT ('    initial TKE is prescribed as ',E9.2,' (m/s)**2')
+456 FORMAT ('    Day of the year at model start :   day_init = ',I3             &
+            /'    UTC time at model start        :   time_utc_init = ',F7.1' s')
 470 FORMAT (//' Actions during the simulation:'/ &
               ' -----------------------------'/)
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 2543)
+++ palm/trunk/SOURCE/parin.f90	(revision 2544)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Moved day_of_year_init and time_utc_init to inipar.
+! 
+! 2397 2017-09-04 16:22:48Z suehring
 ! Enable initialization of 3d model by user in the child domain. 
 ! 
@@ -301,4 +304,7 @@
                vg
 
+    USE date_and_time_mod,                                                     &
+        ONLY:  day_of_year_init, time_utc_init
+               
     USE plant_canopy_model_mod,                                                &
          ONLY: pcm_parin  
@@ -393,4 +399,5 @@
              cycle_mg, damp_level_1d,                                          &
              data_output_during_spinup,                                        &
+             day_of_year_init,                                                 &
              dissipation_1d,                                                   &
              dp_external, dp_level_b, dp_smooth, dpdxy, dry_aerosol_radius,    &
@@ -427,5 +434,5 @@
              surface_scalarflux, surface_waterflux,                            &
              s_surface, s_surface_initial_change, s_vertical_gradient,         &
-             s_vertical_gradient_level, timestep_scheme,                       &
+             s_vertical_gradient_level, time_utc_init, timestep_scheme,        &
              topography, topography_grid_convention, top_heatflux,             &
              top_momentumflux_u, top_momentumflux_v, top_salinityflux,         &
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2543)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2544)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Moved date and time quantitis to separate module date_and_time_mod 
+! 
+! 2512 2017-10-04 08:26:59Z raasch
 ! upper bounds of cross section and 3d output changed from nx+1,ny+1 to nx,ny
 ! no output of ghost layer data
@@ -183,4 +186,8 @@
                surface_pressure, time_since_reference_point
 
+    USE date_and_time_mod,                                                     &
+        ONLY:  calc_date_and_time, d_hours_day, d_seconds_hour, day_of_year,   &
+               time_utc
+
     USE indices,                                                               &
         ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
@@ -262,6 +269,4 @@
 
     INTEGER(iwp) :: albedo_type  = 9999999, & !< Albedo surface type
-                    day,                    & !< current day of the year
-                    day_init     = 172,     & !< day of the year at model start (21/06)
                     dots_rad     = 0          !< starting index for timeseries output 
 
@@ -276,7 +281,5 @@
 
 
-    REAL(wp), PARAMETER :: d_seconds_hour  = 0.000277777777778_wp,  & !< inverse of seconds per hour (1/3600)
-                           d_hours_day    = 0.0416666666667_wp,     & !< inverse of hours per day (1/24)
-                           sigma_sb       = 5.67037321E-8_wp,       & !< Stefan-Boltzmann constant
+    REAL(wp), PARAMETER :: sigma_sb       = 5.67037321E-8_wp,       & !< Stefan-Boltzmann constant
                            solar_constant = 1368.0_wp                 !< solar constant at top of atmosphere
 
@@ -297,7 +300,6 @@
                 skip_time_do_radiation = 0.0_wp, & !< Radiation model is not called before this time
                 sky_trans,                       & !< sky transmissivity
-                time_radiation = 0.0_wp,         & !< time since last call of radiation code
-                time_utc,                        & !< current time in UTC
-                time_utc_init = 43200.0_wp         !< UTC time at model start (noon)
+                time_radiation = 0.0_wp            !< time since last call of radiation code
+
 
     REAL(wp), DIMENSION(0:0) ::  zenith,         & !< cosine of solar zenith angle
@@ -562,7 +564,7 @@
            rad_sw_in_av, rad_sw_out, rad_sw_out_av, rad_sw_cs_hr,              &
            rad_sw_cs_hr_av, rad_sw_hr, rad_sw_hr_av, sigma_sb,                 &
-           skip_time_do_radiation, time_radiation, unscheduled_radiation_calls,&
-           zenith, calc_zenith, sun_direction, sun_dir_lat, sun_dir_lon,       &
-           day_init, time_utc_init
+           skip_time_do_radiation, solar_constant, time_radiation,             &
+           unscheduled_radiation_calls, zenith, calc_zenith, sun_direction,    &
+           sun_dir_lat, sun_dir_lon
 
 
@@ -1360,5 +1362,4 @@
        IF ( radiation .AND. radiation_scheme /= 'constant' )  THEN
           WRITE ( io, 1 )  lambda
-          WRITE ( io, 2 )  day_init, time_utc_init
        ENDIF
 
@@ -1367,6 +1368,4 @@
 
  1 FORMAT ('    Geograph. longitude            :   lambda = ',F4.1,' degr')
- 2 FORMAT ('    Day of the year at model start :   day_init = ',I3             &
-            /'    UTC time at model start        :   time_utc_init = ',F7.1' s')
  3 FORMAT (//' Radiation model information:'/                                  &
               ' ----------------------------'/)
@@ -1401,9 +1400,8 @@
        NAMELIST /radiation_par/   albedo, albedo_type, albedo_lw_dir,          &
                                   albedo_lw_dif, albedo_sw_dir, albedo_sw_dif, &
-                                  constant_albedo, day_init, dt_radiation,     &
+                                  constant_albedo, dt_radiation,               &
                                   lambda, lw_radiation, net_radiation,         &
                                   radiation_scheme, skip_time_do_radiation,    &
-                                  sw_radiation, time_utc_init,                 &
-                                  unscheduled_radiation_calls
+                                  sw_radiation, unscheduled_radiation_calls
        
        line = ' '
@@ -1630,5 +1628,5 @@
                rrtm_ch4vmr     , rrtm_n2ovmr  , rrtm_o2vmr , rrtm_asdir(:,j,i),&
                rrtm_asdif(:,j,i), rrtm_aldir(:,j,i), rrtm_aldif(:,j,i), zenith,&
-               0.0_wp          , day          , solar_constant,   rrtm_inflgsw,&
+               0.0_wp          , day_of_year  , solar_constant,   rrtm_inflgsw,&
                rrtm_iceflgsw   , rrtm_liqflgsw, rrtm_cldfr , rrtm_sw_taucld   ,&
                rrtm_sw_ssacld  , rrtm_sw_asmcld, rrtm_sw_fsfcld, rrtm_cicewp  ,&
@@ -1693,12 +1691,9 @@
 !--    Calculate current day and time based on the initial values and simulation
 !--    time
-       day = day_init + INT(FLOOR( (time_utc_init + time_since_reference_point)&
-                               / 86400.0_wp ), KIND=iwp)
-       time_utc = MOD((time_utc_init + time_since_reference_point), 86400.0_wp)
-
+       CALL calc_date_and_time
 
 !
 !--    Calculate solar declination and hour angle   
-       declination = ASIN( decl_1 * SIN(decl_2 * REAL(day, KIND=wp) - decl_3) )
+       declination = ASIN( decl_1 * SIN(decl_2 * REAL(day_of_year, KIND=wp) - decl_3) )
        hour_angle  = 2.0_wp * pi * (time_utc / 86400.0_wp) + lon - pi
 
Index: palm/trunk/SOURCE/time_integration_spinup.f90
===================================================================
--- palm/trunk/SOURCE/time_integration_spinup.f90	(revision 2543)
+++ palm/trunk/SOURCE/time_integration_spinup.f90	(revision 2544)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Date and time quantities are now read from date_and_time_mod 
+! 
+! 2299 2017-06-29 10:14:38Z maronga
 ! Call of soil model adjusted to avoid prognostic equation for soil moisture
 ! during spinup.
@@ -67,4 +70,7 @@
         ONLY:  cpu_log, log_point, log_point_s
 
+    USE date_and_time_mod,                                                     &
+        ONLY: day_of_year_init, time_utc_init
+
     USE indices,                                                               &
         ONLY:  nbgp, nzb, nzt, nysg, nyng, nxlg, nxrg
@@ -81,5 +87,5 @@
     USE radiation_model_mod,                                                   &
         ONLY:  dt_radiation, force_radiation_call, radiation,                  &
-               radiation_control, rad_sw_in, time_radiation, time_utc_init
+               radiation_control, rad_sw_in, time_radiation 
 
     USE statistics,                                                            &
@@ -425,10 +431,10 @@
 
        USE constants,                                                          &
-           ONLY:  pi
-       
+       ONLY:  pi
+      
        USE kinds
 
        USE radiation_model_mod,                                                &
-           ONLY:  day_init, decl_1, decl_2, decl_3, lat, lon
+           ONLY:  decl_1, decl_2, decl_3, lat, lon
 
        IMPLICIT NONE 
@@ -446,5 +452,5 @@
 !--    time
 
-       day = day_init + INT(FLOOR( local_time / 86400.0_wp ), KIND=iwp)
+       day = day_of_year_init + INT(FLOOR( local_time / 86400.0_wp ), KIND=iwp)
        time_utc = MOD(local_time, 86400.0_wp)
 
Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2543)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2544)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Date and time quantities are now read from date_and_time_mod. Solar constant is
+! read from radiation_model_mod
+! 
+! 2516 2017-10-04 11:03:04Z suehring
 ! Remove tabs
 ! 
@@ -171,4 +175,7 @@
         ONLY:  cpu_log, log_point, log_point_s
      
+    USE date_and_time_mod,                                                     &
+        ONLY:  d_seconds_year, day_of_year_init, time_utc_init
+   
     USE grid_variables,                                                        &
         ONLY:  dx, dy, ddx, ddy, ddx2, ddy2
@@ -189,8 +196,8 @@
     
     USE radiation_model_mod,                                                   &
-        ONLY:  radiation, calc_zenith, zenith, day_init, time_utc_init,        &
+        ONLY:  radiation, calc_zenith, zenith,                                 &
                rad_net, rad_sw_in, rad_lw_in, rad_sw_out, rad_lw_out,          &
-               sigma_sb, sun_direction, sun_dir_lat, sun_dir_lon,              &
-               force_radiation_call
+               sigma_sb, solar_constant, sun_direction, sun_dir_lat,           &
+               sun_dir_lon, force_radiation_call
 
     USE statistics,                                                            &
@@ -1757,8 +1764,6 @@
     SUBROUTINE usm_calc_diffusion_radiation 
     
-        REAL(wp), PARAMETER                          ::  sol_const = 1367.0_wp   !< solar conbstant
         REAL(wp), PARAMETER                          :: lowest_solarUp = 0.1_wp  !< limit the sun elevation to protect stability of the calculation
         INTEGER(iwp)                                 :: i, j
-        REAL(wp), PARAMETER                          ::  year_seconds = 86400._wp * 365._wp
         REAL(wp)                                     ::  year_angle              !< angle
         REAL(wp)                                     ::  etr                     !< extraterestrial radiation
@@ -1770,11 +1775,12 @@
         
 !--     Calculate current day and time based on the initial values and simulation time
-        year_angle = ((day_init*86400) + time_utc_init+time_since_reference_point) &
-                       / year_seconds * 2.0_wp * pi
-        
-        etr = sol_const * (1.00011_wp +                                            &
-                          0.034221_wp * cos(year_angle) +                          &
-                          0.001280_wp * sin(year_angle) +                          &
-                          0.000719_wp * cos(2.0_wp * year_angle) +                 &
+        year_angle = ( (day_of_year_init * 86400) + time_utc_init              &
+                        + time_since_reference_point )  * d_seconds_year       &
+                        * 2.0_wp * pi
+        
+        etr = solar_constant * (1.00011_wp +                                   &
+                          0.034221_wp * cos(year_angle) +                      &
+                          0.001280_wp * sin(year_angle) +                      &
+                          0.000719_wp * cos(2.0_wp * year_angle) +             &
                           0.000077_wp * sin(2.0_wp * year_angle))
         
