#!/bin/bash

#PBS -N {{ job_name }}
#PBS -A {{ account }}
#PBS -q {{ queue }}
#PBS -l job_priority={{ job_priority }}
#PBS -l walltime={{ walltime }}
#PBS -l select=2:ncpus=128:mpiprocs=9:ompthreads=128
#PBS -j oe
#PBS -m abe

echo "Job $PBS_JOBID started at `date` on `hostname` in directory `pwd`."

echo 'Loading modules.'
module --force purge
{%- for module in modules %}
module load {{ module }}
{%- endfor %}
module list

echo 'Setting up MAGE environment.'
source {{ kaijuhome }}/scripts/setupEnvironment.sh

echo 'Setting environment variables.'
export OMP_NUM_THREADS=128
export MPI_TYPE_DEPTH=32
export KMP_STACKSIZE=128M
echo 'The active environment variables are:'
printenv

echo 'Running VOLTRON MPI tests.'
MPICOMMAND="mpiexec $KAIJUHOME/scripts/preproc/pinCpuCores.sh"
${MPICOMMAND} ./voltMpiTests > voltMpiTests.out
echo 'VOLTRON MPI tests complete.'
echo | tail -n 3 ./voltMpiTests.out

echo "Job $PBS_JOBID ended at `date` on `hostname` in directory `pwd`."
