diff --git a/bin/mpirunDebug b/bin/mpirunDebug index 1e901b25aa..695c0fae5e 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -7,7 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2015 OpenFOAM Foundation -# Copyright (C) 2017-2021 OpenCFD Ltd. +# Copyright (C) 2017-2023 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -45,6 +45,7 @@ options: -local Same as -spawn=1 -remote Same as -spawn=2 -clean Remove old processor*.{log,sh} files, mpirun.schema etc + -decompose-dict= Specific decomposeParDict name -help Print the usage Invoke mpirun with separate per-processor log files or running in @@ -111,7 +112,7 @@ Linux) esac unset appName appArgs nProcs -unset method spawn optClean +unset method spawn optClean optValue optConfirm=true decompDict="system/decomposeParDict" @@ -126,7 +127,7 @@ do then knownOption=true # Assume success case "$1" in - '') ;; # ignore junk + ('') ;; # Ignore junk -clean) optClean=true ;; -yes) unset optConfirm ;; @@ -173,14 +174,25 @@ do shift ;; + (-decompose-dict=*) + optValue="${1#*=}" + case "$optValue" in + ('' | none | false) ;; ## Ignore + (*) + decompDict="$optValue" + appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'" + ;; + esac + ;; + -decomposeParDict) # Grab values and add to args immediately decompDict="$2" - appArgs="${appArgs}${appArgs:+ }$1 '$2'" shift + appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'" ;; - *) + (*) knownOption=false # Fallthrough to regular processing ;; esac @@ -192,23 +204,24 @@ do fi fi + # Processing application arguments case "$1" in - -help* | --help*) usage ;; - '') ;; # ignore junk + (-help* | --help*) usage ;; + ('') ;; ## Ignore junk - -np) + (-np) nProcs="$2" shift ;; - -decomposeParDict) + (-decomposeParDict) # Grab values and add to args immediately decompDict="$2" - appArgs="${appArgs}${appArgs:+ }$1 '$2'" + appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'" shift ;; - *) + (*) if [ -z "$appName" ] then appName="$1" diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 5ef1c3c23a..f8482f63f2 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -6,7 +6,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2015-2022 OpenCFD Ltd. +# Copyright (C) 2015-2023 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -180,6 +180,16 @@ getNumberOfProcessors() { local dict="${1:-system/decomposeParDict}" + case "$dict" in + (system/*) # Already qualified + ;; + (*) + # If it does not exist, assume it refers to location in system/ + [ -f "$dict" ] || dict="system/$dict" + ;; + esac + + # Re-use positional parameters for automatic whitespace elimination set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null) @@ -223,7 +233,7 @@ getApplication() # runApplication() { - local appName appRun logFile logMode + local appName appRun optValue logFile logMode # Any additional parsed arguments (eg, decomposeParDict) local appArgs @@ -232,25 +242,39 @@ runApplication() while [ "$#" -gt 0 ] && [ -z "$appRun" ] do case "$1" in - -a | -append) - logMode=append - ;; - -o | -overwrite) - logMode=overwrite - ;; - -s | -suffix) - logFile=".$2" - shift - ;; - -decomposeParDict) - appArgs="$appArgs $1 $2" - shift - ;; - '') - ;; - *) - appRun="$1" - ;; + ('') ;; # Ignore junk + + (-a | -append) + logMode=append + ;; + (-o | -overwrite) + logMode=overwrite + ;; + (-s | -suffix) + logFile=".$2" + shift + ;; + + (-decompose-dict=*) + optValue="${1#*=}" + case "$optValue" in + ('' | none | false) ;; ## Ignore + (*) appArgs="$appArgs -decomposeParDict $optValue" ;; + esac + ;; + + (-decomposeParDict) + optValue="$2" + shift + case "$optValue" in + ('' | none | false) ;; ## Ignore + (*) appArgs="$appArgs -decomposeParDict $optValue" ;; + esac + ;; + + (*) + appRun="$1" + ;; esac shift done @@ -280,7 +304,7 @@ runApplication() # runParallel() { - local appName appRun logFile logMode nProcs + local appName appRun optValue logFile logMode nProcs # Any additional parsed arguments (eg, decomposeParDict) local appArgs="-parallel" @@ -295,30 +319,46 @@ runParallel() while [ "$#" -gt 0 ] && [ -z "$appRun" ] do case "$1" in - -a | -append) - logMode=append + ('') ;; # Ignore junk + + (-a | -append) + logMode=append + ;; + (-o | -overwrite) + logMode=overwrite + ;; + (-s | -suffix) + logFile=".$2" + shift + ;; + (-n | -np) + nProcs="$2" + shift + ;; + (-decompose-dict=*) + optValue="${1#*=}" + case "$optValue" in + ('' | none | false) ;; ## Ignore + (*) + appArgs="$appArgs -decomposeParDict $optValue" + nProcs="$(getNumberOfProcessors "$optValue")" ;; - -o | -overwrite) - logMode=overwrite - ;; - -s | -suffix) - logFile=".$2" - shift - ;; - -n | -np) - nProcs="$2" - shift - ;; - -decomposeParDict) - appArgs="$appArgs $1 $2" - nProcs=$(getNumberOfProcessors "$2") - shift - ;; - '') - ;; - *) - appRun="$1" + esac + ;; + (-decomposeParDict) + optValue="$2" + shift + case "$optValue" in + ('' | none | false) ;; ## Ignore + (*) + appArgs="$appArgs -decomposeParDict $optValue" + nProcs="$(getNumberOfProcessors "$optValue")" ;; + esac + ;; + (*) + appRun="$1" + ;; esac shift done