updated slave to take options

This commit is contained in:
Stephen McQuay 2011-03-30 10:36:20 -06:00
parent 7285da3566
commit d4aea22e0b

View File

@ -4,11 +4,13 @@ import sys
from multiprocessing.managers import BaseManager from multiprocessing.managers import BaseManager
from optparse import OptionParser
import numpy as np import numpy as np
import interp.bootstrap import interp.bootstrap
from interp.grid.gmsh import gmsh_grid3D from interp.grid.gmsh import ggrid
from interp.tools import exact from interp.tools import baker_exact_3D as exact
class QueueManager(BaseManager): pass class QueueManager(BaseManager): pass
QueueManager.register('get_inqueue' ) QueueManager.register('get_inqueue' )
@ -16,21 +18,39 @@ QueueManager.register('get_outqueue')
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 3: parser = OptionParser(usage = "usage: %s [options] <server> <gmsh file>")
print >> sys.stderr, "usage: %s <gmsh file> <id>" % sys.argv[0]
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) 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() m.connect()
inq = m.get_inqueue() inq = m.get_inqueue()
outq = m.get_outqueue() 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]) g.q = np.array([exact(x) for x in g.verts])
my_name = sys.argv[2]
while True: while True:
i, X = inq.get() i, o, e, X = inq.get()
a = g.run_baker(X, order = 3, extra_points = 32) if i == None:
outq.put((i, my_name, a['qlin'], a['error'], a['final'], exact(X))) 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