[cig-commits] r13415 - in seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness: . bin chino
leif at geodynamics.org
leif at geodynamics.org
Wed Nov 26 16:39:42 PST 2008
Author: leif
Date: 2008-11-26 16:39:42 -0800 (Wed, 26 Nov 2008)
New Revision: 13415
Added:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/blank
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/template.py
Modified:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/MANIFEST.in
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/bin/chino
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/config.py
Log:
Extended 'chino' to be a bit more than a harness. It now an assistant
which can generate a blank earth model, in addition to testing an
existing earth model.
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/MANIFEST.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/MANIFEST.in 2008-11-26 23:47:52 UTC (rev 13414)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/MANIFEST.in 2008-11-27 00:39:42 UTC (rev 13415)
@@ -1,3 +1,5 @@
include MANIFEST.in
include chino/*.f90
include chino/*.h
+include chino/blank/*.f90
+include chino/blank/*/*.f90
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/bin/chino
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/bin/chino 2008-11-26 23:47:52 UTC (rev 13414)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/bin/chino 2008-11-27 00:39:42 UTC (rev 13415)
@@ -2,17 +2,63 @@
from chino.harness import Harness
from chino.config import Config
+from chino.template import copyTemplate
+import os, sys
-def main():
+def printUsage():
+ print "usage: chino [ACTION] [options]"
+ print
+ print "actions:"
+ print " create NAME"
+ print " Creates a blank SPECFEM3D GLOBE model with"
+ print " the given name in the current directory."
+ print " Generates the config file '%s'." % Config.filename
+ print
+ print " test"
+ print " Builds and tests the current model."
+ print " (This is the default action.)"
+ print
+
+def usage():
+ printUsage()
+ sys.exit(1)
+
+def test():
try:
config = Config.fromFile()
except IOError:
- Config.configure()
- print "chino: generated config file '%s'" % Config.filename
- print "chino: edit '%s', then run 'chino' again" % Config.filename
- return
-
+ printUsage()
+ sys.exit("chino: missing config file '%s'" % Config.filename)
harness = Harness(config)
harness.run()
+ return
-main()
+def main(argv):
+ if len(argv) < 2:
+ test()
+ elif argv[1] == "create":
+ if len(argv) != 3:
+ usage()
+ name = argv[2]
+ if os.sep in name:
+ sys.exit("chino: invalid name '%s'" % name)
+ copyTemplate(name)
+ print "chino: created '%s'" % name
+ Config.create(name)
+ print "chino: be sure to edit the generated config file '%s'" % Config.filename
+ elif argv[1] == "test":
+ if len(argv) != 2:
+ usage()
+ test()
+ else:
+ usage()
+ return
+
+def start(argv):
+ try:
+ main(argv)
+ except OSError, e:
+ sys.exit("chino: %s" % e)
+ return
+
+start(sys.argv)
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/blank
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/blank (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/blank 2008-11-27 00:39:42 UTC (rev 13415)
@@ -0,0 +1 @@
+link ../../3D/blank
\ No newline at end of file
Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/blank
___________________________________________________________________
Name: svn:special
+ *
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/config.py
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/config.py 2008-11-26 23:47:52 UTC (rev 13414)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/config.py 2008-11-27 00:39:42 UTC (rev 13415)
@@ -22,11 +22,11 @@
fromFile = classmethod(fromFile)
#@classmethod
- def configure(cls):
+ def create(cls, name):
s = open(cls.filename, "w")
print >>s
print >>s, "[general]"
- print >>s, "model-dir = mymodel ; path to model directory"
+ print >>s, "model-dir = %s ; path to model directory" % name
print >>s
print >>s, "[make]"
print >>s, "FC = f90 ; Fortran-90 compiler command"
@@ -37,7 +37,7 @@
print >>s
s.close()
return cls.fromFile()
- configure = classmethod(configure)
+ create = classmethod(create)
def __init__(self, **kwds):
self.__dict__.update(kwds)
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/template.py
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/template.py (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/harness/chino/template.py 2008-11-27 00:39:42 UTC (rev 13415)
@@ -0,0 +1,7 @@
+
+def copyTemplate(name):
+ from shutil import copytree
+ from os.path import dirname, join
+ templateDir = join(dirname(__file__), "blank")
+ copytree(templateDir, name)
+ return
More information about the CIG-COMMITS
mailing list