-
Notifications
You must be signed in to change notification settings - Fork 55
/
espsite.py.example.PBSfifompich2
63 lines (52 loc) · 2.58 KB
/
espsite.py.example.PBSfifompich2
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
# cluster-dependent definitions
# espresso.py will make use of all "self" variables in config class
# although not necessary for the installation at the suncat cluster,
# we use a named pipe instead of stdio for sending coordinates back to pw.x
# as an example how to set this up
import os
class config:
def __init__(self):
self.scratch = '/scratch'
if not os.path.exists(self.scratch):
self.scratch = '/tmp'
self.submitdir = os.getenv('PBS_O_WORKDIR')
self.batch = self.submitdir!=None
#check for batch
if self.batch:
nodefile = os.getenv('PBS_NODEFILE')
f = open(nodefile, 'r')
procs = [x.strip() for x in f.readlines()]
f.close()
self.procs = procs
self.jobid = os.getenv('PBS_JOBID')
nprocs = len(procs)
self.nprocs = nprocs
uniqnodefile = self.scratch+'/uniqnodefile'
os.system('uniq $PBS_NODEFILE >'+uniqnodefile)
p = os.popen('wc -l <'+uniqnodefile, 'r')
nnodes = p.readline().strip()
p.close()
self.perHostMpiExec = 'mpiexec -machinefile '+uniqnodefile+' -np '+nnodes
self.perProcMpiExec = 'mpiexec -machinefile '+nodefile+' -np '+str(nprocs)+' -wdir %s %s'
self.perSpecProcMpiExec = 'mpiexec -machinefile %s -np %d -wdir %s %s'
#put mpi and pw.x in path if not already there
p = os.environ['PATH']
os.environ['PATH']='/opt/dft/espresso/bin:/usr/local/mpich2/bin:'+p
#boot mpd if not already done
if not os.environ.has_key('QEASE_MPD_BOOTED'):
os.system('mpdboot -f '+uniqnodefile+' -r ssh -n '+nnodes)
os.system('mpdtrace -l -v')
os.environ['QEASE_MPD_BOOTED'] = 'yes'
self.mpdshutdown = 'mpdallexit'
def do_perProcMpiExec(self, workdir, program):
os.system(self.fifogen%workdir)
o = os.popen(self.perProcMpiExec % (workdir, program), 'r')
return open(workdir+'/ase3inpfifo', 'w+'), o
def do_perProcMpiExec_outputonly(self, workdir, program):
return os.popen(self.perProcMpiExec % (workdir, program), 'r')
def runonly_perProcMpiExec(self, workdir, program):
os.system(self.perProcMpiExec % (workdir, program))
def do_perSpecProcMpiExec(self, machinefile, nproc, workdir, program):
os.system(self.fifogen%workdir)
i,o,e = os.popen3(self.perSpecProcMpiExec % (machinefile, nproc, workdir, program))
return open(workdir+'/ase3inpfifo', 'w+'), o, e