Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_condor_submit.C
Go to the documentation of this file.
1 // submit condor jobs : used by the cwb_condor command
2 
3 {
5  char cmd[1024];
6 
7  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
8  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
9  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
10 
11  // get condor dag
13  if(gSystem->Getenv("CWB_CONDOR_DAG")!=NULL) {
14  // user define condor tag
15  cwb_condor_dag=TString(gSystem->Getenv("CWB_CONDOR_DAG"));
16  //strip '/' from path
17  TObjArray* token = cwb_condor_dag.Tokenize(TString('/'));
18  TObjString* stoken =(TObjString*)token->At(token->GetEntries()-1);
19  cwb_condor_dag = stoken->GetString();
20  }
21 
22  // get pegasus site
24  if(gSystem->Getenv("CWB_PEGASUS_USITE")!=NULL) {
25  // user define pegasus site
26  TString cwb_pegasus_usite=TString(gSystem->Getenv("CWB_PEGASUS_USITE"));
27  }
28 
29  // get workflow file (used by pegasus)
31  cwb_condor_workflow.ReplaceAll(".","_"); // pegasus do not accept '.'
32  char workflowfile[1024];
33  sprintf(workflowfile,"%s/%s",condor_dir,cwb_condor_workflow.Data());
34 
35  // get job batch command
36  TString batch_cmd = "condor_submit_dag";
37  TString cwb_scripts = TString(gSystem->Getenv("CWB_SCRIPTS"));
38  if(gSystem->Getenv("_USE_PEGASUS")!=NULL) batch_cmd = cwb_scripts+"/cwb_pegasus_submit.sh";
39  if(gSystem->Getenv("_USE_LSF")!=NULL) batch_cmd = cwb_scripts+"/cwb_lsf_submit.sh";
40 
41  if(gSystem->Getenv("_USE_PEGASUS")!=NULL) {
42 
43  // Check if pagasus work file already exist
44  Long_t id,size,flags,mt;
45  int estat = gSystem->GetPathInfo(workflowfile,&id,&size,&flags,&mt);
46  if (estat==0) {
47  char answer[256];
48  strcpy(answer,"");
49  do {
50  cout << "File \"" << workflowfile << "\" already exist" << endl;
51  cout << "Do you want to submit again ? (y/n) ";
52  cin >> answer;
53  cout << endl << endl;
54  } while ((strcmp(answer,"y")!=0)&&(strcmp(answer,"n")!=0));
55  if (strcmp(answer,"n")==0) {
56  exit(0);
57  } else {
58  sprintf(cmd,"rm %s",workflowfile);
59  int ret=gSystem->Exec(cmd);
60  if(ret) {cout << "Error while executing " << cmd << " !!!" << endl;exit(1);}
61  }
62  }
63  }
64 
65  if(cwb_condor_dag=="") {
66  sprintf(cmd,"cd %s/%s;%s %s.dag %s",
67  work_dir,condor_dir,batch_cmd.Data(),data_label,cwb_pegasus_usite.Data());
68  } else {
69  sprintf(cmd,"cd %s/%s;%s %s %s",
70  work_dir,condor_dir,batch_cmd.Data(),cwb_condor_dag.Data(),cwb_pegasus_usite.Data());
71  }
72  cout << cmd << endl;
73  int ret=gSystem->Exec(cmd);
74  if(ret) {cout << "Error while executing " << batch_cmd << " !!!" << endl;exit(1);}
75 
76  if(gSystem->Getenv("_USE_LSF")!=NULL) {
77  cout << endl << endl;
78  cout << "Your LSF jobs has been submitted" << endl;
79  cout << "To monitor the jobs do : cwb_lsf status" << endl;
80  cout << "To monitor the queue : cwb_lsf queue" << endl;
81  cout << "To kill the all jobs do : cwb_lsf kill" << endl;
82  cout << "To resubmit paused jobs do : cwb_lsf resume" << endl;
83  cout << "To suspend all jobs do : cwb_lsf stop" << endl << endl;
84  }
85 
86  if(gSystem->Getenv("_USE_PEGASUS")!=NULL) {
87  sprintf(cmd, "cd %s;ls -1 -trd workflows/*/pegasus/cwb/* | tail -n 1 | awk 'BEGIN { OFS = \"\"; ORS = \"\" } ; {print $1}; {print \" %s\"}' | xargs ln -sf",condor_dir,data_label);
88  cout << cmd << endl;
89  int ret=gSystem->Exec(cmd);
90  if(ret) {cout << "Error while executing " << cmd << " !!!" << endl;exit(1);}
91  sprintf(cmd, "ln -sfn %s/%s pegasus",condor_dir,data_label);
92  cout << cmd << endl;
93  ret=gSystem->Exec(cmd);
94  cout << endl << endl;
95  cout << "Your workflow has been started and is running in the base directory: " << endl;
96  cout << workflowfile << endl << endl;
97  cout << "To monitor the workflow do : cwb_pstatus" << endl;
98  cout << "To remove the workflow do : cwb_premove" << endl;
99  cout << "To resubmit an aborted or failed workflow do : cwb_prun" << endl;
100  cout << "To analyze the workflow do : cwb_panalyzer" << endl << endl;
101  }
102 
103  gSystem->Exit(0);
104 }
TString cwb_scripts
TString("c")
char cmd[1024]
Long_t flags
Long_t size
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
char workflowfile[1024]
CWB::Toolbox TB
Definition: ComputeSNR.C:5
char data_label[512]
Definition: test_config1.C:160
TString cwb_condor_dag
TObjArray * token
char answer[256]
TString cwb_condor_workflow
int estat
strcpy(RunLabel, RUN_LABEL)
sprintf(workflowfile,"%s/%s", condor_dir, cwb_condor_workflow.Data())
TString cwb_pegasus_usite
Long_t mt
Long_t id
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
TString batch_cmd
exit(0)