forked from kunyuan/FeynCalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.py
executable file
·88 lines (72 loc) · 2.55 KB
/
send.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
#!/usr/bin/python
import random
import os
import sys
##### Modify parameters here ###############
# Cluster="PBS"
Cluster = "local"
# Cluster="condor"
############################################
rootdir = os.getcwd()
execute = "feyncalc.exe"
assert len(sys.argv)==2, "Number of jobs is needed."
Number=int(sys.argv[1])
print "Creating {0} jobs...".format(Number)
PIDList=range(Number)
# if int(para[-2])==0:
# title="freq"
# elif int(para[-2])==1:
# title="eqTime"
# else:
# print "Not yet implemented!"
# break
homedir = os.getcwd() + "/data"
if(os.path.exists(homedir) != True):
os.system("mkdir "+homedir)
os.system("cp -r groups* "+homedir)
os.system("cp {0} {1}".format(execute, homedir))
os.system("cp reweight.data "+homedir)
os.system("cp parameter "+homedir)
outfilepath = homedir+"/outfile"
if(os.path.exists(outfilepath) != True):
os.system("mkdir "+outfilepath)
jobfilepath = homedir+"/jobfile"
if(os.path.exists(jobfilepath) != True):
os.system("mkdir "+jobfilepath)
for pid in PIDList:
### terminal output goes here #############
outfile = "_out"+str(pid)
### job file to submit to cluster ########
jobfile = "_job"+str(pid)+".sh"
if Cluster == "local":
os.chdir(homedir)
os.system("./"+execute+" > "+outfilepath+"/"+outfile+" &")
os.chdir("..")
elif Cluster == "condor":
with open(jobfilepath+"/"+jobfile, "w") as fjob:
fjob.write("executable = {0}\n".format(execute))
fjob.write("output ={0}/{1}\n".format(outfilepath, outfile))
fjob.write("initialdir ={0}\n".format(homedir))
fjob.write("queue")
os.chdir(homedir)
os.system("condor_submit {0}/{1}".format(jobfilepath, jobfile))
os.system("rm "+jobfilepath + "/"+jobfile)
os.chdir("..")
elif Cluster == "PBS":
with open(jobfilepath+"/"+jobfile, "w") as fjob:
fjob.write("#!/bin/sh\n"+"#PBS -N "+jobfile+"\n")
fjob.write("#PBS -o "+homedir+"/Output\n")
fjob.write("#PBS -e "+homedir+"/Error\n")
fjob.write("#PBS -l walltime=2000:00:00\n")
fjob.write("echo $PBS_JOBID >>"+homedir+"/id_job.log\n")
fjob.write("cd "+homedir+"\n")
fjob.write("./"+execute+" > "+outfilepath+"/"+outfile)
os.chdir(homedir)
os.system("qsub "+jobfilepath + "/"+jobfile)
os.system("rm "+jobfilepath + "/"+jobfile)
os.chdir("..")
else:
print("I don't know what is {0}".format(Cluster))
break
print("Jobs manage daemon is ended")
sys.exit(0)