Changeset 8421
- Timestamp:
- May 8, 2012, 7:25:37 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py
r8301 r8421 28 28 29 29 30 """test_that_culvert_runs_rating 31 32 This test exercises the culvert and checks values outside rating curve 33 are dealt with 30 """ 31 32 This test exercises the parallel culvert and checks values 34 33 """ 35 34 verbose = True 36 path = get_pathname_from_package('anuga.culvert_flows') 35 nprocs = 2 36 37 37 38 38 length = 40. … … 286 286 287 287 288 # Test an nprocs-way run of the shallow water equations 289 # against the sequential code. 290 291 class Test_parallel_shallow_domain(unittest.TestCase): 292 def test_parallel_shallow_domain(self): 293 #print "Expect this test to fail if not run from the parallel directory." 294 result = os.system("mpirun -np %d python test_parallel_shallow_domain.py" % nprocs) 295 assert_(result == 0) 296 297 298 # Because we are doing assertions outside of the TestCase class 299 # the PyUnit defined assert_ function can't be used. 300 def assert_(condition, msg="Assertion Failed"): 301 if condition == False: 302 #pypar.finalize() 303 raise AssertionError, msg 304 288 305 if __name__=="__main__": 289 290 test_points = [] 291 292 if myid == 0: 293 294 for i in range(samples): 295 x = random.randrange(0,1000)/1000.0 * length 296 y = random.randrange(0,1000)/1000.0 * width 297 point = [x, y] 298 test_points.append(point) 299 300 for i in range(1,numprocs): 301 pypar.send(test_points, i) 306 if numprocs == 1: 307 runner = unittest.TextTestRunner() 308 suite = unittest.makeSuite(Test_parallel_shallow_domain, 'test') 309 runner.run(suite) 302 310 else: 303 test_points = pypar.receive(0) 304 305 #print "Test Points::" 306 #print test_points 307 308 if myid == 0: 309 control_data = run_test(parallel=False, test_points = test_points, verbose = True) 310 311 for proc in range(1,numprocs): 312 pypar.send(control_data, proc) 313 else: 314 control_data = pypar.receive(0) 315 316 pypar.barrier() 317 run_test(parallel=True, control_data = control_data, test_points = test_points, verbose = True) 318 319 320 finalize() 311 312 pypar.barrier() 313 test_points = [] 314 315 if myid == 0: 316 if verbose: print 'PARALLEL START' 317 for i in range(samples): 318 x = random.randrange(0,1000)/1000.0 * length 319 y = random.randrange(0,1000)/1000.0 * width 320 point = [x, y] 321 test_points.append(point) 322 323 for i in range(1,numprocs): 324 pypar.send(test_points, i) 325 else: 326 test_points = pypar.receive(0) 327 328 if myid == 0: 329 control_data = run_test(parallel=False, test_points = test_points, verbose = True) 330 331 for proc in range(1,numprocs): 332 pypar.send(control_data, proc) 333 else: 334 control_data = pypar.receive(0) 335 336 337 pypar.barrier() 338 run_test(parallel=True, control_data = control_data, test_points = test_points, verbose = True) 339 340 341 finalize() 342 s 343
Note: See TracChangeset
for help on using the changeset viewer.