Skip to content

Instantly share code, notes, and snippets.

@ftessier
Created December 18, 2015 15:10
Show Gist options
  • Save ftessier/df5bd5936f1ae548f857 to your computer and use it in GitHub Desktop.
Save ftessier/df5bd5936f1ae548f857 to your computer and use it in GitHub Desktop.
#!/bin/bash
#####################################################################################
#
# usage:
#
# egs-submit <app> <template> [ pid ]
#
# app: EGSnrc app to invoke
# template: input file with "@" placeholders
# pid: optional, pid of job after which to queue
#
#####################################################################################
# base name of template file
template=$2
basename=${template%.*}
# job dependency for chaining
job=""
if [ $# -gt 2 ]; then
job=$3
fi
# qsub parameters
app=$1
pegs="700icru"
queue="short"
batch="pbsdsh"
cores=16
# egsinp parameters (to be replaced in template)
ncase=100000
ecut=0.512
# submit loop
for pcut in 001 002 005 010 020 050 100; do
# set egsinp file base name
egsinp=${basename}_@${pcut}
printf "\n$egsinp\n"
# generate egsinp input file:
# process template through sed to replace parameters on the fly
printf "generating: ${egsinp}.egsinp\n"
( set -x
cat $template | sed s/@ncase/${ncase}/g \
| sed s/@pcut/${pcut}/g \
| sed s/@ecut/${ecut}/g \
> ${egsinp}.egsinp
)
# job dependency string: start this one after $job
if [ -n "$job" ]; then
dependstr="-W depend=afterany:${job}"
else
dependstr=""
fi
# submit job and grab job number (for next loop)
job=$( set -x; $HEN_HOUSE/scripts/run_user_code_batch ${app} ${egsinp} ${pegs} ${queue} batch=${batch} p=${cores} $dependstr )
printf "submitted: $job\n"
job=${job%%.*}
done
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment