bug fixes in the mlog2db script
This commit is contained in:
38
src/external/scripts/mlog2db
vendored
38
src/external/scripts/mlog2db
vendored
@ -1,12 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ! -e /usr/bin/awk ]; then
|
if [ ! -x /usr/bin/awk ]; then
|
||||||
echo Please make sure you have installed awk!
|
echo Please make sure you have installed awk!
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -lt 2 ] ; then
|
if [ "$#" -lt 2 ] ; then
|
||||||
|
|
||||||
cat <<EOFHELP
|
cat <<EOFHELP
|
||||||
|
|
||||||
"musrfit-mlog to db converter"
|
"musrfit-mlog to db converter"
|
||||||
@ -127,8 +127,8 @@ else
|
|||||||
|
|
||||||
else
|
else
|
||||||
ISDIGIT=$( echo $1 | awk '{ if (( $1 + 0 ) == $1 ) {print 1} else {print 0}}' ) # check if the first parameter is a number or not
|
ISDIGIT=$( echo $1 | awk '{ if (( $1 + 0 ) == $1 ) {print 1} else {print 0}}' ) # check if the first parameter is a number or not
|
||||||
if [ "$ISDIGIT" -eq 1 ]; then # start and end-runs are given
|
if [ "$ISDIGIT" == 1 ]; then # start and end-runs are given
|
||||||
for (( j=0; j<=$2-$1; j++ ));
|
for (( j=0; j<=$2-$1; j++ ))
|
||||||
do
|
do
|
||||||
RUNARRAY[$j]=$(( $1 + $j ))
|
RUNARRAY[$j]=$(( $1 + $j ))
|
||||||
done
|
done
|
||||||
@ -144,9 +144,9 @@ else
|
|||||||
NUM_OF_IND_VAR=1 # 1 for the run number
|
NUM_OF_IND_VAR=1 # 1 for the run number
|
||||||
|
|
||||||
else # assume a runlist-file with "independent variables" is given
|
else # assume a runlist-file with "independent variables" is given
|
||||||
if [ ! -e $1 ]; then
|
if [ ! -r $1 ]; then
|
||||||
echo
|
echo
|
||||||
echo "The specified runlist file" $1 "is not present... Bye bye!"
|
echo "The specified runlist file $1 is not present... Bye bye!"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -156,7 +156,7 @@ else
|
|||||||
exec 3< $1 # open file for reading in the runlist-file the first time and get the runnumbers to be processed
|
exec 3< $1 # open file for reading in the runlist-file the first time and get the runnumbers to be processed
|
||||||
while read -u 3 -a runList
|
while read -u 3 -a runList
|
||||||
do
|
do
|
||||||
if [ "$numberOfReadInLines" == "0" ]; then
|
if [ "$numberOfReadInLines" -eq 0 ]; then
|
||||||
NUM_OF_IND_VAR=${#runList[@]}
|
NUM_OF_IND_VAR=${#runList[@]}
|
||||||
else
|
else
|
||||||
RUNARRAY[(( numberOfReadInLines - 1 ))]=${runList[0]}
|
RUNARRAY[(( numberOfReadInLines - 1 ))]=${runList[0]}
|
||||||
@ -201,9 +201,9 @@ else
|
|||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
if [ -e $TEMP$EXTENSION.mlog ]; then
|
if [ -r $TEMP$EXTENSION.mlog ]; then
|
||||||
TEMPLATE=$TEMP$EXTENSION.mlog
|
TEMPLATE=$TEMP$EXTENSION.mlog
|
||||||
elif [ -e $TEMP$3.msr ]; then
|
elif [ -r $TEMP$3.msr ]; then
|
||||||
TEMPLATE=$TEMP$EXTENSION.msr
|
TEMPLATE=$TEMP$EXTENSION.msr
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -225,7 +225,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if it's the first run to be fitted, take the template and substitute the runnumber to match the first run
|
# if it's the first run to be fitted, take the template and substitute the runnumber to match the first run
|
||||||
if [ "$COUNT" == "${RUNARRAY[0]}" ]; then
|
if [ "$q" -eq 0 ]; then
|
||||||
awk -v count=$TEMP -v nextcount=${RUNARRAY[0]} -v nextinput=$FIRSTINPUT '{
|
awk -v count=$TEMP -v nextcount=${RUNARRAY[0]} -v nextinput=$FIRSTINPUT '{
|
||||||
if(NR==1) print nextcount > nextinput
|
if(NR==1) print nextcount > nextinput
|
||||||
else if($1 == "RUN") {
|
else if($1 == "RUN") {
|
||||||
@ -244,7 +244,7 @@ else
|
|||||||
|
|
||||||
musrfit $COUNT$EXTENSION.msr $MUSRFITPARAM # the fit
|
musrfit $COUNT$EXTENSION.msr $MUSRFITPARAM # the fit
|
||||||
|
|
||||||
if [ "$COUNT" != "${RUNARRAY[$LASTRUN]}" ]; then # create the next musrfit input file if not the last specified run was fitted already
|
if [ "$q" -ne "$LASTRUN" ]; then # create the next musrfit input file if not the last specified run was fitted already
|
||||||
awk -v count=$COUNT -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{
|
awk -v count=$COUNT -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{
|
||||||
if(NR==1) print nextcount > nextinput
|
if(NR==1) print nextcount > nextinput
|
||||||
else if($1 == "RUN") {
|
else if($1 == "RUN") {
|
||||||
@ -257,9 +257,9 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e $COUNT$EXTENSION.mlog ]; then
|
if [ ! -r $COUNT$EXTENSION.mlog ]; then
|
||||||
echo
|
echo
|
||||||
echo "The specified musrfit output file "$COUNT$EXTENSION".mlog does not exist!"
|
echo "The specified musrfit output file $COUNT$EXTENSION.mlog does not exist!"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -305,7 +305,7 @@ else
|
|||||||
|
|
||||||
# put together all data to db-format and write it to the file
|
# put together all data to db-format and write it to the file
|
||||||
awk -v optPARone=$OPT_PAR_ONE -v optPARtwo=$OPT_PAR_TWO -v optPARthree=$OPT_PAR_THREE -v optPARfour=$OPT_PAR_FOUR \
|
awk -v optPARone=$OPT_PAR_ONE -v optPARtwo=$OPT_PAR_TWO -v optPARthree=$OPT_PAR_THREE -v optPARfour=$OPT_PAR_FOUR \
|
||||||
-v optPARfour=$OPT_PAR_FIVE -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR '{
|
-v optPARfive=$OPT_PAR_FIVE -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR '{
|
||||||
|
|
||||||
outfile="out.db"
|
outfile="out.db"
|
||||||
if(optPARone ~ /^-o/) outfile = substr(optPARone,3)
|
if(optPARone ~ /^-o/) outfile = substr(optPARone,3)
|
||||||
@ -384,7 +384,7 @@ else
|
|||||||
if("'"$TEMPERATURE"'" != "") {
|
if("'"$TEMPERATURE"'" != "") {
|
||||||
|
|
||||||
# Write the db-header
|
# Write the db-header
|
||||||
if("'"$COUNT"'" == "'"${RUNARRAY[0]}"'" && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){
|
if("'"$q"'" == 0 && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){
|
||||||
|
|
||||||
print "TITLE" >> outfile
|
print "TITLE" >> outfile
|
||||||
print ">>>Put your title here<<<\n" >> outfile
|
print ">>>Put your title here<<<\n" >> outfile
|
||||||
@ -450,12 +450,12 @@ else
|
|||||||
|
|
||||||
print dataArray[i+3] ",,, " "'"$TITLE"'" >> outfile
|
print dataArray[i+3] ",,, " "'"$TITLE"'" >> outfile
|
||||||
|
|
||||||
if("'"$COUNT"'" == "'"${RUNARRAY[$LASTRUN]}"'") print "\n" >> outfile
|
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||||
}
|
}
|
||||||
|
|
||||||
# If we do not have the information from the summary file or "nosummary" is set
|
# If we do not have the information from the summary file or "nosummary" is set
|
||||||
else {
|
else {
|
||||||
if("'"$COUNT"'" == "'"${RUNARRAY[0]}"'" && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){
|
if("'"$q"'" == 0 && optPARone != "noheader" && optPARtwo != "noheader" && optPARthree != "noheader" && optPARfour != "noheader" && optPARfive != "noheader"){
|
||||||
|
|
||||||
print "TITLE" >> outfile
|
print "TITLE" >> outfile
|
||||||
print ">>>Put your title here<<<\n" >> outfile
|
print ">>>Put your title here<<<\n" >> outfile
|
||||||
@ -501,7 +501,7 @@ else
|
|||||||
|
|
||||||
print dataArray[i+3] ",,, " title >> outfile
|
print dataArray[i+3] ",,, " title >> outfile
|
||||||
|
|
||||||
if("'"$COUNT"'" == "'"${RUNARRAY[$LASTRUN]}"'") print "\n" >> outfile
|
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}' $COUNT$EXTENSION.mlog
|
}' $COUNT$EXTENSION.mlog
|
||||||
|
Reference in New Issue
Block a user