SPEED
MAKE_SEISMIC_MOMENT_POINTSOURCES_NHFAULT.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
27
28 subroutine make_seismic_moment_pointsources_nhfault()
29
30 use max_var
31 use speed_par
33
34
35 implicit none
36
37 include 'SPEED.MPI'
38
39 integer*4 :: n_neighbours, ipt, indxL
40 character*70 :: file_srcout
41
42 real(kdkind) :: query_vec(3)
43 real(kdkind), dimension(:,:), allocatable :: nodes_in_xyz
44 type(kdtree2), pointer :: kd2_obj_locnode
45 type(kdtree2_result) :: result_temp(1)
46
47!*****************************************************************************************
48! SEISMIC MOMENT
49!*****************************************************************************************
50
51 if (mpi_id.eq.0 .and. nload_sism_el.gt.0) &
52 write(*,'(A)') '-----------Building the Seismic Moment vector----------'
53
54 if (nload_sism_el.gt.0) then
55
56 if (mpi_id.eq.0) then
57 file_srcout = 'srcmod_points.out'
58 open(444,file=file_srcout)
59 endif
60
61
65
71
74
75 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
76 ! Defining Kd-tree Object and then search
77 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 allocate(nodes_in_xyz(3,nnod_loc))
79 do ipt = 1, nnod_loc
80 nodes_in_xyz(1,ipt) = xx_spx_loc(ipt)
81 nodes_in_xyz(2,ipt) = yy_spx_loc(ipt)
82 nodes_in_xyz(3,ipt) = zz_spx_loc(ipt)
83 enddo
84
85 kd2_obj_locnode => kdtree2_create(nodes_in_xyz,sort=.false.,rearrange=.true.)
86 n_neighbours = 1
87
88
89
90 !Searching the node 'id' in the global numeration for each seismic faults.
91 !sour_node_sism = node id (global numeration) generating the 'i'th seismic fault
92 do i = 1,nload_sism_el
93
94 query_vec(1) = val_sism_el(i,4)
95 query_vec(2) = val_sism_el(i,5)
96 query_vec(3) = val_sism_el(i,6)
97 call kdtree2_n_nearest(kd2_obj_locnode,query_vec,n_neighbours,result_temp)
98 indxl = result_temp(1)%idx ! Inder of Nearest Neighbor
99
101 pos_sour_node_x(1,i) = xx_spx_loc(indxl)
102 pos_sour_node_y(1,i) = yy_spx_loc(indxl)
103 pos_sour_node_z(1,i) = zz_spx_loc(indxl)
104
105 ! Check dist_sour_node_sism - In Other parts of code its distance between Hypocenter to Node
109
110
111 ! Collecting Nearest Neighbours From all Processors and selecting the nearest one
114
115 call mpi_barrier(mpi_comm, mpi_ierr)
116 call mpi_allgather(sour_node_sism(1,i), 1, speed_integer, sism_el_glo, 1, speed_integer, mpi_comm, mpi_ierr)
117 call mpi_allgather(dist_sour_node_sism(1,i), 1, speed_double, dist_el_glo, 1, speed_double, mpi_comm, mpi_ierr)
118 call mpi_allgather(pos_sour_node_x(1,i), 1, speed_double, posx_el_glo, 1, speed_double, mpi_comm, mpi_ierr)
119 call mpi_allgather(pos_sour_node_y(1,i), 1, speed_double, posy_el_glo, 1, speed_double, mpi_comm, mpi_ierr)
120 call mpi_allgather(pos_sour_node_z(1,i), 1, speed_double, posz_el_glo, 1, speed_double, mpi_comm, mpi_ierr)
121
123
124
130
132
133
134 if (mpi_id.eq.0 .and. i .eq. 1) write(*,'(A)')
135 if (mpi_id.eq.0 .and. i .eq. 1) write(*,'(A)')'Seismic faults'
136 if (mpi_id.eq.0 .and. i .eq. 1) write(*,'(A)')
137 j = 1;
138 if (mpi_id.eq.0) write(*,'(A,I6,A,I6,A)')'Seismic Faults - ',i, ' is generated by ',j,' nodes'
139 do k = 1, j
140 if (mpi_id.eq.0) write(*,*) 'Node :', sour_node_sism(k,i)
141 if (mpi_id.eq.0) write(*,*) 'Position :', pos_sour_node_x(k,i), pos_sour_node_y(k,i), pos_sour_node_z(k,i)
142 if (mpi_id.eq.0) write(*,*) 'Distance from Actual Node [m] = ', dist_sour_node_sism(k,i)
143 enddo
144 if (mpi_id.eq.0) write(*,'(A)')
145
146
147 if (mpi_id.eq.0) then
148 write(444,*)val_sism_el(i,4),val_sism_el(i,5),val_sism_el(i,6),dist_sour_node_sism(1,i),&
150 endif
151
152
153 enddo !i = 1,nload_sism_el
154
155 deallocate(nodes_in_xyz)
156 call kdtree2_destroy(kd2_obj_locnode)
157
158
159 endif !if (nload_sism_el.gt.0)
160
161 if (nfunc.le.0) nfunc = 1
162
163 if (nload_sism_el.gt.0) then
165 allocate (tau_seismic_moment(nload_sism_el,1))
166 endif
167
168 if ((mpi_id.eq.0).and.(nload_sism_el.gt.0)) write(*,'(A)')'Seismic Moment vector built'
169 call mpi_barrier(mpi_comm, mpi_ierr)
170
171
172 end subroutine make_seismic_moment_pointsources_nhfault
173
subroutine get_minvalues(i_glo, v_glo, n_glo, i_loc, n_loc, np)
Computes positions of minimum values.
type(kdtree2) function, pointer, public kdtree2_create(input_data, dim, sort, rearrange)
Definition kdtree2.f90:612
subroutine, public kdtree2_destroy(tp)
Definition kdtree2.f90:989
subroutine, public kdtree2_n_nearest(tp, qv, nn, results)
Definition kdtree2.f90:1031
Set maximal bounds.
Definition MODULES.f90:54
Contains SPEED PARAMETERS used in (SPEED, READ_INPUT_FILES, MAKE_PARTION_AND_MPI_FILES,...
Definition MODULES.f90:207
integer *4 nload_sism_el
Definition MODULES.f90:269
real *8, dimension(:,:), allocatable pos_sour_node_y
Definition MODULES.f90:474
real *8, dimension(:,:), allocatable pos_sour_node_x
Definition MODULES.f90:474
real *8, dimension(:,:), allocatable factor_seismic_moment
Definition MODULES.f90:474
integer *4 nfunc
Definition MODULES.f90:269
integer *4 j
Definition MODULES.f90:263
integer *4, dimension(:), allocatable sism_el_glo
Definition MODULES.f90:363
real *8, dimension(:,:), allocatable val_sism_el
Definition MODULES.f90:463
real *8, dimension(:), allocatable zz_spx_loc
Definition MODULES.f90:408
integer *4 i
Definition MODULES.f90:263
real *8, dimension(:), allocatable yy_spx_loc
Definition MODULES.f90:408
real *8, dimension(:,:), allocatable dist_sour_node_sism
Definition MODULES.f90:474
integer *4 k
Definition MODULES.f90:263
integer *4 mpi_comm
Definition MODULES.f90:308
integer *4, dimension(:), allocatable local_node_num
Definition MODULES.f90:322
integer *4 mpi_ierr
Definition MODULES.f90:298
real *8, dimension(:), allocatable posy_el_glo
Definition MODULES.f90:417
integer *4, dimension(:), allocatable num_node_sism
Definition MODULES.f90:363
integer *4 max_num_node_sism
Definition MODULES.f90:269
real *8, dimension(:), allocatable posx_el_glo
Definition MODULES.f90:417
integer *4 mpi_np
Definition MODULES.f90:308
real *8, dimension(:), allocatable posz_el_glo
Definition MODULES.f90:417
integer *4 mpi_id
Definition MODULES.f90:308
integer *4 nnod_loc
Definition MODULES.f90:269
real *8, dimension(:), allocatable xx_spx_loc
Definition MODULES.f90:408
real *8, dimension(:,:), allocatable pos_sour_node_z
Definition MODULES.f90:474
integer *4, dimension(:,:), allocatable sour_node_sism
Definition MODULES.f90:383
real *8, dimension(:,:), allocatable tau_seismic_moment
Definition MODULES.f90:474
real *8, dimension(:), allocatable dist_el_glo
Definition MODULES.f90:417