1 | """Simple water flow example using ANUGA |
---|
2 | Water flowing down a channel |
---|
3 | """ |
---|
4 | #------------------------------------------------------------------------------ |
---|
5 | # Import necessary modules |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | import anuga |
---|
8 | import subprocess |
---|
9 | import csv |
---|
10 | import os |
---|
11 | import time |
---|
12 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
13 | from anuga.utilities.log_analyser import analyse_log |
---|
14 | |
---|
15 | #-------------------------------------------------------------------------------------- |
---|
16 | # Set up variables for the correct directories to store the output |
---|
17 | #-------------------------------------------------------------------------------------- |
---|
18 | host = os.getenv('HOST') |
---|
19 | home = os.getenv('INUNDATIONHOME') |
---|
20 | scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"]) |
---|
21 | file1 = 'ex1.csv' |
---|
22 | file_path = os.path.join(scenariodir, file1) |
---|
23 | |
---|
24 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
25 | spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s']) |
---|
26 | |
---|
27 | |
---|
28 | # main loop that runs macpus - 1 times |
---|
29 | maxcpus = 18 |
---|
30 | |
---|
31 | for n in range(1,maxcpus,1): |
---|
32 | z = time.time() # time it |
---|
33 | |
---|
34 | #the necessary ways to run this script in parallel on the different hosts we use |
---|
35 | if (host == 'cyclone.agso.gov.au'): |
---|
36 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
37 | if (host == 'tornado.agso.gov.au'): |
---|
38 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
39 | if (host == 'vayu1'): |
---|
40 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
41 | if (host == 'rhe-compute1.ga.gov.au'): |
---|
42 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) |
---|
43 | if (host == 'xe'): |
---|
44 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
45 | |
---|
46 | y = time.time()# time it |
---|
47 | spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results |
---|
48 | print 'DONE' |
---|
49 | |
---|
50 | analyse_log(scenariodir, 'metalog.csv') # interrogate log files for the memory usage information |
---|