diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C index 286cb2e7583186d3ca3a1f68cc02280b3beef6e2..f7c602ad1435decd81992d505a6fd9395e36d78e 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C @@ -39,9 +39,17 @@ void Foam::IOdictionary::readFile(const bool masterOnly) Pout<< "IOdictionary : Reading " << objectPath() << " from file " << endl; } + + // Set flag for e.g. codeStream + bool oldFlag = regIOobject::masterOnlyReading; + regIOobject::masterOnlyReading = masterOnly; + + // Read file readStream(typeName) >> *this; close(); + regIOobject::masterOnlyReading = oldFlag; + if (writeDictionaries && Pstream::master()) { Sout<< nl diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 34dd4e80d14a3920ad5b0fb2bcf9556aaef83b41..46413a1608d1e100634688af474196d307def339 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -197,25 +197,12 @@ Foam::functionEntries::codeStream::getFunction } } - //- We don't know whether this code was from IOdictionary - // (possibly read on master only) or from e.g. Field so cannot - // decide here. - //// all processes must wait for compile to finish - except if this - //// file is only read on the master - //bool masterOnly = - // ( - // regIOobject::fileModificationChecking - // == regIOobject::timeStampMaster - // ) - // || ( - // regIOobject::fileModificationChecking - // == regIOobject::inotifyMaster - // ); - // - //if (!masterOnly) - //{ + //- Only block if we're not doing master-only reading. (flag set by + // regIOobject::read, IOdictionary constructor) + if (!regIOobject::masterOnlyReading) + { reduce(create, orOp<bool>()); - //} + } if (isA<IOdictionary>(topDict(parentDict))) { diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index e15678fbc7bc57c03a35725dda72dfcb1a4f9550..1c269ecb6fde6a0dd4d09156696a9f2227838680 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,6 +69,9 @@ Foam::regIOobject::fileCheckTypes Foam::regIOobject::fileModificationChecking ); +bool Foam::regIOobject::masterOnlyReading = false; + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from IOobject diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 100ae0a7d65bac0e8ada2eb9b15f096222a89c86..320e51782535c3b7e500ec34fab0fa936d00a957 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,6 +49,11 @@ SourceFiles namespace Foam { +namespace functionEntries +{ + class codeStream; +} + /*---------------------------------------------------------------------------*\ Class regIOobject Declaration \*---------------------------------------------------------------------------*/ @@ -72,6 +77,12 @@ public: static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames; +protected: + + //- To flag master-only reading of objects + static bool masterOnlyReading; + + private: // Private data @@ -103,6 +114,11 @@ private: public: + //- Declare friendship with any classes that need access to + // masterOnlyReading + friend class functionEntries::codeStream; + + // Static data //- Runtime type information diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index 31b932bbdfdfef4bd38aeb76965746c79f797a2d..cefcefd9360789157681c3ddd60b443959e0cf36 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -186,8 +186,16 @@ bool Foam::regIOobject::read() << "reading object " << name() << " from file " << endl; } + + // Set flag for e.g. codeStream + bool oldFlag = regIOobject::masterOnlyReading; + regIOobject::masterOnlyReading = masterOnly; + + // Read file ok = readData(readStream(type())); close(); + + regIOobject::masterOnlyReading = oldFlag; } if (masterOnly && Pstream::parRun())