1 |
ksteube |
1312 |
|
2 |
ksteube |
1809 |
######################################################## |
3 |
ksteube |
1312 |
# |
4 |
ksteube |
1809 |
# Copyright (c) 2003-2008 by University of Queensland |
5 |
|
|
# Earth Systems Science Computational Center (ESSCC) |
6 |
|
|
# http://www.uq.edu.au/esscc |
7 |
ksteube |
1312 |
# |
8 |
ksteube |
1809 |
# Primary Business: Queensland, Australia |
9 |
|
|
# Licensed under the Open Software License version 3.0 |
10 |
|
|
# http://www.opensource.org/licenses/osl-3.0.php |
11 |
ksteube |
1312 |
# |
12 |
ksteube |
1809 |
######################################################## |
13 |
elspeth |
609 |
|
14 |
ksteube |
1809 |
__copyright__="""Copyright (c) 2003-2008 by University of Queensland |
15 |
|
|
Earth Systems Science Computational Center (ESSCC) |
16 |
|
|
http://www.uq.edu.au/esscc |
17 |
|
|
Primary Business: Queensland, Australia""" |
18 |
|
|
__license__="""Licensed under the Open Software License version 3.0 |
19 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
|
|
__url__="http://www.uq.edu.au/esscc/escript-finley" |
21 |
|
|
|
22 |
gross |
637 |
""" |
23 |
|
|
commandline utility to take an xml file, parse it, and run a simulation. |
24 |
|
|
invoke this by doing ./runmodel.py <filename.xml> |
25 |
|
|
|
26 |
|
|
@var __author__: name of author |
27 |
|
|
@var __copyright__: copyrights |
28 |
|
|
@var __license__: licence agreement |
29 |
|
|
@var __url__: url entry point on documentation |
30 |
|
|
@var __version__: version |
31 |
|
|
@var __date__: date of the version |
32 |
|
|
""" |
33 |
|
|
|
34 |
|
|
__author__="Elspeth Thorne, e.thorne@uq.edu.au" |
35 |
elspeth |
609 |
|
36 |
gross |
637 |
|
37 |
elspeth |
269 |
from esys.escript import modelframe |
38 |
gross |
250 |
import optparse |
39 |
|
|
|
40 |
gross |
918 |
parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>") |
41 |
gross |
250 |
parser.add_option('-f', '--file', dest='filename', |
42 |
gross |
918 |
help='the input ESySXML file', metavar='FILE') |
43 |
|
|
parser.add_option('-d', '--debug', dest='dbg', action="store_true", |
44 |
|
|
help='switch debug on', default=False) |
45 |
|
|
parser.add_option('-n', '--new', action="store", |
46 |
|
|
help='output ESySXML file', |
47 |
|
|
dest='new_file_name', default='') |
48 |
gross |
250 |
def main(): |
49 |
|
|
(options, args) = parser.parse_args() |
50 |
|
|
if options.filename: |
51 |
gross |
918 |
filenames=list(options.filename) + args |
52 |
|
|
else: |
53 |
|
|
filenames=args |
54 |
|
|
if len(filenames)<1: |
55 |
|
|
parser.error("no input file.") |
56 |
gross |
250 |
|
57 |
gross |
918 |
files = [(file(arg), arg) for arg in filenames] |
58 |
gross |
250 |
for f, filename in files: |
59 |
gross |
918 |
xml = modelframe.ESySXMLParser(f.read(), debug=options.dbg) |
60 |
|
|
sims = xml.parse() |
61 |
|
|
for s in sims: |
62 |
|
|
if isinstance(s, modelframe.Simulation): |
63 |
|
|
if options.new_file_name: s.writeXML(file(options.new_file_name,'w')) |
64 |
|
|
s.run() |
65 |
gross |
250 |
|
66 |
|
|
if __name__=='__main__': |
67 |
|
|
main() |
68 |
|
|
|