#!Jinja2
[meta]
    title = "Parameterized task example: static model chunking."
    description = "Same as chunking1 but without any 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  # number of runs
        n = 0..1  # number of members per run
        c = 0..2  # number of model chunks, per member, per run
[scheduling]
    [[dependencies]]
        graph = """
prep => init<r> => start<r,n> => sim<r,n,c=0>
   sim<r,n,c-1> => sim<r,n,c>
      post<r,n,c-1> => post<r,n,c>
        post<r,n,c=2> => stop<r,n>
           sim<r,n,c> => post<r,n,c>
              stop<r,n> => comb<r> => end"""
[runtime]
    [[root]]
        script = """
[[ -n ${CYLC_TASK_PARAM_r:-} ]] && echo "run.....$CYLC_TASK_PARAM_r"
[[ -n ${CYLC_TASK_PARAM_n:-} ]] && echo "member..$CYLC_TASK_PARAM_n"
if [[ -n ${CYLC_TASK_PARAM_c:-} ]]; then
    echo "chunk...$CYLC_TASK_PARAM_c"
    OFFSET=P$((CYLC_TASK_PARAM_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"
