Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_condor_mtpe.C
Go to the documentation of this file.
1 
2 {
3 
4  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
5  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
6  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
7 
8  if(TString(condor_tag)=="") {
9  cout << endl;
10  cout << "cwb_condor_mtpe.C : Error - the accounting_group is not defined !!!" << endl;
11  cout << "The accounting_group must be defined in the user_parameters.C file" << endl;
12  cout << "See the following link:" << endl;
13  cout <<" https://ldas-gridmon.ligo.caltech.edu/accounting/condor_groups/determine_condor_account_group.html" << endl;
14  cout << "Examples : " << endl;
15  cout << "strcpy(condor_tag,\"ligo.dev.o2.burst.allsky.cwboffline\");" << endl;
16  cout << "strcpy(condor_tag,\"ligo.prod.o2.burst.allsky.cwboffline\");" << endl;
17  cout << "If you don't need it set : strcpy(condor_tag,\"disabled\");" << endl << endl;
18  exit(1);
19  }
20  if(TString(condor_tag)=="disabled") strcpy(condor_tag,"");
21 
22  if(!(simulation==4) && !(simulation==0)) {
23  cout << endl << "cwb_condor_mtpe Error : allowed only with simulation=0/4 !!!" << endl << endl;
24  gSystem->Exit(1);
25  }
26 
27  bool singleDetector=false;
28  if(nIFO==1) { // Single Detector Mode
30  config.Import();
31  config.SetSingleDetectorMode();
32  config.Export();
33  singleDetector=true;
34  }
35  if(nIFO==2) { // 2 detectors with the same name "same detector -> nIFO=1"
36  if(TString(ifo[0])==TString(ifo[1])) singleDetector=true;
37  }
38 
39  // get PE jobid
41  if(gSystem->Getenv("CWB_CONDOR_MTPE_JOBID")==NULL) {
42  cout << endl << "cwb_condor_mtpe Error : environment CWB_CONDOR_MTPE_JOBID is not defined!!!" << endl << endl;
43  gSystem->Exit(1);
44  } else {
45  if(TString(gSystem->Getenv("CWB_CONDOR_MTPE_JOBID")).IsDigit()) {
46  cwb_condor_mtpe_jobid=TString(gSystem->Getenv("CWB_CONDOR_MTPE_JOBID")).Atoi();
47  } else {
48  cout << endl << "cwb_condor_mtpe Error : environment CWB_CONDOR_MTPE_JOBID is not an integer number!!!" << endl << endl;
49  gSystem->Exit(1);
50  }
51  }
52  if(cwb_condor_mtpe_jobid<1) {
53  cout << endl << "cwb_condor_mtpe Error : environment CWB_CONDOR_MTPE_JOBID is not an integer number >0 !!!" << endl << endl;
54  gSystem->Exit(1);
55  }
56 
57  // get PE trials
58  int cwb_condor_mtpe_trials=-1;
60 
61  // for simulation=4 the trials are defined in the nfactor, factors parameters
62  if(simulation==4 && nfactor>1) {
63  cwb_condor_mtpe_trials = factors[0]+nfactor-1;
64  cwb_condor_mtpe_offset = factors[0];
65  if(cwb_condor_mtpe_trials<1) {
66  cout << endl << "cwb_condor_mtpe Error : (simulation=4) nfactor is not an integer number >0 !!!" << endl << endl;
67  gSystem->Exit(1);
68  }
69  if(cwb_condor_mtpe_offset<1) {
70  cout << endl << "cwb_condor_mtpe Error : (simulation=4) factors[0] is not an integer number >0 !!!" << endl << endl;
71  gSystem->Exit(1);
72  }
73  }
74 
75  // for simulation=0 the trials are defined in the PE parPlugin
76  if((simulation==0)||(simulation==4 && nfactor==1)) {
77  bool multitask=false;
78  TString pe_options = parPlugin;
79  if(pe_options.CompareTo("")!=0) {
80  cout << pe_options << endl;
81  if(!pe_options.Contains("--")) {
82 
83  TObjArray* token = TString(pe_options).Tokenize(TString(' '));
84 
85  for(int j=0;j<token->GetEntries();j++) {
86 
87  TObjString* tok = (TObjString*)token->At(j);
88  TString stok = tok->GetString();
89 
90  if(stok.Contains("pe_multitask=")) {
91  TString pe_multitask=stok;
92  pe_multitask.Remove(0,pe_multitask.Last('=')+1);
93  if(pe_multitask=="true") multitask=true;
94  if(pe_multitask=="false") multitask=false;
95  }
96 
97  if(stok.Contains("pe_trials=") || stok.Contains("pe_retry=")) {
98  TString pe_trials=stok;
99  pe_trials.Remove(0,pe_trials.Last('=')+1);
100  if(pe_trials.IsDigit()) cwb_condor_mtpe_trials=pe_trials.Atoi();
101  }
102  }
103  }
104  }
105  if(!multitask) {
106  cout << endl << "cwb_condor_mtpe Error : (simulation=0) pe_multitask must be enabled !!!" << endl << endl;
107  gSystem->Exit(1);
108  }
109  if(cwb_condor_mtpe_trials<1 || cwb_condor_mtpe_trials>99) {
110  cout << endl << "cwb_condor_mtpe Error : (simulation=0) pe_trials in PE parPlugin is not an integer number >0 && <100 !!!" << endl << endl;
111  gSystem->Exit(1);
112  }
113  }
114 
115  char condor_label[1024];
116  sprintf(condor_label,"%s.mtpe",data_label);
117 
118  // create condor sub file
119 
120  char ofile_condor_sub[1024];
121  sprintf(ofile_condor_sub,"%s/%s.sub",condor_dir,condor_label);
122 
123  FILE *fP=NULL;
124  if((fP = fopen(ofile_condor_sub, "w")) == NULL) {
125  cout << endl << "cwb_condor_mtpe.C : Error - cannot open file " << ofile_condor_sub << endl << endl;
126  exit(1);
127  }
128  cout << endl << ofile_condor_sub << endl;
129 
130  char full_condor_dir[1024];
131  char full_condor_out_dir[1024];
132  char full_condor_err_dir[1024];
133 
134  sprintf(full_condor_dir,"%s/%s",work_dir,condor_dir);
135  sprintf(full_condor_out_dir,"%s/%s",work_dir,log_dir);
136  sprintf(full_condor_err_dir,"%s/%s",work_dir,log_dir);
137 
138  fprintf(fP,"universe = vanilla\n");
139  fprintf(fP,"getenv = true\n");
140  fprintf(fP,"priority = $(PRI)\n");
141  fprintf(fP,"on_exit_hold = ( ExitCode != 0 )\n");
142  fprintf(fP,"request_memory = 2000\n");
143  fprintf(fP,"executable = loudest.sh\n");
144  fprintf(fP,"job_machine_attrs = Machine\n");
145  fprintf(fP,"job_machine_attrs_history_length = 5\n");
146  fprintf(fP,"requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && target.machine =!= MachineAttrMachine3 && target.machine =!= MachineAttrMachine4 && target.machine =!= MachineAttrMachine5\n");
147  fprintf(fP,"environment = CWB_JOBID=$(PID);CWB_UFILE=$(CWB_UFILE);CWB_STAGE=$(CWB_STAGE);CWB_MDC_FACTOR=$(CWB_MDC_FACTOR);CWB_CED_DIR=$(CWB_CED_DIR)\n");
148  if(TString(condor_tag)!="") fprintf(fP,"accounting_group = %s\n",condor_tag);
149  fprintf(fP,"output = %s/$(PID)_$(CWB_MDC_FACTOR)_%s.out\n",full_condor_out_dir,condor_label);
150  fprintf(fP,"error = %s/$(PID)_$(CWB_MDC_FACTOR)_%s.err\n",full_condor_err_dir,condor_label);
151  fprintf(fP,"log = %s/%s.log\n",condor_log,condor_label);
152  fprintf(fP,"notification = never\n");
153  fprintf(fP,"rank=memory\n");
154  fprintf(fP,"queue\n");
155 
156  fclose(fP);
157 
158  // create condor dag file
159 
160  char ofile_condor_dag[1024];
161  sprintf(ofile_condor_dag,"%s/%s.dag",condor_dir,condor_label);
162 
163  ofstream out;
164  out.open(ofile_condor_dag,ios::out);
165  if (!out.good()) {cout << endl << "cwb_condor_mtpe Error Opening File : " << ofile_condor_dag << endl << endl;exit(1);}
166  cout << ofile_condor_dag << endl << endl;
167 
168  TString cwb_uparameters_file=TString(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
169 
170  for(int n=cwb_condor_mtpe_offset; n<=cwb_condor_mtpe_trials; n++) {
171  char ostring[1024*16];
172  sprintf(ostring,"JOB A%i_%d %s/%s.sub",cwb_condor_mtpe_jobid,n,full_condor_dir,condor_label);
173  out << ostring << endl;
174  sprintf(ostring,"VARS A%i_%d PID=\"%i\" CWB_UFILE=\"%s\" CWB_STAGE=\"CWB_STAGE_FULL\" CWB_MDC_FACTOR=\"%d\" CWB_CED_DIR=\"output\"",
175  cwb_condor_mtpe_jobid,n,cwb_condor_mtpe_jobid,cwb_uparameters_file.Data(),n);
176  out << ostring << endl;
177  sprintf(ostring,"RETRY A%i_%d 3000",cwb_condor_mtpe_jobid,n);
178  out << ostring << endl;
179  }
180 
181  if((simulation==0)||(simulation==4 && nfactor==1)) {
182  out << "PARENT ";
183  for(int n=1; n<cwb_condor_mtpe_trials; n++) {
184  sprintf(ostring,"A%i_%d ",cwb_condor_mtpe_jobid,n);
185  out << ostring;
186  }
187  sprintf(ostring,"CHILD A%i_%d",cwb_condor_mtpe_jobid,cwb_condor_mtpe_trials);
188  out << ostring << endl;
189  out.close();
190  }
191 
192  exit(0);
193 }
194 
void Export(TString fname="")
Definition: config.cc:388
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
char parPlugin[1024]
int n
Definition: cwb_net.C:10
char ofile_condor_sub[1024]
TString("c")
char condor_label[1024]
FILE * fP
int j
Definition: cwb_net.C:10
void Import(TString umacro="")
Definition: config.cc:334
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
int cwb_condor_mtpe_jobid
char ifo[NIFO_MAX][8]
bool singleDetector
#define nIFO
ofstream out
Definition: cwb_merge.C:196
char data_label[512]
Definition: test_config1.C:160
TObjArray * token
char log_dir[512]
Definition: test_config1.C:151
double factors[100]
Definition: test_config1.C:84
int cwb_condor_mtpe_offset
sprintf(condor_label,"%s.mtpe", data_label)
strcpy(RunLabel, RUN_LABEL)
nfactor[0]
Definition: cwb_eced.C:10
char condor_log[512]
Definition: test_config1.C:163
TString cwb_uparameters_file
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
char full_condor_out_dir[512]
simulation
Definition: cwb_eced.C:9
fclose(ftrig)
TString config
char full_condor_dir[512]
void SetSingleDetectorMode()
Definition: config.cc:1334
char full_condor_err_dir[512]
exit(0)