[cig-commits] [commit] pluggable: Allow this portal-centric version code to be configured normally, for debugging purposes. E.g.: (cabf219)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Apr 9 08:54:51 PDT 2014
Repository : ssh://geoshell/specfem3d_globe
On branch : pluggable
Link : https://github.com/geodynamics/specfem3d_globe/compare/64e1b38f0c5ebb4056cce0b15d41c0b9f94ab6e5...099a4d330d5b173b21e51ad441f9f429e5d37842
>---------------------------------------------------------------
commit cabf219ebe4e59a746c78aee4805800d46301308
Author: Leif Strand <leif at geodynamics.org>
Date: Tue Feb 10 01:38:41 2009 +0000
Allow this portal-centric version code to be configured normally, for
debugging purposes. E.g.:
./configure FC=g95 MODEL=MODELS/3D/s20rts
This will cause 'configure' to tar-up MODELS/3D/s20rts as "model.tgz".
Then, the resulting archive is processed just as if it had been
downloaded from the portal:
* The files are extracted to the 'model' directory, but with the
@THIS_DIR@ macro expanded.
* The 'make' include file "model.mk" is generated to build the
extracted, preprocessed source.
* At runtime, the "model.tgz" archive is automatically broadcast
to all the nodes and extracted. See "bcast_model.c".
For debugging model code changes, one can either edit the extracted
source under 'model', or edit the original. If you edit the original,
be sure to run 'prepare-model.py'.
>---------------------------------------------------------------
cabf219ebe4e59a746c78aee4805800d46301308
Makefile.in | 38 ++++++++++++-----------
configure | 28 +++++++++++++++--
configure.ac | 14 +++++++++
prepare-model.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 153 insertions(+), 19 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 481e14c..dce00c0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -221,33 +221,34 @@ xspecfem3D: $(XSPECFEM_OBJECTS)
${MPIFCCOMPILE_NO_CHECK} -o xspecfem3D $(XSPECFEM_OBJECTS) $(MPILIBS)
+SERIAL_LIBS = $(model_OBJECTS) $O/exit_mpi_dummy.o $(LIBSPECFEM)
+
xconvolve_source_timefunction: $O/convolve_source_timefunction.o
${FCCOMPILE_CHECK} -o xconvolve_source_timefunction $O/convolve_source_timefunction.o
-# XXX: This is not an MPI program!
-xcreate_header_file: $O/create_header_file.o $(model_OBJECTS) $(LIBSPECFEM)
- ${MPIFCCOMPILE_CHECK} -o xcreate_header_file $O/create_header_file.o $(model_OBJECTS) $(LIBSPECFEM)
+xcreate_header_file: $O/create_header_file.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcreate_header_file $O/create_header_file.o $(SERIAL_LIBS)
-xcreate_movie_AVS_DX: $O/create_movie_AVS_DX.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcreate_movie_AVS_DX $O/create_movie_AVS_DX.o $(LIBSPECFEM)
+xcreate_movie_AVS_DX: $O/create_movie_AVS_DX.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcreate_movie_AVS_DX $O/create_movie_AVS_DX.o $(SERIAL_LIBS)
-xcreate_movie_GMT_global: $O/create_movie_GMT_global.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcreate_movie_GMT_global $O/create_movie_GMT_global.o $(LIBSPECFEM)
+xcreate_movie_GMT_global: $O/create_movie_GMT_global.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcreate_movie_GMT_global $O/create_movie_GMT_global.o $(SERIAL_LIBS)
-xcombine_AVS_DX: $O/combine_AVS_DX.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcombine_AVS_DX $O/combine_AVS_DX.o $(LIBSPECFEM)
+xcombine_AVS_DX: $O/combine_AVS_DX.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcombine_AVS_DX $O/combine_AVS_DX.o $(SERIAL_LIBS)
-xcheck_buffers_1D: $O/check_buffers_1D.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcheck_buffers_1D $O/check_buffers_1D.o $(LIBSPECFEM)
+xcheck_buffers_1D: $O/check_buffers_1D.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcheck_buffers_1D $O/check_buffers_1D.o $(SERIAL_LIBS)
-xcheck_buffers_2D: $O/check_buffers_2D.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcheck_buffers_2D $O/check_buffers_2D.o $(LIBSPECFEM)
+xcheck_buffers_2D: $O/check_buffers_2D.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcheck_buffers_2D $O/check_buffers_2D.o $(SERIAL_LIBS)
-xcheck_buffers_corners_chunks: $O/check_buffers_corners_chunks.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcheck_buffers_corners_chunks $O/check_buffers_corners_chunks.o $(LIBSPECFEM)
+xcheck_buffers_corners_chunks: $O/check_buffers_corners_chunks.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcheck_buffers_corners_chunks $O/check_buffers_corners_chunks.o $(SERIAL_LIBS)
-xcheck_buffers_faces_chunks: $O/check_buffers_faces_chunks.o $(LIBSPECFEM)
- ${FCCOMPILE_CHECK} -o xcheck_buffers_faces_chunks $O/check_buffers_faces_chunks.o $(LIBSPECFEM)
+xcheck_buffers_faces_chunks: $O/check_buffers_faces_chunks.o $(SERIAL_LIBS)
+ ${FCCOMPILE_CHECK} -o xcheck_buffers_faces_chunks $O/check_buffers_faces_chunks.o $(SERIAL_LIBS)
xcombine_vol_data: $O/combine_vol_data.o $O/write_c_binary.o
${FCCOMPILE_CHECK} -o xcombine_vol_data $O/combine_vol_data.o $O/write_c_binary.o
@@ -359,6 +360,9 @@ $O/locate_receivers.o: constants.h $S/locate_receivers.f90
$O/exit_mpi.o: constants.h $S/exit_mpi.f90
${MPIFCCOMPILE_CHECK} -c -o $O/exit_mpi.o ${FCFLAGS_f90} $S/exit_mpi.f90
+$O/exit_mpi_dummy.o: constants.h $S/MODELS/harness/lib/chino/exit_mpi.f90
+ ${FCCOMPILE_CHECK} -c -o $O/exit_mpi_dummy.o ${FCFLAGS_f90} $S/MODELS/harness/lib/chino/exit_mpi.f90
+
$O/count_number_of_sources.o: constants.h $S/count_number_of_sources.f90
${FCCOMPILE_CHECK} -c -o $O/count_number_of_sources.o ${FCFLAGS_f90} $S/count_number_of_sources.f90
diff --git a/configure b/configure
index a1cc203..daa4a0a 100755
--- a/configure
+++ b/configure
@@ -636,6 +636,7 @@ MPILIBS
FLAGS_CHECK
FLAGS_NO_CHECK
LOCAL_PATH_IS_ALSO_GLOBAL
+MODEL
LIBOBJS
LTLIBOBJS'
ac_subst_files=''
@@ -653,7 +654,8 @@ MPIFC
MPILIBS
FLAGS_CHECK
FLAGS_NO_CHECK
-LOCAL_PATH_IS_ALSO_GLOBAL'
+LOCAL_PATH_IS_ALSO_GLOBAL
+MODEL'
# Initialize some variables set by options.
@@ -1246,6 +1248,7 @@ Some influential environment variables:
LOCAL_PATH_IS_ALSO_GLOBAL
files on a local path on each node are also seen as global with
same path [default=false]
+ MODEL directory containing Earth model source
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -1704,6 +1707,24 @@ fi
+if test x$MODEL = x; then
+ if test -f model.mk; then
+ { echo "$as_me:$LINENO: using previously configured Earth model" >&5
+echo "$as_me: using previously configured Earth model" >&6;}
+ else
+ { { echo "$as_me:$LINENO: error: MODEL is not set, and there is no previously configured Earth model" >&5
+echo "$as_me: error: MODEL is not set, and there is no previously configured Earth model" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ { echo "$as_me:$LINENO: running prepare-model.py" >&5
+echo "$as_me: running prepare-model.py" >&6;}
+ $srcdir/prepare-model.py || { { echo "$as_me:$LINENO: error: prepare-model.py failed" >&5
+echo "$as_me: error: prepare-model.py failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
# Checks for programs.
# a courtesy to the installed base of users
@@ -4641,6 +4662,8 @@ fi
+
+
# Checks for libraries.
@@ -5485,11 +5508,12 @@ MPILIBS!$MPILIBS$ac_delim
FLAGS_CHECK!$FLAGS_CHECK$ac_delim
FLAGS_NO_CHECK!$FLAGS_NO_CHECK$ac_delim
LOCAL_PATH_IS_ALSO_GLOBAL!$LOCAL_PATH_IS_ALSO_GLOBAL$ac_delim
+MODEL!$MODEL$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 60; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.ac b/configure.ac
index 424eeac..c38ec46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,18 @@ AC_SUBST([CUSTOM_REAL])
AC_SUBST([CUSTOM_MPI_TYPE])
+if test x$MODEL = x; then
+ if test -f model.mk; then
+ AC_MSG_NOTICE([using previously configured Earth model])
+ else
+ AC_MSG_ERROR([MODEL is not set, and there is no previously configured Earth model])
+ fi
+else
+ AC_MSG_NOTICE([running prepare-model.py])
+ $srcdir/prepare-model.py || AC_MSG_ERROR([prepare-model.py failed])
+fi
+
+
# Checks for programs.
# a courtesy to the installed base of users
@@ -82,6 +94,8 @@ if test x"$LOCAL_PATH_IS_ALSO_GLOBAL" = x; then
LOCAL_PATH_IS_ALSO_GLOBAL=false
fi
+AC_ARG_VAR(MODEL, [directory containing Earth model source])
+
# Checks for libraries.
diff --git a/prepare-model.py b/prepare-model.py
new file mode 100755
index 0000000..956b559
--- /dev/null
+++ b/prepare-model.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+
+
+import os, sys
+
+
+class CopiedFromPortal:
+
+ def __init__(self, model):
+ self.model = model
+
+ def prepareModel(self):
+ import tarfile
+ from os.path import basename, dirname, splitext
+
+ tgz = tarfile.open(self.model, 'r:gz')
+ path = "model"
+
+ directories = []
+ fortranSourceFiles = []
+
+ 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"):
+ pathname = os.path.join(path, tarinfo.name)
+ fortranSourceFiles.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 fortranSourceFiles:
+ 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
+ return
+
+
+def prepareModel():
+ import tarfile
+
+ model = "model.tgz"
+
+ modelDir = os.environ['MODEL']
+ tgzOut = tarfile.open(model, 'w:gz')
+ tgzOut.dereference = True # follow symlinks
+ tgzOut.add(modelDir)
+ tgzOut.close()
+
+ CopiedFromPortal(model).prepareModel()
+
+
+try:
+ prepareModel()
+except Exception, e:
+ sys.exit("%s: %s" % (__file__, e))
More information about the CIG-COMMITS
mailing list