# Unique Scheduling Specification

**URL:** <https://cylc.discourse.group/t/unique-scheduling-specification/859>\
**Category:** Cylc Support\
**Created:** [January 18, 2024, 8:23pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859 "2024-01-18T20:23:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtsu](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jtsu/32/517_2.png) [@jtsu](https://cylc.discourse.group/u/jtsu)\
**Post date:** [January 18, 2024, 8:23pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/1 "2024-01-18T20:23:35Z")

</div>

Hello,  
I am using Cylc version 7.9.3. I’ve come across a particular situation where I need particular tasks to run only once at the beginning of the suite, but only if the hour is a 00z or 12z. So if the initial cycle point is 20210806T06, then this task should only run once and it should only run on 20210806T12. So far, I have this:

```ini
[[[R1/T00,T12]]]
    graph = """
        stage_verify => grid_stat_run
    """

```

Testing this, though, shows that stage\_verify (which is the task I want to only run once), in fact runs every cycle point that ends in a 00Z or 12Z.

How do I get this to only run once during the course of the entire cycling but during the first instance of a 00Z or 12Z, whichever comes first relative to the initial cycle point?

---

<div class="post-metadata">

**Author:** ![hilary.j.oliver](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/hilary.j.oliver/32/4_2.png) [@hilary.j.oliver](https://cylc.discourse.group/u/hilary.j.oliver)\
**Post date:** [January 18, 2024, 10:01pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/2 "2024-01-18T22:01:42Z")

</div>

Firstly, `[[[R1/T00,T12]]]` is equivalent to (separately) `[[[R1/T00]]]` and `[[[T12]]]`(not `R1/T12`). So you should see, e.g. via `cylc graph` or at run time, that the tasks will run at the first T00 and T12 points, and every T12 after that.  
So it should be `[[[R1/T00, R1/T12]]]` if you want to combine them.

However, for what you really want, try this:

```ini
initial cycle point = next(T00; T12) # note semicolon separator
[[[R1]]]
   graph = "stage_verify => grid_stat_run"

```

In the old Cylc 7 documentation, see: [15.1. Suite.rc Reference — The Cylc Suite Engine 7.9.3 documentation](https://cylc.github.io/cylc-doc/7.9.3/html/appendices/suiterc-config-ref.html#scheduling-initial-cycle-point-initial-cycle-point-relative-to-current-time)

For Cylc 8: [Scheduling Configuration — Cylc 8.2.3 documentation](https://cylc.github.io/cylc-doc/stable/html/user-guide/writing-workflows/scheduling.html#setting-the-initial-cycle-point-relative-to-the-current-time)

---

<div class="post-metadata">

**Author:** ![jtsu](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jtsu/32/517_2.png) [@jtsu](https://cylc.discourse.group/u/jtsu)\
**Post date:** [January 18, 2024, 11:43pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/3 "2024-01-18T23:43:20Z")

</div>

Thanks for the quick response. What if I wanted to accomplish this relative to a specified initial cycle point instead of current local time?

---

<div class="post-metadata">

**Author:** ![wxtim](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/wxtim/32/151_2.png) [@wxtim](https://cylc.discourse.group/u/wxtim)\
**Post date:** [January 19, 2024, 8:35am UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/4 "2024-01-19T08:35:20Z")

</div>

If you are setting the ICP, why would you not set it to be anything other than --------T12–Z or T00–Z?

If you are writing for other users you can set [[scheduler]initial cycle point constraints](https://cylc.github.io/cylc-doc/7.8.8/html/appendices/suiterc-config-ref.html?highlight=next#scheduling-initial-cycle-point-constraints):

```ini
[scheduler]
    initial cycle point constraints = T00, T12

```

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [January 19, 2024, 10:08am UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/5 "2024-01-19T10:08:51Z")

</div>

Hi,

It’s ugly, but it does the job:

```ini
[scheduler]
    allow implicit tasks = True

[scheduling]
    initial cycle point = 2000-01-01T12Z
    [[graph]]
        R1/T00 ! ( R1/^+PT6H, R1/^+PT12H, R1/^+PT18H, R1/^+PT24H) = """
            t00
        """
        R1/T12 ! ( R1/^+PT6H, R1/^+PT12H, R1/^+PT18H, R1/^+PT24H) = """
            t12
        """

```

- `R1/T00` - run once at the first instance of `T00`
- `R1/^+PT6H` - run once, six hours after the initial cycle point
- `R1/T00 ! R1/^+PT6H` - run once at the first instance of `T00` UNLESS it is six hours after the initial cycle point.
- `R1/T00 ! ( R1/^+PT6H, R1/^+PT12H, R1/^+PT18H, R1/^+PT24H)` - run once at the first instance of `T00` UNLESS it is a multiple of six hours after the initial cycle point.

Chaining up long lists of [exclusions](https://cylc.github.io/cylc-doc/stable/html/user-guide/writing-workflows/scheduling.html#excluding-recurrences) (`!`) can increase the computational load of the scheduler, but in this case the recurrence is only run once (`R1`) so the impact won’t persist for the live of the workflow.

* * *

However, it is worth noting that there is also a Jinja2 solution using the [strftime](https://cylc.github.io/cylc-doc/stable/html/user-guide/writing-workflows/jinja2.html#cylc.flow.jinja.filters.strftime.strftime) filter:

```jinja2
#!Jinja2

{# untested! #}

{% set ICP="2000-01-01T00" %}

[scheduling]
    initial cycle point = {{ ICP }}
    [[graph]]
{% if ICP | strftime('%H') == '00' %}
        R1/T00 = t00
{% else if ICP | strftime('%H') == '12' %}
        R1/T12 = t12
{% endif %}

```

Ar rare case where the Jinja2 solution might actually be a little more readable!

---

<div class="post-metadata">

**Author:** ![jtsu](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jtsu/32/517_2.png) [@jtsu](https://cylc.discourse.group/u/jtsu)\
**Post date:** [January 19, 2024, 10:44pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/6 "2024-01-19T22:44:19Z")

</div>

This is a specific scenario where verification must only be run on the 0z and 12z times, as we only have verifying data for these hours. However, the user might want to start forecasts on 6z or 18z. If this occurs, verification will not occur on 6z/18z but will occurs one cycle later (12z/0z, respectively)

---

<div class="post-metadata">

**Author:** ![jtsu](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jtsu/32/517_2.png) [@jtsu](https://cylc.discourse.group/u/jtsu)\
**Post date:** [January 19, 2024, 10:47pm UTC](https://cylc.discourse.group/t/unique-scheduling-specification/859/7 "2024-01-19T22:47:44Z")

</div>

Thank you! The “exclusions” hyperlink actually led me to the very answer that I needed. The syntax that worked for me was

[[[R1/min(T00,T12)]]]

This runs the intended tasks in the first 00z or 12z (but not both), after the ICP. I just tested this and it works as I expect.

I appreciate the help
