X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=cluster_tools%2Fgate_power_merge.sh;h=aaf063b18d4f8cc85be856ef0f19df1087c1570d;hb=0b8e61cfe53d9d1f697b1d9d85c948ca27c29898;hp=c35d67d6b4238389d1e2ff7af17c483f6077730b;hpb=26db5a9d9577aa964dbdbe7ac282605281434867;p=clitk.git diff --git a/cluster_tools/gate_power_merge.sh b/cluster_tools/gate_power_merge.sh index c35d67d..aaf063b 100755 --- a/cluster_tools/gate_power_merge.sh +++ b/cluster_tools/gate_power_merge.sh @@ -290,7 +290,7 @@ function merge_mhd_image { then update_bar ${count} "copying first partial result ${partial}" cp "${partial}" "${merged}" - if test "$last_character" = "d" + if test "$last_character" = "d" then cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}" fi @@ -319,7 +319,10 @@ function merge_dispatcher { if test ${nboutputdirs} -ne ${nboutputfiles} then warning "missing files" - return + if ! test "${2}" == "--force" + then + return + fi fi local firstpartialoutputfile="$(echo "${partialoutputfiles}" | head -n 1)" @@ -436,7 +439,10 @@ function merge_dispatcher_uncertainty { if test ${nboutputdirs} -ne ${nboutputfiles} then warning "missing files" - return + if ! test "${2}" == "--force" + then + return + fi fi local firstpartialoutputfile="$(echo "${partialoutputfiles}" | head -n 1)" @@ -493,10 +499,13 @@ function merge_dispatcher_uncertainty { } echo "!!!! this is $0 v0.3k !!!!" +echo "Usage: gate_power_merge.sh run.dir [--force]" +echo " where --force allows to merge files even if the file is missing in some output directories" rundir="${1?"provide run dir"}" +force=${2:-""} rundir="$(echo "${rundir}" | sed 's|/*$||')" -nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -o -type l -name 'output*' | wc -l)" +nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -name 'output*' -o -type l -name 'output*' | wc -l)" test ${nboutputdirs} -gt 0 || error "no output dir found" echo "found ${nboutputdirs} partial output dirs" @@ -511,17 +520,16 @@ echo "output dir is ${outputdir}" test -d "${outputdir}" && rm -r "${outputdir}" mkdir "${outputdir}" -ls ${rundir}/ for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) do - merge_dispatcher "${outputfile}" + merge_dispatcher "${outputfile}" "${force}" done echo "" echo "Merging done. Special case for statistical uncertainty" for outputfile in $(find -L "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq) do - merge_dispatcher_uncertainty "${outputfile}" + merge_dispatcher_uncertainty "${outputfile}" "${force}" done if [ -f "${rundir}/params.txt" ] @@ -530,4 +538,10 @@ then cp "${rundir}/params.txt" "${outputdir}/params.txt" fi +if [ -d "${rundir}/mac" ] +then + echo "copying mac folder" + cp -r "${rundir}/mac" "${outputdir}/mac" +fi + echo "these was ${warning_count} warning(s)"