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

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

creating files first then writing to them

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1"""Simple water flow example using ANUGA
2Water flowing down a channel
3"""
4#------------------------------------------------------------------------------
5# Import necessary modules
6#------------------------------------------------------------------------------
7# Import standard shallow water domain and standard boundaries.
8import anuga
9import subprocess
10import csv
11import os
12import time
13import liststore
14from anuga.utilities import system_tools, log
15from anuga.abstract_2d_finite_volumes.util import add_directories
16
17
18#------------------------------------------------------------------------------
19# Setup computational domain
20#------------------------------------------------------------------------------
21a = []
22#SpaceUsed = 0.0
23#number = 0
24
25home1 = os.getenv('INUNDATIONHOME')
26scenariodir = add_directories(home1, ["data","mem_time_test", "triangles","area"])
27file1 = 'ex1.csv'
28file_path = os.path.join(scenariodir, file1)
29storel ='storel.txt'
30file_path_storel = os.path.join(scenariodir, storel)
31storea ='storea.txt'
32file_path_storea = os.path.join(scenariodir, storea)
33store ='store.txt'
34file_path_store = os.path.join(scenariodir, store)
35storen ='storen.txt'
36file_path_storen = os.path.join(scenariodir, storen)
37
38log.log_filename = os.path.join(scenariodir, 'log.txt')
39
40spamWriter = csv.writer(open(file_path, 'wb'))
41spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s'])
42g = open(file_path_store,'a')
43g.close()
44g = open(file_path_storea,'a')
45g.close()
46g = open(file_path_storel,'a')
47g.close()
48g = open(file_path_storen,'a')
49g.close()
50
51
52def rum(d):
53     f = 4
54     for l in range(100,2000,100):
55       
56        g = open(file_path_storel,'r+')
57        g.write(str(l))
58
59        h = open(file_path_storea,'r+')
60        h.write(str(d))
61       
62        z = time.time()
63        subprocess.call(['mpirun', '-np', str(f), '-hostfile' ,'~/machinefiles/t.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.5', 'runcairns.py']) 
64        #subprocess.call(['python2.5', 'runcairns.py'])
65        y = time.time()
66
67        f = open(file_path_store,'r+')
68        x = float(f.readline())
69        f.close()
70
71        f = open(file_path_storen,'r+')
72        i = float(f.readline())
73        f.close()
74
75        spamWriter.writerow([i,d,(l*l),x ,(y-z)])
76        liststore.store = [0,0,0,0]
77
78for m in range(90,100,10):
79    rum(m)
80
81print 'Done'
82
Note: See TracBrowser for help on using the repository browser.