#!/bin/bash
#
# example.slurm
# Invoke with:
# sbatch -p express example.slurm

# Uncomment the following to see the values of SLURM Environment variables
# echo "slurm host is"
# echo $SLURMD_NODENAME
# echo "slurm queue is"
# echo $SLURM_JOB_PARTITION
# echo "slurm working directory absolute is"
# echo $SLURM_SUBMIT_DIR
# echo "slurm batch id"
# echo $PBS_JOBID
# echo "slurm job name from me is"
# echo $SLURM_JOB_NAME

source /app/cern/root_v6.08.06/bin/thisroot.sh

# Make sure we are in the right directory in case writing files
mkdir -p /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID
mkdir /disk/data12/lhcb/saslie/$PBS_JOBID
cp test.py /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID
cp raremodel.py /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID
cp pdg_const.py /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID
cp helperfunctions.py /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID

cd /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID

# Run actual commands here
#echo "test worked"
python test.py

cp  -a /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID/  /disk/data12/lhcb/saslie/$PBS_JOBID
# Remove scratch directory at the end of your job
# Do not forget to copy any output first to a safe place
rm -a /disk/data12/lhcb/saslie/scratch/$USER/$PBS_JOBID
