Skip to content

Commit 933fc59

Browse files
committed
change jobid from int to string
1 parent f595cd9 commit 933fc59

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

src/STAT.C

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,12 @@ StatError_t parseArgs(StatArgs_t *statArgs, STAT_FrontEnd *statFrontEnd, int arg
640640
statFrontEnd->setProcsPerNode(atoi(optarg));
641641
break;
642642
case 'j':
643-
statFrontEnd->setJobId(atoi(optarg));
643+
statError = statFrontEnd->setJobId(optarg);
644+
if (statError != STAT_OK)
645+
{
646+
statFrontEnd->printMsg(statError, __FILE__, __LINE__, "Failed to set job ID\n");
647+
return statError;
648+
}
644649
break;
645650
case 'r':
646651
statArgs->nRetries = atoi(optarg);

src/STAT.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ class STAT_FrontEnd
226226
unsigned int getLauncherPid();
227227
unsigned int getNumApplProcs();
228228
unsigned int getNumApplNodes();
229-
void setJobId(unsigned int jobId);
230-
unsigned int getJobId();
229+
StatError_t setJobId(const char *jobId);
230+
char *getJobId();
231231
void setNDaemonsPerNode(unsigned int nDaemonsPerNode);
232232
unsigned int getNDaemonsPerNode();
233233
const char *getApplExe();

src/STAT_FrontEnd.C

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ STAT_FrontEnd::STAT_FrontEnd()
234234
launcherArgc_ = 1;
235235
topologySize_ = 0;
236236
logging_ = 0;
237-
jobId_ = 0;
237+
jobId_ = NULL;
238238
launcherArgv_ = NULL;
239239
applExe_ = NULL;
240240
remoteNode_ = NULL;
@@ -1813,10 +1813,10 @@ StatError_t STAT_FrontEnd::createOutputDir()
18131813
/* Create run-specific results directory with a unique name */
18141814
for (fileNameCount = 0; fileNameCount < STAT_MAX_FILENAME_ID; fileNameCount++)
18151815
{
1816-
if (jobId_ == 0)
1816+
if (jobId_ == NULL)
18171817
snprintf(outDir_, BUFSIZE, "%s/%s.%04d", resultsDirectory, applExe_, fileNameCount);
18181818
else
1819-
snprintf(outDir_, BUFSIZE, "%s/%s.%d.%04d", resultsDirectory, applExe_, jobId_, fileNameCount);
1819+
snprintf(outDir_, BUFSIZE, "%s/%s.%s.%04d", resultsDirectory, applExe_, jobId_, fileNameCount);
18201820
intRet = mkdir(outDir_, S_IRUSR | S_IWUSR | S_IXUSR);
18211821
if (intRet == 0)
18221822
break;
@@ -1829,10 +1829,10 @@ StatError_t STAT_FrontEnd::createOutputDir()
18291829
printMsg(STAT_LOG_MESSAGE, __FILE__, __LINE__, "Output directory %s created\n", outDir_);
18301830

18311831
/* Generate the file prefix for output files */
1832-
if (jobId_ == 0)
1832+
if (jobId_ == NULL)
18331833
snprintf(filePrefix_, BUFSIZE, "%s.%04d", applExe_, fileNameCount);
18341834
else
1835-
snprintf(filePrefix_, BUFSIZE, "%s.%d.%04d", applExe_, jobId_, fileNameCount);
1835+
snprintf(filePrefix_, BUFSIZE, "%s.%s.%04d", applExe_, jobId_, fileNameCount);
18361836
printMsg(STAT_LOG_MESSAGE, __FILE__, __LINE__, "Generated file prefix: %s\n", outDir_);
18371837

18381838
return STAT_OK;
@@ -3626,13 +3626,25 @@ unsigned int STAT_FrontEnd::getNumApplNodes()
36263626
}
36273627

36283628

3629-
void STAT_FrontEnd::setJobId(unsigned int jobId)
3629+
StatError_t STAT_FrontEnd::setJobId(const char *jobId)
36303630
{
3631-
jobId_ = jobId;
3631+
if (jobId != NULL)
3632+
{
3633+
printMsg(STAT_LOG_MESSAGE, __FILE__, __LINE__, "Setting job ID to %s\n", jobId);
3634+
if (jobId_ != NULL)
3635+
free(jobId_);
3636+
jobId_ = strdup(jobId);
3637+
if (jobId_ == NULL)
3638+
{
3639+
printMsg(STAT_ALLOCATE_ERROR, __FILE__, __LINE__, "%s: Failed to set job ID path with strdup() to %s\n", strerror(errno), jobId);
3640+
return STAT_ALLOCATE_ERROR;
3641+
}
3642+
}
3643+
return STAT_OK;
36323644
}
36333645

36343646

3635-
unsigned int STAT_FrontEnd::getJobId()
3647+
const char *STAT_FrontEnd::getJobId()
36363648
{
36373649
return jobId_;
36383650
}

src/STAT_FrontEnd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,13 @@ class STAT_FrontEnd
468468
directory. This is helpful for example to associate a STAT run with
469469
a particular batch job ID.
470470
*/
471-
void setJobId(unsigned int jobId);
471+
StatError_t setJobId(const char *jobId);
472472

473473
//! Gets the job ID
474474
/*!
475475
\return the job ID
476476
*/
477-
unsigned int getJobId();
477+
const char *getJobId();
478478

479479
//! Set the number of daemons per node
480480
/*!
@@ -946,14 +946,14 @@ class STAT_FrontEnd
946946
unsigned int topologySize_; /*!< the size of the MRNet topology */
947947
unsigned int logging_; /*!< the logging level */
948948
unsigned int nDaemonsPerNode_; /*!< the number of daemons per node */
949-
int jobId_; /*!< the batch job ID */
950949
int mrnetOutputLevel_; /*!< the MRNet output level */
951950
char **launcherArgv_; /*!< the job launch arguments */
952951
char *toolDaemonExe_; /*!< the path to the STATD daemon executable */
953952
char *applExe_; /*!< the name of the application executable */
954953
char *filterPath_; /*!< the path to the STAT_FilterDefinitions.so filter file */
955954
char *remoteNode_; /*!< the hostname of the remote node running the job launcher */
956955
char *nodeListFile_; /*!< the file to containing the nodelist */
956+
char *jobId_; /*!< the batch job ID */
957957
char lastDotFileName_[BUFSIZE]; /*!< the path to the last generated .dot file */
958958
char outDir_[BUFSIZE]; /*!< the output directory */
959959
char logOutDir_[BUFSIZE]; /*!< the directory for log files */

0 commit comments

Comments
 (0)