#!/bin/bash

{% for key, val in slurm_directives.items() -%}
#SBATCH --{{key}}={{val}}
{% endfor %}

# Stop on errors
set -e

{% for cmd in pre_commands %}
{{ cmd }}
{% endfor %}

{% if env_modules %}
module purge
{% for name in env_modules -%}
module load {{name}}
{% endfor %}
{% endif %}

ulimit -s unlimited

{{ commands | join('\n') }}