source: trunk/anuga_work/development/mem_time_tests/triangles/area/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: 4.3 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities.log_analyser import analyse_log
11
12#------------------------------------------------------------------------------
13# Set up variables for the correct directories to store the output
14#------------------------------------------------------------------------------
15home = os.getenv('INUNDATIONHOME')
16host = os.getenv('HOST')
17scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"])
18meta = 'metalog.csv'
19meta_path = os.path.join(scenariodir, meta)
20final = 'final.csv'
21final_path = os.path.join(scenariodir, final)
22
23# this is the main loops that assigns the maximum triangle area (m) and the map side length(l)
24
25n = 4 #number of processors to use
26for m in range(90,100,10):
27     for l in range(100,2000,100):
28        #the different ways each host calls MPI properly
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',str(m),str(l)]) 
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',str(m),str(l)])
33        elif (host == 'rhe-compute1.ga.gov.au'):
34            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py',str(m),str(l)])   
35        else:
36            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 
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"))
62
63indexlist.append(firstrow.index("extent"))
64indexlist.append(firstrow.index("trianglearea"))
65indexlist.append(firstrow.index("numberoftriangles"))
66indexlist.append(firstrow.index("numberofcpus"))
67indexlist.append(firstrow.index("numberoftriangles"))
68indexlist.append(firstrow.index("myid"))
69
70
71#write the header for the final csv
72final.writerow(["TimeTaken(s)","MeshTime(s)",
73                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
74                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
75                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
76                firstrow[(indexlist[9])],firstrow[(indexlist[10])],
77                firstrow[(indexlist[11])],firstrow[(indexlist[12])],
78                firstrow[(indexlist[13])]])
79
80#write the data for each column in the final csv
81for row in metalog:
82
83    #manipulate the beginning and end time to get the time taken
84    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
85    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
86    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
87    taken = time.mktime(end) - time.mktime(begin)
88    meshtime = time.mktime(mesh) - time.mktime(begin)
89
90    #write to file
91    final.writerow([str(taken),str(meshtime),
92                    row[(indexlist[3])],row[(indexlist[4])],
93                    row[(indexlist[5])],row[(indexlist[6])],
94                    row[(indexlist[7])],row[(indexlist[8])],
95                    row[(indexlist[9])],row[(indexlist[10])],
96                    row[(indexlist[11])],row[(indexlist[12])]
97                    row[(indexlist[13])]])
Note: See TracBrowser for help on using the repository browser.