source: trunk/anuga_work/development/mem_time_tests/hardware/template/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.7 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", "parallel","template"])
21meta_path = os.path.join(scenariodir, 'metalog.csv')
22final_path = os.path.join(scenariodir, 'final.csv')
23
24
25#main loop that runs maxcpus - 1 times
26maxcpus = 40
27
28for n in range(1,maxcpus,1):
29 
30    #the different ways each HOST requires the parallel script to be run
31    if (host == 'cyclone.agso.gov.au'):
32        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
33    elif (host == 'tornado.agso.gov.au'):
34        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
35    elif (host == 'rhe-compute1.ga.gov.au'):
36        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
37    else:
38        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
39   
40
41print 'Done'
42
43#get the important data for the experiments from the anuga experiments
44analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 
45
46#open files to read from and write to
47metalog = csv.reader(open(meta_path,'rb'))
48final = csv.writer(open(final_path,'wb'))
49
50#list stores the index of the values required
51indexlist = []
52
53#read in the first row
54firstrow = metalog.next()
55
56#get the indices of the values we want, so that the data can be condensed
57indexlist.append(firstrow.index("beforetime"))
58indexlist.append(firstrow.index("aftertime"))
59indexlist.append(firstrow.index("aftermeshtime"))
60indexlist.append(firstrow.index("beforesimulationmemory"))
61indexlist.append(firstrow.index("aftermeshmemory"))
62indexlist.append(firstrow.index("afterinitialconditionsmemory"))
63indexlist.append(firstrow.index("afterboundarymemory"))
64indexlist.append(firstrow.index("aftersimulationmemory"))
65indexlist.append(firstrow.index("numberofcpus"))
66indexlist.append(firstrow.index("myid"))
67
68#write the header for the final csv
69final.writerow(["TimeTaken(s)","MeshTime(s)",
70                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
71                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
72                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
73                firstrow[(indexlist[9])]])
74
75#write the data for each column in the final csv
76for row in metalog:
77
78    #manipulate the beginning and end time to get the time taken
79    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
80    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
81    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
82    taken = time.mktime(end) - time.mktime(begin)
83    meshtime =time.mktime(mesh) - time.mktime(begin)
84
85    #write to file
86    final.writerow([str(taken),str(meshtime),
87                    row[(indexlist[3])],row[(indexlist[4])],
88                    row[(indexlist[5])],row[(indexlist[6])],
89                    row[(indexlist[7])],row[(indexlist[8])],
90                    row[(indexlist[9])]])
Note: See TracBrowser for help on using the repository browser.