forked from philbording/model_build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdlb_001.f
338 lines (295 loc) · 7.9 KB
/
mdlb_001.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
Program mdlb
!
! Model Building Program
! R. P. Bording
! Copy Right May 2020
!
parameter (ndpts = 4096)
parameter (ndl = 4096)
parameter (ndx=2000,ndz=2000)
character*80 line
character*80 model_name
dimension ip1v(ndl),ip2v(ndl)
dimension vpv(ndl),vsv(ndl),dev(ndl)
dimension iptype(ndl)
! = 1 single line segment == line
! = 2 multi-line segment == segment
dimension xzp(2,ndpts)
dimension kxzp(ndpts)
dimension vp (ndx,ndz)
dimension vs (ndx,ndz)
dimension den(ndx,ndz)
open ( 10, file="velmod.dat",form="formatted",
x status="unknown")
read(10,"(a)") model_name
write(6,*) " "
write(6,"(a)") model_name
read(10,*) nmx,nmz
read(10,*) xmin,zmin
read(10,*) dx,dz
read(10,*) vpmin,vsmin,denmin
write(6,*) " "
write(6,*) " Grid sizes nx,nz = ",nmx,nmz
write(6,*) " Grid Spacing dx,dz ",dx,dz
xmax = (nmx-1)*dx - xmin
zmax = (nmz-1)*dz - zmin
write(6,*) " Xmin, Zmin ",xmin,zmin
write(6,*)" Min velocity, Vp, Vs, Density ",vpmin,vsmin,denmin
write(6,*) " "
close(10)
open ( 11, file="velline.dat",form="formatted",
x status="unknown")
ipc = 0
write(6,*) " line inputs "
write(6,*) " Point 1, Point 2, Vp, Vs, Density "
99 continue
c read( 11,*,end=100) ip1,ip2,vpl,vsl,denl
c read( 11,*,end=100) ip1,ip2,vpl
read( 11,"(a)",end=100) line
write( 6,"(a)") line
if( line(1:4) .eq. "Line" ) then
itype = 1
go to 99
endif
if( line(1:4) .eq. "line" ) then
itype = 1
go to 99
endif
if( line(1:4) .eq. "Segm" ) then
itype = 2
go to 99
endif
if( line(1:4) .eq. "segm" ) then
itype = 2
go to 99
endif
read(line,*) ip1,ip2,vpl
! if( ip1 .eq. 0 .and. ip2 .eq. 0 ) go to 100
vsl = 1300.0
denl = 2.2
if( mod(ipc,20) .eq. 0 ) then
write(6,*) " line inputs "
write(6,*) " Point 1, Point 2, Vp, Vs, Density "
endif
write( 6, *) ip1,ip2,vpl,vsl,denl
ipc = ipc + 1
iptype(ipc) = itype
ip1v(ipc) = ip1
ip2v(ipc) = ip2
vpv(ipc) = vpl
vsv(ipc) = vsl
dev(ipc) = denl
go to 99
100 continue
npc = ipc
close(11)
write(6,*) " "
!
! End of line segment input
!
do i=1,ndpts
kxzp(i) = 0
enddo
!
write(6,*) " "
open ( 11, file="velpts.dat",form="formatted",
x status="unknown")
write(6,*) " Scale of input points "
read( 11, *) xp_scale,zp_scale
write( 6, *) " x,z scale ",xp_scale,zp_scale
write(6,*) " "
98 continue
read( 11,*,end=101) ixzp,xp,zp
kxzp(ixzp) = 1
xzp(1,ixzp) = xp*xp_scale
xzp(2,ixzp) = zp*zp_scale
if( xzp(1,ixzp) .lt. xmin ) xzp(1,ixzp) = xmin
if( xzp(1,ixzp) .gt. xmax ) xzp(1,ixzp) = xmax
if( xzp(2,ixzp) .lt. zmin ) xzp(2,ixzp) = zmin
if( xzp(2,ixzp) .gt. zmax ) xzp(2,ixzp) = zmax
write( 6, *) " grid point number, x,z ", ixzp,xp,zp,
x xzp(1,ixzp),xzp(2,ixzp)
go to 98
101 continue
close(11)
write(6,*) " "
!
! end of grid point inputs, these points make up the line segments
!
call setmin(vp,vs,den,vpmin,vsmin,denmin)
write(6,*) " Arrays are set to zero "
!
call bvelmodel(ip1v,ip2v,kxzp,iptype,xzp,
x nmx,nmz,
x vpv,vsv,denv,vp,vs,den,
x npc,dx,dz,xmin,zmin)
!
write(6,*) " Grid sizes nx,nz = ",nmx,nmz
open ( 20, file="vp.dat",form="unformatted",
x status="unknown")
do ix=1,nmx
write(20) (vp(ix,jz),jz=1,nmz)
enddo
close(20)
do ix=1,nmx
write(20) (vp(ix,jz),jz=1,nmz)
enddo
write(21) ((vs(ix,jz),jz=1,nmz),ix=1,nmx)
write(22) ((den(ix,jz),jz=1,nmz),ix=1,nmx)
end
subroutine setmin(vp,vs,den,vpmin,vsmin,denmin)
parameter (ndx=2000,ndz=2000)
dimension vp (ndx,ndz)
dimension vs (ndx,ndz)
dimension den(ndx,ndz)
c
c python f2py calling sequence directives
c
c
c
cf2py intent (in) vpmin
cf2py intent (in) vsmin
cf2py intent (in) denmin
cf2py intent (out) vp
cf2py intent (out) vs
cf2py intent (out) den
c
c end of directives
c
do ix=1,ndx
do jz=1,ndz
vp(ix,jz) = vpmin
vs(ix,jz) = vsmin
den(ix,jz) = denmin
enddo
enddo
return
end
subroutine bvelmodel(ip1v,ip2v,kxzp,iptype,xzp,
x nmx,nmz,
x vpv,vsv,denv,vp,vs,den,
x npc,dx,dz,xmin,zmin)
parameter (ndpts = 4096)
parameter (ndl = 4096)
parameter (ndx=2000,ndz=2000)
dimension ip1v(ndl),ip2v(ndl)
dimension vpv(ndl),vsv(ndl),dev(ndl)
dimension iptype(ndl)
! = 1 single line segment == line
! = 2 multi-line segment == segment
dimension xzp(2,ndpts)
dimension kxzp(ndpts)
dimension vp (ndx,ndz)
dimension vs (ndx,ndz)
dimension den(ndx,ndz)
c
c python f2py calling sequence directives
c
c
c
cf2py intent (in) ip1v
cf2py intent (in) 1p2v
cf2py intent (in) kxpz
cf2py intent (in) iptype
cf2py intent (in) xzp
cf2py intent (in) nmx
cf2py intent (in) nmz
cf2py intent (in) vpv
cf2py intent (in) vsv
cf2py intent (in) denv
cf2py intent (in) npc
cf2py intent (in) dx
cf2py intent (in) dz
cf2py intent (in) xmin
cf2py intent (in) zmin
cf2py intent (in,out) vp
cf2py intent (in,out) vs
cf2py intent (in,out) den
c
c end of directives
c
write(6,*) " npc ",npc
do ipc=1,npc
!
! process each line segment
!
! they must be sequenced from top to bottom
!
ip1a = ip1v(ipc)
ip2a = ip2v(ipc)
write(6,*) " ip1a,ip2a ",ip1a,ip2a
if( ip1a .gt. ip2a ) then
ittp = ip1a
ip1a = ip2a
ip2a = ittp
endif
!
if( kxzp(ip1a) .eq. 1 ) then
if( kxzp(ip2a) .eq. 1 ) then
if( iptype(ipc) .eq. 1 ) then
kip = ip2a-ip1a
endif
if( iptype(ipc) .eq. 2 ) then
kip = 1
endif
write(6,*) " "
write(6,*) ip1a,ip2a,kip
write(6,*) " "
do ip1=ip1a,ip2a,kip
if( ip1 .ne. ip2a ) then
if( iptype(ipc) .eq. 1 ) then
ip2 = ip1+kip
endif
if( iptype(ipc) .eq. 2 ) then
ip2 = ip1 + 1
endif
! point is ok
xa = xzp(1,ip1)
za = xzp(2,ip1)
xb = xzp(1,ip2)
zb = xzp(2,ip2)
write(6,*) xa,za,xb,zb
!
if( xb .lt. xa ) then
xt = xa
xa = xb
xb = xt
zt = za
za = zb
zb = zt
endif
!
ixa = (xa-dx)/dx
ixb = (xb+dx)/dx
if( ixa .lt. 1 ) ixa = 1
if( ixb .gt. nmx ) ixb = nmx
do ix = ixa,ixb
xxp = (ix-1)*dx + xmin
if( xxp .ge. xa ) then
if( xxp .le. xb ) then
amu = (xxp-xa)/(xb-xa)
zzp = za + amu*(zb-za)
jza = (zzp-2.0*dz)/dz
if( jza .lt. 1 ) jza = 1
jzb = nmz
do jz = jza,jzb
zpz = (jz-1)*dz + zmin
if( zpz .ge. zzp ) then
vp(ix,jz) = vpv(ipc)
vs(ix,jz) = vsv(ipc)
den(ix,jz) = dev(ipc)
endif
enddo
endif
endif
enddo
!
endif
enddo
else
write(6,*) " error p1 or p2 is bad ",ip1,ip2
endif
endif
enddo
return
end