mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add error::master() static for low-level messages
- a Pstream::master with a Pstream::parRun guard in case Pstream has not yet been initialised, as will be the case for low-level messages during startup. - propagate relativeName handling into IOstreams
This commit is contained in:
@ -84,7 +84,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< " stream not open for reading essential object from file "
|
<< " stream not open for reading essential object from file "
|
||||||
<< is.name()
|
<< is.relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
|
|||||||
{
|
{
|
||||||
SeriousIOErrorInFunction(is)
|
SeriousIOErrorInFunction(is)
|
||||||
<< " stream not open for reading from file "
|
<< " stream not open for reading from file "
|
||||||
<< is.name() << endl;
|
<< is.relativeName() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -135,8 +135,8 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
|
|||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< " stream failure while reading header"
|
<< " stream failure while reading header"
|
||||||
<< " on line " << is.lineNumber()
|
<< " on line " << is.lineNumber()
|
||||||
<< " of file " << is.name()
|
<< " of file " << is.relativeName()
|
||||||
<< " for essential object" << name()
|
<< " for essential object:" << name()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is)
|
|||||||
InfoInFunction
|
InfoInFunction
|
||||||
<< "Stream failure while reading header"
|
<< "Stream failure while reading header"
|
||||||
<< " on line " << is.lineNumber()
|
<< " on line " << is.lineNumber()
|
||||||
<< " of file " << is.name() << endl;
|
<< " of file " << is.relativeName() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
objState_ = BAD;
|
objState_ = BAD;
|
||||||
|
|||||||
@ -259,8 +259,8 @@ Foam::decomposedBlockData::readBlock
|
|||||||
if (!headerIO.readHeader(*realIsPtr))
|
if (!headerIO.readHeader(*realIsPtr))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*realIsPtr)
|
FatalIOErrorInFunction(*realIsPtr)
|
||||||
<< "Problem while reading header for object "
|
<< "Problem while reading object header "
|
||||||
<< is.name() << nl
|
<< is.relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,8 +273,8 @@ Foam::decomposedBlockData::readBlock
|
|||||||
if (!headerIO.readHeader(headerStream))
|
if (!headerIO.readHeader(headerStream))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(headerStream)
|
FatalIOErrorInFunction(headerStream)
|
||||||
<< "Problem while reading header for object "
|
<< "Problem while reading object header "
|
||||||
<< is.name() << nl
|
<< is.relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
streamOptData = static_cast<IOstreamOption>(headerStream);
|
streamOptData = static_cast<IOstreamOption>(headerStream);
|
||||||
@ -447,8 +447,8 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
|
|||||||
if (!headerIO.readHeader(*realIsPtr))
|
if (!headerIO.readHeader(*realIsPtr))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*realIsPtr)
|
FatalIOErrorInFunction(*realIsPtr)
|
||||||
<< "Problem while reading header for object "
|
<< "Problem while reading object header "
|
||||||
<< is.name() << nl
|
<< is.relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ License
|
|||||||
|
|
||||||
#include "IOstream.H"
|
#include "IOstream.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
#include "argList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -48,6 +49,12 @@ Foam::fileName& Foam::IOstream::name()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::IOstream::relativeName() const
|
||||||
|
{
|
||||||
|
return argList::envRelativePath(this->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::IOstream::check(const char* operation) const
|
bool Foam::IOstream::check(const char* operation) const
|
||||||
{
|
{
|
||||||
return fatalCheck(operation);
|
return fatalCheck(operation);
|
||||||
@ -61,7 +68,8 @@ bool Foam::IOstream::fatalCheck(const char* operation) const
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "error in IOstream " << name() << " for operation " << operation
|
<< "error in IOstream " << relativeName()
|
||||||
|
<< " for operation " << operation
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,6 +201,10 @@ public:
|
|||||||
//- Return stream name for modification
|
//- Return stream name for modification
|
||||||
virtual fileName& name();
|
virtual fileName& name();
|
||||||
|
|
||||||
|
//- Return the name of the stream relative to the current case.
|
||||||
|
// Uses argList::envRelativePath()
|
||||||
|
fileName relativeName() const;
|
||||||
|
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
|
|||||||
@ -262,7 +262,7 @@ void Foam::dictionary::checkITstream
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
relativeName(), // ioFileName == dictionary name
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -284,7 +284,8 @@ void Foam::dictionary::checkITstream
|
|||||||
<< remaining << " excess tokens in stream" << nl << nl;
|
<< remaining << " excess tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
// ioFileName == dictionary name
|
||||||
|
<< "file: " << relativeName()
|
||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@ -301,7 +302,7 @@ void Foam::dictionary::checkITstream
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
relativeName(), // ioFileName == dictionary name
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
)
|
)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
@ -317,7 +318,8 @@ void Foam::dictionary::checkITstream
|
|||||||
<< "' had no tokens in stream" << nl << nl;
|
<< "' had no tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
// ioFileName == dictionary name
|
||||||
|
<< "file: " << relativeName()
|
||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@ -340,7 +342,7 @@ void Foam::dictionary::raiseBadInput
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
relativeName(), // ioFileName == dictionary name
|
||||||
is.lineNumber(), // ioStartLineNumber
|
is.lineNumber(), // ioStartLineNumber
|
||||||
-1 // ioEndLineNumber
|
-1 // ioEndLineNumber
|
||||||
)
|
)
|
||||||
@ -401,7 +403,7 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +527,7 @@ const Foam::dictionary& Foam::dictionary::subDict
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,7 +547,7 @@ Foam::dictionary& Foam::dictionary::subDict
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,7 +576,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd
|
|||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' is not a sub-dictionary in dictionary "
|
<< "' is not a sub-dictionary in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +587,7 @@ Foam::dictionary& Foam::dictionary::subDictOrAdd
|
|||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Failed to insert sub-dictionary '" << keyword
|
<< "Failed to insert sub-dictionary '" << keyword
|
||||||
<< "' in dictionary "
|
<< "' in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +615,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
|||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' is not a sub-dictionary in dictionary "
|
<< "' is not a sub-dictionary in dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,7 +624,7 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
|||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' found but not a sub-dictionary in dictionary "
|
<< "' found but not a sub-dictionary in dictionary "
|
||||||
<< name() << endl;
|
<< relativeName() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The move constructor properly qualifies the dictionary name
|
// The move constructor properly qualifies the dictionary name
|
||||||
@ -649,7 +651,7 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
|||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
<< "' found but not a sub-dictionary in dictionary "
|
<< "' found but not a sub-dictionary in dictionary "
|
||||||
<< name() << endl;
|
<< relativeName() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@ -737,7 +739,7 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
|
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "Problem replacing entry "<< entryPtr->keyword()
|
<< "Problem replacing entry "<< entryPtr->keyword()
|
||||||
<< " in dictionary " << name() << endl;
|
<< " in dictionary " << relativeName() << endl;
|
||||||
|
|
||||||
parent_type::remove(entryPtr);
|
parent_type::remove(entryPtr);
|
||||||
|
|
||||||
@ -765,7 +767,8 @@ Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
|||||||
|
|
||||||
IOWarningInFunction(*this)
|
IOWarningInFunction(*this)
|
||||||
<< "Attempt to add entry " << entryPtr->keyword()
|
<< "Attempt to add entry " << entryPtr->keyword()
|
||||||
<< " which already exists in dictionary " << name() << endl;
|
<< " which already exists in dictionary "
|
||||||
|
<< relativeName() << endl;
|
||||||
|
|
||||||
delete entryPtr;
|
delete entryPtr;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -871,7 +874,7 @@ bool Foam::dictionary::merge(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Attempted merge to self, for dictionary "
|
<< "Attempted merge to self, for dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,7 +963,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Attempted addition to self, for dictionary "
|
<< "Attempted addition to self, for dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,7 +980,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Attempted |= merging to self, for dictionary "
|
<< "Attempted |= merging to self, for dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,7 +1000,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Attempted addition to self, for dictionary "
|
<< "Attempted addition to self, for dictionary "
|
||||||
<< name() << nl
|
<< relativeName() << nl
|
||||||
<< abort(FatalIOError);
|
<< abort(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,21 +50,14 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
|||||||
|
|
||||||
if (finder.good())
|
if (finder.good())
|
||||||
{
|
{
|
||||||
// Want single warning (on master), but guard with parRun to avoid
|
if (error::warnAboutAge(alt.second) && error::master())
|
||||||
// Pstream::master() when Pstream has not yet been initialized
|
|
||||||
if
|
|
||||||
(
|
|
||||||
(Pstream::parRun() ? Pstream::master() : true)
|
|
||||||
&& error::warnAboutAge(alt.second)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "--> FOAM IOWarning :" << nl
|
<< "--> FOAM IOWarning :" << nl
|
||||||
<< " Found [v" << alt.second << "] '"
|
<< " Found [v" << alt.second << "] '"
|
||||||
<< alt.first << "' entry instead of '"
|
<< alt.first << "' entry instead of '"
|
||||||
<< keyword.c_str() << "' in dictionary \""
|
<< keyword.c_str() << "' in dictionary \""
|
||||||
<< name().c_str() << "\" "
|
<< relativeName() << '"' << nl
|
||||||
<< nl
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
error::warnAboutAge("keyword", alt.second);
|
error::warnAboutAge("keyword", alt.second);
|
||||||
@ -113,7 +106,7 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
|
|||||||
{
|
{
|
||||||
FatalIOErrorInFunction(*this)
|
FatalIOErrorInFunction(*this)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< name()
|
<< relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,12 @@ public:
|
|||||||
return dictionary::name();
|
return dictionary::name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return scoped dictionary name relative to the current case
|
||||||
|
virtual fileName relativeName() const
|
||||||
|
{
|
||||||
|
return dictionary::relativeName();
|
||||||
|
}
|
||||||
|
|
||||||
//- Return line number of first token in dictionary
|
//- Return line number of first token in dictionary
|
||||||
virtual label startLineNumber() const;
|
virtual label startLineNumber() const;
|
||||||
|
|
||||||
@ -132,7 +138,7 @@ public:
|
|||||||
virtual label endLineNumber() const;
|
virtual label endLineNumber() const;
|
||||||
|
|
||||||
//- This entry is not a primitive,
|
//- This entry is not a primitive,
|
||||||
// calling this function generates a FatalError
|
//- calling this function generates a FatalError
|
||||||
virtual ITstream& stream() const;
|
virtual ITstream& stream() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -44,6 +44,20 @@ Foam::entry::inputMode Foam::entry::globalInputMode = inputMode::MERGE;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::entry::reportReadWarning
|
||||||
|
(
|
||||||
|
const IOstream& is,
|
||||||
|
const std::string& msg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::cerr
|
||||||
|
<< "--> FOAM Warning :\n"
|
||||||
|
<< " Reading \"" << is.relativeName()
|
||||||
|
<< "\" at line " << is.lineNumber() << '\n'
|
||||||
|
<< " " << msg << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::entry::resetInputMode()
|
void Foam::entry::resetInputMode()
|
||||||
{
|
{
|
||||||
globalInputMode = inputMode::MERGE;
|
globalInputMode = inputMode::MERGE;
|
||||||
@ -85,7 +99,7 @@ void Foam::entry::raiseBadInput(const ITstream& is) const
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
this->relativeName(), // ioFileName
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
)
|
)
|
||||||
<< "Entry '" << keyword << "' with invalid input" << nl << nl
|
<< "Entry '" << keyword << "' with invalid input" << nl << nl
|
||||||
@ -110,7 +124,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
this->relativeName(), // ioFileName
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -132,7 +146,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
<< remaining << " excess tokens in stream" << nl << nl;
|
<< remaining << " excess tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
<< "file: " << this->relativeName()
|
||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
@ -149,7 +163,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
"", // functionName
|
"", // functionName
|
||||||
"", // sourceFileName
|
"", // sourceFileName
|
||||||
0, // sourceFileLineNumber
|
0, // sourceFileLineNumber
|
||||||
this->name(), // ioFileName
|
this->relativeName(), // ioFileName
|
||||||
is.lineNumber() // ioStartLineNumber
|
is.lineNumber() // ioStartLineNumber
|
||||||
)
|
)
|
||||||
<< "Entry '" << keyword
|
<< "Entry '" << keyword
|
||||||
@ -165,7 +179,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
<< "' had no tokens in stream" << nl << nl;
|
<< "' had no tokens in stream" << nl << nl;
|
||||||
|
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "file: " << this->name()
|
<< "file: " << this->relativeName()
|
||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Keyword of entry
|
//- Keyword of entry
|
||||||
keyType keyword_;
|
keyType keyword_;
|
||||||
@ -114,6 +114,14 @@ private:
|
|||||||
void raiseBadInput(const ITstream& is) const;
|
void raiseBadInput(const ITstream& is) const;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Report a read warning (on std::cerr)
|
||||||
|
static void reportReadWarning(const IOstream&, const std::string&);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Enable or disable use of function entries and variable expansions.
|
//- Enable or disable use of function entries and variable expansions.
|
||||||
@ -202,6 +210,9 @@ public:
|
|||||||
//- Return the entry name for modification
|
//- Return the entry name for modification
|
||||||
virtual fileName& name() = 0;
|
virtual fileName& name() = 0;
|
||||||
|
|
||||||
|
//- Return the entry name relative to the current case
|
||||||
|
virtual fileName relativeName() const = 0;
|
||||||
|
|
||||||
//- Return line number of first token in dictionary
|
//- Return line number of first token in dictionary
|
||||||
virtual label startLineNumber() const = 0;
|
virtual label startLineNumber() const = 0;
|
||||||
|
|
||||||
|
|||||||
@ -92,10 +92,11 @@ bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
|
|||||||
<< "--> FOAM Warning :" << nl
|
<< "--> FOAM Warning :" << nl
|
||||||
<< " From function " << FUNCTION_NAME << nl
|
<< " From function " << FUNCTION_NAME << nl
|
||||||
<< " in file " << __FILE__ << " at line " << __LINE__ << nl
|
<< " in file " << __FILE__ << " at line " << __LINE__ << nl
|
||||||
<< " Reading " << is.name() << nl
|
<< " Reading " << is.relativeName() << nl
|
||||||
<< " found " << keyToken << nl
|
<< " found " << keyToken << nl
|
||||||
<< " expected either " << token::END_BLOCK << " or EOF"
|
<< " expected either " << token::END_BLOCK << " or EOF"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,8 +68,9 @@ Foam::string Foam::functionEntries::calcEntry::evaluate
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
DetailInfo
|
DetailInfo
|
||||||
<< "Using #calc at line " << is.lineNumber()
|
<< "Using #calc - line "
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< is.lineNumber() << " in file "
|
||||||
|
<< parentDict.relativeName() << nl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
(
|
(
|
||||||
|
|||||||
@ -356,7 +356,7 @@ Foam::string Foam::functionEntries::codeStream::evaluate
|
|||||||
{
|
{
|
||||||
DetailInfo
|
DetailInfo
|
||||||
<< "Using #codeStream at line " << is.lineNumber()
|
<< "Using #codeStream at line " << is.lineNumber()
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< " in file " << parentDict.relativeName() << endl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
(
|
(
|
||||||
|
|||||||
@ -58,25 +58,6 @@ namespace functionEntries
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
// This is akin to a SafeIOWarning, which does not yet exist
|
|
||||||
inline void safeIOWarning
|
|
||||||
(
|
|
||||||
const Foam::IOstream& is,
|
|
||||||
const std::string& msg
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< "--> FOAM Warning :\n"
|
|
||||||
<< " Reading \"" << is.name() << "\" at line "
|
|
||||||
<< is.lineNumber() << '\n'
|
|
||||||
<< " " << msg << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End anonymous namespace
|
|
||||||
|
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -158,8 +139,6 @@ static bool slurpUntilBalancedBrace(ISstream& is, std::string& str)
|
|||||||
|
|
||||||
str.append(buf, nChar); // Finalize pending content
|
str.append(buf, nChar); // Finalize pending content
|
||||||
|
|
||||||
safeIOWarning(is, "Premature end while reading expression - missing '}'?");
|
|
||||||
|
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -252,7 +231,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
|
|||||||
{
|
{
|
||||||
InfoErr
|
InfoErr
|
||||||
<< "Empty #eval - line "
|
<< "Empty #eval - line "
|
||||||
<< is.lineNumber() << " in file " << parentDict.name() << nl;
|
<< is.lineNumber() << " in file "
|
||||||
|
<< parentDict.relativeName() << nl;
|
||||||
|
|
||||||
return tokenList();
|
return tokenList();
|
||||||
}
|
}
|
||||||
@ -268,7 +248,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
|
|||||||
{
|
{
|
||||||
InfoErr
|
InfoErr
|
||||||
<< "Failed #eval - line "
|
<< "Failed #eval - line "
|
||||||
<< is.lineNumber() << " in file " << parentDict.name() << nl;
|
<< is.lineNumber() << " in file "
|
||||||
|
<< parentDict.relativeName() << nl;
|
||||||
|
|
||||||
return tokenList();
|
return tokenList();
|
||||||
}
|
}
|
||||||
@ -296,7 +277,8 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
|
|||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
DetailInfo
|
DetailInfo
|
||||||
<< "Using #eval - line "
|
<< "Using #eval - line "
|
||||||
<< is.lineNumber() << " in file " << parentDict.name() << nl;
|
<< is.lineNumber() << " in file "
|
||||||
|
<< parentDict.relativeName() << nl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
token tok(is);
|
token tok(is);
|
||||||
@ -321,7 +303,14 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
|
|||||||
else if (tok.isPunctuation(token::BEGIN_BLOCK))
|
else if (tok.isPunctuation(token::BEGIN_BLOCK))
|
||||||
{
|
{
|
||||||
// - #eval { expr }
|
// - #eval { expr }
|
||||||
slurpUntilBalancedBrace(dynamic_cast<ISstream&>(is), str);
|
if (!slurpUntilBalancedBrace(dynamic_cast<ISstream&>(is), str))
|
||||||
|
{
|
||||||
|
reportReadWarning
|
||||||
|
(
|
||||||
|
is,
|
||||||
|
"Premature end while reading expression - missing '}'?"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,7 +72,7 @@ Foam::functionEntry::functionEntry
|
|||||||
:
|
:
|
||||||
primitiveEntry
|
primitiveEntry
|
||||||
(
|
(
|
||||||
word(key+dict.name()+Foam::name(is.lineNumber())),
|
word(key + dict.name() + Foam::name(is.lineNumber())),
|
||||||
readLine(key, is)
|
readLine(key, is)
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
@ -106,9 +107,9 @@ bool Foam::functionEntry::execute
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unknown functionEntry '" << functionName
|
<< "Unknown functionEntry '" << functionName
|
||||||
<< "' in " << is.name() << " near line " << is.lineNumber()
|
<< "' in " << is.relativeName()
|
||||||
<< nl << nl
|
<< " near line " << is.lineNumber() << nl << nl
|
||||||
<< "Valid functionEntries :" << endl
|
<< "Valid functionEntries :" << nl
|
||||||
<< executedictionaryIstreamMemberFunctionTablePtr_->sortedToc()
|
<< executedictionaryIstreamMemberFunctionTablePtr_->sortedToc()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -148,9 +149,9 @@ bool Foam::functionEntry::execute
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unknown functionEntry '" << functionName
|
<< "Unknown functionEntry '" << functionName
|
||||||
<< "' in " << is.name() << " near line " << is.lineNumber()
|
<< "' in " << is.relativeName()
|
||||||
<< nl << nl
|
<< " near line " << is.lineNumber() << nl << nl
|
||||||
<< "Valid functionEntries :" << endl
|
<< "Valid functionEntries :" << nl
|
||||||
<< executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc()
|
<< executeprimitiveEntryIstreamMemberFunctionTablePtr_->sortedToc()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -48,15 +49,15 @@ SourceFiles
|
|||||||
#ifndef functionEntry_H
|
#ifndef functionEntry_H
|
||||||
#define functionEntry_H
|
#define functionEntry_H
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "memberFunctionSelectionTables.H"
|
|
||||||
#include "primitiveEntry.H"
|
#include "primitiveEntry.H"
|
||||||
|
#include "memberFunctionSelectionTables.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -67,17 +68,10 @@ class functionEntry
|
|||||||
:
|
:
|
||||||
public primitiveEntry
|
public primitiveEntry
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
functionEntry(const functionEntry&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const functionEntry&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Read line and return as a string token
|
//- Read line and return as a string token
|
||||||
static token readLine(const word& key, Istream& is);
|
static token readLine(const word& key, Istream& is);
|
||||||
|
|
||||||
@ -86,6 +80,12 @@ protected:
|
|||||||
template<class StringType>
|
template<class StringType>
|
||||||
static List<StringType> readStringList(Istream& is);
|
static List<StringType> readStringList(Istream& is);
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
functionEntry(const functionEntry&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const functionEntry&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|||||||
@ -391,8 +391,8 @@ bool Foam::functionEntries::ifeqEntry::execute
|
|||||||
|
|
||||||
if (ifEntry::isTrue(e.stream()))
|
if (ifEntry::isTrue(e.stream()))
|
||||||
{
|
{
|
||||||
// Info<< "Using #elif " << doIf << " at line " << lineNo
|
// Info<< "Using #elif " << doIf << " - line " << lineNo
|
||||||
// << " in file " << is.name() << endl;
|
// << " in file " << is.relativeName() << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -170,7 +170,7 @@ bool Foam::functionEntries::includeEntry::execute
|
|||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Cannot open include file "
|
<< "Cannot open include file "
|
||||||
<< (ifs.name().size() ? ifs.name() : rawName)
|
<< (ifs.name().size() ? ifs.name() : rawName)
|
||||||
<< " while reading dictionary " << parentDict.name()
|
<< " while reading dictionary " << parentDict.relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -222,7 +222,7 @@ bool Foam::functionEntries::includeEntry::execute
|
|||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Cannot open include file "
|
<< "Cannot open include file "
|
||||||
<< (ifs.name().size() ? ifs.name() : rawName)
|
<< (ifs.name().size() ? ifs.name() : rawName)
|
||||||
<< " while reading dictionary " << parentDict.name()
|
<< " while reading dictionary " << parentDict.relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -138,7 +138,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
|
|||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Cannot open etc file "
|
<< "Cannot open etc file "
|
||||||
<< (ifs.name().size() ? ifs.name() : rawName)
|
<< (ifs.name().size() ? ifs.name() : rawName)
|
||||||
<< " while reading dictionary " << parentDict.name()
|
<< " while reading dictionary " << parentDict.relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -178,7 +178,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
|
|||||||
FatalIOErrorInFunction(is)
|
FatalIOErrorInFunction(is)
|
||||||
<< "Cannot open etc file "
|
<< "Cannot open etc file "
|
||||||
<< (ifs.name().size() ? ifs.name() : rawName)
|
<< (ifs.name().size() ? ifs.name() : rawName)
|
||||||
<< " while reading dictionary " << parentDict.name()
|
<< " while reading dictionary " << parentDict.relativeName()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -155,6 +155,12 @@ public:
|
|||||||
return ITstream::name();
|
return ITstream::name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return token stream name relative to the current case
|
||||||
|
virtual fileName relativeName() const
|
||||||
|
{
|
||||||
|
return ITstream::relativeName();
|
||||||
|
}
|
||||||
|
|
||||||
//- Return line number of first token in dictionary
|
//- Return line number of first token in dictionary
|
||||||
virtual label startLineNumber() const;
|
virtual label startLineNumber() const;
|
||||||
|
|
||||||
|
|||||||
@ -30,27 +30,6 @@ License
|
|||||||
#include "functionEntry.H"
|
#include "functionEntry.H"
|
||||||
#include "evalEntry.H"
|
#include "evalEntry.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
// This is akin to a SafeIOWarning, which does not yet exist
|
|
||||||
inline void safeIOWarning
|
|
||||||
(
|
|
||||||
const Foam::IOstream& is,
|
|
||||||
const std::string& msg
|
|
||||||
)
|
|
||||||
{
|
|
||||||
std::cerr
|
|
||||||
<< "--> FOAM Warning :\n"
|
|
||||||
<< " Reading \"" << is.name() << "\" at line "
|
|
||||||
<< is.lineNumber() << '\n'
|
|
||||||
<< " " << msg << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End anonymous namespace
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::primitiveEntry::acceptToken
|
bool Foam::primitiveEntry::acceptToken
|
||||||
@ -182,7 +161,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
|
|||||||
--depth;
|
--depth;
|
||||||
if (depth < 0)
|
if (depth < 0)
|
||||||
{
|
{
|
||||||
safeIOWarning
|
reportReadWarning
|
||||||
(
|
(
|
||||||
is,
|
is,
|
||||||
"Too many closing ')' ... was a ';' forgotten?"
|
"Too many closing ')' ... was a ';' forgotten?"
|
||||||
@ -191,7 +170,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
|
|||||||
else if (depth < 61 && ((balanced >> depth) & 1u))
|
else if (depth < 61 && ((balanced >> depth) & 1u))
|
||||||
{
|
{
|
||||||
// Bit was set, but expected it to be unset.
|
// Bit was set, but expected it to be unset.
|
||||||
safeIOWarning(is, "Imbalanced '{' with ')'");
|
reportReadWarning(is, "Imbalanced '{' with ')'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -201,7 +180,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
|
|||||||
--depth;
|
--depth;
|
||||||
if (depth < 0)
|
if (depth < 0)
|
||||||
{
|
{
|
||||||
safeIOWarning
|
reportReadWarning
|
||||||
(
|
(
|
||||||
is,
|
is,
|
||||||
"Too many closing '}' ... was a ';' forgotten?"
|
"Too many closing '}' ... was a ';' forgotten?"
|
||||||
@ -210,7 +189,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
|
|||||||
else if (depth < 61 && !((balanced >> depth) & 1u))
|
else if (depth < 61 && !((balanced >> depth) & 1u))
|
||||||
{
|
{
|
||||||
// Bit was unset, but expected it to be set.
|
// Bit was unset, but expected it to be set.
|
||||||
safeIOWarning(is, "Imbalanced '(' with '}'");
|
reportReadWarning(is, "Imbalanced '(' with '}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -230,7 +209,7 @@ bool Foam::primitiveEntry::read(const dictionary& dict, Istream& is)
|
|||||||
|
|
||||||
if (depth)
|
if (depth)
|
||||||
{
|
{
|
||||||
safeIOWarning(is, "Imbalanced brackets");
|
reportReadWarning(is, "Imbalanced brackets");
|
||||||
}
|
}
|
||||||
|
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|||||||
@ -27,7 +27,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "argList.H"
|
|
||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
#include "fileName.H"
|
#include "fileName.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
@ -100,7 +99,7 @@ Foam::OSstream& Foam::IOerror::operator()
|
|||||||
functionName,
|
functionName,
|
||||||
sourceFileName,
|
sourceFileName,
|
||||||
sourceFileLineNumber,
|
sourceFileLineNumber,
|
||||||
argList::envRelativePath(ioStream.name()),
|
ioStream.relativeName(),
|
||||||
ioStream.lineNumber(),
|
ioStream.lineNumber(),
|
||||||
-1 // No known endLineNumber
|
-1 // No known endLineNumber
|
||||||
);
|
);
|
||||||
@ -137,8 +136,8 @@ Foam::OSstream& Foam::IOerror::operator()
|
|||||||
(
|
(
|
||||||
where.c_str(),
|
where.c_str(),
|
||||||
"", // No source file
|
"", // No source file
|
||||||
1, // Non-zero to ensure that 'where' is reported
|
-1, // Non-zero to ensure 'where' is reported
|
||||||
argList::envRelativePath(ioStream.name()),
|
ioStream.relativeName(),
|
||||||
ioStream.lineNumber(),
|
ioStream.lineNumber(),
|
||||||
-1 // No known endLineNumber
|
-1 // No known endLineNumber
|
||||||
);
|
);
|
||||||
@ -155,7 +154,7 @@ Foam::OSstream& Foam::IOerror::operator()
|
|||||||
(
|
(
|
||||||
where.c_str(),
|
where.c_str(),
|
||||||
"", // No source file
|
"", // No source file
|
||||||
1, // Non-zero to ensure that 'where' is reported
|
-1, // Non-zero to ensure 'where' is reported
|
||||||
dict.relativeName(),
|
dict.relativeName(),
|
||||||
dict.startLineNumber(),
|
dict.startLineNumber(),
|
||||||
dict.endLineNumber()
|
dict.endLineNumber()
|
||||||
@ -188,7 +187,7 @@ void Foam::IOerror::SafeFatalIOError
|
|||||||
<< nl
|
<< nl
|
||||||
<< "--> FOAM FATAL IO ERROR:" << nl
|
<< "--> FOAM FATAL IO ERROR:" << nl
|
||||||
<< msg << nl
|
<< msg << nl
|
||||||
<< "file: " << ioStream.name()
|
<< "file: " << ioStream.relativeName()
|
||||||
<< " at line " << ioStream.lineNumber() << '.' << nl << nl
|
<< " at line " << ioStream.lineNumber() << '.' << nl << nl
|
||||||
<< " From " << functionName << nl
|
<< " From " << functionName << nl
|
||||||
<< " in file " << sourceFileName
|
<< " in file " << sourceFileName
|
||||||
@ -253,7 +252,7 @@ void Foam::IOerror::abort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::IOerror::write(Ostream& os, const bool includeTitle) const
|
void Foam::IOerror::write(Ostream& os, const bool withTitle) const
|
||||||
{
|
{
|
||||||
if (os.bad())
|
if (os.bad())
|
||||||
{
|
{
|
||||||
@ -261,7 +260,7 @@ void Foam::IOerror::write(Ostream& os, const bool includeTitle) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
os << nl;
|
||||||
if (includeTitle && !title().empty())
|
if (withTitle && !title().empty())
|
||||||
{
|
{
|
||||||
os << title().c_str()
|
os << title().c_str()
|
||||||
<< "(openfoam-" << foamVersion::api;
|
<< "(openfoam-" << foamVersion::api;
|
||||||
|
|||||||
@ -38,6 +38,20 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::error::master(const label communicator)
|
||||||
|
{
|
||||||
|
// Trap negative value for comm as 'default'. This avoids direct use
|
||||||
|
// of Pstream::worldComm which may not have been initialised
|
||||||
|
|
||||||
|
return
|
||||||
|
(
|
||||||
|
UPstream::parRun()
|
||||||
|
? (communicator < 0 ? UPstream::master() : UPstream::master(communicator))
|
||||||
|
: true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::error::warnAboutAge(const int version) noexcept
|
bool Foam::error::warnAboutAge(const int version) noexcept
|
||||||
{
|
{
|
||||||
// No warning for 0 (unversioned) or -ve values (silent versioning)
|
// No warning for 0 (unversioned) or -ve values (silent versioning)
|
||||||
@ -245,20 +259,20 @@ void Foam::error::simpleExit(const int errNo, const bool isAbort)
|
|||||||
error::printStack(Perr);
|
error::printStack(Perr);
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
else if (Pstream::parRun())
|
else if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
if (isAbort)
|
if (isAbort)
|
||||||
{
|
{
|
||||||
Perr<< nl << *this << nl
|
Perr<< nl << *this << nl
|
||||||
<< "\nFOAM parallel run aborting\n" << endl;
|
<< "\nFOAM parallel run aborting\n" << endl;
|
||||||
error::printStack(Perr);
|
error::printStack(Perr);
|
||||||
Pstream::abort();
|
UPstream::abort();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Perr<< nl << *this << nl
|
Perr<< nl << *this << nl
|
||||||
<< "\nFOAM parallel run exiting\n" << endl;
|
<< "\nFOAM parallel run exiting\n" << endl;
|
||||||
Pstream::exit(errNo);
|
UPstream::exit(errNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -326,7 +340,7 @@ void Foam::error::abort()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::error::write(Ostream& os, const bool includeTitle) const
|
void Foam::error::write(Ostream& os, const bool withTitle) const
|
||||||
{
|
{
|
||||||
if (os.bad())
|
if (os.bad())
|
||||||
{
|
{
|
||||||
@ -334,7 +348,7 @@ void Foam::error::write(Ostream& os, const bool includeTitle) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
os << nl;
|
os << nl;
|
||||||
if (includeTitle && !title().empty())
|
if (withTitle && !title().empty())
|
||||||
{
|
{
|
||||||
os << title().c_str()
|
os << title().c_str()
|
||||||
<< "(openfoam-" << foamVersion::api;
|
<< "(openfoam-" << foamVersion::api;
|
||||||
|
|||||||
@ -119,6 +119,13 @@ public:
|
|||||||
|
|
||||||
// Static Functions
|
// Static Functions
|
||||||
|
|
||||||
|
//- Like Pstream::master but with a Pstream::parRun guard in case
|
||||||
|
//- Pstream has not yet been initialised.
|
||||||
|
//
|
||||||
|
// \param communicator is the numbered MPI communicator.
|
||||||
|
// By default it uses UPstream::worldComm
|
||||||
|
static bool master(const label communicator = -1);
|
||||||
|
|
||||||
//- Test if an age warning should be emitted.
|
//- Test if an age warning should be emitted.
|
||||||
// \param version is the old version (YYMM) for determining the
|
// \param version is the old version (YYMM) for determining the
|
||||||
// age in months compared to the current OpenFOAM version
|
// age in months compared to the current OpenFOAM version
|
||||||
@ -244,7 +251,7 @@ public:
|
|||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
//- Print error message
|
//- Print error message
|
||||||
virtual void write(Ostream& os, const bool includeTitle = true) const;
|
virtual void write(Ostream& os, const bool withTitle = true) const;
|
||||||
|
|
||||||
|
|
||||||
// Housekeeping
|
// Housekeeping
|
||||||
@ -405,7 +412,7 @@ public:
|
|||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
//- Print error message
|
//- Print error message
|
||||||
virtual void write(Ostream& os, const bool includeTitle = true) const;
|
virtual void write(Ostream& os, const bool withTitle = true) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -80,10 +80,10 @@ Foam::OSstream& Foam::messageStream::stream(OSstream* alternative)
|
|||||||
|| severity_ == INFO_STDERR
|
|| severity_ == INFO_STDERR
|
||||||
|| severity_ == WARNING
|
|| severity_ == WARNING
|
||||||
)
|
)
|
||||||
|| !Pstream::parRun()
|
|| !UPstream::parRun()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (serialOnly && (Pstream::parRun() && !Pstream::master()))
|
if (serialOnly && (UPstream::parRun() && !UPstream::master()))
|
||||||
{
|
{
|
||||||
return Snull; // Non-serial, non-master: exit early
|
return Snull; // Non-serial, non-master: exit early
|
||||||
}
|
}
|
||||||
|
|||||||
@ -571,6 +571,7 @@ Foam::word Foam::argList::optionCompat(const word& optName)
|
|||||||
{
|
{
|
||||||
const auto& alt = fnd.val();
|
const auto& alt = fnd.val();
|
||||||
|
|
||||||
|
// No error::master() guard - only called on master anyhow
|
||||||
if (error::warnAboutAge(alt.second))
|
if (error::warnAboutAge(alt.second))
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
@ -609,6 +610,7 @@ int Foam::argList::optionIgnore(const word& optName)
|
|||||||
// '-option ARG' or '-option'
|
// '-option ARG' or '-option'
|
||||||
const int nskip = (alt.first ? 2 : 1);
|
const int nskip = (alt.first ? 2 : 1);
|
||||||
|
|
||||||
|
// No error::master() guard - only called on master anyhow
|
||||||
if (error::warnAboutAge(alt.second))
|
if (error::warnAboutAge(alt.second))
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -161,9 +161,7 @@ static void expandLeadingTilde(std::string& s)
|
|||||||
// Compat Warning
|
// Compat Warning
|
||||||
const int version(1806);
|
const int version(1806);
|
||||||
|
|
||||||
// Single warning (on master) with guard to avoid Pstream::master()
|
if (error::master())
|
||||||
// when Pstream has not yet been initialized
|
|
||||||
if (UPstream::parRun() ? UPstream::master() : true)
|
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< nl
|
<< nl
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -56,7 +56,8 @@ const Foam::dictionary* Foam::coordinateSystem::subDictCompat
|
|||||||
const word csName(finder.ref().stream());
|
const word csName(finder.ref().stream());
|
||||||
|
|
||||||
// Deprecated, unsupported syntax
|
// Deprecated, unsupported syntax
|
||||||
|
if (error::master())
|
||||||
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "--> FOAM IOWarning :" << nl
|
<< "--> FOAM IOWarning :" << nl
|
||||||
<< " Ignoring 'coordinateSystem' as a keyword."
|
<< " Ignoring 'coordinateSystem' as a keyword."
|
||||||
@ -71,6 +72,7 @@ const Foam::dictionary* Foam::coordinateSystem::subDictCompat
|
|||||||
error::warnAboutAge("syntax change", 1806);
|
error::warnAboutAge("syntax change", 1806);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return dictPtr;
|
return dictPtr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,12 +60,15 @@ void Foam::coordinateSystems::readFromStream(const bool valid)
|
|||||||
else if (headerClassName() == headerTypeCompat)
|
else if (headerClassName() == headerTypeCompat)
|
||||||
{
|
{
|
||||||
// Older (1806 and earlier) header name
|
// Older (1806 and earlier) header name
|
||||||
|
if (error::master())
|
||||||
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "--> FOAM IOWarning :" << nl
|
<< "--> FOAM IOWarning :" << nl
|
||||||
<< " Found header class name '" << headerTypeCompat
|
<< " Found header class name '" << headerTypeCompat
|
||||||
<< "' instead of '" << typeName << "'" << nl;
|
<< "' instead of '" << typeName << "'" << nl;
|
||||||
|
|
||||||
error::warnAboutAge("header class", 1806);
|
error::warnAboutAge("header class", 1806);
|
||||||
|
}
|
||||||
|
|
||||||
this->readIstream(is, coordinateSystem::iNew());
|
this->readIstream(is, coordinateSystem::iNew());
|
||||||
close();
|
close();
|
||||||
|
|||||||
@ -55,12 +55,12 @@ namespace Foam
|
|||||||
|
|
||||||
static inline void warnCompatDegrees(const Foam::dictionary& dict)
|
static inline void warnCompatDegrees(const Foam::dictionary& dict)
|
||||||
{
|
{
|
||||||
if (Pstream::parRun() ? Pstream::master() : true)
|
if (error::master())
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "--> FOAM IOWarning :" << nl
|
<< "--> FOAM IOWarning :" << nl
|
||||||
<< " Found [v1806] 'degrees' keyword in dictionary \""
|
<< " Found [v1806] 'degrees' keyword in dictionary \""
|
||||||
<< dict.name().c_str() << "\" Ignored, now radians only." << nl
|
<< dict.relativeName() << "\" Ignored, now radians only." << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user