8 parameter(nmx=10,nmx2=2*nmx,nmx3=3*nmx,nmx4=4*nmx,
9 & nmx8=8*nmx,nmxm=nmx*(nmx-1)/2)
10 REAL*8 m,mass,mc,mij,mkk,r2(nmx,nmx),ang(3)
12 common/chain1/ xch(nmx3),vch(nmx3),m(nmx),
13 & zz(nmx3),wc(nmx3),mc(nmx),
14 & xi(nmx3),pi(nmx3),mass,rinv(nmxm),rsum,mkk(nmx),
15 & mij(nmx,nmx),tkk(nmx),tk1(nmx),iname(nmx),nn
16 common/chainc/ xc(3,ncmax),uc(3,ncmax),bodyc(ncmax),ich,
18 common/chreg/ timec,tmax,rmaxc,cm(10),namec(6),nstep1,kz27,kz30
19 common/clump/ bodys(ncmax,5),t0s(5),ts(5),
steps(5),rmaxs(5),
20 & names(ncmax,5),isys(5)
21 common/ccoll2/ qk(nmx4),pk(nmx4),rik(nmx,nmx),
SIZE(nmx),vstar1,
22 & ecoll1,rcoll,qperi,istar(nmx),icoll,isync,ndiss1
23 common/incond/ x4(3,nmx),xdot4(3,nmx)
48 ELSE IF (nch.EQ.4)
THEN
50 ELSE IF (nch.GT.4)
THEN
56 IF (j1.EQ.i1.OR.j1.EQ.i2) go to 2
58 IF (j2.EQ.i1.OR.j2.EQ.i2) go to 1
59 IF (r2(j1,j2).LT.rx1.AND.r2(j1,j2).GT.rx0)
THEN
68 IF (i.EQ.i1.OR.i.EQ.i2.OR.i.EQ.i3.OR.i.EQ.i4) go to 3
80 WRITE (6,4) sqrt(r2(i1,i2)), sqrt(r2(i1,i3)),sqrt(r2(i2,i3)),
81 & sqrt(r2(i2,i4)), sqrt(r2(i3,i4))
82 4
FORMAT (
' CHTERM: RIJ (1-2 1-3 2-3 2-4 3-4) ',1p,5e9.1)
90 IF (nch.EQ.6) jlist(11) = namec(i6)
100 IF (name(j).EQ.jlist(l+5))
THEN
102 IF (body(j).GT.0.0d0) icm = j
113 ELSE IF (nch.EQ.3)
THEN
118 icomp = min(jlist(1),jlist(2))
119 jcomp = max(jlist(1),jlist(2))
131 ri2 = ri2 + x4(k,l)**2
132 vi2 = vi2 + xdot4(k,l)**2
143 time2 = t0s(isub) + timec - tprev
144 dt8 = (tblock - tprev)/8.0d0
148 IF (time2.GT.0.0d0)
THEN
150 dtn = nint(dtn2/dt8)*dt8
155 dtn = -nint(dtn2/dt8)*dt8
161 IF (dtn.LE.smax) time = tblock
164 IF (iterm.LT.0.0) timec = t0s(isub) + timec - time
167 time = min(tblock,time)
172 nnb1 = list(1,ich) + 1
182 cm(k+3) = xdot(k,icm)
198 IF (name(j).EQ.namec(k))
THEN
207 x(k,j) = x4(k,ll) + cm(k)
208 xdot(k,j) = xdot4(k,ll) + cm(k+3)
210 x0dot(k,j) = xdot(k,j)
211 vj2 = vj2 + xdot(k,j)**2
216 IF (ech.GT.0.5*bodym*16.0*eclose)
THEN
217 WRITE (6,41) namex, nch, ech, sqrt(vx2)*vstar
218 41
FORMAT (
' CHAIN DISRUPT NMX NCH ECH VX ',i7,i4,f8.4,f6.1)
223 IF (jg.EQ.icm) jg = jcomp
227 DO 50 j = ifirst,ntot
230 IF (list(l,j).GT.icm) go to 50
232 IF (list(l,j).EQ.icm)
THEN
234 IF (list(k,j).EQ.jg) go to 50
238 IF (j.EQ.jlist(k)) go to 50
241 IF (nnb1.LT.5*lmax)
THEN
255 IF (r2(i1,i4).LT.r2(i1,i3).OR.r2(i3,i4).LT.r2(i1,i3))
THEN
256 IF (r2(i1,i4).LT.r2(i3,i4))
THEN
273 IF (isub.LT.nsub)
THEN
276 bodys(k,l) = bodys(k,l+1)
277 names(k,l) = names(k,l+1)
282 rmaxs(l) = rmaxs(l+1)
299 IF (min(r2(i1,i3),r2(i2,i4)).GT.cmsep2*r2(i1,i2))
THEN
303 IF (nch.EQ.3) jlist(2) = max(ifirst + 4,jlist(1) + 1)
309 jlist(1) = max(ifirst + 4,jcomp + 1)
321 IF (nch.GE.4.AND.r2(i3,i4).LT.rmin2)
THEN
323 IF (r2(i3,i4).LT.0.25*min(r2(i1,i3),r2(i2,i4)))
THEN
324 IF (max(jlist(3),jlist(4)).LE.n)
THEN
333 IF (nch.GE.5) i5 = jlist(5)
334 IF (nch.EQ.6) i6 = jlist(6)
337 IF (listc(1).GT.0)
THEN
338 namc2 = name(listc(2))
339 IF (listc(1).GT.1)
THEN
340 namc3 = name(listc(3))
355 IF (nch.GT.2.AND.ks2.EQ.0)
THEN
360 IF (nch.GE.5.AND.i5.GT.0)
THEN
374 IF (max(i3,i4).GT.n)
THEN
379 ELSE IF (nch.GE.5.AND.i5.GT.0)
THEN
392 IF (sqrt(vx2)*vstar.GT.2.0*vstar)
THEN
395 a1 = -0.5*body(ntot)/h(npairs)
396 pb = days*a1*sqrt(abs(a1)/body(ntot))
397 vi2 = xdot(1,ntot)**2 + xdot(2,ntot)**2 + xdot(3,ntot)**2
398 vcm = sqrt(vi2)*vstar
399 WRITE (6,68) name(j1), name(j2), body(j1)*smu,
400 & body(j2)*smu, vcm, a1, pb
401 68
FORMAT (
' CHAIN BINARY NM M1 M2 VCM A PB ',
402 & 2i7,2f6.1,f7.1,1p,2e10.2)
407 IF (kz(26).GT.2)
THEN
411 IF (rinv(k).GT.rx)
THEN
420 CALL
erel(im,eb,semi)
421 hi = -0.5*body(ntot)/semi
423 CALL
const(xch,vch,m,nch,ener2,ang,gam)
424 err = (ech - ener2)/ech
428 IF (eb1.GT.0.9.AND.gi.LT.gmax)
THEN
429 IF (abs(err).GT.1.0d-08)
THEN
430 WRITE (6,72) nch, nstep1, eb1, semi, gi, err
431 72
FORMAT (
' CHAIN RECTIFY NCH # EB/E A G ERR ',
432 & i4,i6,f6.2,1p,3e10.2)
442 CALL
fpoly1(jcomp,jcomp,0)
444 CALL
fpoly1(icomp,icomp,0)
445 CALL
fpoly2(icomp,icomp,0)
446 CALL
fpoly2(jcomp,jcomp,0)
455 rij2 = rij2 + (x(k,i3) - x(k,ntot))**2
456 vij2 = vij2 + (xdot(k,i3) - xdot(k,ntot))**2
457 rdot = rdot + (x(k,i3) - x(k,ntot))*
458 & (xdot(k,i3) - xdot(k,ntot))
460 hi = 0.5*vij2 - (body(i3) + body(ntot))/sqrt(rij2)
461 IF (hi.GT.0.0.AND.rdot.GT.0.0)
THEN
466 IF (kz(30).GT.1)
THEN
467 WRITE (6,75) time+toff, i3, i4, ntot, step3, step4,step(ntot)
468 75
FORMAT (
' CHTERM: T I3 I4 NT DT ',f10.4,3i6,1p,3e9.1)
476 IF (name(i).EQ.name3) i3 = i
477 IF (name(i).EQ.name4)
THEN
479 IF (i3.GT.0) go to 85
484 85 icomp = min(i3,i4)
488 IF (sqrt(vx2)*vstar.GT.2.0*vstar)
THEN
491 a1 = -0.5*body(ntot)/h(npairs)
492 pb = days*a1*sqrt(abs(a1)/body(ntot))
493 vi2 = xdot(1,ntot)**2 + xdot(2,ntot)**2 + xdot(3,ntot)**2
494 vcm = sqrt(vi2)*vstar
495 WRITE (6,88) name(j1), name(j2), body(j1)*smu,
496 & body(j2)*smu, vcm, a1, pb
497 88
FORMAT (
' CHAIN BINARY2 NM M1 M2 VCM A PB ',
498 & 2i7,2f6.1,f7.1,1p,2e10.2)
500 IF (kz(30).GT.1)
THEN
501 WRITE (6,90) i3, i4, step(ntot), stepr(ntot),
502 & r(npairs), h(npairs), gamma(npairs)
503 90
FORMAT (
' CHTERM: SECOND BINARY I3 I4 DT DTR R H G ',
509 IF (listc(1).GT.0.AND.listc(2).LT.ifirst)
THEN
511 IF (name(j).EQ.namc2)
THEN
513 ELSE IF (listc(1).GT.1.AND.name(j).EQ.namc3)
THEN
525 x0dot(k,j) = xdot(k,j)
532 dminc = min(dminc,rcoll)
535 chcoll = chcoll + cm(9)
538 nstepc = nstepc + nstep1
539 ndiss = ndiss + ndiss1
540 nsync = nsync + max(isync,0)
541 ecoll = ecoll + ecoll1
542 egrav = egrav + ecoll1
543 e(10) = e(10) + ecoll1
551 IF (nsub.EQ.0.AND.kz(2).GT.1)
THEN
552 IF (time - tdump.LT.timec)
THEN
559 100
IF (iterm.GE.0) tprev = time - 16.0*dt8