-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathadi.f
86 lines (86 loc) · 2.48 KB
/
adi.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
SUBROUTINE ADI(A,B,C,D,E,F,G,U,JMAX,K,ALPHA,BETA,EPS)
IMPLICIT REAL*8(A-H,O-Z)
PARAMETER(JJ=100,KK=6,NRR=32,MAXITS=100,ZERO=0.D0,TWO=2.D0,HALF=.5
*D0)
DIMENSION A(JMAX,JMAX),B(JMAX,JMAX),C(JMAX,JMAX),D(JMAX,JMAX),
* E(JMAX,JMAX),F(JMAX,JMAX),G(JMAX,JMAX),U(JMAX,JMAX),
* AA(JJ),BB(JJ),CC(JJ),RR(JJ),UU(JJ),PSI(JJ,JJ),
* ALPH(KK),BET(KK),R(NRR),S(NRR,KK)
IF(JMAX.GT.JJ)PAUSE 'Increase JJ'
IF(K.GT.KK-1)PAUSE 'Increase KK'
K1=K+1
NR=2**K
ALPH(1)=ALPHA
BET(1)=BETA
DO 11 J=1,K
ALPH(J+1)=SQRT(ALPH(J)*BET(J))
BET(J+1)=HALF*(ALPH(J)+BET(J))
11 CONTINUE
S(1,1)=SQRT(ALPH(K1)*BET(K1))
DO 13 J=1,K
AB=ALPH(K1-J)*BET(K1-J)
DO 12 N=1,2**(J-1)
DISC=SQRT(S(N,J)**2-AB)
S(2*N,J+1)=S(N,J)+DISC
S(2*N-1,J+1)=AB/S(2*N,J+1)
12 CONTINUE
13 CONTINUE
DO 14 N=1,NR
R(N)=S(N,K1)
14 CONTINUE
ANORMG=ZERO
DO 16 J=2,JMAX-1
DO 15 L=2,JMAX-1
ANORMG=ANORMG+ABS(G(J,L))
PSI(J,L)=-D(J,L)*U(J,L-1)+(R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