diff --git a/applications/test/foamVersion/Make/files b/applications/test/foamVersion/Make/files index 52262afb8e80b696c8b01e78ffdba11a49a3c0c1..82922e0ca88a449a70743a329ad0728bbeec95de 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 6a9e9810b3d5ce6684bdaf03143933480ff45e42..18e6fe47afacb902cddccf82632772447704fd88 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 0000000000000000000000000000000000000000..8f3e4128fdf7dc23ba7e0250254238e7a70c1f4a --- /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 <http://www.gnu.org/licenses/>. + +Application + Test-foamVersion + +Description + Print the OpenFOAM version information. + +\*---------------------------------------------------------------------------*/ + +#include <iostream> +#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 5ebd4425cb76f5894fde7989ffeb1e6af4b3bcc9..0cccce10a372eb277f4a6fb698028a05699285b0 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 a9466aa28d954dcd5eecbb88d8b4daeb4bd26ca9..84ece4c4b6c8ca00c248b1ea7b7b559dc70511ca 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 441f0b893d02edc1321befb64fc00e76d8e3a6b1..c970a49e3749c1861e17781b4e097dcc094e7727 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 cca72be73ffa9acacf4b993ab64812d7216f6425..92c2c0dd48c2a90c24384952e9eab790c7c3af47 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 245f5d67e5a85775840fcd461ad8dccacb06af6f..6168c68a972f539bf3159e0a70dd31c5a0e925b8 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -181,24 +181,6 @@ static void printHostsSubscription(const UList<string>& 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<<nl <<"Error: option '-" << optName @@ -903,7 +885,7 @@ void Foam::argList::parse // Print the collected error messages and exit if check fails if (!check(checkArgs, checkOpts)) { - printBuildInfo(false); + foamVersion::printBuildInfo(false); FatalError.write(Info, false); Pstream::exit(1); // works for serial and parallel @@ -918,12 +900,12 @@ void Foam::argList::parse if (Pstream::master() && bannerEnabled()) { IOobject::writeBanner(Info, true) - << "Build : " << Foam::FOAMbuild + << "Build : " << foamVersion::build #if OPENFOAM << " (OPENFOAM=" << OPENFOAM << ')' #endif << nl - << "Arch : " << Foam::FOAMbuildArch << nl + << "Arch : " << foamVersion::buildArch << nl << "Exec : " << commandLine_.c_str() << nl << "Date : " << dateString.c_str() << nl << "Time : " << timeString.c_str() << nl @@ -934,7 +916,7 @@ void Foam::argList::parse jobInfo.add("startDate", dateString); jobInfo.add("startTime", timeString); jobInfo.add("userName", userName()); - jobInfo.add("foamVersion", word(Foam::FOAMversion)); + jobInfo.add("foamVersion", word(foamVersion::version)); jobInfo.add("code", executable_); jobInfo.add("argList", commandLine_); jobInfo.add("currentDir", cwd()); @@ -943,8 +925,8 @@ void Foam::argList::parse // Add build information - only use the first word { - std::string build(Foam::FOAMbuild); - std::string::size_type space = build.find(' '); + std::string build(foamVersion::build); + const auto space = build.find(' '); if (space != std::string::npos) { build.resize(space); @@ -1004,10 +986,10 @@ void Foam::argList::parse proci++; // Verify that all processors are running the same build - if (slaveBuild != Foam::FOAMbuild) + if (slaveBuild != foamVersion::build) { FatalErrorIn(executable()) - << "Master is running version " << Foam::FOAMbuild + << "Master is running version " << foamVersion::build << "; slave " << proci << " is running version " << slaveBuild << exit(FatalError); @@ -1021,7 +1003,7 @@ void Foam::argList::parse Pstream::commsTypes::scheduled, Pstream::masterNo() ); - toMaster << string(Foam::FOAMbuild) << hostName() << pid(); + toMaster << string(foamVersion::build) << hostName() << pid(); } } @@ -1623,7 +1605,7 @@ void Foam::argList::printUsage(bool full) const printNotes(); Info<< nl; - printBuildInfo(); + foamVersion::printBuildInfo(true); Info<< endl; } @@ -1771,7 +1753,12 @@ void Foam::argList::displayDoc(bool source) const CStringList command(stringOps::splitSpace(docBrowser)); - Info<<"OpenFOAM-" << Foam::FOAMversion << " documentation:" << nl + Info + << "OpenFOAM" + #if OPENFOAM + << ' ' << OPENFOAM + #endif + << " documentation:" << nl << " " << command << nl << endl; Foam::system(command, true); diff --git a/src/OpenFOAM/global/etcFiles/etcFiles.C b/src/OpenFOAM/global/etcFiles/etcFiles.C index 448bf64f27b3aa0275fcbc632b15bd7b41343bb4..e174f36f5d87341745b8a78f9c4f5a54238be18b 100644 --- a/src/OpenFOAM/global/etcFiles/etcFiles.C +++ b/src/OpenFOAM/global/etcFiles/etcFiles.C @@ -102,7 +102,7 @@ Foam::fileNameList searchEtc // User resource directories if (userResourceDir(dir)) { - candidate = dir/Foam::FOAMversion/name; + candidate = dir/foamVersion::version/name; if (accept(candidate)) { list.append(std::move(candidate)); @@ -126,7 +126,7 @@ Foam::fileNameList searchEtc // Group resource directories if (groupResourceDir(dir)) { - candidate = dir/Foam::FOAMversion/name; + candidate = dir/foamVersion::version/name; if (accept(candidate)) { list.append(std::move(candidate)); diff --git a/src/OpenFOAM/global/global.Cver b/src/OpenFOAM/global/global.Cver index 552dc011ccafc2c017a2e248ec948cae6e00b5eb..177f809c5520fa9759c8b853cde9fd05e9a86910 100644 --- a/src/OpenFOAM/global/global.Cver +++ b/src/OpenFOAM/global/global.Cver @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +31,6 @@ Description \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "foamVersion.H" #include "endian.H" #include "label.H" @@ -39,11 +38,11 @@ Description // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const char* const Foam::FOAMversion = "VERSION_STRING"; -const char* const Foam::FOAMbuild = "BUILD_STRING"; +const char* const Foam::foamVersion::version = "VERSION_STRING"; +const char* const Foam::foamVersion::build = "BUILD_STRING"; // Information about machine endian, label and scalar sizes -const std::string Foam::FOAMbuildArch = +const std::string Foam::foamVersion::buildArch ( #ifdef WM_LITTLE_ENDIAN "LSB" diff --git a/src/OpenFOAM/global/profiling/profilingSysInfo.C b/src/OpenFOAM/global/profiling/profilingSysInfo.C index 166f23e813a02f46b4181e1682421041ce034293..125abecc50e8317e464e29c6bec4660850e86eb1 100644 --- a/src/OpenFOAM/global/profiling/profilingSysInfo.C +++ b/src/OpenFOAM/global/profiling/profilingSysInfo.C @@ -29,7 +29,6 @@ License #include "Ostream.H" #include "OSspecific.H" - // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // file-scope function @@ -59,8 +58,8 @@ Foam::Ostream& Foam::profilingSysInfo::write os.writeEntry("date", Foam::clock::dateTime()); // compile-time information - os.writeEntry("version", std::string(FOAMversion)); - os.writeEntry("build", std::string(FOAMbuild)); + os.writeEntry("version", std::string(foamVersion::version)); + os.writeEntry("build", std::string(foamVersion::build)); printEnv(os, "arch", "WM_ARCH"); printEnv(os, "compilerType", "WM_COMPILER_TYPE"); diff --git a/applications/test/foamVersion/Test-foamVersionString.C b/src/OpenFOAM/global/version/foamVersion.C similarity index 62% rename from applications/test/foamVersion/Test-foamVersionString.C rename to src/OpenFOAM/global/version/foamVersion.C index d9050004c6d0c2742c656ca80fc34854d8fc3961..6356eb357b3a39ca140e5760276a86565e7b7025 100644 --- a/applications/test/foamVersion/Test-foamVersionString.C +++ b/src/OpenFOAM/global/version/foamVersion.C @@ -1,8 +1,8 @@ -/*---------------------------------------------------------------------------*\ +/*-------------------------------*- C++ -*-----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,27 +21,30 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Application - foamVersionString.C - -Description - Print the OpenFOAM version strings. - - Simultaneously the smallest possible program to use a minimal bit of - the OpenFOAM library - \*---------------------------------------------------------------------------*/ -#include <iostream> #include "foamVersion.H" +#include "messageStream.H" -int main() -{ - std::cout - << "version " << Foam::FOAMversion << "\n" - << "build " << Foam::FOAMbuild << "\n"; +// Static data members are constructed in global.Cver - return 0; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void Foam::foamVersion::printBuildInfo(const bool full) +{ + Info<<"Using: OpenFOAM-" << foamVersion::version + << " (see www.OpenFOAM.com)" << nl + << "Build: " << foamVersion::build + #if OPENFOAM + << " (OPENFOAM=" << OPENFOAM << ')' + #endif + << nl; + + 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 e85cc06bfa714e9e84ceaa8069f4584ad0067bed..099e045ffced94d2d2eac71cb32772c5ff078ca2 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 <http://www.gnu.org/licenses/>. -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-<VERSION> (see www.OpenFOAM.com) + // Build: <BUILD> (OPENFOAM=<API_LEVEL>) + // Arch: "<ARCH_INFO>" + // \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 c84e91dc1caa1ff3eb05d4c0f81b93c2a15b4688..473585b5dbdf8a400fdf70682e7ca928d6ccdd2e 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 7152b21dbdd79496df02bcf3e2900a84330edbba..1d88d286dcefc3bda85f81c859396bb76f20965e 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C +++ b/src/fileFormats/sampledSetWriters/ensight/ensightSetWriter.C @@ -106,12 +106,12 @@ void Foam::ensightSetWriter<Type>::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<Type>::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;