@@ -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