Skip to content
Snippets Groups Projects
Commit 36fe080b 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 3792d0a9
Branches
Tags
1 merge request!25Merge foundation
...@@ -40,40 +40,80 @@ getApplication() ...@@ -40,40 +40,80 @@ getApplication()
runApplication() runApplication()
{ {
APP_RUN=$1 APP_RUN=
APP_NAME=${1##*/} 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 shift
done
if [ -f log.$APP_NAME ] if [ -f log.$APP_NAME ] && [ "$LOG_IGNORE" = "false" ]
then then
echo "$APP_NAME already run on $PWD: remove log file to re-run" echo "$APP_NAME already run on $PWD: remove log file to re-run"
else else
echo "Running $APP_RUN on $PWD" 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 fi
} }
runParallel() runParallel()
{ {
APP_RUN=$1 APP_RUN=
APP_NAME=${1##*/} 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 shift
done
if [ -f log.$APP_NAME ] if [ -f log.$APP_NAME ] && [ "$LOG_IGNORE" = "false" ]
then then
echo "$APP_NAME already run on $PWD: remove log file to re-run" echo "$APP_NAME already run on $PWD: remove log file to re-run"
else else
nProcs=$1
shift
echo "Running $APP_RUN in parallel on $PWD using $nProcs processes" echo "Running $APP_RUN in parallel on $PWD using $nProcs processes"
if [ "$LOG_APPEND" = "true" ]; then
#if [ "$WM_SCHEDULER" ] ( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null >> log.$APP_NAME 2>&1 )
#then else
# 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
( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 ) ( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )
#fi fi
fi fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment