SPEED
GET_NODE_DEPTH_AND_VS.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
50
51
52 subroutine get_node_depth_and_vs(loc_n_num, nn_elev, nn_elem, &
53 xx_elev, yy_elev, zz_elev, vs_elev, sediments, &
54 node1_elem, node2_elem, node3_elem, &
55 cs_nnz_loc, cs_loc, nm, tm, sd, &
56 nn_s, xx_s, yy_s, zz_s, &
57 zz_elevation, zz_alluvial, vs, thickness, &
58 tagmat, max_es,tol)
59
60 implicit none
61
62 integer*4 :: im,ie,i,j,k,nn,ip,isn,ic
63 integer*4 :: nn_elev, nn_elem, cs_nnz_loc, nm, ne, nn_s
64 integer*4 :: h, h_sel
65 integer*4 :: tagmat
66
67 integer*4, dimension(nn_s) :: loc_n_num
68 integer*4, dimension(nn_elem) :: node1_elem,node2_elem,node3_elem
69 integer*4, dimension(nm) :: tm
70 integer*4, dimension(nm) :: sd
71 integer*4, dimension(0:cs_nnz_loc) :: cs_loc
72
73 real*8 :: x1,y1,z1
74 real*8 :: x2,y2,z2
75 real*8 :: x3,y3,z3
76 real*8 :: ux,uy,uz,vx,vy,vz
77 real*8 :: a,b,c
78 real*8 :: max_es
79 real*8 :: zz_interp
80 real*8 :: v0x,v0y,v1x,v1y,v2x,v2y
81 real*8 :: dot00,dot01,dot02,dot11,dot12
82 real*8 :: invdenom,u,v
83 real*8 :: d2min
84 real*8 :: zz_elev_min
85 real*8 :: dx,dy,dz,tol, dist, dist_min
86
87 real*8, dimension(:), allocatable :: ct,ww
88 real*8, dimension(nn_elev) :: xx_elev,yy_elev,zz_elev
89 real*8, dimension(nn_elem) :: vs_elev,sediments
90 real*8, dimension(nn_s) :: xx_s,yy_s,zz_s
91 real*8, dimension(nn_s) :: zz_elevation
92 real*8, dimension(nn_s) :: zz_alluvial
93 real*8, dimension(nn_s) :: vs, thickness
94
95 real*8, dimension(:,:), allocatable :: dd
96
97 d2min = (5 * max_es)**2
98
99 zz_elev_min = zz_elev(1)
100 do i = 1,nn_elev
101 if (zz_elev(i).lt.zz_elev_min) then
102 zz_elev_min = zz_elev(i)
103 endif
104 enddo
105 !write(*,*) d2min, max_es
106
107
108 ne = cs_loc(0) - 1
109
110 do ie = 1,ne
111
112 im = cs_loc(cs_loc(ie -1) +0)
113
114 if (im .eq. tagmat) then
115
116 nn = sd(im) +1
117 allocate(ct(nn),ww(nn),dd(nn,nn))
118 call make_lgl_nw(nn,ct,ww,dd)
119
120
121 do k = 1,nn
122 do j = 1,nn
123 do i = 1,nn
124
125 ip = nn*nn*(k -1) +nn*(j -1) +i
126 isn = cs_loc(cs_loc(ie -1) + ip)
127 ic = isn
128
129 dist_min = 1.d+30;
130 h_sel = 0;
131 do h = 1,nn_elem
132
133
134 x1 = xx_elev(node1_elem(h))
135 y1 = yy_elev(node1_elem(h))
136 z1 = zz_elev(node1_elem(h))
137
138 dist = (x1 - xx_s(ic))**2 + (y1 - yy_s(ic))**2
139 if (dist .le. dist_min) then
140 h_sel = h;
141 dist_min = dist;
142 endif
143 enddo
144
145 !write(*,*) h_sel
146 !read(*,*)
147 x1 = xx_elev(node1_elem(h_sel))
148 y1 = yy_elev(node1_elem(h_sel))
149 z1 = zz_elev(node1_elem(h_sel))
150
151 x2 = xx_elev(node2_elem(h_sel))
152 y2 = yy_elev(node2_elem(h_sel))
153 z2 = zz_elev(node2_elem(h_sel))
154
155 x3 = xx_elev(node3_elem(h_sel))
156 y3 = yy_elev(node3_elem(h_sel))
157 z3 = zz_elev(node3_elem(h_sel))
158
159
160 zz_interp = (z1 + z2 + z3)/3.d0
161 zz_elevation(ic) = ( zz_interp - zz_s(ic) )
162 vs(ic) = vs_elev(h_sel)
163 thickness(ic) = sediments(h_sel)
164
165 if(zz_elevation(ic) .le. tol) then
166 zz_elevation(ic) = 0.0d0
167 vs(ic) = vs_elev(h_sel)
168 thickness(ic) = sediments(h_sel)
169 endif
170
171
172
173
174 enddo !do k = 1,nn
175 enddo !do j = 1,nn
176 enddo !do i = 1,nn
177
178 deallocate(ct,ww,dd)
179
180 endif !if im.eq.tagmat
181 enddo
182
183
184 return
185
186 end subroutine get_node_depth_and_vs
187
subroutine get_node_depth_and_vs(loc_n_num, nn_elev, nn_elem, xx_elev, yy_elev, zz_elev, v
Computes elevation from topography (XYZ.out), vs30 velocity and depth of sediments according to the i...
subroutine make_lgl_nw(nb_pnt, xq, wq, dd)
Makes Gauss-Legendre-Lobatto nodes, weigths and spectral derivatives.