#!/bin/bash
#SBATCH --job-name={{task_name}}-{{task_id}}
#SBATCH --output={{task_save_path}}/{{task_name}}-{{task_id}}.out
#SBATCH --error={{task_save_path}}/{{task_name}}-{{task_id}}.err
{% if 'beeflow:MPIRequirement' in hints and 'nodes' in hints['beeflow:MPIRequirement'] %}
#SBATCH -N {{ hints['beeflow:MPIRequirement']['nodes'] }}
{% endif %}
{% if 'beeflow:MPIRequirement' in hints and 'ntasks' in hints['beeflow:MPIRequirement'] %}
#SBATCH -n {{ hints['beeflow:MPIRequirement']['ntasks'] }}
{% endif %}

{{ env_code }}

# pre commands
{% for cmd in pre_commands %}
srun {{ cmd|join(' ') }}
{% endfor %}

# main command
srun --mpi=pmix_v3 {{ main_command|join(' ') }}

# post commands
{% for cmd in post_commands %}
srun {{ cmd|join(' ') }}
{% endfor %}
