Set an environment variable depending on cycle

Hi. I’d like to set environment variable FIRST_CYCLE = true if I am running in the 1st cycle, and set it to false in subsequent cycles. What is the best way to do this?
Thanx!

There is a list of environment variables available in job scripts here: Job Script Environment Variables — Cylc 8.3.4 documentation

So you would want something like this

if [[ "$CYLC_TASK_CYCLE_POINT" == "$CYLC_WORKFLOW_INITIAL_CYCLE_POINT" ]]; then
    ...

Depending on requirements, you can also handle different behaviour in the first cycle with a different graph structure. E.g.:

[scheduling]
    cycling mode = integer
    initial cycle point = 1
    [[graph]]
        R1 = "foo1"  # once at first cycle
        R/2/P1 = "foo"  # every cycle from 2
[runtime]
    [[foo1, foo]]
        script = "echo my name is $CYLC_TASK_NAME"
1 Like