]> Creatis software - clitk.git/commitdiff
works on cc!!!
authorPierre Gueth <pgueth@ccage004.in2p3.fr>
Wed, 1 Jun 2011 11:34:59 +0000 (13:34 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Thu, 27 Jun 2013 12:44:46 +0000 (14:44 +0200)
cluster_tools/gate_run_submit_cluster.sh [new file with mode: 0755]

diff --git a/cluster_tools/gate_run_submit_cluster.sh b/cluster_tools/gate_run_submit_cluster.sh
new file mode 100755 (executable)
index 0000000..136a567
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+set -u
+SCRIPTNAME="$(basename "${0}")"
+
+function error {
+echo "ERROR: $1"
+usage
+exit 1
+}
+
+DEFAULTRELEASESUFFIX="06o"
+DEFAULTNUMBEROFJOBS="10"
+
+function usage {
+echo "${SCRIPTNAME} mac/main.mac njobs releasesuffix paramtogate"
+echo "default njobs = ${DEFAULTNUMBEROFJOBS}"
+echo "default releasesuffix = ${DEFAULTRELEASESUFFIX}"
+}
+
+test $# -eq 0 && usage && exit 0
+
+SCRIPTDIR=~/gate/gate-tests/bin
+RELEASEDIR="${HOME}/gate/release${3:-"${DEFAULTRELEASESUFFIX}"}"
+JOBFILE=~/gate/gate-tests/job_release.job
+
+echo "Checking stuff"
+test -f ${JOBFILE} || error "can't find job file ${JOBFILE}"
+test -d ${RELEASEDIR} || error "invalid release dir ${RELEASEDIR}"
+MACRODIR=$(pwd)
+test -d ${MACRODIR}/mac && test -d ${MACRODIR}/data || error "invalid path"
+MACROFILE=${1:?"provide relative macro path"}
+test -f ${MACRODIR}/${MACROFILE} || error "invalid macro"
+OUTPUTDIR=$(mktemp --tmpdir=${MACRODIR} -d run.XXXX)
+test -d ${OUTPUTDIR} || error "can't locate output dir"
+RUNID=${OUTPUTDIR##*.}
+NJOBS=${2:-"${DEFAULTNUMBEROFJOBS}"}
+NJOBSMAX=${NJOBS}
+PARAM="${4:-""}"
+
+echo "Lets roll!!"
+echo "runid is ${RUNID}"
+test -z "${PARAM}" && echo "no param" || echo "param is ${PARAM}"
+echo "using release $(basename ${RELEASEDIR})"
+echo "submitting ${NJOBS} jobs"
+
+while test $NJOBS -gt 0; do
+       qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \
+       -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},SCRIPTDIR=${SCRIPTDIR},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \
+       ${JOBFILE} || error "submission error"
+       let NJOBS--
+done
+
+echo "runid is ${RUNID}"