source: trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py @ 8427

Last change on this file since 8427 was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 3.8 KB
Line 
1"""Simple water flow example using ANUGA
2Water flowing down a channel
3"""
4#------------------------------------------------------------------------------
5# Import necessary modules
6#------------------------------------------------------------------------------
7import anuga
8import subprocess
9import csv
10import os
11import time
12from anuga.abstract_2d_finite_volumes.util import add_directories
13from anuga.utilities.log_analyser import analyse_log
14
15#--------------------------------------------------------------------------------------
16# Set up variables for the correct directories to store the output
17#--------------------------------------------------------------------------------------
18host = os.getenv('HOST')
19home = os.getenv('INUNDATIONHOME')
20scenariodir = add_directories(home, ["data","mem_time_test", "parallel1","cairns"])
21meta_path = os.path.join(scenariodir, 'metalog.csv')
22final_path = os.path.join(scenariodir, 'final.csv')
23
24# main loop that runs macpus - 1 times
25maxcpus = 4
26
27for n in range(1,maxcpus,1):
28    #the necessary ways to run this script in parallel on the different hosts we use
29    if (host == 'cyclone.agso.gov.au'):
30        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
31    elif (host == 'tornado.agso.gov.au'):
32        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
33    elif (host == 'rhe-compute1.ga.gov.au'):
34        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
35    else:
36        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
37     
38print 'DONE'
39
40#get the important data for the experiments from the anuga experiments
41analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 
42
43#open files to read from and write to
44metalog = csv.reader(open(meta_path,'rb'))
45final = csv.writer(open(final_path,'wb'))
46
47#list stores the index of the values requird
48indexlist = []
49
50#read in the first row
51firstrow = metalog.next()
52
53#get the indices of the values we want, so that the data can be condensed
54indexlist.append(firstrow.index("beforetime"))
55indexlist.append(firstrow.index("aftertime"))
56indexlist.append(firstrow.index("aftermeshtime"))
57indexlist.append(firstrow.index("beforesimulationmemory"))
58indexlist.append(firstrow.index("aftermeshmemory"))
59indexlist.append(firstrow.index("afterinitialconditionsmemory"))
60indexlist.append(firstrow.index("afterboundarymemory"))
61indexlist.append(firstrow.index("aftersimulationmemory"))
62indexlist.append(firstrow.index("numberofcpus"))
63indexlist.append(firstrow.index("myid"))
64
65
66#write the header for the final csv
67final.writerow(["TimeTaken(s)","Time For Mesh (s)",
68                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
69                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
70                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
71                firstrow[(indexlist[9])]])
72
73#write the data for each column in the final csv
74for row in metalog:
75
76    #manipulate the beginning and end time to get the time taken
77    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
78    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
79    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
80    taken = time.mktime(end) - time.mktime(begin)
81    meshtime = time.mktime(mesh) - time.mktime(begin)
82
83    #write to file
84    final.writerow([str(taken),str(meshtime),
85                    row[(indexlist[3])],row[(indexlist[4])],
86                    row[(indexlist[5])],row[(indexlist[6])],
87                    row[(indexlist[7])],row[(indexlist[8])],
88                    row[(indexlist[9])]])
89
Note: See TracBrowser for help on using the repository browser.