-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_submit.py
More file actions
89 lines (73 loc) · 3.6 KB
/
python_submit.py
File metadata and controls
89 lines (73 loc) · 3.6 KB
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
def submitJob(cmd, slurmFile):
import commands, os
if os.path.exists(slurmFile):
print "submitting job using : %s" % cmd
status, jobnum = commands.getstatusoutput(cmd)
return status, jobnum.split()[-1]
else:
print "FATAL ERROR!"
print "file %s doesnt exits" % slurmFile
return (1, '0000') #TODO compatibility with if, return a tuple
def tryJob(jobPrefix, someIndex, queue):
simuLogFile = "log.userLabelListOp_DaiT_0_0p6_"+str(someIndex)
slurmFile = queue
if queue == 'mononode' :
with open(slurmFile,'w') as sf:
sf.write("#!/bin/bash\n")
sf.write("#SBATCH --job-name="+str(jobPrefix)+"_"+str(someIndex)+"\n")
sf.write("#SBATCH --output=job.%j.out\n")
sf.write("#SBATCH --error=job.%j.err\n")
sf.write("#SBATCH --mail-type=ALL\n")
sf.write("#SBATCH --partition=mononode\n")
sf.write("#SBATCH --mem=8000\n")
sf.write("#SBATCH --nodes=1\n")
sf.write("#SBATCH --ntasks=1\n")
sf.write("#SBATCH --cpus-per-task=1\n")
sf.write("##SBATCH --exclusive\n")
sf.write("#SBATCH --time=01:00:00\n\n") # min is the smallest unit here
sf.write("module purge\n")
sf.write("module load OpenMPI/1.6.5-GCC-4.8.3 \n")
sf.write(". /home/lmfa/hluo/LocalSoftware/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc.Opt\n\n")
sf.write("sliceStore=/store/lmfa/fct/hluo/occigen/caseByGeometry/T/shape_square/2a_3_T/sliceStore\n")
sf.write("userLabelListOp_Dai T $sliceStore slice"+str(someIndex)+" -time '0:0.6' > %s\n" % simuLogFile)
sf.close()
elif queue == 'test' :
with open(slurmFile,'w') as sf:
sf.write("#!/bin/bash\n")
sf.write("#SBATCH --job-name="+str(jobPrefix)+"_"+str(someIndex)+"\n")
sf.write("#SBATCH --output=job.%j.out\n")
sf.write("#SBATCH --error=job.%j.err\n")
sf.write("#SBATCH --mail-type=ALL\n")
sf.write("#SBATCH --partition=test\n")
sf.write("#SBATCH --mem=8000\n")
sf.write("#SBATCH --nodes=1\n")
sf.write("#SBATCH --ntasks=1\n")
sf.write("#SBATCH --cpus-per-task=1\n")
sf.write("##SBATCH --exclusive\n")
sf.write("#SBATCH --time=01:00:00\n\n") # min is the smallest unit here
sf.write("module purge\n")
sf.write("module load OpenMPI/1.6.5-GCC-4.8.3 \n")
sf.write(". /home/lmfa/hluo/LocalSoftware/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc.Opt\n\n")
sf.write("sliceStore=/store/lmfa/fct/hluo/occigen/caseByGeometry/T/shape_square/2a_3_T/sliceStore\n")
sf.write("userLabelListOp_Dai T $sliceStore slice"+str(someIndex)+" -time '0:0.6' > %s\n" % simuLogFile)
sf.close()
else:
print "!! no queue named " + queue
cmd = "sbatch %s" % slurmFile
status, jobID = submitJob(cmd, slurmFile)
return jobID
def main():
import sys
jobNamePrefix = sys.argv[1]
queue = sys.argv[2]
sliceList = [0,1,2,3,4,5,6,7,8,9,10,11,12,16,24,32,40,48,56,64,72,73,74,75]
jobList =[]
for slicei in sliceList:
jobList.append(tryJob(jobNamePrefix, slicei, queue))
with open(jobNamePrefix, 'w') as jobListFile:
for jobID in jobList:
jobListFile.write('%s\n' % jobID)
jobListFile.close()
main()