Loading...
Searching...
No Matches
profilingSysInfo.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "profilingSysInfo.H"
29#include "foamVersion.H"
30#include "clock.H"
31#include "Ostream.H"
32#include "OSspecific.H"
33
34// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
35
36namespace
37{
38
39// Write environment entry
40inline void printEnv
41(
43 const Foam::word& key,
44 const std::string& envName
45)
46{
47 const std::string value(Foam::getEnv(envName));
48 if (!value.empty())
49 {
50 os.writeEntry(key, value);
51 }
53
54} // End anonymous namespace
55
56
57// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58
60{
61 os.writeEntry("host", Foam::hostName()); // short name
62 os.writeEntry("date", Foam::clock::dateTime());
63
64 // compile-time information
65 os.writeEntry("version", foamVersion::version);
66 os.writeEntry("build", foamVersion::build);
67
68 printEnv(os, "arch", "WM_ARCH");
69 printEnv(os, "compilerType", "WM_COMPILER_TYPE");
70 printEnv(os, "compiler", "WM_COMPILER");
71 printEnv(os, "mplib", "WM_MPLIB");
72 printEnv(os, "options", "WM_OPTIONS");
73}
74
75
76void Foam::profilingSysInfo::writeEntry(const word& keyword, Ostream& os) const
77{
78 os.beginBlock(keyword);
79 writeEntries(os);
80 os.endBlock();
81}
82
83
84// ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
static std::string dateTime()
The current wall-clock date/time (in local time) as a string in ISO-8601 format (yyyy-mm-ddThh:mm:ss)...
Definition clock.C:53
void writeEntries(Ostream &os) const
Write system-info as dictionary entries.
void writeEntry(const word &keyword, Ostream &os) const
Write system-info as dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
const std::string build
OpenFOAM build information as a std::string.
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
string getEnv(const std::string &envName)
Get environment value for given envName.
Definition POSIX.C:341
string hostName()
Return the system's host name, as per hostname(1).
Definition POSIX.C:373