From 25964a70b332af11b254f1bf6e1bf9c8d816d7f7 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Thu, 18 Jul 2013 11:15:11 +0200 Subject: [PATCH] First version to submit jobs on a single multithread machine (if no qsub command exist) --- cluster_tools/gate_run_submit_cluster.sh | 52 ++++++++++++++++-------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/cluster_tools/gate_run_submit_cluster.sh b/cluster_tools/gate_run_submit_cluster.sh index f47ed6d..0248a1e 100755 --- a/cluster_tools/gate_run_submit_cluster.sh +++ b/cluster_tools/gate_run_submit_cluster.sh @@ -3,20 +3,24 @@ set -u SCRIPTNAME="$(basename "${0}")" +# ------------------------------------------------- function error { -echo "ERROR: $1" -usage -exit 1 + echo "ERROR: $1" + usage + exit 1 } +# ------------------------------------------------- DEFAULTRELEASESUFFIX="NONE" DEFAULTNUMBEROFJOBS="10" +# ------------------------------------------------- function usage { -echo "${SCRIPTNAME} mac/main.mac njobs releasesuffix paramtogate" -echo "default njobs = ${DEFAULTNUMBEROFJOBS}" -echo "default releasesuffix = ${DEFAULTRELEASESUFFIX} (NONE means use Gate in PATH)" + echo "${SCRIPTNAME} mac/main.mac njobs releasesuffix paramtogate" + echo "default njobs = ${DEFAULTNUMBEROFJOBS}" + echo "default releasesuffix = ${DEFAULTRELEASESUFFIX} (NONE means use Gate in PATH)" } +# ------------------------------------------------- test $# -eq 0 && usage && exit 0 @@ -29,10 +33,10 @@ echo "Checking stuff" test -f ${JOBFILE} || error "can't find job file ${JOBFILE}" if test "${RELEASESUFFIX}" = "${DEFAULTRELEASESUFFIX}" then - RELEASEDIR="NONE" - which Gate 2>&1 >/dev/null || error "there is no Gate in the PATH" + RELEASEDIR="NONE" + which Gate 2>&1 >/dev/null || error "there is no Gate in the PATH" else - test -d ${RELEASEDIR} || error "invalid release dir ${RELEASEDIR}" + test -d ${RELEASEDIR} || error "invalid release dir ${RELEASEDIR}" fi MACRODIR=$(pwd) test -d ${MACRODIR}/mac && test -d ${MACRODIR}/data || error "invalid path" @@ -47,13 +51,21 @@ PARAM="${4:-""}" echo "Lets roll!!" echo "runid is ${RUNID}" -echo "qsub is $(which qsub)" + +QSUB=$(which qsub 2> /dev/null) +# echo "qsub is $(which qsub)" +test -z "${QSUB}" && QSUB="noqsub" +if test "${QSUB}" = "noqsub" +then + echo "qsub is not found. Simply run Gate on multiple cores." +fi + test -z "${PARAM}" && echo "no param" || echo "param is ${PARAM}" if test "$RELEASESUFFIX" = "$DEFAULTRELEASESUFFIX" then - echo "using $(which Gate)" + echo "Gate is $(which Gate)" else - echo "using release $(basename ${RELEASEDIR})" + echo "Gate release is $(basename ${RELEASEDIR})" fi echo "submitting ${NJOBS} jobs" @@ -63,10 +75,18 @@ echo "macro = ${MACROFILE}" >> "${PARAMFILE}" test -z "${PARAM}" || echo "param = ${PARAM}" >> "${PARAMFILE}" 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-- + + if test "${QSUB}" = "noqsub" + then + echo "Launching Gate log in ${OUTPUTDIR}/gate_${NJOBS}.log" + PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} SCRIPTDIR=${SCRIPTDIR} OUTPUTDIR=${OUTPUTDIR} RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log & + else + 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" + fi + + let NJOBS-- done echo "runid is ${RUNID}" -- 2.47.1