From c31c4c6c87764a41e8764692b923b8aa6dd4f508 Mon Sep 17 00:00:00 2001 From: "Bastian M. Wojek" Date: Wed, 20 May 2009 18:42:38 +0000 Subject: [PATCH] Fixed a bug in msr2data which affected the msr-file generation if the fit template was equal to one of the target files --- src/external/scripts/msr2data | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/external/scripts/msr2data b/src/external/scripts/msr2data index 42ceb83e..188e5ab8 100644 --- a/src/external/scripts/msr2data +++ b/src/external/scripts/msr2data @@ -80,7 +80,8 @@ EOFHELP else - export PATH=./:$PATH + PATH=./:$PATH + LC_NUMERIC=en_US.UTF-8 SUMMDIR="/mnt/data/nemu/summ" @@ -260,7 +261,7 @@ else fi # if it's the first run to be fitted, take the template and substitute the runnumber to match the first run - if [ "$q" -eq 0 ]; then + if [ "$q" -eq 0 ] && [ "$TEMPLATE" != "$FIRSTINPUT" ]; then awk -v count=$TEMP -v nextcount=${RUNARRAY[0]} -v nextinput=$FIRSTINPUT '{ if(NR==1) print nextcount > nextinput else if($1 == "RUN") { @@ -300,21 +301,23 @@ else COUNTX=$COUNT TEMPLATEX=$COUNT$EXTENSION.$OUTPUTEXT fi - awk -v count=$COUNTX -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{ - if(NR==1) print nextcount > nextinput - else if($1 == "RUN") { - if (substr(count,1,1) != "_"){ count = sprintf("_%04u", count); nextcount = sprintf("_%04u", nextcount);} - if ($2 !~ count){ - print " " - print ">> msr2data: ATTENTION The run-numbers in the filename and the RUN-block of the file do not match!" - print ">> msr2data: The run-number substitution is most likely going wrong!" - print " " + if [ "$TEMPLATEX" != "$NEXTINPUT" ]; then + awk -v count=$COUNTX -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{ + if(NR==1) print nextcount > nextinput + else if($1 == "RUN") { + if (substr(count,1,1) != "_"){ count = sprintf("_%04u", count); nextcount = sprintf("_%04u", nextcount);} + if ($2 !~ count){ + print " " + print ">> msr2data: ATTENTION The run-numbers in the filename and the RUN-block of the file do not match!" + print ">> msr2data: The run-number substitution is most likely going wrong!" + print " " + } + sub(count, nextcount, $0); + print $0 >> nextinput } - sub(count, nextcount, $0); - print $0 >> nextinput - } - else print $0 >> nextinput - }' $TEMPLATEX + else print $0 >> nextinput + }' $TEMPLATEX + fi fi fi @@ -420,6 +423,9 @@ else # put together all data to db- or column-format and write it to the file awk -v outfile=$OUTFILE -v noheader=$NOHEADER -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR -v format=$FORMAT '{ + if(tolower(outfile) == "none") + exit 0 + FS = " " OFS = " "