From b64ada3ddea3b2972c328fa17fa083d974784264 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 9 Jul 2020 15:11:39 +0100 Subject: [PATCH] BUG: argList: use fileHandler to read decomposeParDict. Fixes #1765 --- src/OpenFOAM/global/argList/argList.C | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index feea556952..1984b16c7f 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -29,7 +29,6 @@ License #include "argList.H" #include "OSspecific.H" #include "clock.H" -#include "IFstream.H" #include "dictionary.H" #include "IOobject.H" #include "JobInfo.H" @@ -1252,17 +1251,29 @@ void Foam::argList::parse // Use values from decomposeParDict, the location was already // established above. - IFstream decompDictStream(source); + // Disable any parallel comms happening inside the fileHandler + // since we are on master. This can happen e.g. inside + // the masterUncollated/collated handler. + const bool oldParRun = Pstream::parRun(); + Pstream::parRun() = false; - if (!decompDictStream.good()) + autoPtr decompDictStream + ( + fileHandler().NewIFstream(source) + ); + + if (!decompDictStream.valid() || !decompDictStream->good()) { FatalError << "Cannot read decomposeParDict from " - << decompDictStream.name() - << exit(FatalError); + << source << exit(FatalError); } - dictionary decompDict(decompDictStream); + dictionary decompDict(*decompDictStream); + + // Restore parallel behaviour + Pstream::parRun() = oldParRun; + decompDict.readEntry("numberOfSubdomains", dictNProcs);