#!jinja2

# A suite which runs a <chain_num> parallel chains of <tasks_per_chain> tasks.

# Implemented using jinja2 rather than parameterized tasks to allow for
# profiling with older cylc versions.

{% if not batch_system is defined %}
    {% set batch_system = 'background' %}
{% endif %}
{% if not chains is defined %}
    {% set chains = 1 %}
{% endif %}
{% if not tasks_per_chain is defined %}
    {% set tasks_per_chain = 1 %}
{% endif %}
{% if not sleep_time is defined %}
    {% set script = 'true' %}
{% else %}
    {% set script = 'sleep ' + sleep_time %}
{% endif %}

[scheduling]
    cycling mode = integer
    initial cycle point = 1
    final cycle point = 2
    [[dependencies]]
        [[[P1]]]
            graph = """
            {% for chain_num in range(chains|int) -%}
                task_{{chain_num}}_{{tasks_per_chain}}[-P1] => \
                    task_{{chain_num}}_1
            {% for task_num in range(1, tasks_per_chain|int) -%}
                task_{{chain_num}}_{{task_num}} => \
                    task_{{chain_num}}_{{task_num + 1}}
            {% endfor -%}
            {% endfor -%}
            """
[runtime]
    [[root]]
    {% if cylc_compat_mode is defined and cylc_compat_mode == '6' %}
        command scripting = {{ script }}
        [[[job submission]]]
            method = {{ batch_system }}
    {% else %}
        script = {{ script }}
        [[[job]]]
            batch system = {{ batch_system }}
    {% endif %}
