From 1c20dca23d22ea6d24d57ad64e88107ea1a0c67a Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 9 Feb 2017 15:28:54 +0100 Subject: [PATCH] Clean up of David's commits --- cluster_tools/gate_job_ccin2p3.job | 4 +- cluster_tools/gate_power_merge.sh | 8 +- cluster_tools/gate_run_submit_cluster.sh | 10 +- cluster_tools/gate_run_submit_cluster_sps.sh | 125 ------------------- 4 files changed, 8 insertions(+), 139 deletions(-) delete mode 100755 cluster_tools/gate_run_submit_cluster_sps.sh diff --git a/cluster_tools/gate_job_ccin2p3.job b/cluster_tools/gate_job_ccin2p3.job index 016b236..c7abaac 100644 --- a/cluster_tools/gate_job_ccin2p3.job +++ b/cluster_tools/gate_job_ccin2p3.job @@ -17,8 +17,6 @@ function transferJobData { echo "Copying data back" - #ssh -i ${HOME}/.ssh/ccin2p3 linux1.dg.creatis.insa-lyon.fr "mkdir cc/$(basename ${OUTPUTDIR})/output.${JOB_ID%%.*}" - #rsync -av --remove-source-files -e "ssh -i ${HOME}/.ssh/ccin2p3" output/ "linux1.dg.creatis.insa-lyon.fr:./cc/$(basename ${OUTPUTDIR})/output.${JOB_ID%%.*}" pwd echo ${OUTPUTDIR} mkdir "${OUTPUTDIR}/output.${JOB_ID%%.*}" @@ -76,7 +74,7 @@ test -d "${MACRODIR}" && test -d "${MACRODIR}/mac" || error "invalid macro" echo "Copying inputs" LOCALMACRODIR=$(mktemp -d) -trap "wait ; transferJobData ; exit 1" 137 138 152 153 +trap "wait ; transferJobData ; exit 1" 1 2 3 15 cd ${LOCALMACRODIR} cp -r -L "${MACRODIR}"/{data,mac} . mkdir output diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index fa2904a..aaf063b 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -51,9 +51,9 @@ END { print xsize * ysize * zsize * byte_per_pixel; }' "${input_interfile}") function write_mhd_header { local input_interfile="${1:?"provide input interfile"}" - local output_mhd="$(dirname "${input_interfile}")/$(basename "${input_interfile}" ".hdr").hdr.mhd" + local output_mhd="$(dirname "${input_interfile}")/$(basename "${input_interfile}" ".hdr").mhd" - check_interfile "${input_interfile}" || warning "${input_interfile} isn't an interfile image (or unknown format)" + check_interfile "${input_interfile}" || error "${input_interfile} isn't an interfile image" local header_start='ObjectType = Image NDims = 3 @@ -334,8 +334,8 @@ function merge_dispatcher { echo "${indent}this is a interfile image" echo "${indent}creating mhd headers" for partialoutputfile in $partialoutputfiles; do write_mhd_header "${partialoutputfile}"; done - local mhd_partialoutputfiles="$(for partialoutputfile in $partialoutputfiles; do echo "${partialoutputfile%.*}.hdr.mhd"; done)" - local mhd_mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}" ".hdr").hdr.mhd" + local mhd_partialoutputfiles="$(for partialoutputfile in $partialoutputfiles; do echo "${partialoutputfile%.*}.mhd"; done)" + local mhd_mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}" ".hdr").mhd" merge_mhd_image "${mhd_mergedfile}" ${mhd_partialoutputfiles} || error "error while merging" echo "${indent}cleaning mhd headers" for mhd_partialoutputfile in $mhd_partialoutputfiles; do rm "${mhd_partialoutputfile}"; done diff --git a/cluster_tools/gate_run_submit_cluster.sh b/cluster_tools/gate_run_submit_cluster.sh index 2ae6186..edd798b 100755 --- a/cluster_tools/gate_run_submit_cluster.sh +++ b/cluster_tools/gate_run_submit_cluster.sh @@ -1,4 +1,4 @@ -#!/bin/bash -l +#! /bin/bash -lx set -u SCRIPTNAME="$(basename "${0}")" @@ -91,7 +91,6 @@ cp ${MACROFILE} ${OUTPUTDIR}/mac files=`grep "control/execute" ${MACROFILE} | cut -d " " -f 2` for i in $files do - echo $i cp $i ${OUTPUTDIR}/mac done @@ -105,11 +104,12 @@ while test $NJOBS -gt 0; do then PROJECTGROUP=creatis qsub -o "${OUTPUTDIR}" \ + -l sps=1 \ -N "gate.${RUNID}" \ -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ "${JOBFILE}" || error "submission error" else - qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \ + qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \ -v "PARAM=${PARAM},INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ "${JOBFILE}" || error "submission error" fi @@ -118,7 +118,3 @@ while test $NJOBS -gt 0; do done echo "runid is ${RUNID}" -if test "$(dnsdomainname)" = "in2p3.fr" -then - rsync -av --remove-source-files -e "ssh -i ${HOME}/.ssh/ccin2p3" ${OUTPUTDIR}/ "linux1.dg.creatis.insa-lyon.fr:./cc/$(basename ${OUTPUTDIR})" --exclude '.__afs*' --exclude "${OUTPUTDIR}/gatejob.*.o*" -fi diff --git a/cluster_tools/gate_run_submit_cluster_sps.sh b/cluster_tools/gate_run_submit_cluster_sps.sh deleted file mode 100755 index ddc48ca..0000000 --- a/cluster_tools/gate_run_submit_cluster_sps.sh +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/local/bin/bash -lx - -set -u -SCRIPTNAME="$(basename "${0}")" - -# ------------------------------------------------- -function error { - 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 "default paramtogate = \"\" (use \"\" around params and \\ in front of commas)" -} -# ------------------------------------------------- - -test $# -eq 0 && usage && exit 0 - -RELEASESUFFIX=${3:-"${DEFAULTRELEASESUFFIX}"} -RELEASEDIR="${HOME}/releases/grid_release${RELEASESUFFIX}" -if test "$(dnsdomainname)" = "in2p3.fr" -then - JOBFILE="$(dirname $0)/gate_job_ccin2p3.job" -else - JOBFILE="$(dirname $0)/gate_job_cluster.job" -fi - -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" -else - test -d ${RELEASEDIR} || error "invalid release dir ${RELEASEDIR}" -fi -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" -if test "$(dnsdomainname)" = "in2p3.fr" -then - OUTPUTDIR=$(mktemp -d -p "${MACRODIR}" run.XXXX || error "can't create temp dir") - ssh -i ${HOME}/.ssh/ccin2p3 linux1.dg.creatis.insa-lyon.fr mkdir -p "cc/$(basename ${OUTPUTDIR})" -else - OUTPUTDIR=$(mktemp --tmpdir=${MACRODIR} -d run.XXXX || error "can't create temp dir") -fi -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}" - -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 "Gate is $(which Gate)" -else - echo "Gate release is $(basename ${RELEASEDIR})" -fi -echo "submitting ${NJOBS} jobs" - -PARAMFILE="${OUTPUTDIR}/params.txt" -echo "njobs = ${NJOBS}" >> "${PARAMFILE}" -echo "macro = ${MACROFILE}" >> "${PARAMFILE}" -test -z "${PARAM}" || echo "param = ${PARAM}" >> "${PARAMFILE}" - -# Copy macros files (for log) -mkdir ${OUTPUTDIR}/mac -cp ${MACROFILE} ${OUTPUTDIR}/mac -files=`grep "control/execute" ${MACROFILE} | cut -d " " -f 2` -for i in $files -do - cp $i ${OUTPUTDIR}/mac -done - -while test $NJOBS -gt 0; do - - if test "${QSUB}" = "noqsub" - then - echo "Launching Gate log in ${OUTPUTDIR}/gate_${NJOBS}.log" - PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} OUTPUTDIR=${OUTPUTDIR} RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log & - elif test "$(dnsdomainname)" = "in2p3.fr" - then - PROJECTGROUP=creatis - qsub -o "${OUTPUTDIR}" \ - -l sps=1 \ - -N "gate.${RUNID}" \ - -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ - "${JOBFILE}" || error "submission error" - else - qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \ - -l sps=1 \ - -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ - "${JOBFILE}" || error "submission error" - fi - - let NJOBS-- -done - -echo "runid is ${RUNID}" -if test "$(dnsdomainname)" = "in2p3.fr" -then - rsync -av --remove-source-files -e "ssh -i ${HOME}/.ssh/ccin2p3" ${OUTPUTDIR}/ "linux1.dg.creatis.insa-lyon.fr:./cc/$(basename ${OUTPUTDIR})" --exclude '.__afs*' --exclude "${OUTPUTDIR}/gatejob.*.o*" -fi -- 2.47.1