forked from lkwagner/autogenv2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPySCFRunner.py
148 lines (134 loc) · 4.44 KB
/
PySCFRunner.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
145
146
147
148
from __future__ import print_function
import os
import sys
import numpy as np
import subprocess as sub
import shutil
import submitter
from submitter import LocalSubmitter
class LocalPySCFRunner(LocalSubmitter):
def __init__(self, BIN=''):
self.BIN=BIN
self.np=1
self.nn=1
self.jobname='ag_pyscf'
self._queueid=None
#-------------------------------------------------
def check_status(self):
# This is only for a queue, so just never return 'running'.
return 'ok'
#-------------------------------------------------
def run(self,inpfn,outfn):
# TODO This code organization doesn't match CRYSTAL.
""" Submits executibles using _qsub. """
exe = self.BIN+"python3 %s"%inpfn[0]
prep_commands = []
final_commands = []
loc = os.getcwd()
qids=self._qsub(exe,prep_commands,final_commands,self.jobname,outfn[0],loc)
self._queueid=qids
####################################################
class PySCFRunnerPBS:
_name_='PySCFRunnerPBS'
def __init__(self,queue='batch',
walltime='12:00:00',
np=1,
nn=1,
jobname=os.getcwd().split('/')[-1]+'_pyscf',
prefix="",#for example, load modules
postfix=""#for example, remove tmp files.
):
self.np=np
if nn!=1: raise NotImplementedError
self.nn=nn
self.jobname=jobname
self.queue=queue
self.walltime=walltime
self.prefix=prefix
self.postfix=postfix
self.queueid=None
#-------------------------------------
def check_status(self):
return submitter.check_PBS_status(self.queueid)
#-------------------------------------
def run(self,inpfns,outfns):
#just running in serial for now
exe="python3"
for pyscf_driver,pyscf_out in zip(inpfns,outfns):
jobout=pyscf_driver+".jobout"
qsublines=[
"#PBS -q %s"%self.queue,
"#PBS -l nodes=%i:ppn=%i"%(self.nn,self.np),
"#PBS -l walltime=%s"%self.walltime,
"#PBS -j oe",
"#PBS -N %s"%self.jobname,
"#PBS -o %s"%jobout,
self.prefix,
"export OMP_NUM_THREADS=%i"%(self.np),
"cd ${PBS_O_WORKDIR}",
"export PYTHONPATH=%s"%(':'.join(sys.path)),
"%s %s > %s \n"%(exe,pyscf_driver,pyscf_out),
self.postfix
]
qsubfile=pyscf_driver+".qsub"
with open(qsubfile,'w') as f:
f.write('\n'.join(qsublines))
result = sub.check_output("qsub %s"%(qsubfile),shell=True)
self.queueid = result.decode().split()[0]
print("Submitted as %s"%self.queueid)
class PySCFRunnerTaub:
_name_='PySCFRunnerPBS'
def __init__(self,queue='secondary',
walltime='12:00:00',
np=None,
nn=1,
jobname=os.getcwd().split('/')[-1]+'_pyscf',
prefix="",#for example, load modules
postfix=""#for example, remove tmp files.
):
self.np=np
if nn!=1: raise NotImplementedError
self.nn=nn
self.jobname=jobname
self.queue=queue
self.walltime=walltime
self.prefix=prefix
self.postfix=postfix
self.queueid=None
#-------------------------------------
def check_status(self):
return submitter.check_PBS_status(self.queueid)
#-------------------------------------
def run(self,inpfns,outfns):
#just running in serial for now
exe="python3"
for pyscf_driver,pyscf_out in zip(inpfns,outfns):
jobout=pyscf_driver+".jobout"
qsublines=[
"#PBS -q %s"%self.queue,
]
if self.np is None:
qsublines+=[
"#PBS -l nodes=%i,flags=allprocs"%self.nn,
]
else:
qsublines+=[
"#PBS -l nodes=%i:ppn=%i"%(self.nn,self.np),
]
qsublines+=[
"#PBS -l walltime=%s"%self.walltime,
"#PBS -j oe",
"#PBS -N %s"%self.jobname,
"#PBS -o %s"%jobout,
self.prefix,
"cd ${PBS_O_WORKDIR}",
"export PYTHONPATH=%s"%(':'.join(sys.path)),
"%s %s > %s \n"%(exe,pyscf_driver,pyscf_out),
self.postfix
]
qsubfile=pyscf_driver+".qsub"
with open(qsubfile,'w') as f:
f.write('\n'.join(qsublines))
result = sub.check_output("qsub %s"%(qsubfile),shell=True)
self.queueid = result.decode().split()[0]
print("Submitted as %s"%self.queueid)