/[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 1388 - (show annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 8 months ago) by trankine
File MIME type: text/x-python
File size: 2311 byte(s)
And get the *(&(*&(* name right
1 #!/usr/bin/python
2
3 #
4 # $Id$
5 #
6 #######################################################
7 #
8 # Copyright 2003-2007 by ACceSS MNRF
9 # Copyright 2007 by University of Queensland
10 #
11 # http://esscc.uq.edu.au
12 # Primary Business: Queensland, Australia
13 # Licensed under the Open Software License version 3.0
14 # http://www.opensource.org/licenses/osl-3.0.php
15 #
16 #######################################################
17 #
18
19 """
20 commandline utility to take an xml file, parse it, and run a simulation.
21 invoke this by doing ./runmodel.py <filename.xml>
22
23 @var __author__: name of author
24 @var __copyright__: copyrights
25 @var __license__: licence agreement
26 @var __url__: url entry point on documentation
27 @var __version__: version
28 @var __date__: date of the version
29 """
30
31 __author__="Elspeth Thorne, e.thorne@uq.edu.au"
32 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
33 http://www.access.edu.au
34 Primary Business: Queensland, Australia"""
35 __license__="""Licensed under the Open Software License version 3.0
36 http://www.opensource.org/licenses/osl-3.0.php"""
37 __url__="http://www.iservo.edu.au/esys"
38 __version__="$Revision$"
39 __date__="$Date$"
40
41
42 from esys.escript import modelframe
43 import optparse
44
45 parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>")
46 parser.add_option('-f', '--file', dest='filename',
47 help='the input ESySXML file', metavar='FILE')
48 parser.add_option('-d', '--debug', dest='dbg', action="store_true",
49 help='switch debug on', default=False)
50 parser.add_option('-n', '--new', action="store",
51 help='output ESySXML file',
52 dest='new_file_name', default='')
53 def main():
54 (options, args) = parser.parse_args()
55 if options.filename:
56 filenames=list(options.filename) + args
57 else:
58 filenames=args
59 if len(filenames)<1:
60 parser.error("no input file.")
61
62 files = [(file(arg), arg) for arg in filenames]
63 for f, filename in files:
64 xml = modelframe.ESySXMLParser(f.read(), debug=options.dbg)
65 sims = xml.parse()
66 for s in sims:
67 if isinstance(s, modelframe.Simulation):
68 if options.new_file_name: s.writeXML(file(options.new_file_name,'w'))
69 s.run()
70
71 if __name__=='__main__':
72 main()
73

  ViewVC Help
Powered by ViewVC 1.1.26