Last active
August 29, 2015 14:13
-
-
Save pontikos/7b6b111db80a71514b14 to your computer and use it in GitHub Desktop.
script to output SGE job array, which can then be submitted with qsub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| set -e | |
| set -u | |
| ## | |
| until [ -z "$1" ] | |
| do | |
| # use a case statement to test vars. we always test $1 and shift at the end of the for block. | |
| case $1 in | |
| # parameters to qsub | |
| --scratch) | |
| shift | |
| scratch=$1;; | |
| --nhours) | |
| shift | |
| nhours=$1;; | |
| --ncores) | |
| shift | |
| ncores=$1;; | |
| --mem) | |
| shift | |
| vmem=$1;; | |
| --tc) | |
| shift | |
| tc=$1;; | |
| #log | |
| --qsub.out) | |
| shift | |
| out=$1;; | |
| --qsub.err) | |
| shift | |
| err=$1;; | |
| # | |
| --input.args) | |
| shift | |
| inputargs=$1;; | |
| --script) | |
| shift | |
| script=$1;; | |
| -* ) | |
| echo "Unrecognized option: $1" | |
| usage | |
| exit 1;; | |
| esac | |
| shift | |
| if [ "$#" = "0" ]; then break; fi | |
| done | |
| #required input | |
| njobs=`cat $inputargs | wc -l` | |
| cat <<EOL | |
| #!/bin/bash | |
| #$ -S /bin/bash | |
| #$ -o /dev/null | |
| #$ -e /dev/null | |
| #$ -cwd | |
| #$ -V | |
| #$ -R y | |
| #$ -pe smp ${ncores-1} | |
| #$ -l scr=${scratch-1}G | |
| #$ -l tmem=${vmem-2}G,h_vmem=${vmem-1}G | |
| #$ -l h_rt=${nhours-1}:0:0 | |
| #$ -t 1-${njobs} | |
| #$ -tc ${tc-25} | |
| set -u | |
| set -x | |
| let "SGE_TASK_ID=\$SGE_TASK_ID-1" | |
| mkdir -p ${out-qsub.out} ${err-qsub.err} | |
| exec >${out}/${script}_\${SGE_TASK_ID}_\${JOB_ID}.out 2>${err}/${script}_\${SGE_TASK_ID}_\${JOB_ID}.err | |
| args=(\$(cat $inputargs)) | |
| ./${script} \${args[\$SGE_TASK_ID]} | |
| EOL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment