Skip to content

Instantly share code, notes, and snippets.

@goerz
Created January 23, 2012 15:40
Show Gist options
  • Save goerz/1663862 to your computer and use it in GitHub Desktop.
Save goerz/1663862 to your computer and use it in GitHub Desktop.
Example PBS file
#!/bin/bash
#PBS -N example
#PBS -j oe
#PBS -l nodes=1:ppn=1
#PBS -l mem=1000m
#PBS -l walltime=16:00:00
#PBS -l cput=16:00:00
######PBS -l file=1g
set -x
echo "Job $PBS_JOBID ($PBS_JOBNAME) started on" `hostname` `date` >> ~/.jobs.log
###################### Job Environment #####################
export SCRATCH_ROOT=/local
export PREFIX=$HOME/local
export PATH=$PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
export OMP_NUM_THREADS=1
cd $PBS_O_WORKDIR # where we've run qsub
########### Create data directories / scratch ##############
mkdir -p $SCRATCH_ROOT/$PBS_JOBID || exit 1
mkdir -p $HOME/finished_jobs || exit 1
# Copy entire runfolder to scratch
cp * $SCRATCH_ROOT/$PBS_JOBID/
rm $SCRATCH_ROOT/$PBS_JOBID/*.o[0-9]* # exclude old I/O files
# Copy in executables
execs="RydL_oct RydL_prop"
for exec in $execs; do
if [ ! -e $SCRATCH_ROOT/$PBS_JOBID/$exec ]; then
cp $PREFIX/bin/$exec $SCRATCH_ROOT/$PBS_JOBID
fi
done
############## **** Run main program **** ##################
cd $SCRATCH_ROOT/$PBS_JOBID/
./RydL_oct . 2>stderr.log >stdout.log
./RydL_prop . 2>>stderr.log >>stdout.log
################# Archive the Run ##########################
rm $execs # don't include executables in archive
# We prepend $PBS_O_WORKDIR to the archived paths (under the assumption that
# this is also the runfolder)
tar --transform "s,^,$PBS_O_WORKDIR//," -chz \
-f ~/finished_jobs/$PBS_JOBID.tgz *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment