Skip to content

Commit f1aed57

Browse files
committed
updates receiver check
1 parent 394063d commit f1aed57

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

src/generate_databases/setup_mesh_adjacency.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ subroutine setup_mesh_adjacency()
255255
else
256256
! no neighbors
257257
! warning
258-
print *,'*** Warning: found mesh element with no neighbors : slice ',myrank,' - element ',ispec_ref,' ***'
258+
print *,'*** Warning: found mesh element with no neighbors : slice ',myrank, &
259+
' - element ',ispec_ref,'out of',NSPEC_AB,' ***'
259260
endif
260261

261262
! again loop to get neighbors of neighbors

src/specfem3D/locate_receivers.f90

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ subroutine locate_receivers(rec_filename,utm_x_source,utm_y_source)
3939
xi_receiver,eta_receiver,gamma_receiver,nu_rec, &
4040
station_name,network_name, &
4141
stlat,stlon,stbur, &
42-
x_target_station,y_target_station,z_target_station
42+
x_target_station,y_target_station,z_target_station, &
43+
NPROC
4344
! PML
4445
use pml_par, only: is_CPML
4546

@@ -55,7 +56,7 @@ subroutine locate_receivers(rec_filename,utm_x_source,utm_y_source)
5556
double precision, allocatable, dimension(:) :: x_target,y_target,z_target
5657
double precision, allocatable, dimension(:) :: x_found,y_found,z_found
5758

58-
integer :: irec,ier,ispec
59+
integer :: irec,ier,ispec,islice
5960

6061
! timer MPI
6162
double precision, external :: wtime
@@ -283,35 +284,51 @@ subroutine locate_receivers(rec_filename,utm_x_source,utm_y_source)
283284
call bcast_all_dp(nu_rec,NDIM*NDIM*nrec)
284285
call bcast_all_dp(final_distance,nrec)
285286

286-
! checks if valid receiver element
287-
if (myrank == 0) then
288-
! locate point might return a zero ispec if point outside/above mesh
289-
do irec = 1,nrec
287+
! checks if we got valid receiver elements
288+
! locate point might return a zero ispec if point outside/above mesh
289+
do irec = 1,nrec
290+
! slice the receiver is in
291+
islice = islice_selected_rec(irec)
292+
293+
! checks slice
294+
if (islice < 0 .or. islice > NPROC-1) then
295+
print *,'Error locating station # ',irec,' ',trim(network_name(irec)),' ',trim(station_name(irec))
296+
print *,' found in an invalid slice: ',islice
297+
call exit_MPI(myrank,'Error something is wrong with the slice number of receiver')
298+
endif
299+
300+
! checks found element
301+
if (myrank == islice_selected_rec(irec)) then
302+
! element index
290303
ispec = ispec_selected_rec(irec)
291304
! checks if valid
292305
if (ispec < 1 .or. ispec > NSPEC_AB) then
293306
! invalid element
294307
print *,'Error locating station # ',irec,' ',trim(network_name(irec)),' ',trim(station_name(irec))
295308
if (SUPPRESS_UTM_PROJECTION) then
296-
print *,' original x: ',sngl(stutm_x(irec))
297-
print *,' original y: ',sngl(stutm_y(irec))
309+
print *,' original x: ',sngl(stutm_x(irec))
310+
print *,' original y: ',sngl(stutm_y(irec))
298311
else
299-
print *,' original UTM x: ',sngl(stutm_x(irec))
300-
print *,' original UTM y: ',sngl(stutm_y(irec))
312+
print *,' original UTM x: ',sngl(stutm_x(irec))
313+
print *,' original UTM y: ',sngl(stutm_y(irec))
301314
endif
302315
if (USE_SOURCES_RECEIVERS_Z) then
303-
print *,' original z: ',sngl(stbur(irec))
316+
print *,' original z: ',sngl(stbur(irec))
304317
else
305-
print *,' original depth: ',sngl(stbur(irec)),' m'
318+
print *,' original depth: ',sngl(stbur(irec)),' m'
306319
endif
307-
print *,' only found invalid element: slice ',islice_selected_rec(irec)
308-
print *,' ispec ',ispec_selected_rec(irec)
309-
print *,' domain ',idomain(irec)
310-
print *,' final_distance: ',final_distance(irec)
320+
print *,' found in an invalid element: slice :',islice_selected_rec(irec)
321+
print *,' ispec :',ispec_selected_rec(irec),'out of ',NSPEC_AB
322+
print *,' domain :',idomain(irec)
323+
print *,' xi/eta/gamma :',xi_receiver(irec),eta_receiver(irec),gamma_receiver(irec)
324+
print *,' final_distance: ',final_distance(irec)
325+
print *
326+
print *,'Please check your receiver position in file DATA/STATIONS, and move it closer the mesh geometry - exiting...'
327+
print *
311328
call exit_MPI(myrank,'Error locating receiver')
312329
endif
313-
enddo
314-
endif
330+
endif
331+
enddo
315332
call synchronize_all()
316333

317334
! warning if receiver in C-PML region

0 commit comments

Comments
 (0)