Skip to content

Commit 09adfc1

Browse files
authored
Merge pull request #1869 from lsawade/devel
2 parents 21e40fd + 4a038bb commit 09adfc1

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

src/specfem3D/get_cmt.f90

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ subroutine get_cmt(CMTSOLUTION,yr,jda,mo,da,ho,mi,sec, &
2929
tshift_src,hdur,lat,long,depth,moment_tensor, &
3030
DT,NSOURCES,min_tshift_src_original,user_source_time_function)
3131

32-
use constants, only: IIN,MAX_STRING_LEN,CUSTOM_REAL
33-
use shared_parameters, only: USE_EXTERNAL_SOURCE_FILE,NSTEP_STF,NSOURCES_STF,NOISE_TOMOGRAPHY
32+
use constants, only: IIN,MAX_STRING_LEN,CUSTOM_REAL,TINYVAL
33+
use shared_parameters, only: USE_EXTERNAL_SOURCE_FILE,NSTEP_STF,NSOURCES_STF,NOISE_TOMOGRAPHY,USE_RICKER_TIME_FUNCTION
3434

3535
implicit none
3636

@@ -364,9 +364,14 @@ subroutine get_cmt(CMTSOLUTION,yr,jda,mo,da,ho,mi,sec, &
364364
endif
365365

366366
! checks half-duration
367-
! null half-duration indicates a Heaviside
368-
! replace with very short error function
369-
if (hdur(isource) < 5.d0 * DT) hdur(isource) = 5.d0 * DT
367+
if (USE_RICKER_TIME_FUNCTION) then
368+
! hdur is dominant frequency f0; only guard against zero/negative
369+
if (hdur(isource) < TINYVAL) hdur(isource) = TINYVAL
370+
else
371+
! null half-duration indicates a Heaviside
372+
! replace with very short error function
373+
if (hdur(isource) < 5.d0 * DT) hdur(isource) = 5.d0 * DT
374+
endif
370375

371376
! reads USER EXTERNAL SOURCE if needed
372377
if (USE_EXTERNAL_SOURCE_FILE) then

src/specfem3D/get_elevation.f90

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ subroutine get_elevation_and_z_coordinate_all(npoints,plon,plat,pbur,utm_x,utm_y
3636

3737
use constants, only: CUSTOM_REAL,HUGEVAL,ILONGLAT2UTM
3838
use specfem_par, only: ibool,myrank,NSPEC_AB,NGLOB_AB,USE_SOURCES_RECEIVERS_Z, &
39-
xstore,ystore,zstore,NPROC,num_free_surface_faces,free_surface_ispec,free_surface_ijk
39+
xstore,ystore,zstore,NPROC,num_free_surface_faces,free_surface_ispec,free_surface_ijk, &
40+
NSPEC2D_BOTTOM
41+
use shared_parameters, only: BOTTOM_FREE_SURFACE
4042
implicit none
4143

4244
integer, intent(in) :: npoints
@@ -52,6 +54,7 @@ subroutine get_elevation_and_z_coordinate_all(npoints,plon,plat,pbur,utm_x,utm_y
5254
double precision, dimension(:,:), allocatable :: elevation_all,elevation_distmin_all
5355
real(kind=CUSTOM_REAL) :: xloc,yloc,loc_ele,loc_distmin
5456
integer :: iproc,ier
57+
integer :: num_topo_faces, iface_offset
5558

5659
!debug
5760
!print *,'get elevation: ',npoints
@@ -107,6 +110,16 @@ subroutine get_elevation_and_z_coordinate_all(npoints,plon,plat,pbur,utm_x,utm_y
107110
elevation_all(:,:) = 0.d0
108111
elevation_distmin_all(:,:) = HUGEVAL
109112

113+
! when the bottom is a free surface, its faces are stored first in free_surface_ispec
114+
! (bottom faces are filled before top faces in get_absorbing_boundary.F90).
115+
! skip those bottom faces so elevation is always taken from the top surface.
116+
if (BOTTOM_FREE_SURFACE) then
117+
iface_offset = NSPEC2D_BOTTOM
118+
else
119+
iface_offset = 0
120+
endif
121+
num_topo_faces = num_free_surface_faces - iface_offset
122+
110123
! gets elevation
111124
do ipoin = 1, npoints
112125
xloc = x_target(ipoin)
@@ -115,7 +128,7 @@ subroutine get_elevation_and_z_coordinate_all(npoints,plon,plat,pbur,utm_x,utm_y
115128
! get approximate topography elevation at point x/y coordinates
116129
call get_topo_elevation_free(xloc,yloc,loc_ele,loc_distmin, &
117130
NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
118-
num_free_surface_faces,free_surface_ispec,free_surface_ijk)
131+
num_topo_faces,free_surface_ispec(iface_offset+1:),free_surface_ijk(:,:,iface_offset+1:))
119132

120133
elevation(ipoin) = loc_ele
121134
elevation_distmin(ipoin) = loc_distmin
@@ -166,7 +179,9 @@ subroutine get_elevation_and_z_coordinate(lon,lat,utm_x,utm_y,z_target,elevation
166179

167180
use constants
168181
use specfem_par, only: USE_SOURCES_RECEIVERS_Z,ibool,myrank,NSPEC_AB,NGLOB_AB, &
169-
xstore,ystore,zstore,NPROC,num_free_surface_faces,free_surface_ispec,free_surface_ijk
182+
xstore,ystore,zstore,NPROC,num_free_surface_faces,free_surface_ispec,free_surface_ijk, &
183+
NSPEC2D_BOTTOM
184+
use shared_parameters, only: BOTTOM_FREE_SURFACE
170185

171186
implicit none
172187

@@ -179,6 +194,7 @@ subroutine get_elevation_and_z_coordinate(lon,lat,utm_x,utm_y,z_target,elevation
179194
double precision,dimension(1) :: altitude_rec,distmin_ele
180195
double precision,dimension(NPROC) :: distmin_ele_all,elevation_all
181196
real(kind=CUSTOM_REAL) :: xloc,yloc,loc_ele,loc_distmin
197+
integer :: num_topo_faces,iface_offset
182198

183199
! convert station location to UTM
184200
call utm_geo(lon,lat,utm_x,utm_y,ILONGLAT2UTM)
@@ -194,10 +210,19 @@ subroutine get_elevation_and_z_coordinate(lon,lat,utm_x,utm_y,z_target,elevation
194210
return
195211
endif
196212

213+
! when the bottom is a free surface, its faces are stored first in free_surface_ispec;
214+
! skip them so elevation is always taken from the top surface.
215+
if (BOTTOM_FREE_SURFACE) then
216+
iface_offset = NSPEC2D_BOTTOM
217+
else
218+
iface_offset = 0
219+
endif
220+
num_topo_faces = num_free_surface_faces - iface_offset
221+
197222
! get approximate topography elevation at point long/lat coordinates
198223
call get_topo_elevation_free(xloc,yloc,loc_ele,loc_distmin, &
199224
NSPEC_AB,NGLOB_AB,ibool,xstore,ystore,zstore, &
200-
num_free_surface_faces,free_surface_ispec,free_surface_ijk)
225+
num_topo_faces,free_surface_ispec(iface_offset+1:),free_surface_ijk(:,:,iface_offset+1:))
201226

202227
altitude_rec(1) = loc_ele
203228
distmin_ele(1) = loc_distmin

0 commit comments

Comments
 (0)