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,
143 if (!writeJobControl)
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;
163 <<
"Failed to write to jobInfo file "
175 add(
"cpuTime", cpuTime_.elapsedCpuTime());
179 if (!
found(
"termination"))
181 add(
"termination", terminationType);
185 write(OFstream(finishedJobPath_)());
214 mv(runningJobPath_, finishedJobPath_);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool good() const
Return true if next operation might succeed.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static bool master(const label communicator=0)
Am I the master process.
static string clockTime()
Return the current wall-clock time as a string.
static string date()
Return the current wall-clock date as a string.
const fileName & name() const
Return the dictionary name.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
A class for handling file names.
Helper class for recording information about run/finished jobs.
static bool writeJobControl
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
word name(const bool)
Return a word representation of a bool.
string hostName(const bool full=false)
Return the system's host name, as per hostname(1)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
string getEnv(const word &)
Return environment variable of given name.
pid_t pid()
Return the PID of this process.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.