swift_mvs.f 6.3 KB

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