-
Notifications
You must be signed in to change notification settings - Fork 1
/
qssh.f
241 lines (241 loc) · 5.78 KB
/
qssh.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
subroutine qssh(y,k,lup,llw)
implicit none
c
c calculation of response to sh source
c y(6,6): solution vector (complex)
c k: wave number
c
integer lup,llw
double precision k
double complex y(6,6)
c
include 'qsglobal.h'
c
c work space
c
integer i,istp,l,n,key
double complex cnorm
double complex y0(2),b(2,6),b0(2,6)
double complex y1(2),yup(2),ylw(2)
double complex hk(2,2,nzmax),coef(2,2),cinc(6),c0
logical rsite
c
c===============================================================================
c
c matrix propagation from surface to source
c
rsite=.false.
do l=lup,ls-1
n=nno(l)
call qshksh(hk(1,1,l),hp(l),n,rsite)
enddo
do l=ls,llw-1
n=nno(l)
call qshksh(hk(1,1,l),-hp(l),n,rsite)
enddo
c
c yup: the starting solution vector
c
yup(1)=(1.d0,0.d0)
if(lup.eq.1.and.isurf.eq.0)then
yup(2)=(0.d0,0.d0)
else
n=nno(lup)
yup(2)=cmu(n)*ks(n)
endif
if(lup.eq.lzr)call cmemcpy(yup,y0,2)
c
do l=lup+1,ls
n=nno(l-1)
c
c determination of propagation matrix
c
call caxcb(hk(1,1,l-1),yup,2,2,1,y1)
call cmemcpy(y1,yup,2)
c
c normalization
c
if(l.gt.lzr)then
cnorm=cdexp(-ks(n)*dcmplx(hp(l-1),0.d0))
y0(1)=y0(1)*cnorm
y0(2)=y0(2)*cnorm
else if(l.eq.lzr)then
call cmemcpy(yup,y0,2)
endif
enddo
c
c===============================================================================
c
c matrix propagation from half-space to source
c
c ylw: the starting solution vector
c
n=nno(llw)
ylw(1)=(1.d0,0.d0)
if(sh(llw))then
ylw(2)=-cmu(n)*ks(n)
else
ylw(2)=(0.d0,0.d0)
endif
if(llw.gt.ls.and.llw.eq.lzr)call cmemcpy(ylw,y0,2)
c
do l=llw-1,ls,-1
n=nno(l)
c
c determination of propagation matrix
c
call caxcb(hk(1,1,l),ylw,2,2,1,y1)
call cmemcpy(y1,ylw,2)
if(l.lt.lzr)then
cnorm=cdexp(-ks(n)*dcmplx(hp(l),0.d0))
y0(1)=y0(1)*cnorm
y0(2)=y0(2)*cnorm
else if(l.gt.ls.and.l.eq.lzr)then
call cmemcpy(ylw,y0,2)
endif
enddo
c
c===============================================================================
c source function
c===============================================================================
c
do istp=1,6
do i=1,2
c b(i,istp)=dcmplx(sfct0(i+4,istp)+k*sfct1(i+4,istp),0.d0)
b(i,istp)=sfct0(i+4,istp)+dcmplx(k,0.d0)*sfct1(i+4,istp)
enddo
enddo
do i=1,2
coef(i,1)=yup(i)
coef(i,2)=-ylw(i)
enddo
if(ipath.eq.1)call cmemcpy(b,b0,12)
key=0
call cdgemp(coef,b,2,6,0.d0,key)
if(key.eq.0)then
print *,'warning in qssh: anormal exit from cdgemp!'
return
endif
if(lzr.le.ls)then
do istp=1,6
do i=1,2
y(i+4,istp)=b(1,istp)*y0(i)
enddo
enddo
else
do istp=1,6
do i=1,2
y(i+4,istp)=b(2,istp)*y0(i)
enddo
enddo
endif
if(ipath.eq.1)then
n=nno(lpath)
ylw(1)=(1.d0,0.d0)
if(sh(lpath))then
ylw(2)=-cmu(n)*ks(n)
else
ylw(2)=(0.d0,0.d0)
endif
if(lpath.gt.ls.and.lpath.eq.lzr)call cmemcpy(ylw,y0,2)
do l=lpath-1,ls,-1
n=nno(l)
c
c determination of propagation matrix
c
call caxcb(hk(1,1,l),ylw,2,2,1,y1)
call cmemcpy(y1,ylw,2)
c
if(l.lt.lzr)then
cnorm=cdexp(-ks(n)*dcmplx(hp(l),0.d0))
y0(1)=y0(1)*cnorm
y0(2)=y0(2)*cnorm
else if(l.gt.ls.and.l.eq.lzr)then
call cmemcpy(ylw,y0,2)
endif
enddo
do i=1,2
coef(i,1)=yup(i)
coef(i,2)=-ylw(i)
enddo
key=0
call cdgemp(coef,b0,2,6,0.d0,key)
if(key.eq.0)then
print *,'warning in qssh: anormal exit from cdgemp!'
return
endif
if(lzr.le.ls)then
do istp=1,6
do i=1,2
y(i+4,istp)=y(i+4,istp)-b0(1,istp)*y0(i)
enddo
enddo
else
do istp=1,6
do i=1,2
y(i+4,istp)=y(i+4,istp)-b0(2,istp)*y0(i)
enddo
enddo
endif
endif
c
if(n0rs.gt.0)then
c
c for receiver-site structure different from source-site structure
c
n=nno(lzr)
do istp=1,6
cinc(istp)=(0.5d0,0.d0)*(y(5,istp)+y(6,istp)/(cmu(n)*ks(n)))
enddo
rsite=.true.
do l=1,lprs-1
n=nnors(l)
call qshksh(hk(1,1,l),hprs(l),n,rsite)
enddo
c
c yup: the starting solution vector
c
yup(1)=(1.d0,0.d0)
if(isurf.eq.0)then
yup(2)=(0.d0,0.d0)
else
yup(2)=cmurs(1)*ksrs(1)
endif
if(lzrrs.eq.1)call cmemcpy(yup,y0,2)
c
do l=2,lprs
n=nnors(l-1)
c
c determination of propagation matrix
c
call caxcb(hk(1,1,l-1),yup,2,2,1,y1)
call cmemcpy(y1,yup,2)
c
c normalization
c
if(l.gt.lzrrs)then
cnorm=cdexp(-ksrs(n)*dcmplx(hprs(l-1),0.d0))
y0(1)=y0(1)*cnorm
y0(2)=y0(2)*cnorm
else if(l.eq.lzrrs)then
call cmemcpy(yup,y0,2)
endif
enddo
n=nnors(lprs)
c0=(0.5d0,0.d0)*(yup(1)+yup(2)/(cmurs(n)*ksrs(n)))
do istp=1,6
y(5,istp)=y0(1)*cinc(istp)/c0
y(6,istp)=y0(2)*cinc(istp)/c0
enddo
endif
if(isurf.eq.2)then
c
c free surface corrections
c
do istp=1,6
y(5,istp)=(2.d0,0.d0)*y(5,istp)
y(6,istp)=(0.d0,0.d0)
enddo
endif
return
end