1 | #------------------------------------------------------------------------------ |
---|
2 | # Import necessary modules |
---|
3 | #------------------------------------------------------------------------------ |
---|
4 | import anuga |
---|
5 | import random |
---|
6 | import subprocess |
---|
7 | import csv |
---|
8 | import os |
---|
9 | import time |
---|
10 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
11 | from anuga.utilities.log_analyser import analyse_log |
---|
12 | |
---|
13 | #------------------------------------------------------------------------------ |
---|
14 | # Set up variables for the correct directories to store the output |
---|
15 | #------------------------------------------------------------------------------ |
---|
16 | home = os.getenv('INUNDATIONHOME') |
---|
17 | scenariodir = add_directories(home, ["data","mem_time_test", "scenarios", |
---|
18 | "channelflow"]) |
---|
19 | store ='store.txt' |
---|
20 | file_path_store = os.path.join(scenariodir, store) |
---|
21 | storen ='storen.txt' |
---|
22 | file_path_storen = os.path.join(scenariodir, storen) |
---|
23 | file = 'ex1.csv' |
---|
24 | file_path = os.path.join(scenariodir, file) |
---|
25 | |
---|
26 | #set up the output files |
---|
27 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
28 | spamWriter.writerow(['Length','Stage','Time','Space']) |
---|
29 | e = open(file_path_store,'a') |
---|
30 | e.close() |
---|
31 | e = open(file_path_storen,'a') |
---|
32 | e.close() |
---|
33 | |
---|
34 | #the main loops that give the length of the inflow boundary (i) and the place to begin the step (n) |
---|
35 | for i in range(100,100000,10000): |
---|
36 | for n in range(1,i/10,i/100): |
---|
37 | |
---|
38 | #adjust |
---|
39 | i = i /100.0 |
---|
40 | n = n/10.0 |
---|
41 | |
---|
42 | #write these values to files |
---|
43 | g = open(file_path_store,'r+') |
---|
44 | g.write(str(i)) |
---|
45 | h = open(file_path_storen,'r+') |
---|
46 | h.write(str(n)) |
---|
47 | |
---|
48 | z = time.time() #time it |
---|
49 | subprocess.call(['python2.5', 'ex1.py'])#run the script |
---|
50 | y = time.time() #time it |
---|
51 | |
---|
52 | spamWriter.writerow([i,n,(y-z), 'b'])#record it |
---|
53 | print 'DONE' |
---|
54 | |
---|
55 | analyse_log(scenariodir, 'metalog.csv')#get the memory usage statistics from the various log files |
---|