/[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 918 - (show annotations)
Wed Jan 3 06:30:00 2007 UTC (12 years, 11 months ago) by gross
File MIME type: text/x-python
File size: 1890 byte(s)
fixes on ESySXML to get runmodel going.

    * object ids are now local for read and write of XML
    * ParameterSets are now written with class name
    * ParameterSets linked by other ParameterSets (previously only Models) are written now 
    * list are now lists of str (rather than bools), lists with bool, int or float are mapped to numarray
    * numarray are writen with generic types Bool, Int, Float (portability!)


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

  ViewVC Help
Powered by ViewVC 1.1.26