Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using 360 day calendar #971

Merged
merged 3 commits into from
Jun 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/cylc.lang
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
sed "/^#/d; /^[^=]*$/d; /__many__/d; s/^ *\([^=]*\) =.*$/ <keyword>\1<\/keyword>/g" $CYLC_DIR/conf/suiterc/* | sort | uniq
-->
<keyword>UTC mode</keyword>
<keyword>calendar</keyword>
<keyword>abort if any task fails</keyword>
<keyword>abort if shutdown handler fails</keyword>
<keyword>abort if startup handler fails</keyword>
Expand Down
1 change: 1 addition & 0 deletions conf/cylc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<RegExpr attribute='Keyword' String=' abort if shutdown handler fails '/>
<RegExpr attribute='Keyword' String=' abort if any task fails '/>
<RegExpr attribute='Keyword' String=' UTC mode '/>
<RegExpr attribute='Keyword' String=' calendar '/>
<!-- Non-keyword syntax -->
<RegExpr attribute="Section" String="^ *\[.*\] *$" />
<RegExpr attribute='Assignment' String='=&gt;'/>
Expand Down
4 changes: 3 additions & 1 deletion doc/cug.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,9 @@ \subsubsection{Graph Types (VALIDITY)}
{\em interval}, and an optional {\em limit}.

The time is assumed to be in the local time zone unless you set
\lstinline=[cylc]cycle point time zone= or \lstinline=[cylc]UTC mode=.
\lstinline=[cylc]cycle point time zone= or \lstinline=[cylc]UTC mode=. The
calendar is assumed to be the proleptic Gregorian calendar unless you set
\lstinline=[cylc]calendar=.

The syntax for representations is based on the ISO 8601 date-time standard.
This includes the representation of {\em date-time}, {\em interval}. What we
Expand Down
14 changes: 14 additions & 0 deletions doc/suiterc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ \subsection{[cylc]}
\item {\em default:} False
\end{myitemize}

\subsubsection[calendar]{ [cylc] $\rightarrow$ calendar}
\label{calendar}

Cylc runs using the proleptic Gregorian calendar by default. This item allows
you to run the suite using the 360 day calendar - 12 months of 30 days in a
year.

\begin{myitemize}
\item {\em type:} string
\item {\em legal values:} gregorian, 360
\item {\em default:} gregorian

\end{myitemize}

\subsubsection[cycle point format]{ [cylc] $\rightarrow$ cycle point format}
\label{cycle-point-format}

Expand Down
1 change: 1 addition & 0 deletions lib/cylc/cfgspec/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def _coerce_cycletime_time_zone( value, keys, args ):
'description' : vdr( vtype='string', default="" ),
'cylc' : {
'UTC mode' : vdr( vtype='boolean', default=False),
'calendar' : vdr( vtype='string', default='gregorian', options=['360','gregorian'] ),
'cycle point format' : vdr( vtype='cycletime_format', default=None),
'cycle point num expanded year digits': vdr( vtype='integer', default=0),
'cycle point time zone' : vdr( vtype='cycletime_time_zone', default=None),
Expand Down
14 changes: 10 additions & 4 deletions lib/cylc/cycling/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#C: along with this program. If not, see <http://www.gnu.org/licenses/>.

import re
from isodatetime.data import TimeInterval
import isodatetime.data
from isodatetime.dumpers import TimePointDumper
from isodatetime.parsers import TimePointParser, TimeIntervalParser
from isodatetime.timezone import (
Expand Down Expand Up @@ -159,7 +159,7 @@ def get_inferred_child(self, string):
"hours", "minutes", "seconds"]:
if getattr(interval, attribute):
unit_amounts[attribute] = amount_per_unit
interval = TimeInterval(**unit_amounts)
interval = isodatetime.data.TimeInterval(**unit_amounts)
return ISO8601Interval(str(interval))

def standardise(self):
Expand Down Expand Up @@ -430,6 +430,7 @@ def init_from_cfg(cfg):
initial_cycle_time = cfg['scheduling']['initial cycle time']
final_cycle_time = cfg['scheduling']['final cycle time']
assume_utc = cfg['cylc']['UTC mode']
calendar = cfg['cylc']['calendar']
test_cycle_time = initial_cycle_time
if initial_cycle_time is None:
test_cycle_time = final_cycle_time
Expand All @@ -453,17 +454,22 @@ def init_from_cfg(cfg):
num_expanded_year_digits=num_expanded_year_digits,
custom_dump_format=custom_dump_format,
time_zone=time_zone,
assume_utc=assume_utc
assume_utc=assume_utc,
calendar=calendar
)


def init(num_expanded_year_digits=0, custom_dump_format=None, time_zone=None,
assume_utc=False):
assume_utc=False, calendar="gregorian"):
"""Initialise global variables (yuk)."""
global point_parser
global DUMP_FORMAT
global NUM_EXPANDED_YEAR_DIGITS
global ASSUMED_TIME_ZONE

if calendar == "360":
isodatetime.data.set_360_calendar()

if time_zone is None:
if assume_utc:
time_zone = "Z"
Expand Down
4 changes: 4 additions & 0 deletions lib/cylc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ def configure_suite( self, reconfigure=False ):
# Running in UTC time? (else just use the system clock)
flags.utc = self.config.cfg['cylc']['UTC mode']

# Capture calendar mode
flags.calendar = self.config.cfg['cylc']['calendar']

if not reconfigure:
slog = suite_log( self.suite )
self.suite_log_dir = slog.get_dir()
Expand Down Expand Up @@ -733,6 +736,7 @@ def configure_suite_environment( self ):
# static cylc and suite-specific variables:
self.suite_env = {
'CYLC_UTC' : str(flags.utc),
'CYLC_CALENDAR' : str(flags.calendar),
'CYLC_MODE' : 'scheduler',
'CYLC_DEBUG' : str( flags.debug ),
'CYLC_VERBOSE' : str( flags.verbose ),
Expand Down
31 changes: 31 additions & 0 deletions tests/cyclers/24-360_calendar.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#C: THIS FILE IS PART OF THE CYLC SUITE ENGINE.
#C: Copyright (C) 2008-2014 Hilary Oliver, NIWA
#C:
#C: This program is free software: you can redistribute it and/or modify
#C: it under the terms of the GNU General Public License as published by
#C: the Free Software Foundation, either version 3 of the License, or
#C: (at your option) any later version.
#C:
#C: This program is distributed in the hope that it will be useful,
#C: but WITHOUT ANY WARRANTY; without even the implied warranty of
#C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#C: GNU General Public License for more details.
#C:
#C: You should have received a copy of the GNU General Public License
#C: along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
#C: Test intercycle dependencies.
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE 360
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-validate
run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
41 changes: 41 additions & 0 deletions tests/cyclers/360/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
2014-06-13T09:54:26+01 INFO - Thread-2 start (Event Handlers)
2014-06-13T09:54:26+01 INFO - Thread-3 start (Poll & Kill Commands)
2014-06-13T09:54:26+01 INFO - port:7766
2014-06-13T09:54:26+01 INFO - Suite starting at 2014-06-13T09:54:26+01
2014-06-13T09:54:26+01 INFO - Log event clock: real time
2014-06-13T09:54:26+01 INFO - Run mode: live
2014-06-13T09:54:26+01 INFO - Start tag: 20130228T00
2014-06-13T09:54:26+01 INFO - Stop tag: 20130301T00
2014-06-13T09:54:26+01 INFO - Thread-5 start (Request Handling)
2014-06-13T09:54:26+01 INFO - Thread-4 start (Job Submission)
2014-06-13T09:54:26+01 INFO - Cold Start 20130228T00
2014-06-13T09:54:26+01 INFO - [foo.20130228T0000Z] -triggered off []
2014-06-13T09:54:27+01 INFO - [foo.20130228T0000Z] -(current:ready)> foo.20130228T0000Z submitting now
2014-06-13T09:54:28+01 INFO - [foo.20130228T0000Z] -(current:ready)> foo.20130228T0000Z submission succeeded
2014-06-13T09:54:28+01 INFO - [foo.20130228T0000Z] -(current:submitted)> foo.20130228T0000Z submit_method_id=7793
2014-06-13T09:54:28+01 INFO - [foo.20130228T0000Z] -(current:submitted)> foo.20130228T0000Z started at 2014-06-13T08:54:28Z
2014-06-13T09:54:29+01 INFO - [foo.20130228T0000Z] -(current:running)> foo.20130228T0000Z succeeded at 2014-06-13T08:54:28Z
2014-06-13T09:54:30+01 INFO - [foo.20130229T0000Z] -triggered off ['foo.20130228T0000Z']
2014-06-13T09:54:31+01 INFO - [foo.20130229T0000Z] -(current:ready)> foo.20130229T0000Z submitting now
2014-06-13T09:54:31+01 INFO - [foo.20130229T0000Z] -(current:ready)> foo.20130229T0000Z submission succeeded
2014-06-13T09:54:31+01 INFO - [foo.20130229T0000Z] -(current:submitted)> foo.20130229T0000Z submit_method_id=7902
2014-06-13T09:54:32+01 INFO - [foo.20130229T0000Z] -(current:submitted)> foo.20130229T0000Z started at 2014-06-13T08:54:31Z
2014-06-13T09:54:32+01 INFO - [foo.20130229T0000Z] -(current:running)> foo.20130229T0000Z succeeded at 2014-06-13T08:54:32Z
2014-06-13T09:54:33+01 INFO - [foo.20130230T0000Z] -triggered off ['foo.20130229T0000Z']
2014-06-13T09:54:34+01 INFO - [foo.20130230T0000Z] -(current:ready)> foo.20130230T0000Z submitting now
2014-06-13T09:54:34+01 INFO - [foo.20130230T0000Z] -(current:ready)> foo.20130230T0000Z submission succeeded
2014-06-13T09:54:34+01 INFO - [foo.20130230T0000Z] -(current:submitted)> foo.20130230T0000Z submit_method_id=8008
2014-06-13T09:54:35+01 INFO - [foo.20130230T0000Z] -(current:submitted)> foo.20130230T0000Z started at 2014-06-13T08:54:35Z
2014-06-13T09:54:35+01 INFO - [foo.20130230T0000Z] -(current:running)> foo.20130230T0000Z succeeded at 2014-06-13T08:54:35Z
2014-06-13T09:54:36+01 INFO - [foo.20130301T0000Z] -triggered off ['foo.20130230T0000Z']
2014-06-13T09:54:37+01 INFO - [foo.20130301T0000Z] -(current:ready)> foo.20130301T0000Z submitting now
2014-06-13T09:54:38+01 INFO - [foo.20130301T0000Z] -(current:ready)> foo.20130301T0000Z submission succeeded
2014-06-13T09:54:38+01 INFO - [foo.20130301T0000Z] -(current:submitted)> foo.20130301T0000Z submit_method_id=8117
2014-06-13T09:54:38+01 INFO - [foo.20130301T0000Z] -(current:submitted)> foo.20130301T0000Z started at 2014-06-13T08:54:38Z
2014-06-13T09:54:38+01 INFO - [foo.20130301T0000Z] -(current:running)> foo.20130301T0000Z succeeded at 2014-06-13T08:54:38Z
2014-06-13T09:54:39+01 WARNING - [foo.20130302T0000Z] -not adding (beyond suite stop cycle) 20130301T00
2014-06-13T09:54:39+01 INFO - Stopping:
+ all cycling tasks have spawned past the final cycle 20130301T00
2014-06-13T09:54:40+01 INFO - Thread-2 exit (Event Handlers)
2014-06-13T09:54:40+01 INFO - Thread-3 exit (Poll & Kill Commands)
2014-06-13T09:54:40+01 INFO - Thread-4 exit (Job Submission)
15 changes: 15 additions & 0 deletions tests/cyclers/360/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[cylc]
UTC mode = True
calendar = 360
[[reference test]]
required run mode = live
live mode suite timeout = 0.5 # minutes
[scheduling]
initial cycle time = 20130228T00
final cycle time = 20130301T00
[[dependencies]]
[[[ P1D ]]]
graph = foo[-P1D] => foo
[runtime]
[[foo]]
command scripting = true