mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: drop 'getopt' in favour of hand-rolled option parsing
- improves flexibility and allows more consistent long options
This commit is contained in:
@ -36,11 +36,11 @@ usage()
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
usage: $0 [OPTION]
|
||||
usage: ${0##*/} [OPTION]
|
||||
|
||||
options:
|
||||
-d sets up a default scheme on all schemes
|
||||
-h this usage
|
||||
-default sets up a default scheme on all schemes
|
||||
-help print the usage
|
||||
|
||||
* quickly tests the tutorials and writes out the scheme/solver information
|
||||
|
||||
@ -48,6 +48,30 @@ USAGE
|
||||
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()
|
||||
{
|
||||
@ -98,6 +122,7 @@ done
|
||||
|
||||
[ -f "$MAIN_CONTROL_DICT" ] || usage "main controlDict not found"
|
||||
|
||||
|
||||
TUTORIALS_DIR=.
|
||||
TEST_RUN_DIR=../tutorialsTest
|
||||
FV_SCHEMES=\
|
||||
@ -113,30 +138,7 @@ SCHEMES_FILE="FvSchemes"
|
||||
SCHEMES_TEMP="FvSchemes.temp"
|
||||
SOLVERS_FILE="FvSolution"
|
||||
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
|
||||
@ -182,7 +184,7 @@ do
|
||||
${CD}.org > ${CD}
|
||||
done
|
||||
|
||||
if [ $DEFAULT_SCHEMES = 1 ]
|
||||
if [ "$DEFAULT_SCHEMES" = true ]
|
||||
then
|
||||
echo "Modifying the fvSchemes to contain only default schemes"
|
||||
for FV_SC in `find . -name fvSchemes`
|
||||
@ -209,8 +211,7 @@ do
|
||||
echo "$APP: " | tr -d "\n" >> $SOLVERS_FILE
|
||||
for ST in $FV_SCHEMES
|
||||
do
|
||||
rm $SCHEMES_TEMP > /dev/null 2>&1
|
||||
rm $SOLVERS_TEMP > /dev/null 2>&1
|
||||
rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1
|
||||
echo " ${ST}" >> $SCHEMES_FILE
|
||||
for LOG in `find ${APP} -name "log.${APP}"`
|
||||
do
|
||||
|
||||
@ -20,32 +20,34 @@ USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
unset timeOpt
|
||||
|
||||
OPTS=`getopt hl $*`
|
||||
[ $? -eq 0 ] || usage "Aborting due to invalid option"
|
||||
|
||||
eval set -- "$OPTS"
|
||||
while [ $1 != -- ]
|
||||
# parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case $1 in
|
||||
-l)
|
||||
timeOpt="-latestTime"
|
||||
;;
|
||||
-h)
|
||||
case "$1" in
|
||||
-h | -help)
|
||||
usage
|
||||
;;
|
||||
-l | -latestTime)
|
||||
timeOpt="-latestTime"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage "unknown option/argument: '$*'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
|
||||
sample $timeOpt
|
||||
SDIR="sets"
|
||||
SDIR=sets
|
||||
LSDIR=`ls $SDIR | head -1`
|
||||
EXAMPLE_FILE=`ls -1 $SDIR/${LSDIR}/* | head -1`
|
||||
FS=`basename $EXAMPLE_FILE | cut -d_ -f2-`
|
||||
|
||||
for d in $SDIR/*
|
||||
do
|
||||
cat ${d}/cone25_${FS} ${d}/cone55_${FS} ${d}/base_${FS} > ${d}/biconic_${FS}
|
||||
|
||||
Reference in New Issue
Block a user