61 string baseDir =
getEnv(
"FOAM_JOB_DIR");
64 fileName runningDir(baseDir/
"runningJobs");
65 fileName finishedDir(baseDir/
"finishedJobs");
67 runningJobPath_ = runningDir/jobFile;
68 finishedJobPath_ = finishedDir/jobFile;
73 <<
"Cannot get jobInfo directory $FOAM_JOB_DIR" 80 <<
"Cannot make jobInfo directory " << runningDir
84 if (!
isDir(finishedDir) && !
mkDir(finishedDir))
87 <<
"Cannot make jobInfo directory " << finishedDir
105 mv(runningJobPath_, finishedJobPath_);
114 bool Foam::jobInfo::write(
Ostream& os)
const 135 void Foam::jobInfo::write
137 const word& executable,
145 const fileName jobInfoPath(casePath/
"jobInfo");
147 if (!
isDir(jobInfoPath) && !
mkDir(jobInfoPath))
150 <<
"Cannot make jobInfo directory " << jobInfoPath
156 runningJobPath_ = jobInfoPath/jobFile;
157 finishedJobPath_ = jobInfoPath/jobFile;
160 if (!write(
OFstream(runningJobPath_)()))
163 <<
"Failed to write to jobInfo file " 179 if (!
found(
"termination"))
181 add(
"termination", terminationType);
185 write(
OFstream(finishedJobPath_)());
214 mv(runningJobPath_, finishedJobPath_);
string getEnv(const word &)
Return environment variable of given name.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Helper class for recording information about run/finished jobs.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static bool writeJobControl
static bool master(const label communicator=0)
Am I the master process.
bool good() const
Return true if next operation might succeed.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
const fileName & name() const
Return the dictionary name.
string hostName(const bool full=false)
Return the system's host name, as per hostname(1)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
static string clockTime()
Return the current wall-clock time as a string.
pid_t pid()
Return the PID of this process.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
word name(const complex &)
Return a string representation of a complex.
static string date()
Return the current wall-clock date as a string.
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.