From 1ead175957b68d3594454977bba2b2f7ab28346a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 2 Sep 2021 15:25:51 +0200 Subject: [PATCH] BUG: error with empty distributed roots specification (fixes #2196) --- src/OpenFOAM/global/argList/argList.C | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 01f1bddc5e..ff676ac186 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1184,7 +1184,7 @@ void Foam::argList::parse { parRunControl_.distributed(true); source = "-roots"; - if (roots.size() != 1) + if (roots.size() > 1) { dictNProcs = roots.size()+1; } @@ -1193,6 +1193,7 @@ void Foam::argList::parse { roots.resize(Pstream::nProcs()-1, fileName::null); + parRunControl_.distributed(true); source = "-hostRoots"; ITstream is(source, options_["hostRoots"]); @@ -1231,7 +1232,7 @@ void Foam::argList::parse } } - if (roots.size() != 1) + if (roots.size() > 1) { dictNProcs = roots.size()+1; } @@ -1259,6 +1260,12 @@ void Foam::argList::parse { parRunControl_.distributed(true); decompDict.readEntry("roots", roots); + if (roots.empty()) + { + DetailInfo + << "WARNING: running distributed" + << " but did not specify roots!" << nl; + } } } @@ -1326,8 +1333,8 @@ void Foam::argList::parse { options_.set("case", roots[slave-1]/globalCase_); - OPstream toSlave(Pstream::commsTypes::scheduled, slave); - toSlave << args_ << options_ << roots.size(); + OPstream toProc(Pstream::commsTypes::scheduled, slave); + toProc << args_ << options_ << parRunControl_.distributed(); } options_.erase("case"); @@ -1377,24 +1384,24 @@ void Foam::argList::parse slave++ ) { - OPstream toSlave(Pstream::commsTypes::scheduled, slave); - toSlave << args_ << options_ << roots.size(); + OPstream toProc(Pstream::commsTypes::scheduled, slave); + toProc << args_ << options_ << parRunControl_.distributed(); } } } else { // Collect the master's argument list - label nroots; + bool isDistributed; IPstream fromMaster ( Pstream::commsTypes::scheduled, Pstream::masterNo() ); - fromMaster >> args_ >> options_ >> nroots; + fromMaster >> args_ >> options_ >> isDistributed; - parRunControl_.distributed(nroots); + parRunControl_.distributed(isDistributed); // Establish rootPath_/globalCase_/case_ for slave setCasePaths();