12 REAL*8 g0(3),y(nmx8),r2(nmx,nmx),ksch
13 INTEGER ij(nmx),iold(nmx)
14 LOGICAL check,kslow,kcoll,stopb,icase
15 common/slow1/ tk2(0:nmx),ejump,ksch(nmx),kslow,kcoll
16 common/slow2/ stepl,stopb
17 common/chreg/ timec,tmax,rmaxc,cm(10),namec(6),nstep1,kz27,kz30
18 common/clump/ bodys(nmx,5),t0s(5),ts(5),
steps(5),rmaxs(5),
19 & names(nmx,5),isys(5)
20 common/intfac/ lx,le,lp,lv,lt,j10,nhalf2
22 common/cpert/ rgrav,gpert,ipert,npert
23 common/calls/ tpr,tkpr,step,ider,icall,nfn,nreg,iter,imcirc
24 common/ccoll2/ qk(nmx4),pk(nmx4),rij(nmx,nmx),
SIZE(nmx),vstar1,
25 & ecoll1,rcoll,qperi,istar(nmx),icoll,isync,ndiss1
26 common/bssave/ ep(4),dsc,facm,tfac,itfac,jc
29 common/slow3/ gcrit,kz26
83 IF (
steps(isub).EQ.0.0d0)
THEN
91 tmax = timec +
steps(isub)
146 tmax = timec +
steps(isub)
169 CALL
const(x,v,m,n,ener0,g0,alag)
180 rk = q(ks1)**2 + q(ks1+1)**2 + q(ks1+2)**2 + q(ks1+3)**2
185 energy = ener0 - 0.5d0*mass*(cmv(1)**2 + cmv(2)**2 + cmv(3)**2)
200 rgrav = min(rgrav,0.5*rsum)
203 IF (kz26.LT.2) rslow = 0.0
206 tcr = mass**2.5/abs(2.0d0*
energy)**1.5
213 vp2 = 2.0*(m(i1) + m(i2))/rm
216 stepin = eps**0.2*tstar*alag
217 small = 1.0d-04*stepin
226 rstar = max(
SIZE(i),rstar)
228 rstar = max(
SIZE(n),rstar)
237 IF (n.EQ.4) gcrit = 5.0d-06
238 IF (n.GT.4) gcrit = 1.0d-06
241 WRITE (6,15) n, npert,
energy, rsum, rgrav, tcr, rmaxs(isub),
243 15
FORMAT (
' NEW CHAIN N NP E RSUM RGRAV TCR RMAXS NAM ',
244 & 2i4,f10.5,1p,4e9.1,0p,6i6)
246 IF (rsum.LT.1.0e-05) eps = 1.0d-12
262 IF (n.EQ.2.OR.
energy.GT.0.0) go to 70
268 rmaxc = min(rmaxc,2.0*rsum)
281 IF (icoll.EQ.0.AND.icall.EQ.0.AND.
steps(isub).GT.0.0d0)
THEN
283 dt = 1.01*tmax - chtime
284 IF (dt.LT.0.0) dt = abs(dt)
285 dt = min(1.01*
steps(isub),dt)
289 IF (tpr.GT.tpr0) dtau = 1.1*dtau
291 IF (step.GT.0.0)
THEN
292 step = min(dtau,step)
294 step = min(dtau,saveit)
299 IF (icase.AND.iprev.GT.0)
THEN
307 IF (mod(nstep1,1000).EQ.0.AND.icall.EQ.0.AND.icoll.EQ.0)
THEN
308 CALL
const(x,v,m,n,ener0,g0,alag)
309 small = 1.0d-04*eps**0.2*tstar*alag
311 IF (step.LT.small) step = small
316 IF (ifail.GT.10) icall = 0
320 CALL
difsy1(neq,eps,step,stime,y)
331 22
IF (icall.EQ.0.AND.icoll.EQ.0)
THEN
335 ELSE IF (icoll.LT.0.AND..NOT.kcoll)
THEN
343 IF (imcirc.GT.0) isync = 1
357 IF (kz26.GE.2.AND.(.not.stopb.or.kslow))
then
360 IF (rm.LT.rinv(i))
THEN
366 IF (rm.LT.rslow.AND.icoll.EQ.0)
THEN
376 28 CALL
difsy1(neq,eps,stepl,stime,y)
379 else if (it.LT.5)
then
387 IF (step.GT.10.0*step0.AND.icoll.EQ.0)
THEN
388 step = 10.0*abs(step0)
389 ELSE IF (step.EQ.0.0d0)
THEN
390 WRITE (6,*)
' Stepsize = 0!', char(7)
395 WRITE (6,30) step, tmax-chtime, gpert, (1.0/rinv(k),k=1,n-1)
396 30
FORMAT (
' CHAIN: STEP TM-CHT G R ',1p,8e9.1)
400 IF (chtime.GT.time0.AND.jc.EQ.0)
THEN
405 IF (rinv(k).GT.rm)
THEN
409 rc2 = rc2 + rinv(k)**2
423 sx = max(
SIZE(i1),
SIZE(i2))
425 IF (imcirc.GT.0)
THEN
442 sy = max(
SIZE(j1),
SIZE(j2))
443 IF (sy*rinv(k).GT.sx/ry)
THEN
454 IF (iabs(k-ix).EQ.1)
THEN
459 pmax = 0.01*rinv(ix)**3
466 IF (icoll.LT.0) icall = 1
467 IF (ry.LT.sx.AND.nstep1.GT.next)
THEN
468 IF (zmi3.LT.zmi2.AND.zmi2.GT.zmi1)
THEN
470 IF (isync.EQ.0.AND.ncirc.LT.25.AND.gx.LT.pmax)
THEN
472 IF (kz26.GE.2.AND.kslow)
THEN
484 IF (isync.GT.0.AND.nstep1.GT.nstepx + 100)
THEN
492 IF (icoll.LE.0) go to 50
517 IF (qperi.LT.4.0*max(
SIZE(k1),
SIZE(k2)))
THEN
522 IF (
SIZE(k2).GT.
SIZE(k1))
THEN
529 IF (kz27.GT.0.AND.ebs.LT.0.0)
THEN
530 semi = -0.5*m(k1)*m(k2)/ebs
531 ecc = 1.0 - qperi/semi
532 IF (ecc.GT.0.0022) icirc = 1
537 fac = 0.5*(m(j1) + m(j2))/m(j1)
538 rcr = 1.7*fac**0.3333*
SIZE(j1)
540 clight = 3.0d+05/vstar1
541 rcr = 6.0*(m(j1) + m(j2))/clight**2
544 IF (qperi.LT.rcr)
THEN
552 hc =
energy + 0.5d0*mass*(cm(4)**2 + cm(5)**2 + cm(6)**2)
555 CALL
erel(im,ebs,semi)
577 ELSE IF (icirc.GT.0.AND.kz27.GT.0.AND.isync.EQ.0)
THEN
583 IF (iterm.EQ.-2)
THEN
590 IF (iterm.EQ.-1.AND.n.LE.4)
THEN
599 IF (abs(
energy-en0).EQ.0.0d0)
THEN
612 IF (imcirc.GT.0)
THEN
632 IF (iold(i).NE.iname(i)) isw = isw + 1
634 IF (isw.GT.1) nreg = nreg + 1
636 IF (kslow.AND.isw.GT.1)
THEN
642 IF (chtime.GT.tmax.OR.gpert.GT.0.01)
THEN
648 WRITE (6,55) nstep1, t0s(isub)+timec, tmax-timec,
649 & (1.0/rinv(k),k=1,n-1)
650 55
FORMAT (
' CHAIN: # T DTR R ',i5,f10.4,1p,6e9.1)
655 rgrav = min(sum/abs(
energy),0.5*rsum)
656 CALL
chmod(isub,kcase)
661 IF (kcase.LT.0) go to 60
663 IF (isw.EQ.0.AND.n.EQ.3)
THEN
664 IF (rsum.GT.4.0*rm)
THEN
666 IF (iterm.LT.0) go to 70
669 IF (chtime.LT.tmax.AND.
steps(isub).GT.0.0d0) go to 21
673 IF (chtime.GT.tmax) go to 60
675 IF (nstep1.GT.100000.AND.step.LT.small.AND.step.GT.0.0)
THEN
676 WRITE (6,58) nstep1, n, step, (1.0/rinv(k),k=1,n-1)
677 58
FORMAT (
' ENFORCED CHAIN # N STEP R',i8,i4,1p,9e9.1)
680 IF (
steps(isub).GT.0.0d0) go to 21
685 IF (rsum.GT.4.0*rm)
THEN
687 IF (iterm.LT.0) go to 70
689 ELSE IF (n.EQ.4)
THEN
690 IF (rm.LT.0.1*rsum)
THEN
698 IF (rx.GT.0.7*rsum)
THEN
700 IF (iterm.EQ.0.AND.ix.NE.2)
THEN
704 ELSE IF (rm.LT.0.01*rsum.AND.ix.NE.2)
THEN
707 IF (iterm.LT.0) go to 70
710 ELSE IF (n.GE.5)
THEN
712 IF (iterm.LT.0) go to 70
716 IF (n.GT.5.OR.(kcase.EQ.0.AND.
steps(isub).GT.0.0d0)) go to 100
717 IF (kcase.LT.0) go to 70
718 IF (timec.GT.tmax.AND.rsum.LT.rmaxc)
THEN
719 IF (
steps(isub).GT.0.0d0.OR.n.GT.4) go to 100
736 rik = q(ks+1)**2 + q(ks+2)**2 + q(ks+3)**2 + q(ks+4)**2
747 IF (kz30.GT.1.AND.qperi.LT.1.0)
THEN
748 WRITE (6,80) rij(1,2), rij(1,3), rij(2,3), rcoll, qperi
749 80
FORMAT (
' END CHAIN RIJ RCOLL QPERI ',1p,5e10.1)
753 100
IF (iterm.GE.0) ts(isub) = t0s(isub) + timec