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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 9 months ago) by trankine
File MIME type: text/x-python
File size: 2311 byte(s)
And get the *(&(*&(* name right
1 gross 250 #!/usr/bin/python
2 ksteube 1312
3     #
4 gross 250 # $Id$
5 ksteube 1312 #
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 elspeth 609
19 gross 637 """
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 elspeth 609 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
33     http://www.access.edu.au
34     Primary Business: Queensland, Australia"""
35 elspeth 614 __license__="""Licensed under the Open Software License version 3.0
36     http://www.opensource.org/licenses/osl-3.0.php"""
37 gross 637 __url__="http://www.iservo.edu.au/esys"
38     __version__="$Revision$"
39     __date__="$Date$"
40 elspeth 609
41 gross 637
42 elspeth 269 from esys.escript import modelframe
43 gross 250 import optparse
44    
45 gross 918 parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>")
46 gross 250 parser.add_option('-f', '--file', dest='filename',
47 gross 918 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 gross 250 def main():
54     (options, args) = parser.parse_args()
55     if options.filename:
56 gross 918 filenames=list(options.filename) + args
57     else:
58     filenames=args
59     if len(filenames)<1:
60     parser.error("no input file.")
61 gross 250
62 gross 918 files = [(file(arg), arg) for arg in filenames]
63 gross 250 for f, filename in files:
64 gross 918 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 gross 250
71     if __name__=='__main__':
72     main()
73    

  ViewVC Help
Powered by ViewVC 1.1.26