[cig-commits] r14166 - cs/portal/trunk/northridge/backend
leif at geodynamics.org
leif at geodynamics.org
Thu Feb 26 18:08:44 PST 2009
Author: leif
Date: 2009-02-26 18:08:44 -0800 (Thu, 26 Feb 2009)
New Revision: 14166
Modified:
cs/portal/trunk/northridge/backend/specfem3D.py
Log:
DRY: prepareModel() is now part of SPECFEM.
Modified: cs/portal/trunk/northridge/backend/specfem3D.py
===================================================================
--- cs/portal/trunk/northridge/backend/specfem3D.py 2009-02-27 02:05:50 UTC (rev 14165)
+++ cs/portal/trunk/northridge/backend/specfem3D.py 2009-02-27 02:08:44 UTC (rev 14166)
@@ -166,84 +166,9 @@
continue
os.symlink(src, dest)
- self.prepareModel()
-
return
- def prepareModel(self):
- import tarfile
- from os.path import basename, dirname, splitext
- from itertools import chain
-
- tgz = tarfile.open(self.model, 'r:gz')
- path = "model"
-
- directories = []
- fortranSourceFiles = []
- cSourceFiles = []
-
- for tarinfo in tgz:
- if tarinfo.isdir():
- # Extract directory with a safe mode, so that
- # all files below can be extracted as well.
- try:
- os.makedirs(os.path.join(path, tarinfo.name), 0777)
- except EnvironmentError:
- pass
- directories.append(tarinfo)
- elif tarinfo.name.endswith(".f90") or tarinfo.name.endswith(".c"):
- pathname = os.path.join(path, tarinfo.name)
- if tarinfo.name.endswith(".f90"):
- fortranSourceFiles.append(pathname)
- else:
- cSourceFiles.append(pathname)
- thisDir = dirname(tarinfo.name) # see bcast_model.c
- s = tgz.extractfile(tarinfo)
- f = open(pathname, "w")
- # Preprocess.
- for line in s.readlines():
- line = line.replace('@THIS_DIR@', thisDir)
- f.write(line)
- else:
- tgz.extract(tarinfo, path)
-
- # Reverse sort directories.
- directories.sort(lambda a, b: cmp(a.name, b.name))
- directories.reverse()
-
- # Set correct owner, mtime and filemode on directories.
- for tarinfo in directories:
- path = os.path.join(path, tarinfo.name)
- try:
- tgz.chown(tarinfo, path)
- tgz.utime(tarinfo, path)
- tgz.chmod(tarinfo, path)
- except tarfile.ExtractError, e:
- pass
-
- # Generate the make include file.
- s = open("model.mk", "w")
- print >>s
- print >>s, "model_OBJECTS = \\"
- for sourceFile in chain(fortranSourceFiles, cSourceFiles):
- base = splitext(basename(sourceFile))[0]
- print >>s, "\t$O/%s.o \\" % base
- print >>s, "\t$(empty)"
- print >>s
- for sourceFile in fortranSourceFiles:
- base = splitext(basename(sourceFile))[0]
- print >>s, "$O/%s.o: constants.h %s" % (base, sourceFile)
- print >>s, "\t${MPIFCCOMPILE_CHECK} -c -o $O/%s.o ${FCFLAGS_f90} %s" % (base, sourceFile)
- print >>s
- for sourceFile in cSourceFiles:
- base = splitext(basename(sourceFile))[0]
- print >>s, "$O/%s.o: config.h %s" % (base, sourceFile)
- print >>s, "\tmpicc $(CPPFLAGS) $(CFLAGS) -c -o $O/%s.o %s" % (base, sourceFile)
- print >>s
- return
-
-
def readAndCopyParFile(self):
s = open(self.parFile, "r")
d = open("DATA/Par_file", "w")
@@ -270,7 +195,7 @@
# configure
configure = join(SPECFEM3D_GLOBE, "configure")
configureArgs = self.configureArgs.split()
- argv = [configure] + configureArgs
+ argv = [configure] + configureArgs + ["MODEL=%s" % self.model]
print ' '.join(argv)
status = os.spawnvp(os.P_WAIT, argv[0], argv)
if status != 0:
More information about the CIG-COMMITS
mailing list