# Include a task in all but the first cycle point

**URL:** <https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115>\
**Category:** Cylc Support\
**Created:** [August 7, 2019, 2:12am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115 "2019-08-07T02:12:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [August 7, 2019, 2:12am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/1 "2019-08-07T02:12:07Z")

</div>

Hi there

In [this](https://cylc.github.io/doc/built-sphinx-single/index.html#initial-non-repeating-r1-tasks) section of the Cylc docs, it tells you how to include something in only the first cycle point of a suite.

How would I include a task in every cycle apart from the first one?

Thanks!

Jonny

---

<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:** [August 7, 2019, 3:32am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/2 "2019-08-07T03:32:50Z")

</div>

Hi Jonny,

That’s easy to do with the full form of the graph recurrence notation: **R[n]/A/D** means **R** epeat ( **n** times if given, else indefinitely) from start cycle point **A** , with interval **D**. And the start cycle point for the sequence can be given relative to the suite’s initial cycle point (denoted **^** ).

An example, for a yearly cycle:

```auto
[cylc]
    cycle point format = %Y
[scheduling]
    initial cycle point = 2000
    [[dependencies]]
        [[[R/^/P1Y]]] # initial cycle point onward (can be shortened to just "P1Y")
             graph = "foo[-P1Y] => foo => bar"
        [[[R/^+P1Y/P1Y]]] # second cycle point onward 
             graph = "foo => qux"

```

Result:

 ![foo](https://global.discourse-cdn.com/free1/uploads/cylc1/original/1X/53424487be16ba1763f0b18beb2c6485b5228dbb.png)

Hilary

---

<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:** [August 7, 2019, 4:03pm UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/3 "2019-08-07T16:03:13Z")

</div>

Hi,

There is some good documentation on recurrence sections in another part of the docs ([https://cylc.github.io/doc/built-sphinx-single/index.html](https://cylc.github.io/doc/built-sphinx-single/index.html)) I often look back to this list of examples ([https://cylc.github.io/doc/built-sphinx-single/index.html#advanced-examples](https://cylc.github.io/doc/built-sphinx-single/index.html#advanced-examples)).

Hillary’s solution is the nicest (to those familiar with Cylc’s internals):

```auto
R/^+P1Y/P1Y

```

There is another approach which has it’s place which is to exclude (`!`) the intitial cycle point (`^`) from the recurrence:

```auto
R/P1Y!^

```

[https://cylc.github.io/doc/built-sphinx-single/index.html#advanced-exclusion-syntax](https://cylc.github.io/doc/built-sphinx-single/index.html#advanced-exclusion-syntax)

---

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [August 8, 2019, 2:15am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/4 "2019-08-08T02:15:07Z")

</div>

Many thanks for your help Hilary and Oliver!

The suite I am working on is somewhat more complex than this however!

This is the section I want to change…

```
[[[R/^/{{FMT}}]]]
    graph = """
        {% if RUN %}
            coupled[-{{FMT}}] => coupled {{ '=> \\' if POSTPROC or HOUSEKEEP else '' }}
        {% if POSTPROC %}
            POSTPROC_GROUP{{ ':succeed-all => \\' if HOUSEKEEP else '' }}
        {% endif %}
        {% if HOUSEKEEP %}
            housekeeping
        {% endif %}
        {% if POSTPROC and SPLIT_PP %}
            postproc_atmos[-{{FMT}}] => postproc_atmos
            postproc_cice[-{{FMT}}] => postproc_cice
            postproc_nemo[-{{FMT}}] => postproc_nemo
        {% elif POSTPROC %}
            postproc[-{{FMT}}] => postproc
        {% endif %}
        {% endif %}
"""

```

Basically all I want to do is to change `housekeeping` to `py_for_afterburner => housekeeping` for every cycle point apart from the first one.

In this example would be easier (possible?!) to use an `if` statement instead?

Thanks 🙂

---

<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:** [August 8, 2019, 3:02am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/5 "2019-08-08T03:02:39Z")

</div>

Hi Jonny,

> would be easier (possible?!) to use an `if` statement instead?

If you mean a Jinja2 `{% if … %}’ statement to test if the current cycle point is the initial cycle point - no you certainly can’t do that because Jinja2 is a template preprocessor: it is all “processed out” when the suite is parsed, to generate the final suite configuration that Cylc sees (i.e. it all happens _before runtime_ so there is no “current cycle point” to compare).

You could run `py_for_afterburner => housekeeping` in all cycles including the first, but use a run time test in the `py_for_afterburner` job scripting to compare `$CYLC_TASK_CYCLE_POINT` with `$CYLC_SUITE_INITIAL_CYCLE_POINT`, and have the task succeed without doing anything in the initial cycle (and only do its real work in cycle point two onward). However, that makes the graph somewhat misleading. Better to do what Oliver and I suggested above, either method works (the complexity of your suite - as shown at least - is only in the Jinja2 switches to construct the graph based on input variables; in terms of cycling it is just a single straightforward sequence). Here it is with Oliver’s method:

```auto
  [[dependencies]]
     [[[R1]]] # first cycle point only
        graph = "stuff => housekeeping"
     [[[{{FMT}}!^]]] # every cycle point except for the first 
        graph = "stuff => py_for_afterburner => housekeeping"

```

---

<div class="post-metadata">

**Author:** ![jonnyhtw](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtw/32/232_2.png) [@jonnyhtw](https://cylc.discourse.group/u/jonnyhtw)\
**Post date:** [August 8, 2019, 3:12am UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/6 "2019-08-08T03:12:11Z")

</div>

OK great, that works! 🥳

Here’s the fixed graph…

 ![Annotation%202019-08-08%20151002](https://global.discourse-cdn.com/free1/uploads/cylc1/original/1X/2a9dc21d6ce0673be2e6b0de3ff2c30e8b82f3bf.png)

Thanks a lot for your help, and to Oliver too of course.

Jonny

---

<div class="post-metadata">

**Author:** ![jonnyhtwilliams](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/jonnyhtwilliams/32/567_2.png) [@jonnyhtwilliams](https://cylc.discourse.group/u/jonnyhtwilliams)\
**Post date:** [January 13, 2026, 3:40pm UTC](https://cylc.discourse.group/t/include-a-task-in-all-but-the-first-cycle-point/115/7 "2026-01-13T15:40:58Z")

</div>

Hi all.

Just FYI I’ve revisited this issue from Cylc 8 world and I thought I’d post this in case it is of interest.

In the below, I wanted `pptransfer` to only run from the 2nd cycle point onwards and this solution works. The `vimdiff` output shows a before and after, where the before incldue `pptransfer` in all cycle points.

Cheers.

 ![image](https://global.discourse-cdn.com/free1/uploads/cylc1/original/1X/f908b008340ba6bf2d105d3782034fa85b11bd29.png)
