diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index d8334d3dd6..07c4b29c2d 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-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1284,7 +1284,9 @@ void Foam::argList::parse // Disable any parallel comms happening inside the fileHandler // since we are on master. This can happen e.g. inside - // the masterUncollated/collated handler. + // the masterUncollated/collated handler. Note that we + // also have to protect the actual dictionary parsing since + // it might trigger file access (e.g. #include, #codeStream) const bool oldParRun = Pstream::parRun(false); autoPtr dictStream @@ -1292,8 +1294,6 @@ void Foam::argList::parse fileHandler().NewIFstream(source) ); - Pstream::parRun(oldParRun); // Restore parallel state - if (dictStream && dictStream->good()) { dictionary decompDict(*dictStream); @@ -1342,6 +1342,8 @@ void Foam::argList::parse } } + Pstream::parRun(oldParRun); // Restore parallel state + if (Pstream::nProcs() == 1) { Warning