1 | """ |
---|
2 | Script to run all the produce_results scripts in the Tests/xxx/xxx/ directories |
---|
3 | """ |
---|
4 | |
---|
5 | import os |
---|
6 | import anuga.utilities.system_tools as anugast |
---|
7 | import anuga |
---|
8 | import time |
---|
9 | |
---|
10 | #-------------------------------- |
---|
11 | # Setup Default values for basis |
---|
12 | # algorithm parameters. |
---|
13 | #-------------------------------- |
---|
14 | import argparse |
---|
15 | parser = argparse.ArgumentParser(description='produce results') |
---|
16 | parser.add_argument('-cfl', type=float, default=1.0, |
---|
17 | help='cfl condition') |
---|
18 | parser.add_argument('-alg', type=str, default = "1_5", |
---|
19 | help='flow algorithm') |
---|
20 | args = parser.parse_args() |
---|
21 | |
---|
22 | cfl = args.cfl |
---|
23 | alg = args.alg |
---|
24 | |
---|
25 | #--------------------------------- |
---|
26 | # Get the current svn revision |
---|
27 | #--------------------------------- |
---|
28 | |
---|
29 | timestamp = time.asctime() |
---|
30 | major_revision = anuga.config.major_revision |
---|
31 | minor_revision = anuga.utilities.system_tools.get_revision_number() |
---|
32 | |
---|
33 | |
---|
34 | #--------------------------------- |
---|
35 | # Run the tests |
---|
36 | #--------------------------------- |
---|
37 | buildroot = os.getcwd() |
---|
38 | |
---|
39 | Upper_dirs = os.listdir('./Tests') |
---|
40 | |
---|
41 | try: |
---|
42 | Upper_dirs.remove('.svn') |
---|
43 | except ValueError: |
---|
44 | pass |
---|
45 | #print Upper_dirs |
---|
46 | os.chdir('./Tests') |
---|
47 | |
---|
48 | for dir in Upper_dirs: |
---|
49 | |
---|
50 | os.chdir(dir) |
---|
51 | #print 'Changing to', os.getcwd() |
---|
52 | Lower_dirs = os.listdir('.') |
---|
53 | try: |
---|
54 | Lower_dirs.remove('.svn') |
---|
55 | except ValueError: |
---|
56 | pass |
---|
57 | #print Lower_dirs |
---|
58 | for l_dir in Lower_dirs: |
---|
59 | os.chdir(l_dir) |
---|
60 | print 'Changing to', os.getcwd() |
---|
61 | try: |
---|
62 | cmd = 'python produce_results.py -alg %s -cfl %s '% (alg,cfl) |
---|
63 | print 'Running: '+cmd |
---|
64 | os.system( cmd ) |
---|
65 | except: |
---|
66 | print 'Failed running produce_results in '+os.getcwd() |
---|
67 | pass |
---|
68 | |
---|
69 | os.chdir('..') |
---|
70 | #print 'Changing to', os.getcwd() |
---|
71 | |
---|
72 | os.chdir('..') |
---|
73 | print 'Changing to', os.getcwd() |
---|
74 | |
---|
75 | os.chdir('..') |
---|
76 | #---------------------------------- |
---|
77 | # Now it is ok to create the latex |
---|
78 | # macro file with run parameters |
---|
79 | #---------------------------------- |
---|
80 | |
---|
81 | f = open('saved_parameters.tex','w') |
---|
82 | f.write('\\newcommand{\\cfl}{\\UScore{%s}}\n' % str(cfl)) |
---|
83 | f.write('\\newcommand{\\alg}{\\UScore{%s}}\n' % str(alg)) |
---|
84 | f.write('\\newcommand{\\majorR}{\\UScore{%s}}\n' % str(major_revision)) |
---|
85 | f.write('\\newcommand{\\minorR}{\\UScore{%s}}\n' % str(minor_revision)) |
---|
86 | f.write('\\newcommand{\\timeR}{{%s}}\n' % str(timestamp)) |
---|
87 | |
---|
88 | f.close() |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | |
---|