source: trunk/anuga_work/development/mem_time_tests/triangles/area/main.py @ 8326

Last change on this file since 8326 was 8326, checked in by pittj, 12 years ago

formatted the experiment scripts

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9import liststore
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities.log_analyser import analyse_log
12
13#------------------------------------------------------------------------------
14# Set up variables for the correct directories to store the output
15#------------------------------------------------------------------------------
16home = os.getenv('INUNDATIONHOME')
17host = os.getenv('HOST')
18scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"])
19file1 = 'ex1.csv'
20file_path = os.path.join(scenariodir, file1)
21storel ='storel.txt'
22file_path_storel = os.path.join(scenariodir, storel)
23storea ='storea.txt'
24file_path_storea = os.path.join(scenariodir, storea)
25storen ='storen.txt'
26file_path_storen = os.path.join(scenariodir, storen)
27
28#create and set up the files
29spamWriter = csv.writer(open(file_path, 'wb'))
30spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
31e = open(file_path_storea,'a')
32e.close()
33e = open(file_path_storel,'a')
34e.close()
35e = open(file_path_storen,'a')
36e.close()
37
38# this is the main loops that assigns the maximum triangle area (m) and the map side length(l)
39
40n = 4 #number of processors to use
41for m in range(90,100,10):
42     for l in range(100,2000,100):
43       
44        #write these values to file
45        g = open(file_path_storel,'r+')
46        g.write(str(l))
47        h = open(file_path_storea,'r+')
48        h.write(str(m))
49       
50        z = time.time()# time it
51
52        #the different ways each host calls MPI properly
53        if (host == 'cyclone.agso.gov.au'):
54            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
55        if (host == 'tornado.agso.gov.au'):
56            subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
57        if (host == 'vayu1'):
58            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
59        if (host == 'rhe-compute1.ga.gov.au'):
60            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])   
61        if (host == 'xe'):
62            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
63       
64        y = time.time()# time it
65
66        # read the number of triangles from this file
67        f = open(file_path_storen,'r+')
68        i = float(f.readline())
69        f.close()
70
71        spamWriter.writerow([i,d,(l*l),'x' ,(y-z)])# record it
72
73print 'Done'
74
75analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files
76
Note: See TracBrowser for help on using the repository browser.