42 #ifndef FOAM_RESOURCE_USER_CONFIG_DIRNAME 43 #define FOAM_RESOURCE_USER_CONFIG_DIRNAME ".OpenFOAM" 45 #warning FOAM_RESOURCE_USER_CONFIG_DIRNAME was undefined (now ".OpenFOAM") 68 <<
"WARNING: no JobInfo directory: " << dir <<
nl 69 <<
" disabling JobInfo" <<
nl;
122 void Foam::JobInfo::jobEnding()
124 if (!running_.empty())
138 void Foam::JobInfo::jobEnding(
const word& terminationType)
140 if (writeJobInfo && !finished_.empty())
142 add(
"cpuTime", cpuTime_.elapsedCpuTime());
146 if (!terminationType.empty() && !
found(
"termination"))
148 add(
"termination", terminationType);
152 OFstream
os(finished_);
156 <<
"WARNING: could not write JobInfo file: " 174 <<
"WARNING: JobInfo was already constructed. " 175 "Should be a singleton!!" <<
nl;
187 running_ = jobDir/
"runningJobs"/jobFile;
188 finished_ = jobDir/
"finishedJobs"/jobFile;
219 if (writeJobInfo && !running_.empty())
225 <<
"WARNING: could not write JobInfo file: " JobInfo()
Default construct.
static bool writeJobDict(Ostream &os, const dictionary &dict)
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
A class for handling file names.
Helper class for recording information about run/finished jobs, acts like global singleton.
~JobInfo()
Destructor, relocates the job file from running to finished.
Output to file stream, using an OSstream.
constexpr char nl
The newline '\n' character (0x0a)
static void shutdown()
Simple shutdown (finalize) of JobInfo.
string getEnv(const std::string &envName)
Get environment value for given envName.
fileName home()
Return home directory path name for the current user.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
const fileName & name() const noexcept
The dictionary name.
static std::string date()
The current wall-clock date as a string formatted as (MON dd yyyy), where MON is Jan, Feb, etc.
void signalEnd()
Relocate job file from "running" to "finished" directory.
static void disable() noexcept
Disallow JobInfo by forcing writeJobInfo (InfoSwitch) off.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void write() const
Write job info to its file in the "running" jobs directory.
#define FOAM_RESOURCE_USER_CONFIG_DIRNAME
static std::string clockTime()
The current wall-clock (in local time) as a string formatted as as (hh:mm:ss).
string hostName()
Return the system's host name, as per hostname(1)
pid_t pid()
Return the PID of this process.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
OBJstream os(runTime.globalPath()/outputName)
void stop()
Job end with "normal" termination.
bool good() const noexcept
True if next operation might succeed.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static bool writeJobInfo
Global value for writeJobInfo enabled.
static bool ensureJobDirExists(const fileName &dir)
void abort()
Job end with "abort" termination.
void writeEntries(Ostream &os, const bool extraNewLine=false) const
Write dictionary entries.
void exit()
Job end with "exit" termination.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.