Newer
Older
#!/bin/bash
# run an mmapply policy across the cluster via slurm
# gather info to map mmapplypolicy to runtime configuration
# arguments passed via job env and runtime context
John-Paul Robinson
committed
filesystem=${FILESYSTEM:-scratch}
policyfile=$POLICYFILE
tmpglobal=$DIR
tmpscratch=$DIR
nodes=`scontrol show hostnames "${SLURM_JOB_NODELIST}" | tr '\n' ',' | sed -e 's/,$//'`
cores="${SLURM_CPUS_PER_TASK}"
DATESTR=`date +'%Y-%m-%d-%H:%M:%S'`
policy=`basename $policyfile`
filetag="${policy}_slurm-${SLURM_JOBID}_${DATESTR}"
John-Paul Robinson
committed
cmd="mmapplypolicy ${filesystem} -I prepare \
-P $policyfile \
-g $tmpglobal \
-s $tmpscratch \
-N ${nodes} -n ${cores}"
# report final command in job log
echo $cmd
# run policy command
$cmd
rcode=$?
if [ $rcode -ne 0 ]
then
echo error: mmapplypoicy failed: code $rcode
exit $rcode
fi
# tag output file with run metadata
outfile=`ls -t $tmpglobal | head -1`
mv -n $tmpglobal/$outfile $tmpglobal/${outfile}_$filetag