[cig-commits] r14030 - seismo/3D/SPECFEM3D_GLOBE/branches/pluggable
leif at geodynamics.org
leif at geodynamics.org
Mon Feb 9 17:38:41 PST 2009
Author: leif
Date: 2009-02-09 17:38:41 -0800 (Mon, 09 Feb 2009)
New Revision: 14030
Added:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py
Modified:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/Makefile.in
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure.ac
Log:
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'.
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/Makefile.in
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/Makefile.in 2009-02-06 23:48:48 UTC (rev 14029)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/Makefile.in 2009-02-10 01:38:41 UTC (rev 14030)
@@ -221,33 +221,34 @@
${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/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
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure 2009-02-06 23:48:48 UTC (rev 14029)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure 2009-02-10 01:38:41 UTC (rev 14030)
@@ -636,6 +636,7 @@
FLAGS_CHECK
FLAGS_NO_CHECK
LOCAL_PATH_IS_ALSO_GLOBAL
+MODEL
LIBOBJS
LTLIBOBJS'
ac_subst_files=''
@@ -653,7 +654,8 @@
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 @@
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 @@
+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 @@
+
+
# Checks for libraries.
@@ -5485,11 +5508,12 @@
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
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure.ac
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure.ac 2009-02-06 23:48:48 UTC (rev 14029)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/configure.ac 2009-02-10 01:38:41 UTC (rev 14030)
@@ -34,6 +34,18 @@
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,8 +94,10 @@
LOCAL_PATH_IS_ALSO_GLOBAL=false
fi
+AC_ARG_VAR(MODEL, [directory containing Earth model source])
+
# Checks for libraries.
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py 2009-02-10 01:38:41 UTC (rev 14030)
@@ -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))
Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the CIG-COMMITS
mailing list