updated slave to take options
This commit is contained in:
parent
7285da3566
commit
d4aea22e0b
40
bin/slave.py
40
bin/slave.py
@ -4,11 +4,13 @@ import sys
|
||||
|
||||
from multiprocessing.managers import BaseManager
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
import interp.bootstrap
|
||||
from interp.grid.gmsh import gmsh_grid3D
|
||||
from interp.tools import exact
|
||||
from interp.grid.gmsh import ggrid
|
||||
from interp.tools import baker_exact_3D as exact
|
||||
|
||||
class QueueManager(BaseManager): pass
|
||||
QueueManager.register('get_inqueue' )
|
||||
@ -16,21 +18,39 @@ QueueManager.register('get_outqueue')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >> sys.stderr, "usage: %s <gmsh file> <id>" % sys.argv[0]
|
||||
parser = OptionParser(usage = "usage: %s [options] <server> <gmsh file>")
|
||||
|
||||
parser.add_option('-l', '--label',
|
||||
type="str", dest="label", default='jane',
|
||||
help="specify this slave's response label (default: %default)")
|
||||
|
||||
parser.add_option('-p', '--port',
|
||||
type="int", dest="port", default='6666',
|
||||
help="specify the port to use on the server (default: %default)")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 2:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
m = QueueManager(address=('gannon', 50000), authkey='asdf')
|
||||
|
||||
server, input_file = args
|
||||
myname = options.label
|
||||
|
||||
m = QueueManager(address=(server, 50000), authkey='asdf')
|
||||
m.connect()
|
||||
|
||||
inq = m.get_inqueue()
|
||||
outq = m.get_outqueue()
|
||||
|
||||
g = gmsh_grid3D(sys.argv[1])
|
||||
g = ggrid(input_file)
|
||||
g.q = np.array([exact(x) for x in g.verts])
|
||||
|
||||
my_name = sys.argv[2]
|
||||
|
||||
while True:
|
||||
i, X = inq.get()
|
||||
a = g.run_baker(X, order = 3, extra_points = 32)
|
||||
outq.put((i, my_name, a['qlin'], a['error'], a['final'], exact(X)))
|
||||
i, o, e, X = inq.get()
|
||||
if i == None:
|
||||
break
|
||||
a = g.run_baker(X, order = o, extra_points = e)
|
||||
outq.put((i, myname, a['qlin'], a['error'], a['final'], exact(X)))
|
||||
|
||||
print "%s finished" % myname
|
||||
|
Loading…
Reference in New Issue
Block a user