diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index cd7c45680b..d550a00516 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -86,7 +86,8 @@ Foam::argList::initValidTables::initValidTables() argList::addOption ( "hostRoots", "(((host1 dir1) .. (hostN dirN))", - "slave root directories (per host) for distributed running" + "slave root directories (per host) for distributed running. " + "The host specification can use a regex." ); validParOptions.set("hostRoots", "((host1 dir1) .. (hostN dirN))"); @@ -647,7 +648,7 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv) args_[nArgs++] = group; } - args_.setSize(nArgs); + args_.resize(nArgs); std::string::size_type len = (nArgs-1); // Spaces between args forAll(args_, argi) @@ -848,7 +849,7 @@ Foam::argList::argList } } - args_.setSize(nArgs); + args_.resize(nArgs); parse(checkArgs, checkOpts, initialise); } @@ -1012,8 +1013,8 @@ void Foam::argList::parse { if (Pstream::master()) { - slaveProcs.setSize(Pstream::nProcs() - 1); - slaveMachine.setSize(Pstream::nProcs() - 1); + slaveProcs.resize(Pstream::nProcs()-1); + slaveMachine.resize(Pstream::nProcs()-1); label proci = 0; for ( @@ -1027,11 +1028,11 @@ void Foam::argList::parse string slaveBuild; label slavePid; fromSlave >> slaveBuild >> slaveMachine[proci] >> slavePid; + slaveProcs[proci] = slaveMachine[proci] + "." + name(slavePid); proci++; - // Check build string to make sure all processors are running - // the same build + // Verify that all processors are running the same build if (slaveBuild != Foam::FOAMbuild) { FatalErrorIn(executable()) @@ -1113,37 +1114,35 @@ void Foam::argList::parse } else if (options_.found("hostRoots")) { - source = "-hostRoots"; - IStringStream is(options_["hostRoots"]); - List> hostRoots(is); + roots.resize(Pstream::nProcs()-1, fileName::null); - roots.setSize(Pstream::nProcs()-1); - forAll(hostRoots, i) + source = "-hostRoots"; + ITstream is = this->lookup("hostRoots"); + List> hostRoots(is); + warnTrailing(is, "hostRoots"); + + for (const auto& hostRoot : hostRoots) { - const Tuple2& hostRoot = hostRoots[i]; const wordRe& re = hostRoot.first(); - labelList matchedRoots(findStrings(re, slaveMachine)); - forAll(matchedRoots, matchi) + labelList matched(findStrings(re, slaveMachine)); + for (const label slavei : matched) { - label slavei = matchedRoots[matchi]; - if (roots[slavei] != wordRe()) + if (!roots[slavei].empty()) { FatalErrorInFunction << "Slave " << slaveMachine[slavei] << " has multiple matching roots in " << hostRoots << exit(FatalError); } - else - { - roots[slavei] = hostRoot.second(); - } + + roots[slavei] = hostRoot.second(); } } // Check forAll(roots, slavei) { - if (roots[slavei] == wordRe()) + if (roots[slavei].empty()) { FatalErrorInFunction << "Slave " << slaveMachine[slavei] @@ -1188,7 +1187,7 @@ void Foam::argList::parse if (roots.size() == 1) { const fileName rootName(roots[0]); - roots.setSize(Pstream::nProcs()-1, rootName); + roots.resize(Pstream::nProcs()-1, rootName); // adjust dictNProcs for command-line '-roots' option if (dictNProcs < 0) diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 5943dbe0e6..7795e89270 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -105,6 +105,9 @@ SourceFiles #include "ITstream.H" #include +// Transitional features - older style access (including 1712 release) +#define Foam_argList_1712 + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -374,65 +377,6 @@ public: inline bool readListIfPresent(const word& optName, List& list) const; - // Older style access (including 1712 release) - - //- Read a value from the argument at index. - // Index 1 is the first non-option argument. - // \deprecated in favour of read() - JAN-2018 - template - inline T argRead(const label index) const; - - //- Return true if the named option is found - // \deprecated in favour of found() - JAN-2018 - inline bool optionFound(const word& optName) const; - - //- Return an input stream from the named option - // \deprecated in favour of lookup() - JAN-2018 - inline ITstream optionLookup(const word& optName) const; - - //- Read a value from the named option - // \deprecated in favour of opt() - JAN-2018 - template - inline T optionRead(const word& optName) const; - - //- Read a value from the named option if present. - // Return true if the named option was found. - // \deprecated in favour of readIfPresent() - JAN-2018 - template - inline bool optionReadIfPresent - ( - const word& optName, - T& val - ) const; - - //- Read a value from the named option if present. - // Return true if the named option was found, otherwise - // use the supplied default and return false. - // \deprecated in favour of readIfPresent() - JAN-2018 - template - inline bool optionReadIfPresent - ( - const word& optName, - T& val, - const T& deflt - ) const; - - //- Read a value from the named option if present. - // Return supplied default otherwise. - // \deprecated in favour of lookupOrDefault() - JAN-2018 - template - inline T optionLookupOrDefault - ( - const word& optName, - const T& deflt - ) const; - - //- Read a List of values from the named option - // \deprecated in favour of readList() - JAN-2018 - template - inline List optionReadList(const word& optName) const; - - // Edit //- Append a (mandatory) argument to validArgs @@ -572,6 +516,93 @@ public: //- The string associated with the named option inline const string& operator[](const word& optName) const; + + // Older style access (including 1712 release) + + #ifdef Foam_argList_1712 + + //- Read a value from the argument at index. + // Index 1 is the first non-option argument. + // \deprecated in favour of read() - JAN-2018 + template + inline T argRead(const label index) const + { + return this->read(index); + } + + //- Return true if the named option is found + // \deprecated in favour of found() - JAN-2018 + inline bool optionFound(const word& optName) const + { + return found(optName); + } + + //- Return an input stream from the named option + // \deprecated in favour of lookup() - JAN-2018 + inline ITstream optionLookup(const word& optName) const + { + return lookup(optName); + } + + //- Read a value from the named option + // \deprecated in favour of opt() - JAN-2018 + template + inline T optionRead(const word& optName) const + { + return opt(optName); + } + + //- Read a value from the named option if present. + // Return true if the named option was found. + // \deprecated in favour of readIfPresent() - JAN-2018 + template + inline bool optionReadIfPresent + ( + const word& optName, + T& val + ) const + { + return readIfPresent(optName, val); + } + + //- Read a value from the named option if present. + // Return true if the named option was found, otherwise + // use the supplied default and return false. + // \deprecated in favour of readIfPresent() - JAN-2018 + template + inline bool optionReadIfPresent + ( + const word& optName, + T& val, + const T& deflt + ) const + { + return readIfPresent(optName, val, deflt); + } + + //- Read a value from the named option if present. + // Return supplied default otherwise. + // \deprecated in favour of lookupOrDefault() - JAN-2018 + template + inline T optionLookupOrDefault + ( + const word& optName, + const T& deflt + ) const + { + return lookupOrDefault(optName, deflt); + } + + //- Read a List of values from the named option + // \deprecated in favour of readList() - JAN-2018 + template + inline List optionReadList(const word& optName) const + { + return this->readList(optName); + } + + #endif /* Foam_argList_1712 */ + }; diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H index a676e532c1..d133ab1b18 100644 --- a/src/OpenFOAM/global/argList/argListI.H +++ b/src/OpenFOAM/global/argList/argListI.H @@ -211,7 +211,6 @@ namespace Foam { return options_[optName]; } - } @@ -359,72 +358,4 @@ inline const Foam::string& Foam::argList::operator[](const word& optName) const } -// * * * * * * * * * * * * * * * Compatibility * * * * * * * * * * * * * * * // - - -template -inline T Foam::argList::argRead(const label index) const -{ - return this->read(index); -} - - -inline bool Foam::argList::optionFound(const word& optName) const -{ - return found(optName); -} - - -inline Foam::ITstream Foam::argList::optionLookup(const word& optName) const -{ - return lookup(optName); -} - - -template -inline T Foam::argList::optionRead(const word& optName) const -{ - return opt(optName); -} - - -template -inline bool -Foam::argList::optionReadIfPresent(const word& optName, T& val) const -{ - return readIfPresent(optName, val); -} - - -template -inline bool Foam::argList::optionReadIfPresent -( - const word& optName, - T& val, - const T& deflt -) const -{ - return readIfPresent(optName, val, deflt); -} - - -template -inline T Foam::argList::optionLookupOrDefault -( - const word& optName, - const T& deflt -) const -{ - return lookupOrDefault(optName, deflt); -} - - -template -inline Foam::List -Foam::argList::optionReadList(const word& optName) const -{ - return this->readList(optName); -} - - // ************************************************************************* //