/[escript]/trunk/escript/py_src/runmodel.py
ViewVC logotype

Contents of /trunk/escript/py_src/runmodel.py

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26