diff --git a/doc/changes/inotify.txt b/doc/changes/inotify.txt index 0f91d7c03b..74e2fc7bb4 100644 --- a/doc/changes/inotify.txt +++ b/doc/changes/inotify.txt @@ -55,15 +55,25 @@ timestamps as before or the (linux-specific) 'inotify' system framework - the slave processor directories have no system directory and the constant directory only contains the mesh. - start the job in distributed mode by specifying the slave roots - (so one less than the number of processors) with - the -roots command line option: + (so one fewer than the number of processors) with + the -roots command-line option: - mpirun -np 2 icoFoam -roots '("/tmp")' -parallel + mpirun -np 4 icoFoam -roots '("/tmp" "/tmp" "/tmp")' -parallel - the alternative to the -roots option is to have a cavity/system/decomposeParDict on the master with distributed yes; - roots ("/tmp"); + roots ("/tmp" "/tmp" "/tmp"); + + - as a convenience for cases when the slave roots are identical, + a single root entry is interpreted as being the same for all slaves. + With the -roots command-line option, this can take one of two forms: + + mpirun -np 4 icoFoam -roots '("/tmp")' -parallel + + or simply + + mpirun -np 4 icoFoam -roots '"/tmp"' -parallel Details: diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index f055011bce..cce4739eae 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -549,9 +549,13 @@ Foam::argList::argList if (options_.found("roots")) { source = "'-roots' option"; - IStringStream str(options_["roots"]); - str >> roots; - dictNProcs = roots.size()+1; + IStringStream is(options_["roots"]); + roots = readList(is); + + if (roots.size() != 1) + { + dictNProcs = roots.size()+1; + } } else { @@ -579,6 +583,21 @@ Foam::argList::argList } } + // convenience: + // when a single root is specified, use it for all processes + if (roots.size() == 1) + { + const fileName rootName(roots[0]); + roots.setSize(Pstream::nProcs()-1, rootName); + + // adjust dictNProcs for command-line '-roots' option + if (dictNProcs < 0) + { + dictNProcs = roots.size()+1; + } + } + + // Check number of processors. // nProcs => number of actual procs // dictNProcs => number of procs specified in decompositionDict @@ -602,11 +621,6 @@ Foam::argList::argList // distributed data if (roots.size()) { - forAll(roots, i) - { - roots[i].expand(); - } - if (roots.size() != Pstream::nProcs()-1) { FatalError @@ -617,6 +631,11 @@ Foam::argList::argList << exit(FatalError); } + forAll(roots, i) + { + roots[i].expand(); + } + // Distribute the master's argument list (with new root) bool hadCaseOpt = options_.found("case"); for @@ -626,11 +645,7 @@ Foam::argList::argList slave++ ) { - options_.set - ( - "case", - fileName(roots[slave-1])/globalCase_ - ); + options_.set("case", roots[slave-1]/globalCase_); OPstream toSlave(Pstream::scheduled, slave); toSlave << args_ << options_;