#!/usr/bin/env bash

# Run me with:
# qsub -t 30 -n 4 --mode script mira.scr

# It is a good idea always to keep these lines for BG/Q
LOCARGS="--block $COBALT_PARTNAME ${COBALT_CORNER:+--corner} $COBALT_CORNER ${COBALT_SHAPE:+--shape} $COBALT_SHAPE"
echo "Cobalt location args: $LOCARGS" >&2

#Use first available project, if the user has more than one project
PROJECT=`projects | cut -d ' ' -f 1`
SCRATCH=/projects/$PROJECT/$USER
export TEMPDIRPATH=$SCRATCH/tmp

export BGW_TEST_MPI_NPROCS=32
# FHJ: Mira ignores OMP_NUM_THREADS and sets the number of threads to:
# 64/(ranks-per-node)
export OMP_NUM_THREADS=1
export MPIEXEC="`which runjob` --ranks-per-node 8 $LOCARGS --verbose=WARN"
# Submit this job with: "qsub -t 30 -n 1 --mode script mira.scr"
# where '-n' is the total number of *nodes* to be allocated.
# The following are the options apply for the *runjob* command:
# -n = number of MPI tasks
# -p = number of MPI tasks/node
#
# So, the '-n' from qsub must be equal to ('-n' from runjob) / ('-p'),
# rounded up.

export NO_STOP_MESSAGE=1
# do not write silly FORTRAN STOP messages from PGI
make check-parallel &> test.out

echo "Exit status = $?"
