#!Jinja2
title = "Parameterized task example: static model chunking."
description = "See chunking2 for the same without redundant dependencies."
# NOTE: dynamic date-time cycling would normally be used for cycling a model.
{% set MODEL_START_DATE = '2001-01' %}
{% set MODEL_CHUNK_MONTHS = 4 %}
[cylc]
    [[parameters]]
        r = 0..2  # runs
        n = 0..2  # members per run
        c = 0..3  # chunks, per member, per run
[scheduling]
    [[dependencies]]
        graph = """
prep => init<r> => start<r,n> => sim<r,n,c> => post<r,n,c> =>
    stop<r,n> => comb<r> => end
sim<r,n,c-1> => sim<r,n,c>  # inter-chunk dependence
                """
[runtime]
    [[root]]
        script = """
[[ -n ${r:-} ]] && echo "run.....$r"
[[ -n ${n:-} ]] && echo "member..$n"
if [[ -n ${c:-} ]]; then
    echo "chunk...$c"
    OFFSET=P$((c*{{MODEL_CHUNK_MONTHS}}))M
    echo "model start date: \
        $(cylc cyclepoint --offset=$OFFSET {{MODEL_START_DATE}})"
fi
sleep 10"""
    [[ENDS]]
    [[prep, end]]
        inherit = None, ENDS
    [[RUN<r>]]
    [[init<r>, comb<r>, sim<r,n,c>, post<r,n,c>, start<r,n>, stop<r,n>]]
        inherit = RUN<r>
[visualization]
    use node color for edges = True
    [[node attributes]]
        RUN<r=0> = "color=red"
        RUN<r=1> = "color=blue"
        RUN<r=2> = "color=darkgreen"
        sim<r,n,c=0> = "style=filled", "fillcolor=LemonChiffon1"
        sim<r,n,c=1> = "style=filled", "fillcolor=LemonChiffon2"
        sim<r,n,c=2> = "style=filled", "fillcolor=LemonChiffon3"
        post<r,n,c=0> = "style=filled", "fillcolor=thistle1"
        post<r,n,c=1> = "style=filled", "fillcolor=thistle2"
        post<r,n,c=2> = "style=filled", "fillcolor=thistle3"
        ENDS = "style=filled", "fillcolor=gray"
