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-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
36 namespace
37 {
38 
39 // Write environment entry
40 inline 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  }
52 }
53 
54 } // End anonymous namespace
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
60 (
61  Ostream& os
62 ) const
63 {
64  os.writeEntry("host", Foam::hostName()); // short name
65  os.writeEntry("date", Foam::clock::dateTime());
66 
67  // compile-time information
68  os.writeEntry("version", foamVersion::version);
69  os.writeEntry("build", foamVersion::build);
70 
71  printEnv(os, "arch", "WM_ARCH");
72  printEnv(os, "compilerType", "WM_COMPILER_TYPE");
73  printEnv(os, "compiler", "WM_COMPILER");
74  printEnv(os, "mplib", "WM_MPLIB");
75  printEnv(os, "options", "WM_OPTIONS");
76 
77  return os;
78 }
79 
80 
81 // ************************************************************************* //
Foam::foamVersion::build
const std::string build
OpenFOAM build information as a std::string.
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::getEnv
string getEnv(const std::string &envName)
Get environment value for given envName.
Definition: MSwindows.C:371
Foam::clock::dateTime
static std::string dateTime()
Definition: clock.C:60
clock.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam::foamVersion::version
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
Ostream.H
Foam::hostName
string hostName(bool full=false)
Return the system's host name, as per hostname(1)
Definition: MSwindows.C:410
profilingSysInfo.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::profilingSysInfo::write
Ostream & write(Ostream &os) const
Write the profiling system-info, use dictionary format.
Definition: profilingSysInfo.C:60
foamVersion.H