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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1809 by ksteube, Thu Sep 25 06:43:44 2008 UTC revision 2169 by caltinay, Wed Dec 17 03:08:58 2008 UTC
# Line 20  http://www.opensource.org/licenses/osl-3 Line 20  http://www.opensource.org/licenses/osl-3
20  __url__="http://www.uq.edu.au/esscc/escript-finley"  __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22  """  """
23  commandline utility to take an xml file, parse it, and run a simulation.  commandline utility to take an xml file, parse it, and run a simulation.
24  invoke this by doing ./runmodel.py <filename.xml>  invoke this by doing ./runmodel.py <filename.xml>
25    
26  @var __author__: name of author  @var __author__: name of author
# Line 38  from esys.escript import modelframe Line 38  from esys.escript import modelframe
38  import optparse  import optparse
39    
40  parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>")  parser = optparse.OptionParser(usage="%prog [options] <ESySXML files>")
41  parser.add_option('-f', '--file', dest='filename',  parser.add_option('-f', '--file', dest='filename',
42          help='the input ESySXML file', metavar='FILE')          help='the input ESySXML file', metavar='FILE')
43  parser.add_option('-d', '--debug', dest='dbg', action="store_true",  parser.add_option('-d', '--debug', dest='dbg', action="store_true",
44          help='switch debug on', default=False)          help='switch debug on', default=False)
45  parser.add_option('-n', '--new', action="store",  parser.add_option('-n', '--new', action="store",
46          help='output ESySXML file',          help='output ESySXML file',
# Line 49  def main(): Line 49  def main():
49      (options, args) = parser.parse_args()      (options, args) = parser.parse_args()
50      if options.filename:      if options.filename:
51         filenames=list(options.filename) + args         filenames=list(options.filename) + args
52      else:      else:
53         filenames=args         filenames=args
54      if len(filenames)<1:      if len(filenames)<1:
55          parser.error("no input file.")          parser.error("no input file.")
56    
57      files = [(file(arg), arg) for arg in filenames]      files = [(file(arg), arg) for arg in filenames]
# Line 59  def main(): Line 59  def main():
59          xml = modelframe.ESySXMLParser(f.read(), debug=options.dbg)          xml = modelframe.ESySXMLParser(f.read(), debug=options.dbg)
60          sims = xml.parse()          sims = xml.parse()
61          for s in sims:          for s in sims:
62            if isinstance(s, modelframe.Simulation):            if isinstance(s, modelframe.Simulation):
63                 if options.new_file_name: s.writeXML(file(options.new_file_name,'w'))                 if options.new_file_name: s.writeXML(file(options.new_file_name,'w'))
64                 s.run()                 s.run()
65    
66  if __name__=='__main__':  if __name__=='__main__':
67      main()      main()
68        

Legend:
Removed from v.1809  
changed lines
  Added in v.2169

  ViewVC Help
Powered by ViewVC 1.1.26