swift_symba5.f 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. c**********************************************************************
  2. c SWIFT_SYMBA5.F
  3. c**********************************************************************
  4. c
  5. c To run, need 2 input files. The code prompts for
  6. c the file names, but examples are :
  7. c
  8. c parameter file like param.in
  9. c planet file like pl.in
  10. c
  11. c NOTE: No test particles in this code and the massive bodies
  12. c are dimensioned at NTPMAX
  13. c
  14. c Authors: Hal Levison \& Martin Duncan
  15. c Date: 11/21/96
  16. c Last revision: 12/27/96
  17. include 'swift.inc'
  18. real*8 mass(NTPMAX),j2rp2,j4rp4
  19. real*8 xh(NTPMAX),yh(NTPMAX),zh(NTPMAX)
  20. real*8 vxh(NTPMAX),vyh(NTPMAX),vzh(NTPMAX)
  21. real*8 xht(1),yht(1),zht(1) ! Dummy for the io
  22. real*8 vxht(1),vyht(1),vzht(1)
  23. integer ntp,istat(1)
  24. integer nbod,i1st,i,nbodm,nbodo
  25. integer iflgchk,iub,iuj,iud,iue,ium
  26. real*8 t0,tstop,dt,dtout,dtdump
  27. real*8 t,tout,tdump,tfrac,eoff
  28. real*8 rpl(NTPMAX),rhill(NTPMAX)
  29. real*8 rmin,rmax,rmaxu,qmin,mtiny
  30. real*8 ke,pot,energy,eltot(3)
  31. logical*2 lclose
  32. integer isenc,ihills
  33. integer mergelst(2,NTPMAX),mergecnt
  34. integer*2 iecnt(NTPMAX)
  35. character*80 outfile,inparfile,inplfile,fopenstat
  36. c-----
  37. c... Executable code
  38. ntp = 0
  39. c... print version number
  40. call util_version
  41. c Get data for the run and the test particles
  42. write(*,*) 'Enter name of parameter data file : '
  43. read(*,999) inparfile
  44. call io_init_param(inparfile,t0,tstop,dt,dtout,dtdump,
  45. & iflgchk,rmin,rmax,rmaxu,qmin,lclose,outfile,fopenstat)
  46. c Prompt and read name of planet data file
  47. write(*,*) ' '
  48. write(*,*) 'Enter name of planet data file : '
  49. read(*,999) inplfile
  50. 999 format(a)
  51. call io_init_pl_symba(inplfile,lclose,iflgchk,nbod,mass,
  52. & xh,yh,zh,vxh,vyh,vzh,rpl,rhill,j2rp2,j4rp4)
  53. write(*,*) 'Enter the smallest mass to self gravitate :'
  54. read(*,*) mtiny
  55. write(*,*) ' mtiny = ',mtiny
  56. c Initialize initial time and times for first output and first dump
  57. t = t0
  58. tout = t0 + dtout
  59. tdump = t0 + dtdump
  60. iub = 20
  61. iuj = 30
  62. iud = 40
  63. iue = 60
  64. ium = 21
  65. c... Do the initial io write
  66. if(btest(iflgchk,0)) then ! bit 0 is set
  67. call io_write_frame(t0,nbod,ntp,mass,xh,yh,zh,vxh,vyh,vzh,
  68. & xht,yht,zht,vxht,vyht,vzht,istat,outfile,iub,fopenstat)
  69. call io_write_mass(t0,nbod,mass,outfile,ium,fopenstat)
  70. endif
  71. if(btest(iflgchk,1)) then ! bit 1 is set
  72. call io_write_frame_r(t0,nbod,ntp,mass,xh,yh,zh,vxh,vyh,vzh,
  73. & xht,yht,zht,vxht,vyht,vzht,istat,outfile,iub,fopenstat)
  74. call io_write_mass_r(t0,nbod,mass,outfile,ium,fopenstat)
  75. endif
  76. c... must initize discard io routine
  77. if(btest(iflgchk,4)) then ! bit 4 is set
  78. call io_discard_mass(0,t,0,mass(1),rpl(1),xh(1),yh(1),zh(1),
  79. & vxh(1),vyh(1),vzh(1),iud,-1,fopenstat)
  80. endif
  81. c... Calculate the location of the last massive particle
  82. call symba5_nbodm(nbod,mass,mtiny,nbodm)
  83. c... set up energy write stuff
  84. if(btest(iflgchk,2)) then ! bit 2 is set
  85. eoff = 0.0d0
  86. call anal_energy_write(t0,nbod,mass,j2rp2,j4rp4,xh,yh,zh,vxh,
  87. & vyh,vzh,iue,fopenstat,eoff)
  88. call anal_energy_discard5(1,nbod,nbodm,mass,j2rp2,j4rp4,
  89. & xh,yh,zh,vxh,vyh,vzh,ke,pot,energy,eltot)
  90. else
  91. call anal_energy_discard5(-1,nbod,nbodm,mass,j2rp2,j4rp4,
  92. & xh,yh,zh,vxh,vyh,vzh,ke,pot,energy,eltot)
  93. endif
  94. ihills = 0
  95. i1st = 0
  96. c***************here's the big loop *************************************
  97. write(*,*) ' ************** MAIN LOOP ****************** '
  98. do while ( (t .le. tstop) .and. (nbod.gt.1) )
  99. call symba5_step_pl(i1st,t,nbod,nbodm,mass,j2rp2,j4rp4,
  100. & xh,yh,zh,vxh,vyh,vzh,dt,lclose,rpl,isenc,
  101. & mergelst,mergecnt,iecnt,eoff,rhill,mtiny)
  102. t = t + dt
  103. if(btest(iflgchk,4)) then ! bit 4 is set
  104. nbodo = nbod
  105. call discard_massive5(t,dt,nbod,mass,xh,yh,zh,
  106. & vxh,vyh,vzh,rmin,rmax,rmaxu,qmin,lclose,
  107. & rpl,rhill,isenc,mergelst,mergecnt,
  108. & iecnt,eoff,i1st)
  109. if(nbodo.ne.nbod) then
  110. call symba5_nbodm(nbod,mass,mtiny,nbodm)
  111. endif
  112. endif
  113. c if it is time, output orb. elements,
  114. if(t .ge. tout) then
  115. if(btest(iflgchk,0)) then ! bit 0 is set
  116. call io_write_frame(t,nbod,ntp,mass,xh,yh,zh,vxh,
  117. & vyh,vzh,xht,yht,zht,vxht,vyht,vzht,istat,outfile,
  118. & iub,fopenstat)
  119. call io_write_mass(t,nbod,mass,outfile,ium,fopenstat)
  120. endif
  121. if(btest(iflgchk,1)) then ! bit 1 is set
  122. call io_write_frame_r(t,nbod,ntp,mass,xh,yh,zh,vxh,
  123. & vyh,vzh,xht,yht,zht,vxht,vyht,vzht,istat,outfile,
  124. & iub,fopenstat)
  125. call io_write_mass_r(t,nbod,mass,outfile,ium,fopenstat)
  126. endif
  127. tout = tout + dtout
  128. endif
  129. c If it is time, do a dump
  130. if(t.ge.tdump) then
  131. tfrac = (t-t0)/(tstop-t0)
  132. write(*,998) t,tfrac,nbod
  133. 998 format(' Time = ',1p1e12.5,': fraction done = ',0pf5.3,
  134. & ': Number of bodies =',i4)
  135. call io_dump_pl_symba('dump_pl.dat',nbod,mass,xh,yh,zh,
  136. & vxh,vyh,vzh,lclose,iflgchk,rpl,rhill,j2rp2,j4rp4)
  137. call io_dump_param('dump_param.dat',t,tstop,dt,dtout,
  138. & dtdump,iflgchk,rmin,rmax,rmaxu,qmin,lclose,outfile)
  139. tdump = tdump + dtdump
  140. if(btest(iflgchk,2)) then ! bit 2 is set
  141. call anal_energy_write(t,nbod,mass,j2rp2,j4rp4,
  142. & xh,yh,zh,vxh,vyh,vzh,iue,fopenstat,eoff)
  143. endif
  144. endif
  145. enddo
  146. c********** end of the big loop from time 't0' to time 'tstop'
  147. c Do a final dump for possible resumption later
  148. call io_dump_pl_symba('dump_pl.dat',nbod,mass,xh,yh,zh,
  149. & vxh,vyh,vzh,lclose,iflgchk,rpl,rhill,j2rp2,j4rp4)
  150. call io_dump_param('dump_param.dat',t,tstop,dt,dtout,
  151. & dtdump,iflgchk,rmin,rmax,rmaxu,qmin,lclose,outfile)
  152. call util_exit(0)
  153. end ! swift_symba5.f
  154. c---------------------------------------------------------------------