Skip to content

Commit ed6d376

Browse files
authored
Merge pull request #848 from danielpeter/devel
adds compatibility flag (for older version comparisons); updates adjacency array setup
2 parents ee26690 + 5a25fa1 commit ed6d376

File tree

9 files changed

+459
-341
lines changed

9 files changed

+459
-341
lines changed

setup/constants.h.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@
564564
! be careful when changing this flag when computing classical kernel
565565
integer, parameter :: NTSTEP_BETWEEN_COMPUTE_KERNELS = 1
566566

567+
!!-----------------------------------------------------------
568+
!!
569+
!! new version compatibility
570+
!!
571+
!!-----------------------------------------------------------
572+
! for comparison against older versions
573+
! in version 7.0: tiso was constrained to below moho, new version allows also in crust
574+
! in version 8.0: conversions between geodetic & geocentric latitudes were always applied,
575+
! and additional differences in 1-chunk centering & source positioning
576+
logical, parameter :: USE_OLD_VERSION_FORMAT = .false.
577+
567578

568579
!!-----------------------------------------------------------
569580
!!
@@ -1024,7 +1035,7 @@
10241035
! parameters for GLL model (used for iterative model inversions)
10251036
character(len=*), parameter :: PATHNAME_GLL_modeldir = 'DATA/GLL/'
10261037

1027-
! to create a reference model based on 1D_REF but with 3D crust and 410/660 topography
1038+
! to create a reference model based on the 1D reference model but with 3D crust and 410/660 topography
10281039
logical,parameter :: USE_1D_REFERENCE = .false.
10291040

10301041
!!-- uncomment for using PREM as reference model (used in CEM inversion)

src/meshfem3D/compute_element_properties.f90

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ subroutine compute_element_tiso_flag(elem_is_tiso,elem_in_mantle,iregion_code,is
480480
use constants, only: IMAIN,myrank, &
481481
IFLAG_CRUST,IFLAG_220_80,IFLAG_80_MOHO,IFLAG_670_220,IFLAG_MANTLE_NORMAL,IREGION_CRUST_MANTLE, &
482482
REFERENCE_MODEL_1DREF,REFERENCE_MODEL_1DREF, &
483-
THREE_D_MODEL_S362WMANI,THREE_D_MODEL_SGLOBE
483+
THREE_D_MODEL_S362WMANI,THREE_D_MODEL_SGLOBE, &
484+
USE_OLD_VERSION_FORMAT
484485

485486
use meshfem_models_par, only: &
486487
TRANSVERSE_ISOTROPY,USE_FULL_TISO_MANTLE,REFERENCE_1D_MODEL,THREE_D_MODEL
@@ -511,6 +512,8 @@ subroutine compute_element_tiso_flag(elem_is_tiso,elem_in_mantle,iregion_code,is
511512
write(IMAIN,*) ' setting tiso flags in mantle model'
512513
if (USE_FULL_TISO_MANTLE) &
513514
write(IMAIN,*) ' using fully transverse isotopic mantle'
515+
if (USE_OLD_VERSION_FORMAT) &
516+
write(IMAIN,*) ' using formatting from old versions (7.0 to 8.0)'
514517
call flush_IMAIN()
515518
endif
516519
endif
@@ -521,12 +524,16 @@ subroutine compute_element_tiso_flag(elem_is_tiso,elem_in_mantle,iregion_code,is
521524
if (USE_FULL_TISO_MANTLE) then
522525
! all elements below the actual moho will be used for transverse isotropy
523526
! note: this will increase the computation time by ~ 45 %
524-
if (idoubling(ispec) == IFLAG_MANTLE_NORMAL &
525-
.or. idoubling(ispec) == IFLAG_670_220 &
526-
.or. idoubling(ispec) == IFLAG_220_80 &
527-
.or. idoubling(ispec) == IFLAG_80_MOHO &
528-
.or. idoubling(ispec) == IFLAG_CRUST) then
529-
elem_is_tiso = .true.
527+
if (USE_OLD_VERSION_FORMAT) then
528+
if (elem_in_mantle) elem_is_tiso = .true.
529+
else
530+
if (idoubling(ispec) == IFLAG_MANTLE_NORMAL &
531+
.or. idoubling(ispec) == IFLAG_670_220 &
532+
.or. idoubling(ispec) == IFLAG_220_80 &
533+
.or. idoubling(ispec) == IFLAG_80_MOHO &
534+
.or. idoubling(ispec) == IFLAG_CRUST) then
535+
elem_is_tiso = .true.
536+
endif
530537
endif
531538

532539
! all done
@@ -545,26 +552,49 @@ subroutine compute_element_tiso_flag(elem_is_tiso,elem_in_mantle,iregion_code,is
545552
! THREE_D_MODEL_S29EA
546553
! THREE_D_MODEL_GLL
547554
! which show significant transverse isotropy also below 220km depth
548-
! assigns TI to elements in crust and mantle down to 670
549-
if (idoubling(ispec) == IFLAG_670_220 &
550-
.or. idoubling(ispec) == IFLAG_220_80 &
551-
.or. idoubling(ispec) == IFLAG_80_MOHO &
552-
.or. idoubling(ispec) == IFLAG_CRUST) then
553-
elem_is_tiso = .true.
555+
if (USE_OLD_VERSION_FORMAT) then
556+
! assigns TI to elements in mantle elements just below actual moho down to 670
557+
if (idoubling(ispec) == IFLAG_670_220 &
558+
.or. idoubling(ispec) == IFLAG_220_80 &
559+
.or. idoubling(ispec) == IFLAG_80_MOHO &
560+
.or. (idoubling(ispec) == IFLAG_CRUST &
561+
.and. elem_in_mantle) ) then
562+
elem_is_tiso = .true.
563+
endif
564+
else
565+
! assigns TI to elements in crust and mantle down to 670
566+
if (idoubling(ispec) == IFLAG_670_220 &
567+
.or. idoubling(ispec) == IFLAG_220_80 &
568+
.or. idoubling(ispec) == IFLAG_80_MOHO &
569+
.or. idoubling(ispec) == IFLAG_CRUST) then
570+
elem_is_tiso = .true.
571+
endif
554572
endif
555573

556574
case default
557575
! default reference models
558576
! for example, PREM assigns transverse isotropy between Moho and 220km
559-
! assigns TI to elements in crust and mantle elements (down to 220),
560-
! to allow for tiso in crust and below actual moho (especially for oceanic crusts);
561-
! the crustal models will decide if model parameters are tiso or iso
562-
if (idoubling(ispec) == IFLAG_220_80 &
563-
.or. idoubling(ispec) == IFLAG_80_MOHO &
564-
.or. idoubling(ispec) == IFLAG_CRUST) then
565-
! default case for PREM reference models:
566-
! models use only transverse isotropy between moho and 220 km depth
567-
elem_is_tiso = .true.
577+
if (USE_OLD_VERSION_FORMAT) then
578+
! assigns TI to elements in mantle elements just below actual moho
579+
if (idoubling(ispec) == IFLAG_220_80 &
580+
.or. idoubling(ispec) == IFLAG_80_MOHO &
581+
.or. (idoubling(ispec) == IFLAG_CRUST &
582+
.and. elem_in_mantle )) then
583+
! default case for PREM reference models:
584+
! models use only transverse isotropy between moho and 220 km depth
585+
elem_is_tiso = .true.
586+
endif
587+
else
588+
! assigns TI to elements in crust and mantle elements (down to 220),
589+
! to allow for tiso in crust and below actual moho (especially for oceanic crusts);
590+
! the crustal models will decide if model parameters are tiso or iso
591+
if (idoubling(ispec) == IFLAG_220_80 &
592+
.or. idoubling(ispec) == IFLAG_80_MOHO &
593+
.or. idoubling(ispec) == IFLAG_CRUST) then
594+
! default case for PREM reference models:
595+
! models use only transverse isotropy between moho and 220 km depth
596+
elem_is_tiso = .true.
597+
endif
568598
endif
569599
end select
570600

src/meshfem3D/meshfem3D_models.F90

Lines changed: 66 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,10 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
703703
!
704704
! note: in general, models here make use of perturbation values with respect to their
705705
! corresponding 1-D reference models
706-
if (MODEL_3D_MANTLE_PERTUBATIONS .and. r_prem > RCMB/R_PLANET .and. .not. suppress_mantle_extension) then
706+
if (MODEL_3D_MANTLE_PERTUBATIONS &
707+
.and. r_prem > RCMB/R_PLANET &
708+
.and. .not. suppress_mantle_extension &
709+
.and. .not. USE_1D_REFERENCE) then
707710

708711
! extend 3-D mantle model above the Moho to the surface before adding the crust
709712
if (r_prem > RCMB/R_PLANET .and. r_prem < RMOHO/R_PLANET) then
@@ -749,6 +752,7 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
749752

750753
case(THREE_D_MODEL_MANTLE_SH)
751754
! full_sh model
755+
! gets lat/lon coordinates from geocentric theta/phi
752756
lat = (PI/2.0d0-theta)*180.0d0/PI
753757
lon = phi*180.0d0/PI
754758
if (lon > 180.0d0) lon = lon - 360.0d0
@@ -794,20 +798,12 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
794798
case (THREE_D_MODEL_S362ANI,THREE_D_MODEL_S362WMANI, &
795799
THREE_D_MODEL_S362ANI_PREM,THREE_D_MODEL_S29EA)
796800
! 3D Harvard models s362ani, s362wmani, s362ani_prem and s2.9ea
801+
! gets colat/lon coordinates from geocentric theta/phi
797802
xcolat = sngl(theta*180.0d0/PI)
798803
xlon = sngl(phi*180.0d0/PI)
799804
xrad = sngl(r_used*R_PLANET_KM)
800805
call model_s362ani_subshsv(xcolat,xlon,xrad,xdvsh,xdvsv,xdvph,xdvpv)
801806

802-
! to use speed values from the 1D reference model but with 3D mesh variations
803-
if (USE_1D_REFERENCE) then
804-
! sets all 3D variations in the mantle to zero
805-
xdvpv = 0.d0
806-
xdvph = 0.d0
807-
xdvsv = 0.d0
808-
xdvsh = 0.d0
809-
endif
810-
811807
if (TRANSVERSE_ISOTROPY) then
812808
! tiso perturbation
813809
vpv = vpv*(1.0d0+dble(xdvpv))
@@ -852,7 +848,6 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
852848

853849
case (THREE_D_MODEL_SGLOBE,THREE_D_MODEL_SGLOBE_ISO)
854850
! 3D SGLOBE-rani model (Chang)
855-
856851
! normally mantle perturbations are taken from 24.4km (R_MOHO) up.
857852
! we need to add the if statement for sgloberani_iso or sgloberani_aniso to take from 50km up:
858853
if (r_prem > RCMB/R_PLANET .and. r_prem < 6321000.d0/R_PLANET) then
@@ -861,7 +856,6 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
861856
! this will then "extend the mantle up to the surface" from 50km depth
862857
r_used = 6321000.d0/R_PLANET
863858
endif
864-
865859
call mantle_sglobe(r_used,theta,phi,vsv,vsh,dvsv,dvsh,dvp,drho)
866860

867861
! updates velocities from reference model
@@ -902,6 +896,7 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
902896

903897
case (THREE_D_MODEL_SPIRAL)
904898
! SPiRaL v1.4 anisotropic model
899+
! gets lat/lon coordinates from geocentric theta/phi
905900
lat = (PI/2.0d0-theta)*180.0d0/PI
906901
lon = phi*180.0d0/PI
907902
! input: lat in range [-90,90]; lon in range [-180,180]
@@ -938,7 +933,8 @@ subroutine meshfem3D_models_get3Dmntl_val(iregion_code,r_prem,rho, &
938933
! (based on density variations) on top of reference 3D model
939934
if (HETEROGEN_3D_MANTLE &
940935
.and. .not. suppress_mantle_extension &
941-
.and. THREE_D_MODEL /= THREE_D_MODEL_HETEROGEN_PREM) then
936+
.and. THREE_D_MODEL /= THREE_D_MODEL_HETEROGEN_PREM &
937+
.and. .not. USE_1D_REFERENCE) then
942938
! gets spherical coordinates of actual point location
943939
r_used = r
944940
! adds hetergeneous perturbations (isotropic)
@@ -1199,7 +1195,6 @@ subroutine meshfem3D_models_get3Dcrust_val(iregion_code,r,theta,phi, &
11991195

12001196
! returns velocities and density for points in 3D crustal region
12011197

1202-
use shared_parameters, only: ELLIPTICITY
12031198
use meshfem_models_par
12041199

12051200
implicit none
@@ -1218,7 +1213,6 @@ subroutine meshfem3D_models_get3Dcrust_val(iregion_code,r,theta,phi, &
12181213
double precision,intent(inout) :: moho,sediment
12191214

12201215
! local parameters
1221-
double precision :: lat,lon
12221216
double precision :: vpvc,vphc,vsvc,vshc,etac
12231217
double precision :: vpc,vsc,rhoc !vpc_eu
12241218
double precision :: c11c,c12c,c13c,c14c,c15c,c16c,c22c,c23c,c24c,c25c,c26c, &
@@ -1231,13 +1225,6 @@ subroutine meshfem3D_models_get3Dcrust_val(iregion_code,r,theta,phi, &
12311225
! for point radius smaller than deepest possible crust radius (~80 km depth)
12321226
if (r < R_DEEPEST_CRUST) return
12331227

1234-
! converts geocentric colatitude/lon (theta/phi) to geographic latitude/lon (lat/lon)
1235-
! lat/lon in degrees (range lat/lon = [-90,90] / [-180,180]
1236-
call thetaphi_2_geographic_latlon_dble(theta,phi,lat,lon,ELLIPTICITY)
1237-
1238-
! double-check lon in range [-180,180]
1239-
if (lon > 180.0d0 ) lon = lon - 360.0d0
1240-
12411228
!---
12421229
!
12431230
! ADD YOUR MODEL HERE
@@ -1260,14 +1247,14 @@ subroutine meshfem3D_models_get3Dcrust_val(iregion_code,r,theta,phi, &
12601247

12611248
if (.not. is_inside_region) then
12621249
! uses default crust outside of model region
1263-
call meshfem3D_model_crust(lat,lon,r,vpvc,vphc,vsvc,vshc,etac,rhoc,moho,sediment,found_crust,elem_in_crust,moho_only, &
1250+
call meshfem3D_model_crust(r,theta,phi,vpvc,vphc,vsvc,vshc,etac,rhoc,moho,sediment,found_crust,elem_in_crust,moho_only, &
12641251
c11c,c12c,c13c,c14c,c15c,c16c,c22c,c23c,c24c,c25c,c26c, &
12651252
c33c,c34c,c35c,c36c,c44c,c45c,c46c,c55c,c56c,c66c)
12661253
endif
12671254

12681255
case default
12691256
! default crust
1270-
call meshfem3D_model_crust(lat,lon,r,vpvc,vphc,vsvc,vshc,etac,rhoc,moho,sediment,found_crust,elem_in_crust,moho_only, &
1257+
call meshfem3D_model_crust(r,theta,phi,vpvc,vphc,vsvc,vshc,etac,rhoc,moho,sediment,found_crust,elem_in_crust,moho_only, &
12711258
c11c,c12c,c13c,c14c,c15c,c16c,c22c,c23c,c24c,c25c,c26c, &
12721259
c33c,c34c,c35c,c36c,c44c,c45c,c46c,c55c,c56c,c66c)
12731260

@@ -1358,20 +1345,21 @@ end subroutine meshfem3D_models_get3Dcrust_val
13581345
!
13591346

13601347

1361-
subroutine meshfem3D_model_crust(lat,lon,r,vpvc,vphc,vsvc,vshc,etac,rhoc, &
1348+
subroutine meshfem3D_model_crust(r,theta,phi,vpvc,vphc,vsvc,vshc,etac,rhoc, &
13621349
moho,sediment,found_crust,elem_in_crust,moho_only, &
13631350
c11c,c12c,c13c,c14c,c15c,c16c,c22c,c23c,c24c,c25c,c26c, &
13641351
c33c,c34c,c35c,c36c,c44c,c45c,c46c,c55c,c56c,c66c)
13651352

13661353
! returns velocity/density for default crust
13671354

1355+
use constants, only: USE_OLD_VERSION_FORMAT
13681356
use meshfem_models_par
13691357

13701358
implicit none
13711359

1372-
! lat/lon - in degrees (range lat/lon = [-90,90] / [-180,180]
13731360
! radius r - normalized by globe radius [0,1.x]
1374-
double precision,intent(in) :: lat,lon,r
1361+
! theta/phi - geocentric coordinates
1362+
double precision,intent(in) :: r,theta,phi
13751363

13761364
double precision,intent(out) :: vpvc,vphc,vsvc,vshc,etac,rhoc
13771365
double precision,intent(out) :: moho,sediment
@@ -1380,6 +1368,7 @@ subroutine meshfem3D_model_crust(lat,lon,r,vpvc,vphc,vsvc,vshc,etac,rhoc, &
13801368
double precision,intent(out) :: c11c,c12c,c13c,c14c,c15c,c16c,c22c,c23c,c24c,c25c,c26c, &
13811369
c33c,c34c,c35c,c36c,c44c,c45c,c46c,c55c,c56c,c66c
13821370
! local parameters
1371+
double precision :: lat,lon
13831372
! for isotropic crust
13841373
double precision :: vpc,vsc
13851374
double precision :: vpc_area,vsc_area,rhoc_area,moho_area,sediment_area
@@ -1420,7 +1409,56 @@ subroutine meshfem3D_model_crust(lat,lon,r,vpvc,vphc,vsvc,vshc,etac,rhoc, &
14201409
! ADD YOUR MODEL HERE
14211410
!
14221411
!---
1423-
! lat/lon range: [-90,90] / [-180,180]
1412+
1413+
! note: Here we assume that the crustal models are defined with respect to geographic lat/lon positions.
1414+
! This is different to mantle models, where we assume that those are referenced to a spherical Earth.
1415+
!
1416+
! Geocentric and geographic colatitude (theta) are only identical for a spherical Earth.
1417+
! Depending on the Par_file 'ELLIPTICITY' flag however, we will stretch out the spherical mesh after assigining
1418+
! the model velocities.
1419+
!
1420+
! Given we want to assign the crustal velocities at point (x/y/z geocentric) which then corresponds to the
1421+
! coordinates (lat/lon geographic) in the final, stretched out mesh, we need to calculate the (lat/lon) position
1422+
! from (theta/phi) with the ellipticity correction.
1423+
!
1424+
! again, in other words (see comment in moho_stretching.f90):
1425+
! "
1426+
! the mesh here by default starts as a spherical mesh. the position (x/y/z) is thus a geocentric position
1427+
! and we want to assign the velocity & depth of the resulting geographic (lat/lon) position after stretching.
1428+
!
1429+
! we would have two options to achieve this:
1430+
! (a) we convert first all the crustal model (lat/lon) positions to the geocentric (lat'/lon') ones
1431+
! and then search for the corresponding geocentric (lat'/lon') position here.
1432+
! (b) we calculate the geographic (lat/lon) for this geocentric point location (x/y/z) and then
1433+
! search for the geographic (lat/lon) position in the original crustal model positions.
1434+
! the implementation here follows option (b) to leave the crustal model in its original form.
1435+
!
1436+
! thus, having the geocentric (x/y/z) position and its geocentric (lat'/lon') coordinate, we account here for the
1437+
! ellipticity stretching afterwards to find the proper resulting geographic (lat/lon) coordinate
1438+
! for which the crustal model is defined.
1439+
! in case the mesh stays spherical (no ELLIPTICITY), the geocentric (lat'/lon') coordinates are identical
1440+
! to geographic (lat/lon) coordinates and no correction is applied.
1441+
!
1442+
! this assumes that the crustal models are given for geographic (lat/lon) positions and
1443+
! not corrected geocentric (lat'/lon') positions.
1444+
! "
1445+
!
1446+
! TODO: we might want to re-visit this assumption.
1447+
1448+
if (USE_OLD_VERSION_FORMAT) then
1449+
! lat/lon from geocentric position w/out geodetic correction
1450+
lat = (PI_OVER_TWO - theta) * RADIANS_TO_DEGREES
1451+
lon = phi * RADIANS_TO_DEGREES
1452+
else
1453+
! converts geocentric colatitude/lon (theta/phi) to geographic latitude/lon (lat/lon)
1454+
! lat/lon in degrees (range lat/lon = [-90,90] / [-180,180]
1455+
call thetaphi_2_geographic_latlon_dble(theta,phi,lat,lon,ELLIPTICITY)
1456+
endif
1457+
1458+
! lat/lon in degrees (range lat/lon = [-90,90] / [-180,180]
1459+
! double-check lon in range [-180,180]
1460+
if (lon > 180.d0) lon = lon - 360.0d0
1461+
if (lon < -180.d0) lon = lon + 360.0d0
14241462

14251463
select case (REFERENCE_CRUSTAL_MODEL)
14261464

0 commit comments

Comments
 (0)