2727
2828
2929 subroutine write_wavefield_discontinuity_database ()
30+
3031! write data related to wavefield discontinuity to proc*_Database
32+
3133 use meshfem_par, only: nb_wd, boundary_to_ispec_wd, side_wd, prname
3234 use constants, only: FNAME_WAVEFIELD_DISCONTINUITY_MESH, &
3335 IFILE_WAVEFIELD_DISCONTINUITY
3436 implicit none
35- ! local variables
37+
3638 open (unit= IFILE_WAVEFIELD_DISCONTINUITY, &
3739 file = prname(1 :len_trim (prname))// &
3840 trim (FNAME_WAVEFIELD_DISCONTINUITY_MESH), &
3941 form= ' unformatted' , action= ' write' )
42+
4043 write (IFILE_WAVEFIELD_DISCONTINUITY) nb_wd
4144 write (IFILE_WAVEFIELD_DISCONTINUITY) boundary_to_ispec_wd
4245 write (IFILE_WAVEFIELD_DISCONTINUITY) side_wd
46+
4347 close (IFILE_WAVEFIELD_DISCONTINUITY)
48+
4449 end subroutine write_wavefield_discontinuity_database
4550
4651!
4752!- ----------------------------------------------------------
4853!
4954
5055 subroutine write_wavefield_discontinuity_file ()
56+
5157! write wavefield discontinuity interfaces to an ascii file
5258! works only when NPROC = 1
59+
5360 use meshfem_par, only: nb_wd, boundary_to_ispec_wd, side_wd
5461 use constants, only: IFILE_WAVEFIELD_DISCONTINUITY, &
5562 FNAME_WAVEFIELD_DISCONTINUITY_INTERFACE
5663 implicit none
5764 ! local variables
5865 integer :: i
66+
5967 open (unit= IFILE_WAVEFIELD_DISCONTINUITY, &
6068 file= ' MESH/' // trim (FNAME_WAVEFIELD_DISCONTINUITY_INTERFACE), &
6169 form= ' formatted' , action= ' write' )
70+
6271 do i = 1 , nb_wd
6372 write (IFILE_WAVEFIELD_DISCONTINUITY, * ) boundary_to_ispec_wd(i), side_wd(i)
6473 enddo
74+
6575 close (IFILE_WAVEFIELD_DISCONTINUITY)
76+
6677 end subroutine write_wavefield_discontinuity_file
6778
6879!
6980!- ----------------------------------------------------------
7081!
7182
7283 subroutine find_wavefield_discontinuity_elements ()
84+
7385! read the wavefield_discontinuity_box file
7486! find the wavefield discontinuity interface
87+
7588 use constants, only: IFILE_WAVEFIELD_DISCONTINUITY, &
7689 FNAME_WAVEFIELD_DISCONTINUITY_BOX
7790 use meshfem_par, only: xstore,ystore,zstore,nspec
@@ -90,6 +103,7 @@ subroutine find_wavefield_discontinuity_elements()
90103 open (unit= IFILE_WAVEFIELD_DISCONTINUITY, &
91104 file= trim (FNAME_WAVEFIELD_DISCONTINUITY_BOX), &
92105 form= ' formatted' , action= ' read' )
106+
93107 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) IS_TOP_WAVEFIELD_DISCONTINUITY
94108 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) IS_EXTRAPOLATION_MODE
95109 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) x_min
@@ -98,7 +112,9 @@ subroutine find_wavefield_discontinuity_elements()
98112 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) y_max
99113 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) z_min
100114 read (IFILE_WAVEFIELD_DISCONTINUITY, * ) z_max
115+
101116 close (IFILE_WAVEFIELD_DISCONTINUITY)
117+
102118 nb_wd = 0
103119 do ispec = 1 , nspec
104120 covered(:) = .false.
@@ -473,9 +489,11 @@ subroutine find_wavefield_discontinuity_elements()
473489 endif
474490 endif
475491 enddo
492+
476493 allocate (boundary_to_ispec_wd(nb_wd), side_wd(nb_wd))
477494 boundary_to_ispec_wd(1 :nb_wd) = boundary_to_ispec_wd_temp(1 :nb_wd)
478495 side_wd(1 :nb_wd) = side_wd_temp(1 :nb_wd)
496+
479497 end subroutine find_wavefield_discontinuity_elements
480498
481499!
@@ -490,7 +508,9 @@ logical function is_boundary_wd(x, y, z, x_min, x_max, y_min, y_max, &
490508 double precision :: x_min, x_max, y_min, y_max, z_min, z_max
491509 double precision :: x, y, z, x_mid, y_mid, z_mid, dx, dy, dz
492510 logical :: IS_TOP_WAVEFIELD_DISCONTINUITY, IS_EXTRAPOLATION_MODE
511+
493512 is_boundary_wd = .false.
513+
494514 if (IS_EXTRAPOLATION_MODE) then
495515 if (((x > x_min - dx) .and. (x < x_max + dx) .and. &
496516 (y > y_min - dy) .and. (y < y_max + dy) .and. &
@@ -510,4 +530,5 @@ logical function is_boundary_wd(x, y, z, x_min, x_max, y_min, y_max, &
510530 (z_mid < z_max))) &
511531 is_boundary_wd = .true.
512532 endif
533+
513534 end function is_boundary_wd
0 commit comments