2011-03-02 22:51:43 -08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
2011-03-31 20:19:20 -07:00
|
|
|
import os
|
2011-03-30 22:09:10 -07:00
|
|
|
import time
|
2011-03-02 22:51:43 -08:00
|
|
|
|
|
|
|
from multiprocessing.managers import BaseManager
|
|
|
|
|
2011-03-30 09:36:20 -07:00
|
|
|
from optparse import OptionParser
|
2011-03-30 21:29:04 -07:00
|
|
|
import datetime
|
2011-03-30 09:36:20 -07:00
|
|
|
|
2011-03-02 23:20:03 -08:00
|
|
|
import numpy as np
|
|
|
|
|
2011-03-02 22:51:43 -08:00
|
|
|
import interp.bootstrap
|
2011-03-30 09:36:20 -07:00
|
|
|
from interp.grid.gmsh import ggrid
|
|
|
|
from interp.tools import baker_exact_3D as exact
|
2011-03-02 22:51:43 -08:00
|
|
|
|
2011-04-01 23:10:29 -07:00
|
|
|
from interp.cluster import QueueManager, get_qs
|
2011-03-02 22:51:43 -08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-03-30 09:36:20 -07:00
|
|
|
parser = OptionParser(usage = "usage: %s [options] <server> <gmsh file>")
|
|
|
|
|
2011-04-01 23:10:29 -07:00
|
|
|
parser.add_option("-v", "--verbose",
|
|
|
|
action="store_true", dest="verbose", default=False,
|
2011-05-08 12:39:19 -07:00
|
|
|
help="verbose flag (default: %default)")
|
2011-03-30 09:36:20 -07:00
|
|
|
|
|
|
|
parser.add_option('-p', '--port',
|
2011-03-30 18:45:47 -07:00
|
|
|
type="int", dest="port", default=6666,
|
2011-03-30 09:36:20 -07:00
|
|
|
help="specify the port to use on the server (default: %default)")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
2011-03-30 20:34:44 -07:00
|
|
|
|
2011-03-30 09:36:20 -07:00
|
|
|
if len(args) != 2:
|
|
|
|
parser.print_usage()
|
2011-03-02 22:51:43 -08:00
|
|
|
sys.exit(1)
|
2011-03-30 09:36:20 -07:00
|
|
|
|
|
|
|
server, input_file = args
|
|
|
|
|
2011-05-08 19:43:43 -07:00
|
|
|
myname = "%s-%d" % (os.uname()[1], os.getpid())
|
|
|
|
if options.verbose:
|
|
|
|
print "%s: started" % myname
|
|
|
|
|
|
|
|
|
2011-03-30 18:45:47 -07:00
|
|
|
m = QueueManager(address=(server, options.port), authkey='asdf')
|
2011-03-02 22:51:43 -08:00
|
|
|
m.connect()
|
|
|
|
|
2011-05-08 12:36:06 -07:00
|
|
|
tasksq, resultsq, masterq, minionsq = get_qs(m)
|
2011-03-02 22:51:43 -08:00
|
|
|
|
2011-05-08 19:43:43 -07:00
|
|
|
if options.verbose:
|
|
|
|
print "%s: starting parse input file" % myname
|
2011-03-30 09:36:20 -07:00
|
|
|
g = ggrid(input_file)
|
2011-03-02 23:20:03 -08:00
|
|
|
g.q = np.array([exact(x) for x in g.verts])
|
2011-04-01 23:10:29 -07:00
|
|
|
if options.verbose:
|
2011-05-08 19:43:43 -07:00
|
|
|
print "%s: done parsing input file" % myname
|
2011-03-30 22:09:10 -07:00
|
|
|
|
2011-04-02 00:20:59 -07:00
|
|
|
|
2011-04-01 23:10:29 -07:00
|
|
|
while True:
|
2011-05-08 19:43:43 -07:00
|
|
|
if options.verbose:
|
|
|
|
print "%s: letting master know that I am ready" % myname
|
2011-04-01 23:10:29 -07:00
|
|
|
masterq.put(myname)
|
2011-05-08 19:46:45 -07:00
|
|
|
|
2011-05-08 19:43:43 -07:00
|
|
|
if options.verbose:
|
|
|
|
print "%s: waiting for master to tell me to start" % myname
|
2011-05-08 12:36:06 -07:00
|
|
|
action = minionsq.get()
|
2011-05-08 19:46:45 -07:00
|
|
|
if options.verbose:
|
|
|
|
print "%s: master said go!!" % myname
|
|
|
|
|
2011-05-08 19:43:43 -07:00
|
|
|
if action in ('teardown', 'slay'):
|
2011-04-01 23:10:29 -07:00
|
|
|
break
|
|
|
|
|
|
|
|
while not tasksq.empty():
|
|
|
|
i, o, e, X = tasksq.get()
|
|
|
|
try:
|
|
|
|
a = g.run_baker(X, order = o, extra_points = e)
|
|
|
|
resultsq.put((i, myname, a['qlin'], a['error'], a['final'], exact(X)))
|
|
|
|
except Exception as e:
|
|
|
|
print X, e
|
|
|
|
resultsq.put((i, myname, 0.0, 0.0, 0.0, 0.0))
|
|
|
|
|
|
|
|
if options.verbose:
|
2011-05-08 19:50:55 -07:00
|
|
|
print "%s: exiting" % myname
|