-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReSubmit.py
executable file
·144 lines (131 loc) · 6.3 KB
/
ReSubmit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python
from RunParams import *
from GetAndCheckData import *
from CreateFortFiles import *
import sys
import subprocess
import commands
DefParams = [it_sst[0],ProjectorList[0],DSList[0]]
def IncrementRun(stage,ism,tsink,Projector,DS):
if 'twoptprop' in stage:
stage = 'twoptcorr'
return [stage,ism]+DefParams
if 'twoptcorr' in stage:
if OnlyTwoPt:
if ism == ismlist[-1]:
stage,ism,tsink,Projector,DS = ['Done',ismlist[0]]+DefParams
else:
stage,ism,tsink,Projector,DS = ['twoptprop',ismlist[ismlist.index(ism)+1]]+DefParams
return stage,ism,tsink,Projector,DS
else:
stage = 'threeptcorr'
return [stage,ism]+DefParams
if 'threeptcorr' in stage:
if tsink == it_sst[-1]:
if Projector == ProjectorList[-1]:
if DS == DSList[-1]:
if ism == ismlist[-1]:
stage,ism,tsink,Projector,DS = ['Done',ismlist[0]]+DefParams
else:
stage,ism,tsink,Projector,DS = ['twoptprop',ismlist[ismlist.index(ism)+1]]+DefParams
else:
tsink = it_sst[0]
Projector = ProjectorList[0]
DS = DSList[DSList.index(DS)+1]
else:
tsink = it_sst[0]
Projector = ProjectorList[ProjectorList.index(Projector)+1]
else:
tsink = it_sst[it_sst.index(tsink)+1]
return stage,ism,tsink,Projector,DS
def RunNext(icfg,fcfg,gfos,stage='twoptprop',ism=ismlist[0],Failed='Success',tsink=it_sst[0],Projector=ProjectorList[0],DS=DSList[0],Start=False):
icfg,fcfg,gfos,ism,tsink,Projector = map(int,[icfg,fcfg,gfos,ism,tsink,Projector])
#removes fort parameter files
if 'twoptprop' in stage:
Remove2ptPropFiles(FortFolder,FortFileFlag,icfg,gfos,[ism])
elif 'twoptcorr' in stage:
Remove2ptCorrFiles(FortFolder,FortFileFlag,icfg,gfos,[ism])
elif 'threeptcorr' in stage:
Remove3ptCorrFiles(FortFolder,FortFileFlag,icfg,gfos,[ism],[DS],[Projector],[tsink])
#check if whole run is done
if Failed == 'Failed':
print 'Error with Configuration ' + str(icfg) + ' source ' + str(gfos)
RemoveProp(icfg,gfos,ismlist)
RemoveGaugeField(icfg,gfos)
Remove2ptCorr(icfg,gfos,ismlist,jsmlist)
Remove3ptCorr(icfg,gfos,ismlist,it_sst,ProjectorList,DSList)
if icfg<fcfg:
RunNext(icfg+1,fcfg,gfos,Start=True)
return
else:
print 'All Complete'
return
if OnlyTwoPt:
boolcheck = Check2ptCorr(icfg,gfos,[ism],jsmlist)
else:
boolcheck = Check2ptCorr(icfg,gfos,[ism],jsmlist) and Check3ptCorr(icfg,gfos,[ism],it_sst,ProjectorList,DSList)
if boolcheck:
RemoveProp(icfg,gfos,[ism])
if ism == ismlist[-1]:
RemoveGaugeField(icfg,gfos)
if icfg<fcfg:
RunNext(icfg+1,fcfg,gfos,Start=True)
return
else:
print 'All Complete'
return
else:
RunNext(icfg,fcfg,gfos,ism=ismlist[ismlist.index(ism)+1],Start=True)
return
GetGaugeField(icfg,gfos)
Move2ptCorr(icfg,gfos,[ism],jsmlist)
prevism = ism
if not Start: stage,ism,tsink,Projector,DS = IncrementRun(stage,ism,tsink,Projector,DS)
StillInc = True
while StillInc:
StillInc = False
if 'twoptprop' in stage:
if Check2ptProp(icfg,gfos,[ism]):
stage,ism,tsink,Projector,DS = IncrementRun(stage,ism,tsink,Projector,DS)
StillInc = True
elif 'twoptcorr' in stage:
Move2ptCorr(icfg,gfos,[ism],jsmlist)
if Check2ptCorr(icfg,gfos,[ism],jsmlist):
stage,ism,tsink,Projector,DS = IncrementRun(stage,ism,tsink,Projector,DS)
if 'Done' not in stage: StillInc = True
elif 'threeptcorr' in stage:
if Check3ptCorr(icfg,gfos,[ism],[tsink],[Projector],[DS]):
stage,ism,tsink,Projector,DS = IncrementRun(stage,ism,tsink,Projector,DS)
if 'Done' not in stage: StillInc = True
if prevism != ism:
RemoveProp(icfg,gfos,[prevism])
if 'twoptprop' in stage:
[thisjobid] = Create2ptPropFiles(FortFolder,FortFileFlag,icfg,gfos,[ism])
Jstring = str(icfg)+'-'+str(fcfg)+'-S'+str(gfos)+'-sm'+str(ism)
sbatchstring = ('sbatch -J '+Jstring+' --export=ALL,gfos='+str(gfos)+',ism='+str(ism)+
',icfg='+str(icfg)+',fcfg='+str(fcfg)+',jobid='+str(thisjobid)+',mach='+str(thismachine)+' '+str(scriptdir)+'Run2ptProp'+thismachine+'.csh')
print sbatchstring
subprocess.call(sbatchstring.split(),cwd=basedir)
elif 'twoptcorr' in stage:
[thisjobid] = Create2ptCorrFiles(FortFolder,FortFileFlag,icfg,gfos,[ism])
Jstring = str(icfg)+'-'+str(fcfg)+'-S'+str(gfos)+'-sm'+str(ism)
sbatchstring = ('sbatch -J '+Jstring+' --export=ALL,gfos='+str(gfos)+',ism='+str(ism)+
',icfg='+str(icfg)+',fcfg='+str(fcfg)+',jobid='+str(thisjobid)+',mach='+str(thismachine)+' '+str(scriptdir)+'Run2ptCorr'+thismachine+'.csh')
print sbatchstring
subprocess.call(sbatchstring.split(),cwd=basedir)
elif 'threeptcorr' in stage:
[thisjobid] = Create3ptCorrFiles(FortFolder,FortFileFlag,icfg,gfos,[ism],[DS],[Projector],[tsink])
mkdir_p(Get3ptCorrFolder(icfg,gfos,ism,tsink,Projector,DS))
Jstring = str(icfg)+'-'+str(fcfg)+'-S'+str(gfos)+'-sm'+str(ism)+'-ts'+str(tsink)+'-P'+str(Projector)+'-'+DS[0]
sbatchstring = ('sbatch -J '+Jstring+' --export=ALL,gfos='+str(gfos)+',ism='+str(ism)+
',tsink='+str(tsink)+',Projector='+str(Projector)+',DS='+str(DS)+
',icfg='+str(icfg)+',fcfg='+str(fcfg)+',jobid='+str(thisjobid)+',mach='+str(thismachine)+' '+str(scriptdir)+'Run3ptCorr'+thismachine+'.csh')
print sbatchstring
subprocess.call(sbatchstring.split(),cwd=basedir)
elif 'Done' in stage:
if icfg<fcfg:
RunNext(icfg+1,fcfg,gfos,Start=True)
else:
print 'All Complete'
if len(sys.argv) > 1 and 'ReSubmit' in sys.argv[0]:
RunNext(*sys.argv[1:])