Modify RunFunctions to enable an optional custom log file name to be specified.
new commandline: runApplication -l <log-file name> <application> <app args> NOTE: This is a transparent change, and providing no "-l <log-file name>" argument reverts the script back to the default operational mode. Modified the Allrun script in the "cavitatingFoam/les" tutorial to use the new runApplication command.
This commit is contained in:
parent
c11e475551
commit
555e3f71f6
3 changed files with 119 additions and 9 deletions
|
@ -36,26 +36,47 @@ getApplication ()
|
||||||
|
|
||||||
runApplication ()
|
runApplication ()
|
||||||
{
|
{
|
||||||
|
LOG_NAME=
|
||||||
|
while getopts "l:" OPTFLAG ; do
|
||||||
|
LOG_NAME=$OPTARG
|
||||||
|
shift $((OPTIND-1)) ; OPTIND=1
|
||||||
|
done
|
||||||
|
|
||||||
APP_RUN=$1; shift
|
APP_RUN=$1; shift
|
||||||
APP_NAME=${APP_RUN##*/}
|
APP_NAME=${APP_RUN##*/}
|
||||||
|
|
||||||
if [ -f log.$APP_NAME ] ; then
|
if [ -z $LOG_NAME ] ; then
|
||||||
|
LOG_NAME=log.$APP_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f $LOG_NAME ] ; then
|
||||||
echo "$APP_NAME already run on $PWD: remove log file to run"
|
echo "$APP_NAME already run on $PWD: remove log file to run"
|
||||||
else
|
else
|
||||||
echo "Running $APP_RUN on $PWD"
|
echo "Running $APP_NAME on $PWD"
|
||||||
$APP_RUN $* > log.$APP_NAME 2>&1
|
$APP_RUN $* > $LOG_NAME 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
runParallel ()
|
runParallel ()
|
||||||
{
|
{
|
||||||
APP_RUN=$1; shift
|
LOG_NAME=
|
||||||
|
while getopts "l:" OPTFLAG ; do
|
||||||
|
LOG_NAME=$OPTARG
|
||||||
|
shift $((OPTIND-1)) ; OPTIND=1
|
||||||
|
done
|
||||||
|
|
||||||
if [ -f $log.$APP_RUN ] ; then
|
APP_RUN=$1; shift
|
||||||
echo "$APP_RUN already run on $PWD: remove log file to run"
|
APP_NAME=${APP_RUN##*/}
|
||||||
|
|
||||||
|
if [ -z $LOG_NAME ] ; then
|
||||||
|
LOG_NAME=log.$APP_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f $LOG_NAME ] ; then
|
||||||
|
echo "$APP_NAME already run on $PWD: remove log file to run"
|
||||||
else
|
else
|
||||||
echo "Running $APP_RUN in parallel on $PWD using $1 processes"
|
echo "Running $APP_NAME in parallel on $PWD using $1 processes"
|
||||||
( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_RUN 2>&1 )
|
( mpirun -np $1 $APP_RUN -parallel < /dev/null > $LOG_NAME 2>&1 )
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
89
bin/tools/RunFunctions.old
Normal file
89
bin/tools/RunFunctions.old
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#---------------------------------*- sh -*-------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright held by original author
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# License
|
||||||
|
# This file is part of OpenFOAM.
|
||||||
|
#
|
||||||
|
# OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
# option) any later version.
|
||||||
|
#
|
||||||
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
# for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# RunFunctions
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
getApplication ()
|
||||||
|
{
|
||||||
|
grep application system/controlDict | sed "s/application *\([a-zA-Z]*\);/\1/"
|
||||||
|
}
|
||||||
|
|
||||||
|
runApplication ()
|
||||||
|
{
|
||||||
|
APP_RUN=$1; shift
|
||||||
|
APP_NAME=${APP_RUN##*/}
|
||||||
|
|
||||||
|
if [ -f log.$APP_NAME ] ; then
|
||||||
|
echo "$APP_NAME already run on $PWD: remove log file to run"
|
||||||
|
else
|
||||||
|
echo "Running $APP_RUN on $PWD"
|
||||||
|
$APP_RUN $* > log.$APP_NAME 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
runParallel ()
|
||||||
|
{
|
||||||
|
APP_RUN=$1; shift
|
||||||
|
|
||||||
|
if [ -f $log.$APP_RUN ] ; then
|
||||||
|
echo "$APP_RUN already run on $PWD: remove log file to run"
|
||||||
|
else
|
||||||
|
echo "Running $APP_RUN in parallel on $PWD using $1 processes"
|
||||||
|
( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_RUN 2>&1 )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
compileApplication ()
|
||||||
|
{
|
||||||
|
echo "Compiling $1 application"
|
||||||
|
wmake $1
|
||||||
|
}
|
||||||
|
|
||||||
|
compileLibrary ()
|
||||||
|
{
|
||||||
|
echo "Compiling $1 application"
|
||||||
|
wmake libso $1
|
||||||
|
}
|
||||||
|
|
||||||
|
cloneCase ()
|
||||||
|
{
|
||||||
|
if [ -d $2 ] ; then
|
||||||
|
echo "Case already cloned: remove case directory $2 to clone"
|
||||||
|
else
|
||||||
|
echo "Cloning $2 case from $1"
|
||||||
|
mkdir $2
|
||||||
|
cpfiles="0 system constant"
|
||||||
|
for f in $cpfiles
|
||||||
|
do
|
||||||
|
cp -r $1/$f $2
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
|
@ -12,10 +12,10 @@ refineMeshByCellSet()
|
||||||
do
|
do
|
||||||
echo "creating cell set for primary zone - $1"
|
echo "creating cell set for primary zone - $1"
|
||||||
cp system/cellSetDict.$1 system/cellSetDict
|
cp system/cellSetDict.$1 system/cellSetDict
|
||||||
cellSet > log.cellSet.$1 2>&1
|
runApplication -l log.cellSet.$1 cellSet
|
||||||
|
|
||||||
echo "refining primary zone - $1"
|
echo "refining primary zone - $1"
|
||||||
refineMesh -dict -overwrite > log.refineMesh.$1 2>&1
|
runApplication -l log.refineMesh.$1 refineMesh -dict -overwrite
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue