31 IF (name(i).EQ.1) isun = i
32 zmass = zmass + body(i)
34 cmr(k) = cmr(k) + body(i)*x(k,i)
35 cmrdot(k) = cmrdot(k) + body(i)*xdot(k,i)
39 az = az + body(i)*(x(1,i)*xdot(2,i) - x(2,i)*xdot(1,i))
40 zm = zm + body(i)*(x(1,i)**2 + x(2,i)**2)
46 cmrdot(k) = cmrdot(k)/zmass
49 cmr(4) = sqrt(cmr(1)**2 + cmr(2)**2 + cmr(3)**2)
50 cmrdot(4) = sqrt(cmrdot(1)**2 + cmrdot(2)**2 + cmrdot(3)**2)
53 IF (kz(13).GT.0) zkin = zkin - 0.5*zmass*cmrdot(4)**2
66 IF (kz(14).EQ.1.OR.kz(14).EQ.2)
THEN
67 az = az + 0.5*tidal(4)*zm
71 tcr = zmass**2.5/(2.0*abs(e(3)))**1.5
73 IF (q.GT.1.0.AND.kz(14).LT.3)
THEN
77 etot = zkin - pot + etide
80 etot = etot + ebin + esub + emerge + ecoll + emdot + ecdot
87 IF (time.LE.0.0d0)
THEN
98 de = de/max(zkin,abs(e(3)))
105 rscale = 0.5*zmass**2/pot
110 DO 30 i = ifirst,ntot
111 nnb = nnb + list(1,i)
112 IF (list(1,i).GT.0) rs0 = min(rs0,rs(i))
114 nnb = nnb/(n - npairs)
117 IF (rsmin.EQ.0.0d0) rsmin = rs0
120 IF (n-npairs.GE.20.AND.kz(29).EQ.0.AND.kz(5).NE.3)
THEN
142 IF (name(i).EQ.1.OR.name(i).EQ.nzero) go to 40
143 ri2 = (x(1,i) - x(1,isun))**2 + (x(2,i) - x(2,isun))**2
144 vi2 = (xdot(1,i) - xdot(1,isun))**2 +
145 & (xdot(2,i) - xdot(2,isun))**2
146 rrdot = (x(1,i) - x(1,isun))*(xdot(1,i) - xdot(1,isun)) +
147 & (x(2,i) - x(2,isun))*(xdot(2,i) - xdot(2,isun))
149 semi = 2.0/ri - vi2/(body(isun) + body(i))
151 ecc2 = (1.0 - ri/semi)**2 +
152 & rrdot**2/(semi*(body(i) + body(isun)))
154 edisk = edisk - 0.5*body(i)/semi
156 disp = sqrt(disp2/float(n-2))
157 WRITE (35,42) ttot, disp, edisk
158 42
FORMAT (
' ',f8.1,1p,e10.2,e12.4)
167 rhod = 4.0*twopi*rhod*rscale**3/(3.0*zmass)
168 rhom = 4.0*twopi*rhom*rscale**3/(3.0*zmass)
171 IF (kz(29).GT.0.AND.zkin.GT.pot)
THEN
177 IF (kz(16).GT.0)
THEN
181 rmin = 4.0*rscale/(float(n)*rhod**0.3333)
183 IF (kz(16).GT.1.AND.nc.LT.0.01*n)
THEN
184 rmin = 0.05*rc/float(nc)**0.3333
187 IF (time.GT.0.0d0) rmin = sqrt(rmin0*rmin)
189 rmin = min(rmin,rsmin*gmin**0.3333)
191 dtmin = 0.04*sqrt(etai/0.02d0)*sqrt(rmin**3/bodym)
193 eclose = 4.0*max(zkin,abs(zkin - pot))/zmass
195 IF (2.0*zkin/zmass.GT.vc**2.AND.vc.GT.0.0) eclose = 2.0*vc**2
197 eclose = 0.5*eclose/q
199 eclose = min(eclose,1.0d0)
204 IF (kz(29).GT.0.AND.q.GT.1.0)
THEN
205 dtmin = 0.04*sqrt(etai/0.02d0)*sqrt(rmin**3/bodym)
206 sigma2 = 2.0*zkin/zmass
208 dtmin = dtmin*sqrt((vp2 + sigma2/q)/(vp2 + 2.0d0*sigma2))
210 tcr = 2.0*rscale/sqrt(sigma2)
217 ebh = -0.5*bodym*eclose
218 IF (time.LE.0.0d0)
THEN
219 stepj = 0.01*(60000.0/float(n))**0.3333
220 IF (dmod(smax,dtk(10)).NE.0.0d0)
THEN
221 WRITE (6,43) smax, smax/dtk(10)
222 43
FORMAT (
' FATAL ERROR! SMAX SMAX/DTK(10) ',1p,2e10.2)
227 rsfac = max(25.0/tcr,3.0d0*vc/(2.0d0*rsmin))
230 IF (time.LE.0.0d0.OR.kz(40).EQ.0)
THEN
231 alpha = float(nnbmax)*sqrt(0.08d0*rscale**3/float(n-npairs))
234 IF (kz(40).EQ.1.AND.float(nnb).LT.0.5*nnbmax)
THEN
235 fac = 1.0 + (0.5*nnbmax - nnb)/(0.5*float(nnbmax))
240 IF (kz(14).EQ.0) rtide = 10.0*rscale
242 IF ((kz(14).EQ.3.OR.kz(14).EQ.4).AND.zkin.GT.0.0)
THEN
243 tcr = 2.0*rscale/sqrt(2.0*zkin/zmass)
248 WRITE (6,45) ttot, q, de, be(3), rmin, dtmin, icr, delta1, e(3),
250 45
FORMAT (/,
' ADJUST: TIME =',f8.2,
' Q =',f5.2,
' DE =',1p,e10.2,
251 &
' E =',0p,f10.6,
' RMIN =',1p,e8.1,
' DTMIN =',e8.1,
252 &
' TC =',0p,i5,
' DELTA =',1p,e9.1,
' E(3) =',0p,f10.6,
258 IF (abs(de).GT.5.0*qe) go to 70
261 IF (kz(23).GT.0)
THEN
266 IF (kz(31).GT.0)
THEN
273 DO 50 ipair = 1,npairs
274 IF (name(2*ipair-1).LE.2.OR.name(2*ipair).LE.2)
THEN
281 semi = -0.5*body(n+ip)/h(ip)
282 ecc2 = (1.0 - r(ip)/semi)**2 +
283 & tdot2(ip)**2/(semi*body(n+ip))
284 eb = body(i1)*body(i2)*h(ip)/body(n+ip)
285 WRITE (35,52) ttot, semi, eb, e(3), sqrt(ecc2),
287 52
FORMAT (
' ',f8.1,1p,3e12.4,0p,f7.3,2i5)
294 IF (kz(40).EQ.3)
THEN
295 nnbmax = nbzero*sqrt(float(n)/float(nzero))
297 znbmin = max(0.2*nnbmax,1.0)
301 IF (kz(40).GE.2)
THEN
302 IF (nnb.LT.nnbmax/5.0)
THEN
311 IF (time.GE.tnext)
THEN
317 IF (kz(33).GE.2.AND.iout.GT.0)
THEN
320 DO 60 ipair = 1,npairs
322 IF (h(ipair).LT.hp.AND.body(n+ipair).GT.0.0d0)
THEN
327 IF (ip.GT.0.AND.hp.LT.-eclose)
THEN
330 semi = -0.5*body(n+ip)/h(ip)
331 pb = days*semi*sqrt(semi/body(n+ip))
332 ecc2 = (1.0 - r(ip)/semi)**2 +
333 & tdot2(ip)**2/(semi*body(n+ip))
334 eb = body(i1)*body(i2)*h(ip)/body(n+ip)
335 WRITE (39,62) ttot, name(i1), name(i2), kstar(n+ip),
336 & list(1,i1), sqrt(ecc2), semi, pb, eb, e(3)
337 62
FORMAT (
' BINARY: T NAME K* NP E A P EB E3 ',
338 & f8.1,2i6,2i4,f7.3,1p,2e10.2,0p,2f9.4)
344 IF (kz(8).GT.0.AND.dmod(time,dtk(10)).EQ.0.0d0)
THEN
357 IF (kz(35).GT.0.AND.time.GE.dtoff)
THEN
363 cputot = cputot + tcomp - cpu0
368 IF (kz(2).GE.1.AND.nsub.EQ.0) CALL
mydump(1,2)
371 IF (ttot.GE.tcrit.OR.n.LE.ncrit.OR.ttot+dtadj.GT.tcrit)
THEN
373 WRITE (6,65) ttot, cputot/60.0, errtot, detot
374 65
FORMAT (//,9x,
'END RUN',3x,
'TIME =',f7.1,
' CPUTOT =',f7.1,
375 &
' ERRTOT =',f10.6,
' DETOT =',f10.6)
376 IF (kz(1).GT.0.AND.nsub.EQ.0) CALL
mydump(1,1)