#!/bin/bash

# Request 1 TITAN Black GPU - use '--constraint=teslak20' for a Tesla or '--constraint=maxwell' to request a Maxwell GPU for single precision runs
#SBATCH --constraint=titanblack
#SBATCH --job-name=nb_pm
#SBATCH --ntasks=2
#SBATCH --gres=gpu:2
#SBATCH --mail-type=FAIL

hostname
echo "Time: `date`"
source /etc/profile.d/modules.sh

# Load the appropriate compiler modules on the node - should be the same as those used to compile the executable on pat
module add cuda/6.5
module add icc/64/2013_sp1/4/211
module add anaconda/python2/2.2.0 # Needed for python networkx module - must be python 2, not 3

# Set the GPU to exclusive process mode
sudo nvidia-smi -i $CUDA_VISIBLE_DEVICES -c 3

# Make a temporary directory on the node, copy job files there and change to that directory
# TMP=/scratch/$USER/$SLURM_JOB_ID
# mkdir -p $TMP
# cp ${SLURM_SUBMIT_DIR}/{coords.inpcrd,coords.mdcrd,coords.prmtop,,min.in,min.A,min.B,min.data,ts.data,points.min,points.ts,pathdata,perm.allow} $TMP
# cd $TMP

# Run the executable in the local node scratch directory
/home/$USER/bin/PATHSAMPLE_CHECKSP_MUT > pathsample_checkmin.out

# Copy all files back to the original submission directory
# cp * $SLURM_SUBMIT_DIR
# STATUS=$?
# echo "$STATUS"
# if [ $STATUS == 0 ];
#    then
#       echo "No error in cp"
#       cd $SLURM_SUBMIT_DIR
#       rm -rf $TMP
# fi

echo Finished at `date`
