Index: palm/trunk/SOURCE/palm_date_time_mod.f90
===================================================================
--- palm/trunk/SOURCE/palm_date_time_mod.f90	(revision 4360)
+++ palm/trunk/SOURCE/palm_date_time_mod.f90	(revision 4680)
@@ -1,30 +1,32 @@
 !> @file palm_date_time_mod.f90
-!------------------------------------------------------------------------------!
+!--------------------------------------------------------------------------------------------------!
 ! This file is part of the PALM model system.
 !
-! 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/>.
+! 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-2020 Leibniz Universitaet Hannover
-!------------------------------------------------------------------------------!
+!--------------------------------------------------------------------------------------------------!
 !
 ! Current revisions:
 ! ------------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Add option to fix date and time; renamed set_reference_date_time to init_date_time
+!
+! 4360 2020-01-07 11:25:50Z suehring
 ! Add days of northward- and southward equinox
-! 
+!
 ! 4227 2019-09-10 18:04:34Z gronemeier
 ! Complete rework of module date_and_time_mod:
@@ -48,10 +50,10 @@
 !>
 !> @todo Consider leap seconds
-!> @note Time_zone only supports full-hour time zones, i.e., time zones like
-!>       Australian Central Standard Time (UTC+9.5) are not possible
-!------------------------------------------------------------------------------!
+!> @note Time_zone only supports full-hour time zones, i.e., time zones like Australian Central
+!>       Standard Time (UTC+9.5) are not possible
+!--------------------------------------------------------------------------------------------------!
  MODULE palm_date_time_mod
 
-    USE control_parameters,                                                    &
+    USE control_parameters,                                                                        &
          ONLY:  message_string
 
@@ -68,8 +70,7 @@
     INTEGER(iwp), PARAMETER ::  months_per_year    = 12_iwp                                 !< months in a year
 !
-!-- Definition of mean northward and southward equinox (summer and winter half year) 
-!-- in days of year. For simplicity, March 21 and September 21 is assumed.
-    INTEGER(iwp), PARAMETER ::  northward_equinox  = 80_iwp
-    INTEGER(iwp), PARAMETER ::  southward_equinox  = 264_iwp
+!-- Day of year of the mean northward and southward equinox (summer and winter half year)
+    INTEGER(iwp), PARAMETER ::  northward_equinox  = 80_iwp                                 !< Mar 21 (leap year: Mar 20)
+    INTEGER(iwp), PARAMETER ::  southward_equinox  = 264_iwp                                !< Sep 21 (leap year: Sep 20)
 
     REAL(wp),     PARAMETER ::  seconds_per_minute = 60.0_wp                                !< seconds in a minute
@@ -124,5 +125,7 @@
 !
 !-- Variable Declaration
+    LOGICAL              ::  date_is_fixed              = .FALSE.  !< if true, date is fixed (time can still change)
     LOGICAL              ::  reference_date_time_is_set = .FALSE.  !< true if reference_date_time is set
+    LOGICAL              ::  time_is_fixed              = .FALSE.  !< if true, time does not change at all
 
     TYPE(date_time_type) ::  reference_date_time                   !< reference date-time
@@ -133,7 +136,7 @@
 !
 !-- Set reference date and time
-    INTERFACE set_reference_date_time
-        MODULE PROCEDURE set_reference_date_time
-    END INTERFACE set_reference_date_time
+    INTERFACE init_date_time
+        MODULE PROCEDURE init_date_time
+    END INTERFACE init_date_time
 !
 !-- Return date and time information
@@ -145,5 +148,5 @@
     PUBLIC &
        get_date_time, &
-       set_reference_date_time
+       init_date_time
 !
 !-- Public variables
@@ -167,11 +170,14 @@
 ! Description:
 ! ------------
-!> Set reference date-time.
+!> Initialize date-time setting by defining a global reference date-time and choosing a variable or
+!> fixed date.
 !> Only a single call is allowed to this routine during execution.
 !--------------------------------------------------------------------------------------------------!
- SUBROUTINE set_reference_date_time( date_time_str )
+ SUBROUTINE init_date_time( date_time_str, use_fixed_date, use_fixed_time )
 
     CHARACTER(LEN=date_time_str_len), INTENT(IN) ::  date_time_str  !< string containing date-time information
 
+    LOGICAL, INTENT(IN), OPTIONAL ::  use_fixed_date  !< flag to fix date
+    LOGICAL, INTENT(IN), OPTIONAL ::  use_fixed_time  !< flag to fix time
 !
 !-- Check if date and time are already set
@@ -179,7 +185,7 @@
        !> @note This error should never be observed by a user.
        !>       It can only appear if the code was modified.
-       WRITE( message_string, * ) 'Multiple calls to set_reference_date_time detected.&' //  &
-                                  'The reference date-time must be set only once.'
-       CALL message( 'set_reference_date_time', 'PA0680', 2, 2, 0, 6, 0 )
+       WRITE( message_string, * ) 'Multiple calls to init_date_time detected.&' //  &
+                                  'This routine must not be called more than once.'
+       CALL message( 'init_date_time', 'PA0680', 2, 2, 0, 6, 0 )
        RETURN
 
@@ -190,7 +196,10 @@
        reference_date_time_is_set = .TRUE.
 
-    ENDIF
-
- END SUBROUTINE set_reference_date_time
+       IF ( PRESENT( use_fixed_date ) )  date_is_fixed = use_fixed_date
+       IF ( PRESENT( use_fixed_time ) )  time_is_fixed = use_fixed_time
+
+    ENDIF
+
+ END SUBROUTINE init_date_time
 
 
@@ -201,5 +210,5 @@
 !> An alternative reference date-time string can be specified via 'reference_date_time_str'.
 !> Call to this routine is only possible if a reference time is either specified in the call itself
-!> via 'reference_date_time_str' or previously set by calling routine 'set_reference_date_time'.
+!> via 'reference_date_time_str' or previously set by calling routine 'init_date_time'.
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE get_date_time( time_since_reference, reference_date_time_str,    &
@@ -241,5 +250,5 @@
                                   'Returning date-time information is not possible. ' // &
                                   'Either specify reference_date_time_str ' //           &
-                                  'or set a reference via set_reference_date_time.'
+                                  'or set a reference via init_date_time.'
        CALL message( 'get_date_time', 'PA0677', 2, 2, 0, 6, 0 )
        RETURN
@@ -252,7 +261,31 @@
        internal_reference_date_time = reference_date_time
     ENDIF
-!
-!-- Add time to reference time
-    date_time = add_date_time( time_since_reference, internal_reference_date_time )
+
+    IF ( time_is_fixed )  THEN
+!
+!--    If time shall not change, set new time to reference time
+       date_time = internal_reference_date_time
+    ELSE
+!
+!--    Add time to reference time
+       date_time = add_date_time( time_since_reference, internal_reference_date_time )
+!
+!--    If date shall be fixed, revert it to the reference date if changed
+       IF ( date_is_fixed )  THEN
+          IF ( date_time%year /= internal_reference_date_time%year  .OR.                          &
+               get_day_of_year( date_time ) /= get_day_of_year( internal_reference_date_time ) )  &
+          THEN
+
+             date_time%year           = internal_reference_date_time%year
+             date_time%month          = internal_reference_date_time%month
+             date_time%day            = internal_reference_date_time%day
+
+             date_time = update_leapyear_setting( date_time )
+
+             date_time%second_of_year = get_second_of_year( date_time )
+
+          ENDIF
+       ENDIF
+    ENDIF
 !
 !-- Set requested return values
