[cig-commits] r14031 - in seismo/3D/SPECFEM3D_GLOBE/branches/pluggable: . MODELS/3D MODELS/3D/blank-c
leif at geodynamics.org
leif at geodynamics.org
Mon Feb 9 18:28:46 PST 2009
Author: leif
Date: 2009-02-09 18:28:45 -0800 (Mon, 09 Feb 2009)
New Revision: 14031
Added:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/1D_ref
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/crust
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/fortran_stuff.f90
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/my_mantle_model.c
Modified:
seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py
Log:
Allow C source files in pluggable Earth models. Wrote blank C
versions of read_3d_mantle_model() and iso_mantle_model() as examples.
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/1D_ref
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/1D_ref (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/1D_ref 2009-02-10 02:28:45 UTC (rev 14031)
@@ -0,0 +1 @@
+link ../../1D_ref/blank
\ No newline at end of file
Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/1D_ref
___________________________________________________________________
Name: svn:special
+ *
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/crust
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/crust (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/crust 2009-02-10 02:28:45 UTC (rev 14031)
@@ -0,0 +1 @@
+link ../../crustal/blank
\ No newline at end of file
Property changes on: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/crust
___________________________________________________________________
Name: svn:special
+ *
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/fortran_stuff.f90
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/fortran_stuff.f90 (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/fortran_stuff.f90 2009-02-10 02:28:45 UTC (rev 14031)
@@ -0,0 +1,126 @@
+!=====================================================================
+!
+! S p e c f e m 3 D G l o b e V e r s i o n 4 . 0
+! --------------------------------------------------
+!
+! Main authors: Dimitri Komatitsch and Jeroen Tromp
+! Seismological Laboratory, California Institute of Technology, USA
+! and University of Pau / CNRS / INRIA, France
+! (c) California Institute of Technology and University of Pau / CNRS / INRIA
+! February 2008
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along
+! with this program; if not, write to the Free Software Foundation, Inc.,
+! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+!
+!=====================================================================
+
+
+subroutine get_model_properties(HONOR_1D_SPHERICAL_MOHO,ONE_CRUST, &
+ TRANSVERSE_ISOTROPY, &
+ ISOTROPIC_3D_MANTLE,ANISOTROPIC_3D_MANTLE,ANISOTROPIC_INNER_CORE, &
+ CRUSTAL,CASE_3D, &
+ ATTENUATION_3D)
+
+ implicit none
+
+ logical HONOR_1D_SPHERICAL_MOHO,ONE_CRUST,&
+ TRANSVERSE_ISOTROPY,&
+ ISOTROPIC_3D_MANTLE,ANISOTROPIC_3D_MANTLE,ANISOTROPIC_INNER_CORE,&
+ CRUSTAL,CASE_3D,&
+ ATTENUATION_3D
+
+ ! Define model properties here.
+
+ ! HONOR_1D_SPHERICAL_MOHO: honor PREM Moho or not: doing so drastically reduces
+ ! the stability condition and therefore the time step, resulting in expensive
+ ! calculations. If not, honor a fictitious Moho at the depth of 40 km
+ ! in order to have even radial sampling from the d220 to the Earth surface.
+ HONOR_1D_SPHERICAL_MOHO = .false.
+
+ ! ONE_CRUST: in order to increase stability and therefore to allow cheaper
+ ! simulations (larger time step), 1D models can be run with just one average crustal
+ ! layer instead of two.
+ ONE_CRUST = .false.
+
+ ! TRANSVERSE_ISOTROPY
+ TRANSVERSE_ISOTROPY = .false.
+
+ ! ISOTROPIC_3D_MANTLE and ANISOTROPIC_3D_MANTLE: Set exactly one of
+ ! these two flags for 3D models. If you set ISOTROPIC_3D_MANTLE,
+ ! the subroutine 'iso_mantle_model' will be called; if you set
+ ! ANISOTROPIC_3D_MANTLE instead, the subroutine 'aniso_mantle_model'
+ ! will be called.
+ ISOTROPIC_3D_MANTLE = .false.
+ ANISOTROPIC_3D_MANTLE = .false.
+
+ ! ANISOTROPIC_INNER_CORE
+ ANISOTROPIC_INNER_CORE = .false.
+
+ ! CRUSTAL
+ CRUSTAL = .false.
+
+ ! CASE_3D: this flag allows the stretching of the elements in the crustal
+ ! layers in the case of 3D models. The purpose of this stretching is to squeeze more
+ ! GLL points per km in the upper part of the crust than in the lower part.
+ CASE_3D = .false.
+
+ ! ATTENUATION_3D
+ ATTENUATION_3D = .false.
+
+end subroutine get_model_properties
+
+
+subroutine aniso_mantle_model(r,theta,phi,rho, &
+ c11,c12,c13,c14,c15,c16,c22,c23,c24,c25,c26,c33,c34,c35,c36,c44,c45,c46,c55,c56,c66)
+
+ implicit none
+
+ double precision r,theta,phi
+ double precision rho
+ double precision c11,c12,c13,c14,c15,c16,c22,c23,c24,c25,c26, &
+ c33,c34,c35,c36,c44,c45,c46,c55,c56,c66
+
+ ! Define 3D anisotropic models here.
+
+end subroutine aniso_mantle_model
+
+
+subroutine add_moho_topography(myrank,xelm,yelm,zelm,RMOHO,R220)
+
+ implicit none
+
+ include "constants.h"
+
+ integer myrank
+ double precision xelm(NGNOD)
+ double precision yelm(NGNOD)
+ double precision zelm(NGNOD)
+ double precision RMOHO,R220
+
+end subroutine add_moho_topography
+
+
+subroutine add_topography_410_650(myrank,xelm,yelm,zelm,R220,R400,R670,R771)
+
+ implicit none
+
+ include "constants.h"
+
+ integer myrank
+ double precision xelm(NGNOD)
+ double precision yelm(NGNOD)
+ double precision zelm(NGNOD)
+ double precision R220,R400,R670,R771
+
+end subroutine add_topography_410_650
Added: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/my_mantle_model.c
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/my_mantle_model.c (rev 0)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/MODELS/3D/blank-c/my_mantle_model.c 2009-02-10 02:28:45 UTC (rev 14031)
@@ -0,0 +1,33 @@
+
+#include "config.h"
+
+
+void FC_FUNC_(read_3d_mantle_model,READ_3D_MANTLE_MODEL)() {
+
+ /* Insert code to read data files here. */
+
+}
+
+
+void FC_FUNC_(iso_mantle_model,ISO_MANTLE_MODEL)
+ (double *pRadius, double *pTheta, double *pPhi,
+ double *vpv, double *vph, double *vsv, double *vsh,
+ double *rho, double *eta_aniso)
+{
+ /* Define 3D isotropic models here. */
+
+ double radius, theta, phi;
+
+ /* inputs */
+ radius = *pRadius;
+ theta = *pTheta;
+ phi = *pPhi;
+
+ /* outputs */
+ *vpv = 0.0;
+ *vph = 0.0;
+ *vsv = 0.0;
+ *vsh = 0.0;
+ *rho = 0.0;
+ *eta_aniso = 0.0;
+}
Modified: seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py
===================================================================
--- seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py 2009-02-10 01:38:41 UTC (rev 14030)
+++ seismo/3D/SPECFEM3D_GLOBE/branches/pluggable/prepare-model.py 2009-02-10 02:28:45 UTC (rev 14031)
@@ -12,12 +12,14 @@
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 @@
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 @@
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 @@
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 @@
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