1 | # To change this template, choose Tools | Templates |
---|
2 | # and open the template in the editor. |
---|
3 | |
---|
4 | __author__="steve" |
---|
5 | __date__ ="$10/07/2012 1:18:38 PM$" |
---|
6 | |
---|
7 | |
---|
8 | |
---|
9 | |
---|
10 | def create_standard_parser(): |
---|
11 | """ Creates a standard argument parser""" |
---|
12 | |
---|
13 | |
---|
14 | #from anuga.validation_utilities.parameters import cfl as default_cfl |
---|
15 | from anuga.validation_utilities.parameters import alg as default_alg |
---|
16 | |
---|
17 | import argparse |
---|
18 | parser = argparse.ArgumentParser(description='validation parse') |
---|
19 | |
---|
20 | #parser.add_argument('-cfl', type=float, default=default_cfl, |
---|
21 | # help='cfl condition') |
---|
22 | |
---|
23 | parser.add_argument('-ft', '--finaltime', type=float, default=-1.0, |
---|
24 | help='finaltime') |
---|
25 | |
---|
26 | parser.add_argument('-ys', '--yieldstep', type=float, default=-1.0, |
---|
27 | help='yieldstep') |
---|
28 | |
---|
29 | parser.add_argument('-alg', type=str, default = default_alg, |
---|
30 | help='flow algorithm') |
---|
31 | |
---|
32 | parser.add_argument('-np', type=int, default = 1, |
---|
33 | help='number of processors to be used') |
---|
34 | |
---|
35 | parser.add_argument('-v', '--verbose', nargs='?', type=bool, const=True, default=False, |
---|
36 | help='turn on verbosity') |
---|
37 | |
---|
38 | parser.add_argument('-cp', '--checkpointing', nargs='?', type=bool, const=True, default=False, |
---|
39 | help='turn on checkpointing') |
---|
40 | |
---|
41 | return parser |
---|
42 | |
---|
43 | |
---|
44 | def parse_standard_args(): |
---|
45 | """ Parse arguments for standard validation |
---|
46 | arguments. Returns values of |
---|
47 | |
---|
48 | alg |
---|
49 | cfl |
---|
50 | |
---|
51 | """ |
---|
52 | |
---|
53 | parser = create_standard_parser() |
---|
54 | |
---|
55 | args = parser.parse_args() |
---|
56 | |
---|
57 | cfl = args.cfl |
---|
58 | alg = args.alg |
---|
59 | verbose= args.v |
---|
60 | np = args.np |
---|
61 | |
---|
62 | |
---|
63 | return alg, cfl |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | if __name__ == "__main__": |
---|
76 | print "Hello World" |
---|