[cig-commits] [commit] pluggable: Allow C source files in pluggable Earth models. Wrote blank C versions of read_3d_mantle_model() and iso_mantle_model() as examples. (ef0fe5a)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Apr 9 08:54:53 PDT 2014
Repository : ssh://geoshell/specfem3d_globe
On branch : pluggable
Link : https://github.com/geodynamics/specfem3d_globe/compare/64e1b38f0c5ebb4056cce0b15d41c0b9f94ab6e5...099a4d330d5b173b21e51ad441f9f429e5d37842
>---------------------------------------------------------------
commit ef0fe5ac6e361abb6c8b9d1819eb97bedabf799d
Author: Leif Strand <leif at geodynamics.org>
Date: Tue Feb 10 02:28:45 2009 +0000
Allow C source files in pluggable Earth models. Wrote blank C
versions of read_3d_mantle_model() and iso_mantle_model() as examples.
>---------------------------------------------------------------
ef0fe5ac6e361abb6c8b9d1819eb97bedabf799d
prepare-model.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/prepare-model.py b/prepare-model.py
index 956b559..de242a3 100755
--- a/prepare-model.py
+++ b/prepare-model.py
@@ -12,12 +12,14 @@ class CopiedFromPortal:
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():
@@ -28,9 +30,12 @@ class CopiedFromPortal:
except EnvironmentError:
pass
directories.append(tarinfo)
- elif tarinfo.name.endswith(".f90"):
+ elif tarinfo.name.endswith(".f90") or tarinfo.name.endswith(".c"):
pathname = os.path.join(path, tarinfo.name)
- fortranSourceFiles.append(pathname)
+ 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")
@@ -59,7 +64,7 @@ class CopiedFromPortal:
s = open("model.mk", "w")
print >>s
print >>s, "model_OBJECTS = \\"
- for sourceFile in fortranSourceFiles:
+ for sourceFile in chain(fortranSourceFiles, cSourceFiles):
base = splitext(basename(sourceFile))[0]
print >>s, "\t$O/%s.o \\" % base
print >>s, "\t$(empty)"
@@ -69,6 +74,11 @@ class CopiedFromPortal:
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
@@ -77,7 +87,8 @@ def prepareModel():
model = "model.tgz"
- modelDir = os.environ['MODEL']
+ modelDir = os.environ.get('MODEL')
+ assert modelDir, "MODEL environment variable is not set"
tgzOut = tarfile.open(model, 'w:gz')
tgzOut.dereference = True # follow symlinks
tgzOut.add(modelDir)
More information about the CIG-COMMITS
mailing list