STYLE: drop 'getopt' in favour of hand-rolled option parsing

- improves flexibility and allows more consistent long options
This commit is contained in:
Mark Olesen
2010-04-09 16:55:47 +02:00
parent a55ce8eeba
commit f7b0b7ca71
4 changed files with 259 additions and 276 deletions

View File

@ -31,35 +31,36 @@
# Bugs # Bugs
# -solution singularity not handled # -solution singularity not handled
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Script=${0##*/}
toolsDir=${0%/*}/tools
PROGDIR=`dirname $0` usage() {
PROGNAME=`basename $0` while [ "$#" -ge 1 ]; do echo "$1"; shift; done
DBFILE=${PROGNAME}.db cat <<USAGE
printUsage() { Usage: $Script [OPTIONS] <log>
cat <<USAGE -list lists but does not extract
$PROGNAME - extracts xy files from OpenFOAM logs. -n create single column files with the extracted data only
-quiet quiet operation
-help print the usage
Usage: $PROGNAME [-n][-s] <log> $Script - extracts xy files from OpenFOAM logs.
extracts xy files from log
$PROGNAME -l <log>
lists but does not extract
$PROGNAME -h
for a help message
USAGE USAGE
exit 1
} }
#------------------------------------------------------------------------------
printHelp() { printHelp() {
printUsage cat <<HELP
cat <<LABHELP -----------------------------------------------------------------------------
The default is to extract for all the 'Solved for' variables the initial The default is to extract for all the 'Solved for' variables the initial
residual, the final residual and the number of iterations. Additionally, a residual, the final residual and the number of iterations. Additionally, a
(user editable) database is used to extract data for standard non-solved for (user editable) database is used to extract data for standard non-solved for
variables like Courant number, and execution time. variables like Courant number, and execution time.
$PROGNAME -l lists all the possible variables without extracting them. $Script -l lists all the possible variables without extracting them.
The program will generate and run an awk script which writes a set of files, The program will generate and run an awk script which writes a set of files,
logs/<var>_<subIter>, for every <var> specified, for every occurrence inside logs/<var>_<subIter>, for every <var> specified, for every occurrence inside
@ -79,7 +80,7 @@ separated with '/' :
Column 2 is the extended regular expression (egrep) to select the line. Column 2 is the extended regular expression (egrep) to select the line.
Column 3 is the string (fgrep) to select the column inside the line. Column 3 is the string (fgrep) to select the column inside the line.
The value taken will be the first (non-space)word after this column. The value taken will be the first (non-space)word after this column.
The database ($PROGNAME.db) will taken from these locations: The database ($Script.db) will taken from these locations:
. .
$HOME/.OpenFOAM/$WM_PROJECT_VERSION $HOME/.OpenFOAM/$WM_PROJECT_VERSION
@ -87,61 +88,97 @@ The database ($PROGNAME.db) will taken from these locations:
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION
$WM_PROJECT_INST_DIR/site $WM_PROJECT_INST_DIR/site
$WM_PROJECT_DIR/etc $WM_PROJECT_DIR/etc
$PROGDIR/tools $toolsDir
Option -s suppresses the default information and only prints the extracted Option -q suppresses the default information and only prints the extracted
variables. variables.
-----------------------------------------------------------------------------
HELP
LABHELP usage
} }
# The various places to be searched: timeName=Time
for i in \ unset listOpt quietOpt
. \
$HOME/.OpenFOAM/$WM_PROJECT_VERSION \ # parse options
$HOME/.OpenFOAM \ while [ "$#" -gt 0 ]
$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION \
$WM_PROJECT_INST_DIR/site \
$WM_PROJECT_DIR/etc \
$PROGDIR/tools \
;
do do
if [ -r $i/$DBFILE ] case "$1" in
then -h | -help)
DBFILE="$i/$DBFILE" printHelp
exit 0
;;
-n)
unset timeName
shift
;;
-l | -list)
listOpt=true
shift
;;
-q | -quiet | -s | -silent)
quietOpt=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break break
fi ;;
esac
done done
# find the database file
DBFILE=$Script.db
[ -f $DBFILE ] || DBFILE=`foamEtcFile $Script.db` || DBFILE=$toolsDir/$Script.db
myEcho() { # need the database file
if [ "$VERBOSE" ] [ -f $DBFILE ] || {
then echo "$Script: Cannot read database $DBFILE"
echo "$*" exit 1
fi
} }
# single logFile
if [ $# -eq 1 ]
then
LOG=$1
[ -r "$LOG" ] && [ -f "$LOG" ] || usage "Cannot read log $LOG"
else
usage
fi
myEcho()
{
[ "$quietOpt" = true ] || echo "$*"
}
# getSolvedVars logFile # getSolvedVars logFile
# Prints names of all 'solved for' variables in the log file. # Prints names of all 'solved for' variables in the log file.
getSolvedVars() { getSolvedVars()
{
fgrep ' Solving for ' $1 | fgrep ',' | sed -e 's/.* Solving for \([^,]*\)[,:].*/\1/' | sort -u fgrep ' Solving for ' $1 | fgrep ',' | sed -e 's/.* Solving for \([^,]*\)[,:].*/\1/' | sort -u
} }
# getQueries dbFile queryName # getQueries dbFile queryName
# Gets regular expressions for a certain queryName from the database # Gets regular expressions for a certain queryName from the database
getQueries() { getQueries()
if [ ! -f "$1" ] {
then dbFile=$1
echo "Cannot find dbFile $1"
exit 1
fi
queryName=$2 queryName=$2
LINEQ=`grep -v '^#' $1 | awk -F '/' "/$queryName/ {if (\"$queryName\" "'!= $1) next; print $2}'` [ -f "$dbFile" ] || {
NUMQ=`grep -v '^#' $1 | awk -F '/' "/$queryName/ {if (\"$queryName\" "'!= $1) next; print $3}'` echo "Cannot find dbFile $dbFile"
exit 1
}
LINEQ=`grep -v '^#' $dbFile | awk -F '/' "/$queryName/ {if (\"$queryName\" "'!= $1) next; print $2}'`
NUMQ=`grep -v '^#' $dbFile | awk -F '/' "/$queryName/ {if (\"$queryName\" "'!= $1) next; print $3}'`
#echo "For $queryName found line selection /$LINEQ/ , column selection /$NUMQ/" 1>&2 #echo "For $queryName found line selection /$LINEQ/ , column selection /$NUMQ/" 1>&2
#if [ ! "$LINEQ" -o ! "$NUMQ" ] #if [ ! "$LINEQ" -o ! "$NUMQ" ]
@ -153,14 +190,16 @@ getQueries() {
# getDbQueryList dbFile # getDbQueryList dbFile
# Echoes list of possible queries # Echoes list of possible queries
getDbQueryList() { getDbQueryList()
{
grep -v '^#' $1 | grep '[^ \t]' | awk -F '/' '{print $1}' grep -v '^#' $1 | grep '[^ \t]' | awk -F '/' '{print $1}'
} }
# getSolveQueryList logFile # getSolveQueryList logFile
# Echoes list of queries from "solved for" variables in log file # Echoes list of queries from "solved for" variables in log file
getSolveQueryList() { getSolveQueryList()
{
solvedVars=`getSolvedVars $1` solvedVars=`getSolvedVars $1`
for var in $solvedVars for var in $solvedVars
@ -174,7 +213,8 @@ getSolveQueryList() {
# getAllQueries dbFile logFile # getAllQueries dbFile logFile
# Gets all queries from database and from logfile # Gets all queries from database and from logfile
getAllQueries() { getAllQueries()
{
#-- All solved for queries from log file #-- All solved for queries from log file
queries=`getSolveQueryList $2` queries=`getSolveQueryList $2`
@ -208,107 +248,33 @@ getAllQueries() {
# Main # Main
#----------------------------- #-----------------------------
# sort arguments if [ "$listOpt" = true ]
TIMENAME='Time'
VERBOSE='yes'
LISTONLY=''
while getopts nslh flags
do
case $flags in
n)
TIMENAME=""
;;
h)
printHelp
exit 0
;;
s)
VERBOSE=""
;;
l)
LISTONLY='yes'
;;
\?)
printUsage
exit 1
;;
esac
done
# Shift options
shift `expr $OPTIND - 1`
if [ ! -f $DBFILE ]
then then
echo "$PROGNAME: Cannot read database $DBFILE"
exit 1
fi
if [ "$LISTONLY" ]
then
if [ $# -ne 1 ]
then
printUsage
exit 1
fi
LOG=$1;
if [ ! -r $LOG ]
then
echo "$PROGNAME: Cannot read log $LOG"
exit 1
fi
getAllQueries $DBFILE $LOG getAllQueries $DBFILE $LOG
exit 0 exit 0
fi fi
if [ $# -ne 1 ] caseDir=.
then outputDir=$caseDir/logs
printUsage
exit 1
fi
CASEDIR=. [ -d "$caseDir" ] || {
LOG=$1 echo "$Script: Cannot read $caseDir"
if [ ! -r $LOG ]
then
echo "$PROGNAME: Cannot read log $LOG"
exit 1 exit 1
fi }
QUERYNAMES=`getAllQueries $DBFILE $LOG` QUERYNAMES=`getAllQueries $DBFILE $LOG`
#
if [ ! "$CASEDIR" ] # Make logs dir in case directory and place awk file there
then #
printUsage mkdir -p $outputDir
exit 1 AWKFILE=$outputDir/$Script.awk
fi
if [ ! -d "$CASEDIR" ]
then
echo "$PROGNAME: Cannot read $CASEDIR"
exit 1
fi
if [ ! -f "$LOG" ]
then
echo "$PROGNAME: Cannot read log file $LOG"
exit 1
fi
#-- Make logs dir in case directory and put awk file there.
mkdir -p $CASEDIR/logs
AWKFILE=$CASEDIR/logs/$PROGNAME.awk
myEcho "Using:" myEcho "Using:"
myEcho " log : $LOG" myEcho " log : $LOG"
myEcho " database : $DBFILE" myEcho " database : $DBFILE"
myEcho " awk file : $AWKFILE" myEcho " awk file : $AWKFILE"
myEcho " files to : $CASEDIR/logs" myEcho " files to : $outputDir"
myEcho "" myEcho ""
@ -316,22 +282,25 @@ myEcho ""
# Generate Awk program # Generate Awk program
#----------------------------- #-----------------------------
#-- header rm -f $AWKFILE 2> /dev/null
cat << AWK_CONTENTS > $AWKFILE
# header
BEGIN {
Iteration=0
resetCounters()
}
rm -f $AWKFILE; touch $AWKFILE # reset counters used for variable postfix
echo "BEGIN {" >> $AWKFILE function resetCounters() {
echo " Iteration=0" >> $AWKFILE AWK_CONTENTS
echo " resetCounters()" >> $AWKFILE # ----------
echo "}" >> $AWKFILE
echo "" >> $AWKFILE
echo "# reset counters used for variable postfix" >> $AWKFILE
echo "function resetCounters() {" >> $AWKFILE
for queryName in $QUERYNAMES for queryName in $QUERYNAMES
do do
varName=${queryName}Cnt varName=${queryName}Cnt
echo " ${varName}=0" >> $AWKFILE echo " ${varName}=0" >> $AWKFILE
done done
echo " # Reset counters for general Solving for extraction" >> $AWKFILE echo " # Reset counters for general Solving for extraction" >> $AWKFILE
echo " for (varName in subIter)" >> $AWKFILE echo " for (varName in subIter)" >> $AWKFILE
echo " {" >> $AWKFILE echo " {" >> $AWKFILE
@ -341,10 +310,9 @@ echo "}" >> $AWKFILE
echo "" >> $AWKFILE echo "" >> $AWKFILE
cat <<LABEL >> $AWKFILE cat << AWK_CONTENTS >> $AWKFILE
# Extract value after columnSel # Extract value after columnSel
function extract(inLine,columnSel,outVar, function extract(inLine,columnSel,outVar,a,b)
a,b)
{ {
a=index(inLine, columnSel) a=index(inLine, columnSel)
b=length(columnSel) b=length(columnSel)
@ -352,71 +320,82 @@ function extract(inLine,columnSel,outVar,
gsub("[,:]","",outVar[1]) gsub("[,:]","",outVar[1])
} }
LABEL AWK_CONTENTS
# ----------
#
#-- Generate code for iteration separator (increments 'Iteration') # Code for iteration separator (increments 'Iteration')
#
getQueries $DBFILE 'Separator' getQueries $DBFILE 'Separator'
cat <<LABSEP >> $AWKFILE cat << AWK_CONTENTS >> $AWKFILE
#-- Iteration separator (increments 'Iteration') # Iteration separator (increments 'Iteration')
/$LINEQ/ { /$LINEQ/ {
Iteration++ Iteration++
resetCounters() resetCounters()
} }
LABSEP AWK_CONTENTS
# ----------
#
#-- Generate code for extracting Time # Code for extracting Time
#
getQueries $DBFILE 'Time' getQueries $DBFILE 'Time'
cat <<LABTIME >> $AWKFILE cat << AWK_CONTENTS >> $AWKFILE
#-- Time extraction (sets 'Time') # Time extraction (sets 'Time')
/$LINEQ/ { /$LINEQ/ {
extract(\$0, "$NUMQ", val) extract(\$0, "$NUMQ", val)
Time=val[1] Time=val[1]
} }
LABTIME AWK_CONTENTS
# ----------
#
#-- Generate code for singularity handling. # Code for singularity handling.
cat <<LABSING >> $AWKFILE #
#-- Skip whole line with singularity variable cat << AWK_CONTENTS >> $AWKFILE
# Skip whole line with singularity variable
/solution singularity/ { /solution singularity/ {
next; next;
} }
LABSING
AWK_CONTENTS
# ----------
#-- Generate code for extracting solved for quantities #
cat <<LABSOLVE >> $AWKFILE # Code for extracting solved for quantities
#-- Extraction of any solved for variable #
cat << AWK_CONTENTS >> $AWKFILE
# Extraction of any solved for variable
/Solving for/ { /Solving for/ {
extract(\$0, "Solving for ", varNameVal) extract(\$0, "Solving for ", varNameVal)
varName=varNameVal[1] varName=varNameVal[1]
file=varName "_" subIter[varName]++ file=varName "_" subIter[varName]++
file="$CASEDIR/logs/" file file="$outputDir/" file
extract(\$0, "Initial residual = ", val) extract(\$0, "Initial residual = ", val)
print $TIMENAME "\t" val[1] > file print $timeName "\t" val[1] > file
varName=varNameVal[1] "FinalRes" varName=varNameVal[1] "FinalRes"
file=varName "_" subIter[varName]++ file=varName "_" subIter[varName]++
file="$CASEDIR/logs/" file file="$outputDir/" file
extract(\$0, "Final residual = ", val) extract(\$0, "Final residual = ", val)
print $TIMENAME "\t" val[1] > file print $timeName "\t" val[1] > file
varName=varNameVal[1] "Iters" varName=varNameVal[1] "Iters"
file=varName "_" subIter[varName]++ file=varName "_" subIter[varName]++
file="$CASEDIR/logs/" file file="$outputDir/" file
extract(\$0, "No Iterations ", val) extract(\$0, "No Iterations ", val)
print $TIMENAME "\t" val[1] > file print $timeName "\t" val[1] > file
} }
LABSOLVE AWK_CONTENTS
# ----------
#
#-- generate code to process queries # Code to process queries
#
for queryName in $QUERYNAMES for queryName in $QUERYNAMES
do do
getQueries $DBFILE $queryName getQueries $DBFILE $queryName
@ -424,11 +403,11 @@ do
then then
counter=${queryName}Cnt counter=${queryName}Cnt
echo "#-- Extraction of $queryName" >> $AWKFILE echo "# Extraction of $queryName" >> $AWKFILE
echo "/$LINEQ/ {" >> $AWKFILE echo "/$LINEQ/ {" >> $AWKFILE
echo " extract(\$0, \"$NUMQ\", val)" >> $AWKFILE echo " extract(\$0, \"$NUMQ\", val)" >> $AWKFILE
echo " file=\"$CASEDIR/logs/${queryName}_\" ${counter}" >> $AWKFILE echo " file=\"$outputDir/${queryName}_\" ${counter}" >> $AWKFILE
echo " print $TIMENAME \"\\t\" val[1] > file" >> $AWKFILE echo " print $timeName \"\\t\" val[1] > file" >> $AWKFILE
echo " ${counter}++" >> $AWKFILE echo " ${counter}++" >> $AWKFILE
echo "}" >> $AWKFILE echo "}" >> $AWKFILE
echo "" >> $AWKFILE echo "" >> $AWKFILE

View File

@ -32,41 +32,70 @@
# Also removes consecutive blank lines from file. # Also removes consecutive blank lines from file.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
foamVersion=$WM_PROJECT_VERSION
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
Usage: ${0##*/} [OPTION] <file1> ... <fileN> Usage: ${0##*/} [OPTION] <file1> ... <fileN>
options: options:
-v VER specifies the version to be written in the header -version <ver> specifies the version to be written in the header
-h help -help print the usage
Updates the header of application files and removes consecutive blank lines. Updates the header of application files and removes consecutive blank lines.
By default, writes current OpenFOAM version in the header. By default, writes current OpenFOAM version in the header.
An alternative version can be specified with the -v option. An alternative version can be specified with the -version option.
USAGE USAGE
exit 1 exit 1
} }
#------------------------------------------------------------------------------
printHeader() { # parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version="$2"
shift 2
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# constant width for version - default to WM_PROJECT_VERSION
version=$(printf %-36s ${version:-$WM_PROJECT_VERSION})
[ $# -ge 1 ] || usage
#------------------------------------------------------------------------------
printHeader()
{
cat<<HEADER cat<<HEADER
/*--------------------------------*- C++ -*----------------------------------*\\ /*--------------------------------*- C++ -*----------------------------------*\\
| ========= | | | ========= | |
| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\\\ / O peration | Version: ${foamVersion} | | \\\\ / O peration | Version: $version |
| \\\\ / A nd | Web: www.OpenFOAM.org | | \\\\ / A nd | Web: www.OpenFOAM.org |
| \\\\/ M anipulation | | | \\\\/ M anipulation | |
\\*---------------------------------------------------------------------------*/ \\*---------------------------------------------------------------------------*/
FoamFile FoamFile
{ {
version 2.0; version 2.0;
format ${1}; format $1;
class ${2}; class $2;
object ${3}; object $3;
} }
HEADER HEADER
} }
@ -75,68 +104,40 @@ HEADER
# #
# extract attribute '$1' from file '$2' # extract attribute '$1' from file '$2'
# #
FoamFileAttribute() { FoamFileAttribute()
{
sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
} }
# #
# OPTIONS # main
# #
opts=$(getopt hv: $*)
if [ $? -ne 0 ]
then
echo "Aborting due to invalid option"
usage
fi
eval set -- '$opts'
while [ "$1" != "--" ]
do
case $1 in
-v)
foamVersion=$2
shift
;;
-h)
usage
;;
esac
shift
done
shift
[ $# -ge 1 ] || usage
# constant width for version
foamVersion=$(printf %-36s $foamVersion)
#
# MAIN
#
unset NOTE
tmpFile=FoamFile.tmp$$
for caseFile for caseFile
do do
if grep FoamFile $caseFile >/dev/null 2>&1 if grep FoamFile $caseFile >/dev/null 2>&1
then then
echo "Updating case file: $caseFile" echo "Updating case file: $caseFile"
sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp sed -n '/FoamFile/,/}/p' $caseFile > $tmpFile
FORMAT=$(FoamFileAttribute format FoamFile.tmp) format=$(FoamFileAttribute format $tmpFile)
CLASS=$(FoamFileAttribute class FoamFile.tmp) class=$(FoamFileAttribute class $tmpFile)
OBJECT=$(FoamFileAttribute object FoamFile.tmp) object=$(FoamFileAttribute object $tmpFile)
# extract NOTE? # extract note? - needs special handling
unset note
printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp printHeader $format $class $object "$note" > $tmpFile
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> $tmpFile
# use cat to avoid removing/replace soft-links # use cat to avoid removing/replace soft-links
[ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile [ -s $tmpFile ] && cat $tmpFile >| $caseFile
rm -f FoamFile.tmp 2>/dev/null rm -f $tmpFile 2>/dev/null
else else
echo " Invalid case file: $caseFile" 1>&2 echo " Invalid case file: $caseFile" 1>&2
fi fi
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------ end-of-file

View File

@ -36,11 +36,11 @@ usage()
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: $0 [OPTION] usage: ${0##*/} [OPTION]
options: options:
-d sets up a default scheme on all schemes -default sets up a default scheme on all schemes
-h this usage -help print the usage
* quickly tests the tutorials and writes out the scheme/solver information * quickly tests the tutorials and writes out the scheme/solver information
@ -48,6 +48,30 @@ USAGE
exit 1 exit 1
} }
#------------------------------------------------------------------------------
unset DEFAULT_SCHEMES
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-d | -default)
DEFAULT_SCHEMES=true
shift
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
setDefaultFvSchemes() setDefaultFvSchemes()
{ {
@ -98,6 +122,7 @@ done
[ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found" [ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
TUTORIALS_DIR=. TUTORIALS_DIR=.
TEST_RUN_DIR=../tutorialsTest TEST_RUN_DIR=../tutorialsTest
FV_SCHEMES=\ FV_SCHEMES=\
@ -113,30 +138,7 @@ SCHEMES_FILE="FvSchemes"
SCHEMES_TEMP="FvSchemes.temp" SCHEMES_TEMP="FvSchemes.temp"
SOLVERS_FILE="FvSolution" SOLVERS_FILE="FvSolution"
SOLVERS_TEMP="FvSolution.temp" SOLVERS_TEMP="FvSolution.temp"
DEFAULT_SCHEMES=0
#
# OPTIONS
#
OPTS=`getopt hd $*`
if [ $? -ne 0 ]
then
usage "Aborting due to invalid option"
fi
eval set -- "$OPTS"
while [ $1 != -- ]
do
case $1 in
-d)
DEFAULT_SCHEMES=1
;;
-h)
usage
;;
esac
shift
done
shift
# #
# MAIN # MAIN
@ -182,7 +184,7 @@ do
${CD}.org > ${CD} ${CD}.org > ${CD}
done done
if [ $DEFAULT_SCHEMES = 1 ] if [ "$DEFAULT_SCHEMES" = true ]
then then
echo "Modifying the fvSchemes to contain only default schemes" echo "Modifying the fvSchemes to contain only default schemes"
for FV_SC in `find . -name fvSchemes` for FV_SC in `find . -name fvSchemes`
@ -209,8 +211,7 @@ do
echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
for ST in $FV_SCHEMES for ST in $FV_SCHEMES
do do
rm $SCHEMES_TEMP > /dev/null 2>&1 rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1
rm $SOLVERS_TEMP > /dev/null 2>&1
echo " ${ST}" >> $SCHEMES_FILE echo " ${ST}" >> $SCHEMES_FILE
for LOG in `find ${APP} -name "log.${APP}"` for LOG in `find ${APP} -name "log.${APP}"`
do do

View File

@ -20,32 +20,34 @@ USAGE
exit 1 exit 1
} }
# -----------------------------------------------------------------------------
unset timeOpt unset timeOpt
OPTS=`getopt hl $*` # parse options
[ $? -eq 0 ] || usage "Aborting due to invalid option" while [ "$#" -gt 0 ]
eval set -- "$OPTS"
while [ $1 != -- ]
do do
case $1 in case "$1" in
-l) -h | -help)
timeOpt="-latestTime"
;;
-h)
usage usage
;; ;;
-l | -latestTime)
timeOpt="-latestTime"
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac esac
shift
done done
shift
sample $timeOpt sample $timeOpt
SDIR="sets" SDIR=sets
LSDIR=`ls $SDIR | head -1` LSDIR=`ls $SDIR | head -1`
EXAMPLE_FILE=`ls -1 $SDIR/${LSDIR}/* | head -1` EXAMPLE_FILE=`ls -1 $SDIR/${LSDIR}/* | head -1`
FS=`basename $EXAMPLE_FILE | cut -d_ -f2-` FS=`basename $EXAMPLE_FILE | cut -d_ -f2-`
for d in $SDIR/* for d in $SDIR/*
do do
cat ${d}/cone25_${FS} ${d}/cone55_${FS} ${d}/base_${FS} > ${d}/biconic_${FS} cat ${d}/cone25_${FS} ${d}/cone55_${FS} ${d}/base_${FS} > ${d}/biconic_${FS}