Skip to content
Snippets Groups Projects
Commit c2b05310 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: only report the architecture information for binary output files

- not required for ASCII, and makes normal dictionaries too noisy.

STYLE: move archHint to be a file-scope static
parent 6f5cece3
Branches
Tags
No related merge requests found
......@@ -33,26 +33,28 @@ Description
#include "label.H"
#include "scalar.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// file-scope
// Hint about machine endian, OpenFOAM label and scalar sizes
static const std::string archHint =
(
#ifdef WM_LITTLE_ENDIAN
"LSB"
#elif defined (WM_BIG_ENDIAN)
"MSB"
#else
"???"
#endif
";label=" + std::to_string(8*sizeof(Foam::label))
+ ";scalar=" + std::to_string(8*sizeof(Foam::scalar))
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
{
static std::string archHint;
// Hint about machine endian, OpenFOAM label and scalar sizes
if (archHint.empty())
{
#ifdef WM_LITTLE_ENDIAN
archHint.append("LSB;");
#elif defined (WM_BIG_ENDIAN)
archHint.append("MSB;");
#endif
archHint.append("label=");
archHint.append(std::to_string(8*sizeof(label)));
archHint.append(";scalar=");
archHint.append(std::to_string(8*sizeof(scalar)));
}
if (!os.good())
{
InfoInFunction
......@@ -66,10 +68,14 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
<< "FoamFile\n{\n"
<< " version " << os.version() << ";\n"
<< " format " << os.format() << ";\n"
<< " arch " << archHint << ";\n"
<< " class " << type << ";\n";
if (note().size())
if (os.format() == IOstream::BINARY)
{
os << " arch " << archHint << ";\n";
}
if (!note().empty())
{
os << " note " << note() << ";\n";
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment