Nbody6
 All Files Functions Variables
start.f
Go to the documentation of this file.
1  SUBROUTINE start
2 *
3 *
4 * Initialization of data & polynomials.
5 * ------------------------------------
6 *
7  include 'common6.h'
8  EXTERNAL scale,merge
9  parameter(ns=12)
10 *
11 *
12 * Initialize global scalars, counters & useful constants.
13  CALL zero
14 *
15 * Read input parameters.
16  CALL input
17 *
18 * Set initial conditions: BODY(I), X(K,I), XDOT(K,I); I=1,N & K=1,3.
19  CALL DATA
20 *
21 * Scale initial conditions to new units.
22  CALL scale
23 *
24 * Set total mass in case routines DATA & SCALE are not used.
25  zmass = 0.0d0
26  DO 10 i = 1,n
27  zmass = zmass + body(i)
28  10 CONTINUE
29 *
30 * Define mean mass in scaled units and solar mass conversion factor.
31  bodym = zmass/float(n)
32  IF (kz(5).NE.3) THEN
33  zmbar = zmbar/bodym
34  END IF
35 *
36 * Introduce scaling factors DAYS, YRS, SU, RAU, SMU, TSTAR & VSTAR.
37  CALL units
38 *
39 * Check option for external force.
40  IF (kz(14).GT.0) THEN
41  CALL xtrnl0
42  END IF
43 *
44 * Check optional scaling to hot system.
45  IF (kz(29).GT.0) THEN
46  CALL hotsys
47  END IF
48 *
49 * Check option for initial binaries.
50  IF (kz(8).EQ.1.OR.kz(8).GE.3) THEN
51  CALL binpop
52  END IF
53 *
54 * Include stable primordial triples.
55  IF (kz(18).GT.1.AND.kz(8).GT.0) THEN
56  CALL hipop
57  END IF
58 *
59 * Check optional initialization for tidal two-body capture (suppress).
60 * IF (KZ(27).GT.0) THEN
61 * CALL INTIDE
62 * END IF
63 *
64 * Set sequential name, maximum mass & primary velocity.
65  body1 = 0.0
66  DO 20 i = 1,n
67  name(i) = i
68  body1 = max(body1,body(i))
69  DO 15 k = 1,3
70  x0dot(k,i) = xdot(k,i)
71  15 CONTINUE
72  20 CONTINUE
73 *
74 * Randomize particle indices (dummy routine for standard code).
75  CALL swap
76 *
77 * Initialize fixed block steps (40 levels).
78  CALL iblock
79 *
80 * Create table of inverse Stumpff coefficients.
81  DO 30 i = 1,ns
82  scoeff(i) = 1.0d0/((i + 1)*(i + 2))
83  30 CONTINUE
84 *
85 * Set optional stellar evolution parameters or define STEPX.
86  IF (kz(19).GT.2) THEN
87  CALL instar
88  ELSE IF (kz(14).GT.1) THEN
89  dt = 1.0e-03/tscale
90  CALL stepk(dt,dtn)
91  stepx = dtn
92  END IF
93 *
94 * Initialize optional cloud parameters.
95  IF (kz(13).GT.0) THEN
96  CALL cloud0
97  END IF
98 *
99 * Set initial neighbour list & corresponding radius.
100  rs0 = rc
101  nnb0 = 0
102  DO 40 i = 1,n
103  CALL nblist(i,rs0)
104  nnb0 = nnb0 + list(1,i)
105  40 CONTINUE
106 *
107 * Obtain force & first derivative.
108  CALL fpoly1(1,n,0)
109 *
110 * Obtain second & third force derivatives and set time-steps.
111  CALL fpoly2(1,n,0)
112 *
113 * Regularize any hard primordial binaries (assume sequential ordering).
114  IF (nbin0.GT.0) THEN
115  DO 50 ipair = 1,nbin0
116  icomp = 2*ipair - 1
117  jcomp = 2*ipair
118  rij2 = 0.0
119 * Include standard distance criterion.
120  DO 45 k = 1,3
121  rij2 = rij2 + (x(k,icomp) - x(k,jcomp))**2
122  45 CONTINUE
123  IF (rij2.LT.rmin**2) THEN
124  CALL ksreg
125  END IF
126  50 CONTINUE
127  END IF
128 *
129 * Include optional regularization of primordial triples.
130  IF (kz(18).GT.1.AND.nhi0.GT.0) THEN
131  kspair = 1
132 * Note that each KS pair will move to the top of the queue.
133  60 icomp = 2*kspair - 1
134  icm = kspair + n
135  rx2 = 1.0
136 * Find index of closest outer component without any assumption.
137  DO 70 j = ifirst,n
138  rij2 = 0.0
139  DO 65 k = 1,3
140  rij2 = rij2 + (x(k,icm) - x(k,j))**2
141  65 CONTINUE
142  IF (rij2.LT.rx2) THEN
143  rx2 = rij2
144  jcomp = j
145  END IF
146  70 CONTINUE
147  IF (sqrt(rx2).GT.rmin) THEN
148  kspair = kspair + 1
149  IF (kspair.GT.npairs) go to 80
150  go to 60
151  END IF
152 * Evaluate PCRIT for R0(NPAIRS) in MERGE since IMPACT is bypassed.
153  CALL histab(kspair,jcomp,pmin,rstab)
154 * Initialize the triple (constructed to be stable in HIPOP).
155  iphase = 6
156  CALL merge
157 * Examine the same ICM (moved up after successful MERGE).
158  IF (nmerge.LT.nhi0) THEN
159  go to 60
160  END IF
161  END IF
162 *
163 * Check the average neighbour number.
164  80 znb = float(nnb0)/float(n)
165  IF (znb.LT.0.25*znbmax.OR.znb.LT.0.25*sqrt(float(n))) THEN
166  WRITE (6,90) znb
167  90 FORMAT (/,12x,'WARNING! SMALL NEIGHBOUR NUMBERS <NNB> =',
168  & f6.1)
169  END IF
170 *
171  RETURN
172 *
173  END