Commit 26a2c177 authored by Henry Weller's avatar Henry Weller
Browse files

RunFunctions: Added -append and -overwrite options

-append: append to log file
-overwrite: overwrite log file
Original patch provided by Timm Severin
Resolves feature request http://www.openfoam.org/mantisbt/view.php?id=1919
parent 1a992064
......@@ -40,40 +40,80 @@ getApplication()
runApplication()
{
APP_RUN=$1
APP_NAME=${1##*/}
APP_RUN=
LOG_IGNORE=false
LOG_APPEND=false
# Parse options and executable
while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
key="$1"
case "$key" in
-append)
LOG_IGNORE=true
LOG_APPEND=true
;;
-overwrite)
LOG_IGNORE=true
;;
*)
APP_RUN="$key"
APP_NAME="${key##*/}"
;;
esac
shift
done
if [ -f log.$APP_NAME ]
if [ -f log.$APP_NAME ] && [ "$LOG_IGNORE" = "false" ]
then
echo "$APP_NAME already run on $PWD: remove log file to re-run"
else
echo "Running $APP_RUN on $PWD"
$APP_RUN "$@" > log.$APP_NAME 2>&1
if [ "$LOG_APPEND" = "true" ]; then
$APP_RUN "$@" >> log.$APP_NAME 2>&1
else
$APP_RUN "$@" > log.$APP_NAME 2>&1
fi
fi
}
runParallel()
{
APP_RUN=$1
APP_NAME=${1##*/}
APP_RUN=
LOG_IGNORE=false
LOG_APPEND=false
# Parse options and executable
while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
key="$1"
case "$key" in
-append)
LOG_IGNORE=true
LOG_APPEND=true
;;
-overwrite)
LOG_IGNORE=true
;;
*)
APP_RUN="$key"
APP_NAME="${key##*/}"
# also read number of processors
nProcs="$2"
shift
;;
esac
shift
done
if [ -f log.$APP_NAME ]
if [ -f log.$APP_NAME ] && [ "$LOG_IGNORE" = "false" ]
then
echo "$APP_NAME already run on $PWD: remove log file to re-run"
else
nProcs=$1
shift
echo "Running $APP_RUN in parallel on $PWD using $nProcs processes"
#if [ "$WM_SCHEDULER" ]
#then
# echo "$PWD: $WM_SCHEDULER -np $nProcs" 1>&2
# $WM_SCHEDULER -np $nProcs "( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )"
#else
if [ "$LOG_APPEND" = "true" ]; then
( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null >> log.$APP_NAME 2>&1 )
else
( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )
#fi
fi
fi
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment