diff --git a/applications/test/foamVersion/Make/files b/applications/test/foamVersion/Make/files index 52262afb8e..82922e0ca8 100644 --- a/applications/test/foamVersion/Make/files +++ b/applications/test/foamVersion/Make/files @@ -1,3 +1,3 @@ -Test-foamVersionString.C +Test-foamVersion.C -EXE = $(FOAM_USER_APPBIN)/Test-foamVersionString +EXE = $(FOAM_USER_APPBIN)/Test-foamVersion diff --git a/applications/test/foamVersion/Make/options b/applications/test/foamVersion/Make/options index 6a9e9810b3..18e6fe47af 100644 --- a/applications/test/foamVersion/Make/options +++ b/applications/test/foamVersion/Make/options @@ -1,2 +1,2 @@ -/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ -/* EXE_LIBS = -lfiniteVolume */ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/foamVersion/Test-foamVersion.C b/applications/test/foamVersion/Test-foamVersion.C new file mode 100644 index 0000000000..8f3e4128fd --- /dev/null +++ b/applications/test/foamVersion/Test-foamVersion.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + Test-foamVersion + +Description + Print the OpenFOAM version information. + +\*---------------------------------------------------------------------------*/ + +#include +#include "foamVersion.H" + +using namespace Foam; + +int main() +{ + std::cout + << "\nVersion information (macros)\n" + << "version " << Foam::FOAMversion << '\n' + << "build " << Foam::FOAMbuild << '\n' + << "buildArch " << Foam::FOAMbuildArch << '\n'; + + std::cout + << "\nVersion information (namespace)\n" + << "version " << foamVersion::version << '\n' + << "build " << foamVersion::build << '\n' + << "buildArch " << foamVersion::buildArch << '\n'; + + std::cout + << "\nVerify memory addesses are identical:\n" + << "macro " << long(&(Foam::FOAMversion)) << '\n' + << "namespace " << long(&(foamVersion::version)) << '\n'; + + std::cout + << "\nEnd\n"; + + return 0; +} + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_reader_release.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_reader_release.H index 5ebd4425cb..0cccce10a3 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_reader_release.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_reader_release.H @@ -8,7 +8,7 @@ int USERD_get_reader_release Info<< "Entering: USERD_get_reader_release" << endl; #endif - strncpy(release_number, Foam::FOAMbuild, Z_MAX_USERD_NAME); + strncpy(release_number, foamVersion::build, Z_MAX_USERD_NAME); #ifdef ENSIGHTDEBUG Info<< "Leaving: USERD_get_reader_release" << endl; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index a9466aa28d..84ece4c4b6 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -9,6 +9,7 @@ global/profiling/profilingInformation.C global/profiling/profilingSysInfo.C global/profiling/profilingTrigger.C global/etcFiles/etcFiles.C +global/version/foamVersion.C fileOps = global/fileOperations $(fileOps)/fileOperation/fileOperation.C diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C index 441f0b893d..c970a49e37 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C @@ -48,7 +48,7 @@ Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint) if (!*paddedVersion) { // Populate: like strncpy but without trailing '\0' - const char *p = Foam::FOAMversion; + const char *p = foamVersion::version; memset(paddedVersion, ' ', 38); for (int i = 0; *p && i < 38; ++i) @@ -130,7 +130,7 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const if (os.format() == IOstream::BINARY) { - os << " arch " << Foam::FOAMbuildArch << ";\n"; + os << " arch " << foamVersion::buildArch << ";\n"; } if (!note().empty()) diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C index cca72be73f..92c2c0dd48 100644 --- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C +++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C @@ -211,7 +211,7 @@ void Foam::decomposedBlockData::writeHeader /* if (os.format() == IOstream::BINARY) { - os << " arch " << Foam::FOAMbuildArch << ";\n"; + os << " arch " << foamVersion::buildArch << ";\n"; } */ diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 245f5d67e5..6168c68a97 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -181,24 +181,6 @@ static void printHostsSubscription(const UList& slaveProcs) Info<< ")" << nl; } - -// Print information about version, build, arch -static void printBuildInfo(const bool full=true) -{ - Info<<"Using: OpenFOAM-" << Foam::FOAMversion - << " (see www.OpenFOAM.com)" << nl - << "Build: " << Foam::FOAMbuild - #if OPENFOAM - << " (OPENFOAM=" << OPENFOAM << ')' - #endif - << nl; - - if (full) - { - Info << "Arch: " << Foam::FOAMbuildArch.c_str() << nl; - } -} - } // End namespace Foam @@ -776,7 +758,7 @@ Foam::argList::argList ++argi; if (argi >= args_.size()) { - printBuildInfo(false); + foamVersion::printBuildInfo(false); Info<. -Application - foamVersionString.C - -Description - Print the OpenFOAM version strings. - - Simultaneously the smallest possible program to use a minimal bit of - the OpenFOAM library - \*---------------------------------------------------------------------------*/ -#include #include "foamVersion.H" +#include "messageStream.H" -int main() +// Static data members are constructed in global.Cver + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void Foam::foamVersion::printBuildInfo(const bool full) { - std::cout - << "version " << Foam::FOAMversion << "\n" - << "build " << Foam::FOAMbuild << "\n"; + Info<<"Using: OpenFOAM-" << foamVersion::version + << " (see www.OpenFOAM.com)" << nl + << "Build: " << foamVersion::build + #if OPENFOAM + << " (OPENFOAM=" << OPENFOAM << ')' + #endif + << nl; - return 0; + if (full) + { + Info<< "Arch: " << foamVersion::buildArch.c_str() << nl; + } } + // ************************************************************************* // diff --git a/src/OpenFOAM/global/foamVersion.H b/src/OpenFOAM/global/version/foamVersion.H similarity index 64% rename from src/OpenFOAM/global/foamVersion.H rename to src/OpenFOAM/global/version/foamVersion.H index e85cc06bfa..099e045ffc 100644 --- a/src/OpenFOAM/global/foamVersion.H +++ b/src/OpenFOAM/global/version/foamVersion.H @@ -21,24 +21,11 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Global - Foam::FOAMversion +Namespace + Foam::foamVersion Description - OpenFOAM version number as a static string. - -Global - Foam::FOAMbuild - -Description - OpenFOAM build information as a static string - -Global - Foam::FOAMbuildArch - -Description - OpenFOAM build architecture information (endian, label/scalar sizes) - as a static string + Namespace for OpenFOAM version information Note Compile-time version information is conveyed by the \b OPENFOAM define @@ -48,6 +35,7 @@ Note The OPENFOAM_PLUS define was last used for 1712. SourceFiles + foamVersion.C global.Cver \*---------------------------------------------------------------------------*/ @@ -65,13 +53,41 @@ SourceFiles namespace Foam { - extern const char* const FOAMversion; - extern const char* const FOAMbuild; - extern const std::string FOAMbuildArch; + //- Version information + namespace foamVersion + { + //- OpenFOAM version (number or name) as a static c-string. + extern const char* const version; + + //- OpenFOAM build information as a static c-string + extern const char* const build; + + //- OpenFOAM build architecture information + //- (machine endian, label/scalar sizes) as a static std::string + extern const std::string buildArch; + + //- Print information about version, build, arch to Info + // + // \verbatim + // Using: OpenFOAM- (see www.OpenFOAM.com) + // Build: (OPENFOAM=) + // Arch: "" + // \endverbatim + // + // \param full includes Arch information + void printBuildInfo(const bool full=true); + } } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Compatibility names (1806 and earlier) + +#define FOAMversion foamVersion::version +#define FOAMbuild foamVersion::build +#define FOAMbuildArch foamVersion::buildArch + #endif // ************************************************************************* // diff --git a/src/fileFormats/ensight/file/ensightGeoFile.C b/src/fileFormats/ensight/file/ensightGeoFile.C index c84e91dc1c..473585b5db 100644 --- a/src/fileFormats/ensight/file/ensightGeoFile.C +++ b/src/fileFormats/ensight/file/ensightGeoFile.C @@ -41,7 +41,7 @@ void Foam::ensightGeoFile::initialize() #if OPENFOAM write("Written by OpenFOAM-" STRING_QUOTE(OPENFOAM)); #else - write(string("Written by OpenFOAM-" + string(Foam::FOAMversion))); + write(string("Written by OpenFOAM-" + string(foamVersion::version))); #endif newline(); diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C index 7152b21dbd..1d88d286dc 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C +++ b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C @@ -106,12 +106,12 @@ void Foam::ensightSetWriter::write // Write .mesh file { - string desc = string("written by OpenFOAM-") + Foam::FOAMversion; + string desc("Written by OpenFOAM-" + string(foamVersion::version)); OFstream os(meshFile); os.setf(ios_base::scientific, ios_base::floatfield); os.precision(5); - os << "EnSight Geometry File" << nl + os << "Ensight Geometry File" << nl << desc.c_str() << nl << "node id assign" << nl << "element id assign" << nl @@ -223,11 +223,11 @@ void Foam::ensightSetWriter::write // Write .mesh file { - string desc = string("written by OpenFOAM-") + Foam::FOAMversion; + string desc("Written by OpenFOAM-" + string(foamVersion::version)); OFstream os(meshFile); os.setf(ios_base::scientific, ios_base::floatfield); os.precision(5); - os << "EnSight Geometry File" << nl + os << "Ensight Geometry File" << nl << desc.c_str() << nl << "node id assign" << nl << "element id assign" << nl;