
# Complete a parentless switch task that already exists in the pool but is
# beyond the runahead limit. Cylc should auto-spawn its next instance to
# avoid premature shutdown when it is removed as complete.
# (We only spawn the first runahead-limited instance of parentless tasks).

[scheduler]
    allow implicit tasks = True

[scheduling]
    initial cycle point = 1
    final cycle point = 4
    cycling mode = integer
    runahead limit = P0
    [[graph]]
        P1 = """
            a:x? => x
            a:y? => y
            x | y => z
        """
[runtime]
    [[a]]
        script = """
            cylc__job__wait_cylc_message_started
            cylc message -- x  # always go x-path
        """
        [[[outputs]]]
            x = x
            y = y
    [[z]]
        script = """
            if (( CYLC_TASK_CYCLE_POINT == 1 )); then
                # mark 2/a as succeeded with output y
                # (task will be skipped)
                cylc set "${CYLC_WORKFLOW_ID}//2/a" --out=y,succeeded
            elif (( CYLC_TASK_CYCLE_POINT == 2 )); then
                # mark 2/a as having generated output y
                # (task will re-run and generate output x in the prociess)
                cylc set "${CYLC_WORKFLOW_ID}//3/a" --out=y
            fi
         """
