bug fixes in the mlog2db script
This commit is contained in:
parent
7cdaa0143e
commit
f8553136dd
38
src/external/scripts/mlog2db
vendored
38
src/external/scripts/mlog2db
vendored
@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -e /usr/bin/awk ]; then
|
||||
if [ ! -x /usr/bin/awk ]; then
|
||||
echo Please make sure you have installed awk!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -lt 2 ] ; then
|
||||
|
||||
if [ "$#" -lt 2 ] ; then
|
||||
|
||||
cat <<EOFHELP
|
||||
|
||||
"musrfit-mlog to db converter"
|
||||
@ -127,8 +127,8 @@ 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
|
||||
if [ "$ISDIGIT" -eq 1 ]; then # start and end-runs are given
|
||||
for (( j=0; j<=$2-$1; j++ ));
|
||||
if [ "$ISDIGIT" == 1 ]; then # start and end-runs are given
|
||||
for (( j=0; j<=$2-$1; j++ ))
|
||||
do
|
||||
RUNARRAY[$j]=$(( $1 + $j ))
|
||||
done
|
||||
@ -144,9 +144,9 @@ else
|
||||
NUM_OF_IND_VAR=1 # 1 for the run number
|
||||
|
||||
else # assume a runlist-file with "independent variables" is given
|
||||
if [ ! -e $1 ]; then
|
||||
if [ ! -r $1 ]; then
|
||||
echo
|
||||
echo "The specified runlist file" $1 "is not present... Bye bye!"
|
||||
echo "The specified runlist file $1 is not present... Bye bye!"
|
||||
echo
|
||||
exit 1
|
||||
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
|
||||
while read -u 3 -a runList
|
||||
do
|
||||
if [ "$numberOfReadInLines" == "0" ]; then
|
||||
if [ "$numberOfReadInLines" -eq 0 ]; then
|
||||
NUM_OF_IND_VAR=${#runList[@]}
|
||||
else
|
||||
RUNARRAY[(( numberOfReadInLines - 1 ))]=${runList[0]}
|
||||
@ -201,9 +201,9 @@ else
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
if [ -e $TEMP$EXTENSION.mlog ]; then
|
||||
if [ -r $TEMP$EXTENSION.mlog ]; then
|
||||
TEMPLATE=$TEMP$EXTENSION.mlog
|
||||
elif [ -e $TEMP$3.msr ]; then
|
||||
elif [ -r $TEMP$3.msr ]; then
|
||||
TEMPLATE=$TEMP$EXTENSION.msr
|
||||
fi
|
||||
fi
|
||||
@ -225,7 +225,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 [ "$COUNT" == "${RUNARRAY[0]}" ]; then
|
||||
if [ "$q" -eq 0 ]; then
|
||||
awk -v count=$TEMP -v nextcount=${RUNARRAY[0]} -v nextinput=$FIRSTINPUT '{
|
||||
if(NR==1) print nextcount > nextinput
|
||||
else if($1 == "RUN") {
|
||||
@ -244,7 +244,7 @@ else
|
||||
|
||||
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 '{
|
||||
if(NR==1) print nextcount > nextinput
|
||||
else if($1 == "RUN") {
|
||||
@ -257,9 +257,9 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e $COUNT$EXTENSION.mlog ]; then
|
||||
if [ ! -r $COUNT$EXTENSION.mlog ]; then
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
@ -305,7 +305,7 @@ else
|
||||
|
||||
# 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 \
|
||||
-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"
|
||||
if(optPARone ~ /^-o/) outfile = substr(optPARone,3)
|
||||
@ -384,7 +384,7 @@ else
|
||||
if("'"$TEMPERATURE"'" != "") {
|
||||
|
||||
# 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 ">>>Put your title here<<<\n" >> outfile
|
||||
@ -450,12 +450,12 @@ else
|
||||
|
||||
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
|
||||
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 ">>>Put your title here<<<\n" >> outfile
|
||||
@ -501,7 +501,7 @@ else
|
||||
|
||||
print dataArray[i+3] ",,, " title >> outfile
|
||||
|
||||
if("'"$COUNT"'" == "'"${RUNARRAY[$LASTRUN]}"'") print "\n" >> outfile
|
||||
if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile
|
||||
}
|
||||
}
|
||||
}' $COUNT$EXTENSION.mlog
|
||||
|
Loading…
x
Reference in New Issue
Block a user