Nbody6
 All Files Functions Variables
rename.f
Go to the documentation of this file.
1  SUBROUTINE rename
2 *
3 *
4 * Renaming of list arrays.
5 * ------------------------
6 *
7  include 'common6.h'
8 *
9 *
10 * Old & new names are shown explicitly for three different cases.
11 *
12 * Standard sequence ICOMP = 2*NPAIRS-1 ICOMP = 2*NPAIRS
13 * -------------------------------------------------------------------
14 * 2*NPAIRS-1 ICOMP 2*NPAIRS-1 ICOMP 2*NPAIRS-1 JCOMP
15 * 2*NPAIRS JCOMP ICOMP 2*NPAIRS-1 ICOMP 2*NPAIRS-1
16 * ICOMP 2*NPAIRS-1 2*NPAIRS JCOMP 2*NPAIRS 2*NPAIRS-1
17 * JCOMP 2*NPAIRS JCOMP 2*NPAIRS JCOMP 2*NPAIRS
18 * -------------------------------------------------------------------
19 *
20 * Form the sequential names of exchanged & regularized bodies.
21  ilist(1) = 2*npairs - 1
22  ilist(2) = 2*npairs
23  ilist(3) = icomp
24  ilist(4) = jcomp
25 * Save the corresponding new names for the renaming procedure.
26  ilist(5) = ilist(3)
27  ilist(6) = ilist(4)
28  ilist(7) = ilist(1)
29  ilist(8) = ilist(2)
30 * Ensure consecutive search list and modify renaming list accordingly.
31  IF (icomp.LE.ilist(2)) THEN
32  ilist(3) = ilist(2)
33  ilist(2) = icomp
34 * Note that all the new names are affected by the rearrangement.
35  ilist(5) = ilist(2)
36  ilist(6) = ilist(1)
37  ilist(7) = ilist(4)
38  ilist(8) = ilist(3)
39  IF (icomp.NE.ilist(1)) THEN
40 * First single particle is exchanged twice if ICOMP = 2*NPAIRS.
41  ilist(5) = jcomp
42  ilist(7) = ilist(1)
43 * New name of 2*NPAIRS is not really needed because of duplicity.
44  END IF
45  END IF
46 *
47 * Rename neighbour lists with exchanged or regularized components.
48  DO 40 j = 1,ntot-1
49 * Skip modification if first neighbour comes after second component.
50  IF (list(2,j).GT.jcomp) go to 40
51 * No special precaution needed for case of no neighbours.
52  nnb = list(1,j)
53  nnb1 = 0
54  nij = 0
55 *
56 * See whether any neighbours need to be renamed.
57  k1 = 1
58  DO 25 l = 2,nnb+1
59  IF (list(l,j).GT.jcomp) go to 30
60 * Start search loop above last identified value (bug fix 10/07).
61  DO 20 k = k1,4
62  IF (list(l,j).EQ.ilist(k)) THEN
63  k1 = k + 1
64  nnb1 = nnb1 + 1
65 * Save corresponding list location for the modification loop.
66  jlist(nnb1) = k
67  jlist(nnb1+4) = l
68 * Count number of identified KS components.
69  IF (ilist(k).EQ.icomp.OR.ilist(k).EQ.jcomp)
70  & nij = nij + 1
71 * Advance neighbour list after each identification (note duplicity).
72  go to 25
73  END IF
74  20 CONTINUE
75  25 CONTINUE
76 *
77 * Skip modification if no neighbours need to be renamed.
78  30 IF (nnb1.EQ.0) go to 40
79 *
80 * Include c.m. renaming procedure if both components are neighbours.
81  DO 38 k = 1,nnb1
82  ktime = jlist(k)
83 * Indicator for identified members of search list.
84  inew = ilist(ktime+4)
85 * Replace identified components (or single perturber) by c.m.
86  IF (inew.LT.ifirst) THEN
87  IF (nij.EQ.2.OR.j.LT.ifirst - 3) inew = ntot
88  END IF
89 * Start with the saved list index (may differ by one either way).
90  ls = jlist(k+4)
91 * See if index needs adjusting after previous modification.
92  IF (list(ls,j).LT.ilist(ktime)) ls = ls + 1
93  IF (list(ls,j).GT.ilist(ktime)) ls = ls - 1
94 *
95 * Move list members up or down unless new name is identical to old.
96  IF (ls.LE.0) ls = 2
97  ll = ls
98  IF (inew.LT.ilist(ktime)) THEN
99 * Move list members down by one until location for new name is vacated.
100  DO 32 l = ll,3,-1
101  IF (list(l-1,j).GT.inew) THEN
102  list(l,j) = list(l-1,j)
103  ls = l - 1
104  ELSE
105  go to 36
106  END IF
107  32 CONTINUE
108  ELSE IF (inew.GT.ilist(ktime)) THEN
109 * Move list members up by one until sequential location is reached.
110  DO 34 l = ll,nnb
111  IF (list(l+1,j).LT.inew) THEN
112  list(l,j) = list(l+1,j)
113  ls = l + 1
114  ELSE
115  go to 36
116  END IF
117  34 CONTINUE
118  END IF
119 * Set renamed neighbour in sequential location.
120  36 list(ls,j) = inew
121  38 CONTINUE
122 *
123 * Reduce membership by one if c.m. set in last two locations.
124  IF (nij.EQ.2) list(1,j) = nnb - 1
125  40 CONTINUE
126 *
127 * Update the list of recently regularized particles.
128  41 nnb = listr(1)
129  DO 44 l = 2,nnb+1
130 * First see whether either component has been regularized before.
131  IF (listr(l).EQ.icomp.OR.listr(l).EQ.jcomp) THEN
132 * Remove corresponding pair even if only one component is present.
133  j = 2*kvec(l-1)
134 * Move up the subsequent pairs and reduce membership by two.
135  DO 42 k = j,nnb-1
136  listr(k) = listr(k+2)
137  42 CONTINUE
138  listr(1) = listr(1) - 2
139 * Make a new search otherwise LISTR -> -2 if NNB = 2.
140  go to 41
141  END IF
142  44 CONTINUE
143 *
144 * Rename exchanged components if present in the list.
145  DO 48 kcomp = 1,2
146  DO 46 l = 2,nnb+1
147  IF (listr(l).EQ.2*npairs - 2 + kcomp) THEN
148  IF (kcomp.EQ.1) listr(l) = icomp
149  IF (kcomp.EQ.2) listr(l) = jcomp
150  END IF
151  46 CONTINUE
152  48 CONTINUE
153 *
154 * Update the list of high velocity particles.
155  IF (listv(1).EQ.0) go to 70
156  nnb = listv(1)
157  l = 1
158  50 l = l + 1
159 * Check for removal of regularized component.
160  IF (listv(l).EQ.icomp.OR.listv(l).EQ.jcomp) THEN
161  DO 52 k = l,nnb
162  listv(k) = listv(k+1)
163  52 CONTINUE
164  listv(1) = listv(1) - 1
165  nnb = nnb - 1
166 * Consider the same location again.
167  l = l - 1
168  END IF
169  IF (l.LE.nnb) go to 50
170 *
171 * Rename exchanged components.
172  DO 58 kcomp = 1,2
173  DO 56 l = 2,nnb+1
174  IF (listv(l).EQ.2*npairs - 2 + kcomp) THEN
175  IF (kcomp.EQ.1) listv(l) = icomp
176  IF (kcomp.EQ.2) listv(l) = jcomp
177  END IF
178  56 CONTINUE
179  58 CONTINUE
180 *
181 * Remove any fast particles which have slowed down or are outside 2<R>.
182  l = 1
183  60 l = l + 1
184  IF (listv(1).EQ.0) go to 70
185  j = listv(l)
186  a0 = xdot(1,j)**2 + xdot(2,j)**2 + xdot(3,j)**2
187  a2 = (x(1,j) - rdens(1))**2 + (x(2,j) - rdens(2))**2 +
188  & (x(3,j) - rdens(3))**2
189  IF (a0.LT.16.0*eclose.OR.a2.GT.4.0*rscale**2) THEN
190  DO 65 k = l,nnb
191  listv(k) = listv(k+1)
192  65 CONTINUE
193  listv(1) = listv(1) - 1
194  nnb = nnb - 1
195 * Consider the same location again.
196  l = l - 1
197  END IF
198  IF (l.LE.nnb) go to 60
199 *
200  70 RETURN
201 *
202  END