Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_condor_sdag.C
Go to the documentation of this file.
1 // read the standard *.dag file produced with cwb_condor create and produced a new dag file *.sdag
2 // The *.sdag permits to submit in each node N jobs in sequential mode
3 // This solution speedup the submission of jobs when the job execution time is too short
4 
5 {
6  #include <vector>
7 
9 
10  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
11  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
12  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
13 
14  int cwb_condor_njobs=-1; // slag>0
15  if(gSystem->Getenv("CWB_CONDOR_NJOBS")==NULL) {
16  cout << "Error : environment CWB_CONDOR_NJOBS is not defined!!!" << endl;exit(1);
17  }
18  if(TString(gSystem->Getenv("CWB_CONDOR_NJOBS")).IsDigit()) {
19  cwb_condor_njobs=TString(gSystem->Getenv("CWB_CONDOR_NJOBS")).Atoi();
20  }
21  if(cwb_condor_njobs<=1) {
22  cout << "cwb_condor_sdag.C - Error : nJOBS must be >1" << endl;
23  gSystem->Exit(1);
24  }
25 
26  cout << cwb_condor_njobs << endl;
27 
28  // get condor dag
29  char full_condor_dir[512];
30  sprintf(full_condor_dir,"%s/%s",work_dir,condor_dir);
31  TString cwb_condor_dag = TString::Format("%s/%s.dag",condor_dir,data_label);
32  TB.checkFile(cwb_condor_dag,false);
33  if(gSystem->Getenv("CWB_CONDOR_DAG")!=NULL) {
34  // user define condor tag
35  TString cwb_condor_dag=TString(gSystem->Getenv("CWB_CONDOR_DAG"));
36  }
37  if(!cwb_condor_dag.Contains(".dag")) {
38  cout << "cwb_condor_sdag.C - Error : dag file name must contains '.dag'" << endl;
39  gSystem->Exit(1);
40  }
41 
42  vector<int> jobList=TB.getCondorJobList(full_condor_dir, data_label);
43 
45  cwb_condor_sdag.ReplaceAll(".dag",".sdag");
46  cout << cwb_condor_sdag << endl;
47 
48  TB.checkFile(cwb_condor_sdag,true);
49 
50  ofstream out;
51  out.open(cwb_condor_sdag.Data(),ios::out);
52  if (!out.good()) {cout << "cwb_condor_sdag.C - Error Opening File : " << cwb_condor_sdag << endl;exit(1);}
53 
54  ifstream in;
55  in.open(cwb_condor_dag.Data(),ios::in);
56  if (!in.good()) {cout << "cwb_condor_dag.C - Error Opening File : " << cwb_condor_dag << endl;exit(1);}
57 
58  // copy dag to sdag
59  char istr[1024];
60  while(true) {
61  in.getline(istr,1024);
62  if (!in.good()) break;
63  out << istr << endl;
64  }
65  in.close();
66 
67  // add super jobs instructions to sdag file
68  out << endl;
69  int nsjob=0;
70  for(int i=0;i<jobList.size();i++) {
71  for(int j=1;j<cwb_condor_njobs && i<jobList.size()-1;j++) {
72  out << "PARENT A" << jobList[i] << " CHILD A" << jobList[i+1] << endl;
73  //cout << i << " " << j << " jobId : " << jobList[i] << endl;
74  i++;
75  }
76  out << endl;
77  nsjob++;
78  }
79 
80  out.close();
81 
82  cout << endl << "Created new sdag file : " << cwb_condor_sdag << endl << endl;
83 
84  cout << "Number of job files : " << jobList.size() << endl;
85  cout << "Number of sjob files : " << nsjob << endl << endl;
86 
87  exit(0);
88 }
TString("c")
int cwb_condor_njobs
int j
Definition: cwb_net.C:10
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
CWB::Toolbox TB
Definition: ComputeSNR.C:5
ofstream out
Definition: cwb_merge.C:196
char data_label[512]
Definition: test_config1.C:160
TString cwb_condor_dag
vector< int > jobList
TString cwb_condor_sdag
static vector< int > getCondorJobList(TString condor_dir, TString label)
Definition: Toolbox.cc:1378
ifstream in
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
char full_condor_dir[512]
exit(0)