Skip to content
Snippets Groups Projects
Commit 402bd12b authored by Daniel Wielanek's avatar Daniel Wielanek
Browse files

Simplification of xml jobs, added option for VIRGO cluster.

parent 326e6815
No related branches found
No related tags found
No related merge requests found
......@@ -23,37 +23,41 @@ NicaJobs::NicaJobs(TString name) : fArray(kFALSE), fFile(name), fStartJob(1), fE
NicaXMLNode* options = root->GetChild("job_options");
NicaXMLNode* commands = root->GetChild("job_commands");
NicaXMLNode* submit = settings->GetChild("submit");
NicaXMLNode* array = settings->GetChild("array");
NicaXMLNode* shell = settings->GetChild("shell");
fSubmitCommand = submit->GetValue();
fSubmitCommand.ReplaceAll("${NICA_PWD}", gSystem->pwd());
TString Shell;
if (shell != nullptr)
fShell = shell->GetValue();
Shell = shell->GetValue();
else
fShell = "";
Shell = "";
fCommands.push_back(Shell);
NicaXMLNode* start_id = settings->GetChild("submit_start");
NicaXMLNode* end_id = settings->GetChild("submit_end");
fStartJob = start_id->GetValue().Atoi();
fEndJob = end_id->GetValue().Atoi();
fSubmitCommand.ReplaceAll("${NICA_START_ARRAY}", Form("%i", fStartJob));
fSubmitCommand.ReplaceAll("${NICA_END_ARRAY}", Form("%i", fStartJob));
if (options->GetAttrib("array")->GetValue() == "yes") { fArray = kTRUE; }
if (array) {
if (array->GetValue().Length() > 0) fArray = kTRUE;
}
if (fArray) {
TString array_command = array->GetValue();
array_command.ReplaceAll("${NICA_START_ARRAY}", Form("%i", fStartJob));
array_command.ReplaceAll("${NICA_END_ARRAY}", Form("%i", fStartJob));
fOptions.push_back(array_command.Data());
}
for (int i = 0; i < options->GetNChildren(); i++) {
NicaXMLNode* command = options->GetChild(i);
fOptions.push_back(command->GetValue());
fCommands.push_back(command->GetValue());
}
for (int i = 0; i < commands->GetNChildren(); i++) {
NicaXMLNode* command = commands->GetChild(i);
fCommands.push_back(command->GetValue());
}
TString pwd = gSystem->pwd();
for (unsigned int i = 0; i < fCommands.size(); i++) {
fCommands[i].ReplaceAll("${NICA_START_ARRAY}", Form("%i", fStartJob));
fCommands[i].ReplaceAll("${NICA_END_ARRAY}", Form("%i", fStartJob));
fCommands[i].ReplaceAll("${NICA_PWD}", pwd);
}
}
void NicaJobs::SubmitJobs() {
......@@ -82,16 +86,9 @@ void NicaJobs::SubmitJobs() {
}
void NicaJobs::CreateJobs() {
for (unsigned int i = 0; i < fCommands.size(); i++) {
fCommands[i].ReplaceAll("${NICA_PWD}", gSystem->pwd());
}
if (fArray) {
std::ofstream job_array;
job_array.open("jobs/job_array");
if (fShell.Length() > 0) job_array << fShell << std::endl;
for (unsigned int i = 0; i < fOptions.size(); i++) {
job_array << fOptions[i] << std::endl;
}
for (unsigned int i = 0; i < fCommands.size(); i++)
job_array << fCommands[i] << std::endl;
job_array.close();
......@@ -100,12 +97,6 @@ void NicaJobs::CreateJobs() {
for (int iJob = fStartJob; iJob <= fEndJob; iJob++) {
std::ofstream job_file;
job_file.open(Form("jobs/job_%i", iJob));
if (fShell.Length() > 0) job_file << fShell << std::endl;
for (unsigned int i = 0; i < fOptions.size(); i++) {
TString option = fOptions[i];
option.ReplaceAll("${NICA_JOB_ID}", Form("%i", iJob));
job_file << option << std::endl;
}
for (unsigned int i = 0; i < fCommands.size(); i++) {
TString commands = fCommands[i];
commands.ReplaceAll("${NICA_JOB_ID}", Form("%i", iJob));
......@@ -117,9 +108,7 @@ void NicaJobs::CreateJobs() {
}
}
NicaJobs::~NicaJobs() {
// TODO Auto-generated destructor stub
}
NicaJobs::~NicaJobs() {}
Int_t NicaJobs::GetNVariables(TString textfile) {
if (textfile.EndsWith(".xml")) { return GetNVariablesXML(textfile); }
......
......@@ -19,9 +19,7 @@ class NicaJobs : public TObject {
TString fFile;
TString fSubmitCommand;
Int_t fStartJob, fEndJob;
TString fShell;
std::vector<TString> fCommands;
std::vector<TString> fOptions;
static Int_t GetNVariablesTxt(TString textfile);
static Int_t GetNVariablesXML(TString xmlfile);
static TString GetParameterTxt(TString textfile, Int_t job, Int_t var);
......
......@@ -3,14 +3,14 @@
<settings>
<!--submit command-->
<submit>qsub ${NICA_JOB_FILE}</submit>
<!--array command in options, ${NICA_START_ARRAY}/${NICA_END_ARRAY} will
be replaced by submit start/end -->
<array>#PBS -t ${NICA_START_ARRAY}-${NICA_END_ARRAY}</array>
<submit_start>1</submit_start>
<submit_end>1</submit_end>
<shell>#!/bin/bash</shell>
</settings>
<job_options>
<job_options array="yes">
<!--array command in options, ${NICA_START_ARRAY}/${NICA_END_ARRAY} will
be replaced by submit start/end -->
<command>#PBS -t ${NICA_START_ARRAY}-${NICA_END_ARRAY}</command>
<!--job array ids-->
<!--number of nodes, cores per node walltime-->
<command>#PBS -l nodes=1:ppn=1,walltime=30:00</command>
......
......@@ -3,14 +3,12 @@
<settings>
<!--submit command-->
<submit>qsub ${NICA_JOB_FILE}</submit>
<!-- must be emtpy -->
<array></array>>
<!--job ids-->
<submit_start>1</submit_start>
<submit_end>1</submit_end>
<shell>#!/bin/bash</shell>
</settings>
<job_options>
<job_options array="no">
<!--number of nodes, cores per node walltime-->
<command>#PBS -l nodes=1:ppn=1,walltime=30:00</command>
<!--output logs ${NICA_JOB_ID} will be replaced by id-->
......
......@@ -3,14 +3,19 @@
<settings>
<!--submit command-->
<submit>sbatch ${NICA_JOB_FILE}</submit>
<!--array command in options, ${NICA_START_ARRAY}/${NICA_END_ARRAY} will
be replaced by submit start/end -->
<array>#SBATCH --array=${NICA_START_ARRAY}-${NICA_END_ARRAY}</array>
<!-- submit command for VIRGO
<submit>sbatch --output=${NICA_PWD}/ana2021/%j.out
--error=${NICA_PWD}/%j.errors --time=36:00:00 --array=${NICA_START_ARRAY}-${NICA_END_ARRAY}
-p long -- ${NICA_PWD}/${NICA_JOB_FILE}</submit>
-->
<submit_start>1</submit_start>
<submit_end>2</submit_end>
<shell>#!/bin/bash</shell>
</settings>
<job_options>
<job_options array="yes">
<!--array command in options, ${NICA_START_ARRAY}/${NICA_END_ARRAY} will
be replaced by submit start/end -->
<command>#SBATCH --array=${NICA_START_ARRAY}-${NICA_END_ARRAY}</command>
<!--walltime-->
<command>#SBATCH --time=01:30:00</command>
<!--errors logs-->
......
......@@ -3,14 +3,12 @@
<settings>
<!--submit command-->
<submit>sbatch ${NICA_JOB_FILE}</submit>
<!-- must be emtpy -->
<array></array>
<!--job ids-->
<submit_start>1</submit_start>
<submit_end>1</submit_end>
<shell>#!/bin/bash</shell>
</settings>
<job_options>
<job_options array="no">
<!--walltime-->
<command>#SBATCH --time=01:30:00</command>
</job_options>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment