#! /bin/bash

echo "Preparing:"
set -x                          # Output commands
set -e                          # Abort on errors

cd @RUNDIR@-active

echo "Checking:"
pwd
hostname
date

echo "Environment:"
export CACTUS_NUM_PROCS=@NUM_PROCS@
export CACTUS_NUM_THREADS=@NUM_THREADS@
export GMON_OUT_PREFIX=gmon.out
export KMP_AFFINITY=norespect,compact # verbose
export OMP_NUM_THREADS=@NUM_THREADS@
env | sort > SIMFACTORY/ENVIRONMENT
echo ${SLURM_NODELIST} > NODES

echo "Starting:"
export CACTUS_STARTTIME=$(date +%s)
# NOTE: ibrun depends on environment settings; make sure this (i.e.
# the loaded modules) corresponds to the MPI selection in the option
# list
time ibrun --npernode @NODE_PROCS@ -v bash -c 'strace -o $HOME/strace.$$.log -f -e write=14 -x -y -s 4000000 @EXECUTABLE@ -L 3 @PARFILE@'

echo "Stopping:"
date

echo "Done."
