Skip to content

Instantly share code, notes, and snippets.

@bessey
Last active December 13, 2015 18:08
Show Gist options
  • Save bessey/4953172 to your computer and use it in GitHub Desktop.
Save bessey/4953172 to your computer and use it in GitHub Desktop.
Blue Crystal job submitter, features: - Runs make - Submits the job file './lb_submit' - Moves output to '../(CURRENT-FOLDER-NAME)-reports/' - Ctrl+c cancels job - cats the output of report to screen - takes a parameter for the job title
#!/bin/zsh
# Handy run script.
# Call with './run.sh "<COMMENT>" where <COMMENT> is replaced with your title for the run.
# <COMMENT> must be in quotes.
function itsatrap()
{
echo "Aborting job $jnum"
qdel $jnum
exit 2
}
echo "Running version: '$1'"
echo -ne "Running Make, outputting to mkreport.txt... "
make clean; make fast >&| mkreport.txt
[[ $? == 2 ]] && echo "MAKE FAILED!!" && exit 2
echo "Done!"
j=$(qsub lb_submit)
jnum=${j%%\.*}
echo "Submitted job $jnum."
trap 'itsatrap' 2
progb=""
i=0
while [[ ! -a OUT ]]; do
(( m = i % 400))
progb="$progb."
if [[ $m == 2 && $i > 400 ]]; then
echo ""
progb=""
fi
echo -ne "${progb} ${i}s\r"
(( i = $i + 2 ))
sleep 2
done
echo ""
echo "Job $jnum is done"
name=$(date +"%e-%k%M")
cat =(echo "Job Tag: $1") =(echo "Errors:") "OPENMP.e$jnum" =(echo "Output:") OUT =(echo "Build report:") mkreport.txt > report-${name}.txt
cat report-${name}.txt
mv report-${name}.txt ../${PWD##*/}-reports/
echo "Output stored in file report-${name}"
mv final_state.dat ../${PWD##*/}-reports/fstate-${name}.dat
mv av_vels.dat ../${PWD##*/}-reports/vels-${name}.dat
echo "State info moved to fstate-${name}.dat"
echo "Velocity info moved to vels-${name}.dat"
echo -ne "Removing intermediate files... "
rm OPENMP.e$jnum
rm OUT
rm mkreport.txt
rm d2q5-bgk.exe
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment