aboutsummaryrefslogtreecommitdiff
path: root/src/id.cc
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2007-05-24 02:00:22 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2007-05-24 02:00:22 +0000
commit5e81962213ef3462d74096cd82a69394bbd53688 (patch)
treef27c40032d06a3592a9776de3304c759925e2f92 /src/id.cc
parentf0923ce63df941b7665eab963c2e36ac9f0194ed (diff)
Make the parameter file name part of the job id.
Separate date and time elements in the job id by periods. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@123 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/id.cc')
-rw-r--r--src/id.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/id.cc b/src/id.cc
index e981f0a..4ea6531 100644
--- a/src/id.cc
+++ b/src/id.cc
@@ -1,3 +1,4 @@
+#include <cctype>
#include <iomanip>
#include <sstream>
#include <string>
@@ -62,6 +63,32 @@ namespace Formaline
ostringstream job_idbuf;
job_idbuf << "job-";
+ char cparfilename [10000];
+ CCTK_ParameterFilename (sizeof cparfilename, cparfilename);
+ string parfilename (cparfilename);
+ size_t const last_slash = parfilename.rfind ('/');
+ if (last_slash < string::npos) {
+ parfilename.erase (0, last_slash + 1);
+ }
+ size_t const first_dot = parfilename.find ('.');
+ parfilename.erase (first_dot);
+ {
+ string::iterator it = parfilename.begin();
+ while (it != parfilename.end()) {
+ char const c = *it;
+ if (isalnum (c) or c == '+' or c == '-' or c == '.' or c == '_') {
+ // Allow character
+ ++ it;
+ } else {
+ // Remove character
+ it = parfilename.erase (it);
+ }
+ }
+ }
+ job_idbuf << parfilename;
+
+ job_idbuf << "-";
+
char run_host [1000];
Util_GetHostName (run_host, sizeof run_host);
job_idbuf << run_host;
@@ -81,11 +108,15 @@ namespace Formaline
struct tm * const ptm = gmtime (& tim);
job_idbuf << setfill ('0')
<< setw(4) << 1900 + ptm->tm_year
+ << "."
<< setw(2) << ptm->tm_mon + 1
+ << "."
<< setw(2) << ptm->tm_mday
<< "-"
<< setw(2) << ptm->tm_hour
+ << "."
<< setw(2) << ptm->tm_min
+ << "."
<< setw(2) << ptm->tm_sec;
job_idbuf << "-";