Go to the documentation of this file.
39 #ifndef FOAM_RESOURCE_USER_CONFIG_DIRNAME
40 #define FOAM_RESOURCE_USER_CONFIG_DIRNAME ".OpenFOAM"
42 #warning FOAM_RESOURCE_USER_CONFIG_DIRNAME was undefined (now ".OpenFOAM")
65 <<
"WARNING: no JobInfo directory: " << dir <<
nl
66 <<
" disabling JobInfo" <<
nl;
119 void Foam::JobInfo::jobEnding()
121 if (!running_.empty())
135 void Foam::JobInfo::jobEnding(
const word& terminationType)
137 if (writeJobInfo && !finished_.empty())
139 add(
"cpuTime", cpuTime_.elapsedCpuTime());
143 if (!terminationType.empty() && !
found(
"termination"))
145 add(
"termination", terminationType);
149 OFstream
os(finished_);
153 <<
"WARNING: could not write JobInfo file: "
171 <<
"WARNING: JobInfo was already constructed. "
172 "Should be a singleton!!" <<
nl;
184 running_ = jobDir/
"runningJobs"/jobFile;
185 finished_ = jobDir/
"finishedJobs"/jobFile;
216 if (writeJobInfo && !running_.empty())
222 <<
"WARNING: could not write JobInfo file: "
void exit()
Job end with "exit" termination.
static bool writeJobInfo
Global value for writeJobInfo enabled.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Helper class for recording information about run/finished jobs, acts like global singleton.
A class for handling file names.
static bool master(const label communicator=worldComm)
Am I the master process.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
static bool ensureJobDirExists(const fileName &dir)
const fileName & name() const noexcept
The dictionary name.
void write() const
Write job info to its file in the "running" jobs directory.
string getEnv(const std::string &envName)
Get environment value for given envName.
bool good() const noexcept
True if next operation might succeed.
static void disable() noexcept
Disallow JobInfo by forcing writeJobInfo (InfoSwitch) off.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
void signalEnd()
Relocate job file from "running" to "finished" directory.
pid_t pid()
Return the PID of this process.
void writeEntries(Ostream &os, const bool extraNewLine=false) const
Write dictionary entries.
static void shutdown()
Simple shutdown (finalize) of JobInfo.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
OBJstream os(runTime.globalPath()/outputName)
static std::string date()
static bool writeJobDict(Ostream &os, const dictionary &dict)
Output to file stream, using an OSstream.
JobInfo()
Default construct.
#define FOAM_RESOURCE_USER_CONFIG_DIRNAME
fileName home()
Return home directory path name for the current user.
void stop()
Job end with "normal" termination.
string hostName(bool full=false)
Return the system's host name, as per hostname(1)
static std::string clockTime()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
~JobInfo()
Destructor, relocates the job file from running to finished.
void abort()
Job end with "abort" termination.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?