#!jinja2

# This config get appended to the suite config when profiling with
# mode=profile-simulation where namespaces is a list of all tasks present in
# the suite config.
#
# The jinja2 variables sleep_time and batch_system can be provided in the
# options section of an experiment run (e.g. options=["sleep_time=1"]).
#
# The jinja2 variable cylc_compat_mode is provided automatically and contains
# the major version number of the cylc version which will run the suite.

{% if not sleep_time is defined %}
    {% set sleep_time = '1' %}
{% endif %}
{% if not batch_system is defined %}
    {% set batch_system = 'background' %}
{% endif %}
{% if namespaces is string %}
    {% set namespaces = [namespaces] %}
{% endif %}

# The runtime to overwrite.
[runtime]
{% for namespace in namespaces %}
    [[{{namespace}}]]
    {% if cylc_compat_mode is defined and cylc_compat_mode == '6' %}
        pre-command scripting =
        command scripting = sleep {{sleep_time}}
        post-command scripting =
        [[[job submission]]]
            method = {{batch_system}}
    {% else %}
        pre-script =
        script = sleep {{sleep_time}}
        post-script =
        [[[job]]]
            batch system = {{batch_system}}
    {% endif %}
        [[[remote]]]
            host = localhost
{% endfor %}
