1 | """Simple water flow example using ANUGA |
---|
2 | Water flowing down a channel |
---|
3 | """ |
---|
4 | #------------------------------------------------------------------------------ |
---|
5 | # Import necessary modules |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | # Import standard shallow water domain and standard boundaries. |
---|
8 | import anuga |
---|
9 | import random |
---|
10 | import subprocess |
---|
11 | import csv |
---|
12 | import os |
---|
13 | import time |
---|
14 | import liststore |
---|
15 | from anuga.utilities import system_tools, log |
---|
16 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
17 | |
---|
18 | |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | # Setup computational domain |
---|
21 | #------------------------------------------------------------------------------ |
---|
22 | a = [] |
---|
23 | host = os.getenv('HOST') |
---|
24 | home1 = os.getenv('INUNDATIONHOME') |
---|
25 | scenariodir = add_directories(home1, ["data","mem_time_test", "parallel","cairns"]) |
---|
26 | file1 = 'ex1.csv' |
---|
27 | file_path = os.path.join(scenariodir, file1) |
---|
28 | store ='store.txt' |
---|
29 | file_path_store = os.path.join(scenariodir, store) |
---|
30 | |
---|
31 | log.log_filename = os.path.join(scenariodir, 'log.txt') |
---|
32 | |
---|
33 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
34 | spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s']) |
---|
35 | e = open(file_path_store,'a') |
---|
36 | e.close() |
---|
37 | |
---|
38 | maxcpus = 18 |
---|
39 | |
---|
40 | for n in range(1,maxcpus,1): |
---|
41 | z = time.time() |
---|
42 | y = time.time() |
---|
43 | |
---|
44 | if (host == 'cyclone.agso.gov.au'): |
---|
45 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) |
---|
46 | if (host == 'tornado.agso.gov.au'): |
---|
47 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) |
---|
48 | if (host == 'vayu1'): |
---|
49 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
50 | if (host == 'rhe-compute1.ga.gov.au'): |
---|
51 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) |
---|
52 | if (host == 'xe'): |
---|
53 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
54 | |
---|
55 | liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] |
---|
56 | f = open(file_path_store,'r+') |
---|
57 | x = float(f.readline()) |
---|
58 | f.close() |
---|
59 | spamWriter.writerow([n,x ,(y-z)]) |
---|
60 | print a |
---|
61 | |
---|