View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001919 | OpenFOAM | Bug | public | 2015-11-19 14:44 | 2015-11-20 09:31 |
Reporter | Timm Severin | Assigned To | henry | ||
Priority | low | Severity | feature | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | GNU/Linux | OS | Ubuntu | OS Version | 15.04 |
Summary | 0001919: runApplication/runParallel allow to append or overwrite log | ||||
Description | It would be nice if runApplication or runParallel could overwrite or append existing logs, which can be useful in cases where one continues the case (increase endTime in controlDict and startFrom latestTime). This is similar to http://www.openfoam.org/mantisbt/view.php?id=1655, however I don't see foamJob used anywhere, at least not in the tutorials. | ||||
Additional Information | Attached a patch generated in 2.3.x for the RunFunctions file in $WM_PROJECT_DIR/bin/tools/. Now it allows for example: runApplication --append icoFoam runParallel --append icoFoam 4 runApplication --overwrite icoFoam Parameters which are added AFTER the executable will be passed on to it as before, e.g. runApplication --overwrite blockMesh -dict system/myFancyBlockMeshDict will call blockMesh -dict system/myFancyBlockMeshDict > log.blockMesh Note that I have tested the changes, but have not checked for compatibility with all terminals emulators. | ||||
Tags | No tags attached. | ||||
|
RunFunctions.patch (3,159 bytes)
--- RunFunctions 2015-11-19 15:22:27.373679007 +0100 +++ RunFunctions.new 2015-11-19 15:21:25.177370592 +0100 @@ -40,31 +40,80 @@ runApplication() { - APP_RUN=$1 - APP_NAME=${1##*/} + ## parse options and executable + # set default variables + APP_RUN= + LOG_IGNORE=false + LOG_APPEND=false + # loop over all parameters until an executable has been passed, + # all remaining parameters will be interpreted as arguments + # for the 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##*/} + ## parse options and executable + # set default variables + APP_RUN= + LOG_IGNORE=false + LOG_APPEND=false + # loop over all parameters until an executable has been passed, + # all remaining parameters will be interpreted as arguments + # for the 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" ] @@ -72,7 +121,11 @@ # 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 ) + 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 } |
|
foamJob is not used in other OpenFOAM scripts it is an end-user script. I am OK with the changes your propose but I will change the options to -append and -overwrite to be consistent with the rest of OpenFOAM. |
|
Resolved in OpenFOAM-dev by commit 36fe080bc73e2e983d14728cb65d88d05c9a8331 |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-11-19 14:44 | Timm Severin | New Issue | |
2015-11-19 14:44 | Timm Severin | File Added: RunFunctions.patch | |
2015-11-19 15:29 | henry | Note Added: 0005631 | |
2015-11-19 15:50 | henry | Note Added: 0005632 | |
2015-11-19 15:50 | henry | Status | new => resolved |
2015-11-19 15:50 | henry | Resolution | open => fixed |
2015-11-19 15:50 | henry | Assigned To | => henry |