symba5_step_recur.F 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. c*************************************************************************
  2. c SYMBA5_STEP_RECUR.F
  3. c*************************************************************************
  4. c THIS FILE MUST BE PRECOMPILED
  5. c*************************************************************************
  6. c
  7. c Input:
  8. c t ==> time (real Scalar)
  9. c nbod ==> number of massive bodies (int scalar)
  10. c nbodm ==> Location of last massive body(int scalar)
  11. c mass ==> mass of bodies (real array)
  12. c ireci ==> Input recursion level (integer scalar)
  13. c ilevl ==> largest recursion level used
  14. c (integer array)
  15. c iecnt ==> The number of objects that each planet
  16. c is encountering (int*2 array)
  17. c ielev ==> The level that this particle should go
  18. c (int*2 array)
  19. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  20. c (real scalars)
  21. c rhill ==> Hill sphere of planet (real Scalar)
  22. c xh,yh,zh ==> initial position in helio coord
  23. c (real arrays)
  24. c vxb,vyb,vzb ==> initial velocity in bari coord
  25. c (real arrays)
  26. c dt0 ==> Global timestep (real scalar)
  27. c lclose ==> .true. --> marge particles if they
  28. c get too close. Read in that
  29. c distance in io_init_pl
  30. c (logical*2 scalar)
  31. c rpl ==> physical size of a planet.
  32. c (real array)
  33. c eoff ==> Energy offset (real scalar)
  34. c ielc ==> number of encounters (integer*2 scalar)
  35. c ielst ==> list of ecnounters (2D integer*2 array)
  36. c Output:
  37. c xh,yh,zh ==> final position in helio coord
  38. c (real arrays)
  39. c vxb,vyb,vzb ==> final velocity in bari coord
  40. c (real arrays)
  41. c mergelst ==> list of mergers (int array)
  42. c mergecnt ==> count of mergers (int array)
  43. c rpl ==> Recalculated physical size of a planet.
  44. c if merger happened (real array)
  45. c mass ==> Recalculated mass of bodies
  46. c if merger happened (real array)
  47. c eoff ==> Energy offset (real scalar)
  48. c svdotr ==> vdotr relative flag
  49. c = .true. if i,j are receding
  50. c = .false is approaching
  51. c (2D logical*1 array)
  52. c Used internally, but only need 1 copy.
  53. c
  54. c Remarks: If marger occurs, does not change nbod and puts the mass
  55. c of one of the particles to zero.
  56. c Authors: Hal Levison
  57. c Date: 3/20/97
  58. c Last revision: 12/16/09
  59. #ifdef _RECUR_SUB
  60. recursive subroutine
  61. #else
  62. subroutine
  63. #endif
  64. & symba5_step_recur(t,nbod,nbodm,mass,ireci,ilevl,
  65. & iecnt,ielev,rhill,xh,yh,zh,vxb,vyb,vzb,lclose,rpl,mergelst,
  66. & mergecnt,dt0,eoff,svdotr,ielc,ielst)
  67. include '../swift.inc'
  68. include 'symba5.inc'
  69. c... Inputs Only:
  70. integer nbod,ireci,nbodm
  71. real*8 mass(nbod),dt0,rhill(nbod),t
  72. integer*2 iecnt(NTPMAX),ielev(nbod)
  73. logical*2 lclose
  74. integer*2 ielst(2,NENMAX),ielc
  75. c... Inputs and Outputs:
  76. integer ilevl(nbod)
  77. real*8 xh(nbod),yh(nbod),zh(nbod),eoff
  78. real*8 vxb(nbod),vyb(nbod),vzb(nbod),rpl(nbod)
  79. integer mergelst(2,NTPMAX),mergecnt
  80. logical*1 svdotr(NENMAX)
  81. c... Internals:
  82. integer i,j,ie
  83. integer icflg,it,irecp,ieflg
  84. real*8 dtl,dth,sgn
  85. c----
  86. c... Executable code
  87. dtl = dt0/(float(NTENC)**(ireci))
  88. dth = dtl/2.0d0
  89. if( (dtl/dt0) .le. TINY ) then
  90. write(*,*) ' Warning in SYMBA_STEP_RECUR: '
  91. write(*,*) ' Local timestep too small '
  92. write(*,*) ' Roundoff will be important!!!! '
  93. endif
  94. if(ireci.eq.0) then
  95. irecp = ireci + 1
  96. c... Do we need to go deeper?
  97. icflg = 0
  98. do ie=1,ielc
  99. i = ielst(1,ie)
  100. j = ielst(2,ie)
  101. if((ielev(i).ge.ireci).and.(ielev(j).ge.ireci)) then
  102. call symba5_chk(rhill,nbod,i,j,mass,xh,yh,zh,
  103. & vxb,vyb,vzb,dtl,irecp,ieflg,svdotr(ie))
  104. if(ieflg.ne.0) then
  105. icflg = 1
  106. ielev(i) = irecp
  107. ielev(j) = irecp
  108. ilevl(i) = max(irecp,ilevl(i))
  109. ilevl(j) = max(irecp,ilevl(j))
  110. endif
  111. endif
  112. enddo
  113. sgn = 1.0d0
  114. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  115. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,
  116. & ielst)
  117. call symba5_helio_drift(nbod,ielev,ireci,mass,xh,
  118. & yh,zh,vxb,vyb,vzb,dtl)
  119. if(icflg.ne.0) then
  120. call symba5_step_recur(t,nbod,nbodm,mass,irecp,ilevl,
  121. & iecnt,ielev,rhill,xh,yh,zh,vxb,vyb,vzb,lclose,
  122. & rpl,mergelst,mergecnt,dt0,eoff,svdotr,ielc,ielst)
  123. endif
  124. sgn = 1.0d0
  125. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  126. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,ielst)
  127. if( lclose ) then ! look for mergers
  128. do ie=1,ielc
  129. i = ielst(1,ie)
  130. j = ielst(2,ie)
  131. if((ielev(i).ge.ireci).and.(ielev(j).ge.ireci)) then
  132. call symba5_merge(t,dtl,nbod,nbodm,i,j,mass,xh,yh,zh,
  133. & vxb,vyb,vzb,ireci,ilevl,svdotr(ie),
  134. & iecnt,rpl,mergelst,mergecnt,rhill,eoff,ielc,
  135. & ielst)
  136. endif
  137. enddo
  138. endif
  139. do i=2,nbod
  140. if(ielev(i).eq.irecp) then
  141. ielev(i) = ireci
  142. endif
  143. enddo
  144. else
  145. irecp = ireci + 1
  146. do it=1,NTENC
  147. c... Do we need to go deeper?
  148. icflg = 0
  149. do ie=1,ielc
  150. i = ielst(1,ie)
  151. j = ielst(2,ie)
  152. if((ielev(i).ge.ireci).and.(ielev(j).ge.ireci)) then
  153. call symba5_chk(rhill,nbod,i,j,mass,xh,yh,
  154. & zh,vxb,vyb,vzb,dtl,irecp,ieflg,
  155. & svdotr(ie))
  156. if(ieflg.ne.0) then
  157. icflg = 1
  158. ielev(i) = irecp
  159. ielev(j) = irecp
  160. ilevl(i) = max(irecp,ilevl(i))
  161. ilevl(j) = max(irecp,ilevl(j))
  162. endif
  163. endif
  164. enddo
  165. sgn = 1.0d0
  166. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  167. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,ielst)
  168. sgn = -1.0d0
  169. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  170. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,ielst)
  171. call symba5_helio_drift(nbod,ielev,ireci,mass,xh,
  172. & yh,zh,vxb,vyb,vzb,dtl)
  173. if(icflg.ne.0) then
  174. call symba5_step_recur(t,nbod,nbodm,mass,irecp,ilevl,
  175. & iecnt,ielev,rhill,xh,yh,zh,vxb,vyb,vzb,lclose,
  176. & rpl,mergelst,mergecnt,dt0,eoff,svdotr,ielc,ielst)
  177. endif
  178. sgn = 1.0d0
  179. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  180. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,ielst)
  181. sgn = -1.0d0
  182. call symba5_kick(nbod,mass,irecp,iecnt,ielev,
  183. & rhill,xh,yh,zh,vxb,vyb,vzb,dth,sgn,ielc,ielst)
  184. if( lclose ) then ! look for mergers
  185. do ie=1,ielc
  186. i = ielst(1,ie)
  187. j = ielst(2,ie)
  188. if((ielev(i).ge.ireci).and.(ielev(j).ge.ireci)) then
  189. call symba5_merge(t,dtl,nbod,nbodm,i,j,mass,xh,yh,
  190. & zh,vxb,vyb,vzb,ireci,ilevl,svdotr(ie),
  191. & iecnt,rpl,mergelst,mergecnt,rhill,eoff,ielc,
  192. & ielst)
  193. endif
  194. enddo
  195. endif
  196. do i=2,nbod
  197. if(ielev(i).eq.irecp) then
  198. ielev(i) = ireci
  199. endif
  200. enddo
  201. enddo
  202. endif
  203. return
  204. end ! symba5_step_recur.f
  205. c--------------------------------------------------------------