swift_helio.f 6.3 KB

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