-
Notifications
You must be signed in to change notification settings - Fork 0
/
tau_p.f
149 lines (144 loc) · 3.8 KB
/
tau_p.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
SUBROUTINE findp0(x,p0)
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c solve d(tau)/dp = 0 for p0, tau=p*x+eta*z
c input:
c x --- distance
c p0 -- the largest possible p
c output: p0
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
IMPLICIT NONE
REAL ZERO, dtdp0, x
COMPLEX dtdp, p0, p1, p2
ZERO = 1.E-7
p1 = CMPLX(0.,AIMAG(p0))
DO WHILE ( p1.NE.p0 )
p2 = p0
p0 = 0.5*(p1+p2)
dtdp0 = dtdp(x,p0)
IF ( ABS(dtdp0).LT.ZERO .OR. p0.EQ.p1 .OR. p0.EQ.p2 ) RETURN
IF( dtdp0 .GT. 0. ) THEN
p1 = p0
p0 = p2
END IF
ENDDO
RETURN
END
COMPLEX FUNCTION taup(p,x)
c define function tau(p) = p x + eta h
IMPLICIT NONE
INCLUDE'aseries.h'
INTEGER i
REAL x
COMPLEX p, pp
taup = p*x
pp = p*p
DO i = topp, bttm
taup=taup+SQRT(vps(1,i)-pp)*ray_len(1,i)
& +SQRT(vps(2,i)-pp)*ray_len(2,i)
ENDDO
RETURN
END
COMPLEX FUNCTION dtdp(x,p)
c define d(tau)/dp
IMPLICIT NONE
INCLUDE'aseries.h'
INTEGER j
REAL x
COMPLEX p, pp
pp = p*p
dtdp = 0.0
DO j = topp, bttm
dtdp=dtdp-ray_len(1,j)/SQRT(vps(1,j)-pp)
& -ray_len(2,j)/SQRT(vps(2,j)-pp)
ENDDO
dtdp = x + p*dtdp
RETURN
END
SUBROUTINE dtdp23(p, dt2dp2, dt3dp3)
c calculate the second and 3rd derivatives of tau(p)
IMPLICIT NONE
INCLUDE'aseries.h'
COMPLEX e1, e2, p, pp, dt2dp2, dt3dp3
INTEGER j
pp = p*p
dt2dp2 = 0.
dt3dp3 = 0.
DO j = topp, bttm
e1 = vps(1,j)-pp
e2 = vps(2,j)-pp
dt2dp2=dt2dp2-ray_len(1,j)*vps(1,j)/e1/SQRT(e1)
& -ray_len(2,j)*vps(2,j)/e2/SQRT(e2)
dt3dp3=dt3dp3-3*p*ray_len(1,j)*vps(1,j)/e1/e1/SQRT(e1)
& -3*p*ray_len(2,j)*vps(2,j)/e2/e2/SQRT(e2)
ENDDO
RETURN
END
COMPLEX FUNCTION time2(x,p,dpdt)
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c find the p(tau) contour which makes Im(tau) = 0. Return the tau.
c INPUT:
c x: distance
c p: complex ray parameter on the contour
c dpdt: dp/dt at this point p
c OUT:
c p: new point on the contour with time advanced by ~dt
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
IMPLICIT NONE
REAL ti, ti1, ti2, x, ZERO, delpr
COMPLEX taup, p, p1, p2, dpdt
c
ZERO = 1.E-7 ! precision
c
p1 = p+CMPLX(0.,AIMAG(dpdt)) ! move the point up above the contour
time2 = taup(p1,x)
ti1 = AIMAG(time2) ! this should be > 0.
IF (ti1 .LT. 0) THEN
WRITE(0,*)'Contour search failed, p1 is not on the left, p=',p1
CALL EXIT(1)
END IF
delpr = 2*REAL(dpdt)
p = p1
ti = ti1
c first make sure p and p1 are on the opposite sides of the contour
DO WHILE ( ti*ti1 .GT. 0. )
c WRITE(0,*)REAL(p1),ti1,REAL(p),ti
p1 = p
ti1 = ti
p = p+delpr
time2 = taup(p,x)
ti = AIMAG(time2)
ENDDO
c begin to find the point on the contour bracketed by [p1 p]
DO WHILE ( ABS(ti).GT.ZERO )
p2 = p
ti2 = ti
p = p1 + REAL(p-p1)*ti1/(ti1-ti)
time2 = taup(p,x)
IF ( p.EQ.p1 .OR. p.EQ.p2 ) RETURN
ti = AIMAG(time2)
IF( ti1*ti.GT.0. )THEN
p1 = p2
ti1 = ti2
ENDIF
ENDDO
RETURN
END
REAL FUNCTION tstar(p)
c tstar = traveltime/Q, not working for head-wave
IMPLICIT NONE
INCLUDE'aseries.h'
INTEGER i
REAL pp
COMPLEX p
pp = REAL(p)*REAL(p)
tstar = 0.
DO i = topp, bttm
IF (ray_len(1,i) .GT. 0.) THEN
tstar=tstar+ray_len(1,i)*vps(1,i)/SQRT(vps(1,i)-pp)/q(1,i)
ENDIF
IF (ray_len(2,i) .GT. 0.) THEN
tstar=tstar+ray_len(2,i)*vps(2,i)/SQRT(vps(2,i)-pp)/q(2,i)
ENDIF
ENDDO
RETURN
END