CONFIG: accept -decompose-dict=xyz for Run functions and mpirunDebug
- interpret as '-decomposeParDict xyz' for simpler scripting: A empty value ("") as well as "none" or "false" values are ignored. Eg, unset decompDict if some_condition; then decompDict=decomposeParDict-12; fi runParallel -decompose-dict=$decompDict ... ENH: more generous when scanning decomposeParDict for numberOfSubdomains - assume file is in system/ directory if not otherwise found
This commit is contained in:
parent
82c0b360c6
commit
4284d02c99
@ -7,7 +7,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2015 OpenFOAM Foundation
|
# Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
# Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -45,6 +45,7 @@ options:
|
|||||||
-local Same as -spawn=1
|
-local Same as -spawn=1
|
||||||
-remote Same as -spawn=2
|
-remote Same as -spawn=2
|
||||||
-clean Remove old processor*.{log,sh} files, mpirun.schema etc
|
-clean Remove old processor*.{log,sh} files, mpirun.schema etc
|
||||||
|
-decompose-dict=<file> Specific decomposeParDict name
|
||||||
-help Print the usage
|
-help Print the usage
|
||||||
|
|
||||||
Invoke mpirun with separate per-processor log files or running in
|
Invoke mpirun with separate per-processor log files or running in
|
||||||
@ -111,7 +112,7 @@ Linux)
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
unset appName appArgs nProcs
|
unset appName appArgs nProcs
|
||||||
unset method spawn optClean
|
unset method spawn optClean optValue
|
||||||
optConfirm=true
|
optConfirm=true
|
||||||
|
|
||||||
decompDict="system/decomposeParDict"
|
decompDict="system/decomposeParDict"
|
||||||
@ -126,7 +127,7 @@ do
|
|||||||
then
|
then
|
||||||
knownOption=true # Assume success
|
knownOption=true # Assume success
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'') ;; # ignore junk
|
('') ;; # Ignore junk
|
||||||
|
|
||||||
-clean) optClean=true ;;
|
-clean) optClean=true ;;
|
||||||
-yes) unset optConfirm ;;
|
-yes) unset optConfirm ;;
|
||||||
@ -173,14 +174,25 @@ do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(-decompose-dict=*)
|
||||||
|
optValue="${1#*=}"
|
||||||
|
case "$optValue" in
|
||||||
|
('' | none | false) ;; ## Ignore
|
||||||
|
(*)
|
||||||
|
decompDict="$optValue"
|
||||||
|
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
-decomposeParDict)
|
-decomposeParDict)
|
||||||
# Grab values and add to args immediately
|
# Grab values and add to args immediately
|
||||||
decompDict="$2"
|
decompDict="$2"
|
||||||
appArgs="${appArgs}${appArgs:+ }$1 '$2'"
|
|
||||||
shift
|
shift
|
||||||
|
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
(*)
|
||||||
knownOption=false # Fallthrough to regular processing
|
knownOption=false # Fallthrough to regular processing
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -192,23 +204,24 @@ do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Processing application arguments
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-help* | --help*) usage ;;
|
(-help* | --help*) usage ;;
|
||||||
'') ;; # ignore junk
|
('') ;; ## Ignore junk
|
||||||
|
|
||||||
-np)
|
(-np)
|
||||||
nProcs="$2"
|
nProcs="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-decomposeParDict)
|
(-decomposeParDict)
|
||||||
# Grab values and add to args immediately
|
# Grab values and add to args immediately
|
||||||
decompDict="$2"
|
decompDict="$2"
|
||||||
appArgs="${appArgs}${appArgs:+ }$1 '$2'"
|
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
(*)
|
||||||
if [ -z "$appName" ]
|
if [ -z "$appName" ]
|
||||||
then
|
then
|
||||||
appName="$1"
|
appName="$1"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2015-2022 OpenCFD Ltd.
|
# Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -180,6 +180,16 @@ getNumberOfProcessors()
|
|||||||
{
|
{
|
||||||
local dict="${1:-system/decomposeParDict}"
|
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
|
# Re-use positional parameters for automatic whitespace elimination
|
||||||
set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null)
|
set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null)
|
||||||
|
|
||||||
@ -223,7 +233,7 @@ getApplication()
|
|||||||
#
|
#
|
||||||
runApplication()
|
runApplication()
|
||||||
{
|
{
|
||||||
local appName appRun logFile logMode
|
local appName appRun optValue logFile logMode
|
||||||
|
|
||||||
# Any additional parsed arguments (eg, decomposeParDict)
|
# Any additional parsed arguments (eg, decomposeParDict)
|
||||||
local appArgs
|
local appArgs
|
||||||
@ -232,25 +242,39 @@ runApplication()
|
|||||||
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-a | -append)
|
('') ;; # Ignore junk
|
||||||
logMode=append
|
|
||||||
;;
|
(-a | -append)
|
||||||
-o | -overwrite)
|
logMode=append
|
||||||
logMode=overwrite
|
;;
|
||||||
;;
|
(-o | -overwrite)
|
||||||
-s | -suffix)
|
logMode=overwrite
|
||||||
logFile=".$2"
|
;;
|
||||||
shift
|
(-s | -suffix)
|
||||||
;;
|
logFile=".$2"
|
||||||
-decomposeParDict)
|
shift
|
||||||
appArgs="$appArgs $1 $2"
|
;;
|
||||||
shift
|
|
||||||
;;
|
(-decompose-dict=*)
|
||||||
'')
|
optValue="${1#*=}"
|
||||||
;;
|
case "$optValue" in
|
||||||
*)
|
('' | none | false) ;; ## Ignore
|
||||||
appRun="$1"
|
(*) appArgs="$appArgs -decomposeParDict $optValue" ;;
|
||||||
;;
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
(-decomposeParDict)
|
||||||
|
optValue="$2"
|
||||||
|
shift
|
||||||
|
case "$optValue" in
|
||||||
|
('' | none | false) ;; ## Ignore
|
||||||
|
(*) appArgs="$appArgs -decomposeParDict $optValue" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
(*)
|
||||||
|
appRun="$1"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@ -280,7 +304,7 @@ runApplication()
|
|||||||
#
|
#
|
||||||
runParallel()
|
runParallel()
|
||||||
{
|
{
|
||||||
local appName appRun logFile logMode nProcs
|
local appName appRun optValue logFile logMode nProcs
|
||||||
|
|
||||||
# Any additional parsed arguments (eg, decomposeParDict)
|
# Any additional parsed arguments (eg, decomposeParDict)
|
||||||
local appArgs="-parallel"
|
local appArgs="-parallel"
|
||||||
@ -295,30 +319,46 @@ runParallel()
|
|||||||
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-a | -append)
|
('') ;; # Ignore junk
|
||||||
logMode=append
|
|
||||||
|
(-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)
|
esac
|
||||||
logMode=overwrite
|
;;
|
||||||
;;
|
(-decomposeParDict)
|
||||||
-s | -suffix)
|
optValue="$2"
|
||||||
logFile=".$2"
|
shift
|
||||||
shift
|
case "$optValue" in
|
||||||
;;
|
('' | none | false) ;; ## Ignore
|
||||||
-n | -np)
|
(*)
|
||||||
nProcs="$2"
|
appArgs="$appArgs -decomposeParDict $optValue"
|
||||||
shift
|
nProcs="$(getNumberOfProcessors "$optValue")"
|
||||||
;;
|
|
||||||
-decomposeParDict)
|
|
||||||
appArgs="$appArgs $1 $2"
|
|
||||||
nProcs=$(getNumberOfProcessors "$2")
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
'')
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
appRun="$1"
|
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
appRun="$1"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user