Nbody6
 All Files Functions Variables
update.f
Go to the documentation of this file.
1  SUBROUTINE update(IPAIR)
2 *
3 *
4 * List modifications after KS termination.
5 * ----------------------------------------
6 *
7  include 'common6.h'
8  DATA iw /0/
9  SAVE iw
10 *
11 *
12 * Adjust neighbour lists to new sequence (skip last or only pair).
13  icm = n + ipair
14  IF (ipair.GT.npairs) go to 60
15 *
16 * Set largest index of any regularized member.
17  ilast = 2*npairs + 2
18 *
19 * Rename lists containing single regularized components.
20  DO 50 j = 1,ntot
21 * Skip renaming if first neighbour exceeds regularized components.
22  IF (list(2,j).GT.ilast.OR.body(j).EQ.0.0d0) go to 50
23  nnb = list(1,j)
24  IF (nnb.EQ.0) go to 50
25  l = 2
26 * Determine list index and new location of any regularized component.
27  inew = 0
28  10 IF (list(l,j).EQ.2*ipair-1) THEN
29  i = 2*ipair - 1
30  inew = 2*npairs + 1
31  ELSE IF (list(l,j).EQ.2*ipair) THEN
32  i = 2*ipair
33  inew = 2*npairs + 2
34  ELSE IF (inew.EQ.0) THEN
35 * Define as zero for single body test below (at least one < ILAST).
36  i = 0
37 * Note that L = 2 may be single body and L = 3 current KS component.
38  END IF
39  l = l + 1
40  IF (l.LE.nnb+1.AND.list(l,j).LT.ilast) go to 10
41 *
42 * Rename regularized components > 2*IPAIR and reduce by 2 if <= ILAST.
43  DO 20 k = 2,l
44 * Note that L determined above is list index of standard particle.
45  IF (list(k,j).EQ.i) THEN
46  list(k,j) = inew
47  ELSE IF (list(k,j).LE.ilast.AND.
48  & list(k,j).GT.2*ipair) THEN
49  list(k,j) = list(k,j) - 2
50  END IF
51  20 CONTINUE
52 *
53 * Check that list of single KS components is sequential (up to ILAST).
54  l = 2
55  30 IF (list(l+1,j).LT.list(l,j).AND.l.LE.nnb) THEN
56  jl = list(l,j)
57  list(l,j) = list(l+1,j)
58  list(l+1,j) = jl
59  END IF
60  l = l + 1
61  IF (list(l,j).LE.ilast.AND.l.LE.nnb+1) go to 30
62  50 CONTINUE
63 *
64 * Replace c.m. by components and reduce subsequent members by one.
65  60 DO 80 j = 1,ntot
66  IF (body(j).EQ.0.0d0) go to 80
67  nnb = list(1,j)
68  l = nnb + 1
69  move = 0
70 * Check for removal of current c.m. and reduce by one if > N + IPAIR.
71  70 IF (l.EQ.1.OR.list(l,j).LT.icm) go to 80
72 * See whether ICM is on neighbour list (otherwise skip splitting).
73  IF (list(l,j).EQ.icm) move = 1
74  IF (list(l,j).NE.icm) THEN
75  list(l,j) = list(l,j) - 1
76  l = l - 1
77  go to 70
78  END IF
79 *
80 * Skip on zero ID or remove c.m. name by moving up subsequent members.
81  IF (move.EQ.0) go to 80
82  72 IF (l.LE.nnb) THEN
83  list(l,j) = list(l+1,j)
84  l = l + 1
85  go to 72
86  END IF
87 *
88  nnb = nnb - 1
89 * Expand the list to include both components since c.m. was deleted.
90  kcase = 2
91 * Only move neighbours down by one if the list has too many members.
92  IF (nnb.GT.lmax-5) kcase = 1
93  IF (nnb.EQ.0) go to 76
94 * In this special case L = 2 already.
95  l = nnb + 1
96 * Take special precaution if last neighbour is a regularized body.
97  IF (list(l,j).LE.jcomp) THEN
98  l = l + 1
99  go to 76
100  END IF
101 *
102 * Move members down by two (or one) to make room for components.
103  74 list(l+kcase,j) = list(l,j)
104  IF (l.GT.2.AND.list(l-1,j).GE.icomp) THEN
105  l = l - 1
106  go to 74
107  END IF
108 *
109 * Rename deleted c.m. appropriately and increase membership by 2 or 1.
110  76 list(l,j) = icomp
111 * Do not over-write the list if NNB > LMAX-3 after removal of c.m.
112  IF (kcase.EQ.2) list(l+1,j) = jcomp
113  list(1,j) = nnb + kcase
114  IF (kcase.EQ.1.AND.iw.LT.10) THEN
115  WRITE (6,78) nnb, j, jcomp
116  78 FORMAT (5x,'WARNING! UPDATE NNB J JCOMP ',3i6)
117  iw = iw + 1
118  END IF
119  80 CONTINUE
120 *
121 * Modify the list of previously regularized binaries.
122  nnb = listr(1) - 1
123  l = 0
124  91 l = l + 2
125  92 IF (l.GT.nnb + 1) go to 96
126  j = listr(l)
127  k = listr(l+1)
128 * First check the current two-body separation of any old pairs.
129  rjk2 = (x(1,j) - x(1,k))**2 + (x(2,j) - x(2,k))**2 +
130  & (x(3,j) - x(3,k))**2
131 * Remove pair if RJK > 4*RMIN when special procedure not needed.
132  IF (rjk2.LT.16.0*rmin**2) go to 91
133  DO 94 k = l,nnb
134  listr(k) = listr(k+2)
135  94 CONTINUE
136  nnb = nnb - 2
137  go to 92
138 *
139 * Add ICOMP & JCOMP to LISTR (maximum of MLR/2 - 1 pairs).
140  96 IF (nnb.GT.mlr - 4) THEN
141 * Note that NNB is one less than the actual membership.
142  DO 98 k = 2,nnb
143  listr(k) = listr(k+2)
144  98 CONTINUE
145  nnb = nnb - 2
146 * Removal of the oldest KS pair.
147  END IF
148  listr(nnb+3) = icomp
149  listr(nnb+4) = jcomp
150  listr(1) = nnb + 3
151 *
152 * Copy flag index of disrupted pair (set in KSTERM).
153  iflag = jlist(3)
154 * Add primordial pairs to LISTD (skip new KS pairs or primordials).
155  IF (iflag.EQ.0.OR.iabs(jlist(1) - jlist(2)).EQ.1) go to 110
156 *
157 * Check list of disrupted component names.
158  nnb = listd(1) - 1
159  kcomp = 0
160  DO 100 k = 2,nnb+1,2
161  IF (listd(k).EQ.jlist(1).AND.listd(k+1).EQ.jlist(2)) kcomp = 1
162  100 CONTINUE
163 *
164 * Include both components unless already members.
165  IF (kcomp.EQ.0) THEN
166  IF (nnb.GT.mld - 4) THEN
167  DO 102 k = 2,nnb
168  listd(k) = listd(k+2)
169  102 CONTINUE
170  nnb = nnb - 2
171  END IF
172 * Add most recent names at the end (limit is MLD/2 - 1 pairs).
173  listd(nnb+3) = jlist(1)
174  listd(nnb+4) = jlist(2)
175  listd(1) = nnb + 3
176  END IF
177  IF (iflag.NE.-1) WRITE (8,104) ipair, iflag, jlist(1), jlist(2)
178  104 FORMAT (' LISTD INCONSISTENCY!! IPAIR IFLAG NAMES ',2i5,2i8)
179 *
180 * Update list of high velocity particles containing c.m. members.
181  110 nnb = listv(1)
182  DO 130 l = 2,nnb+1
183  IF (listv(l).EQ.icm) THEN
184 * Remove old c.m. and reduce the membership.
185  DO 125 k = l,nnb
186  listv(k) = listv(k+1)
187  125 CONTINUE
188  listv(1) = listv(1) - 1
189  END IF
190 * Reduce higher particle locations by one.
191  IF (listv(l).GT.icm) THEN
192  listv(l) = listv(l) - 1
193  END IF
194  130 CONTINUE
195 *
196  RETURN
197 *
198  END