rmvs2_step_out.f 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. c*************************************************************************
  2. c RMVS2_STEP_OUT.F
  3. c*************************************************************************
  4. c This subroutine takes a full dt step in helio coord for test particles
  5. c in the outer region of an encounter. It will also remember
  6. c where the planets are for the planocentric integration if necessary.
  7. c
  8. c Input:
  9. c i1st ==> = 0 if first step; = 1 not (int scalar)
  10. c nbod ==> number of massive bodies (int scalar)
  11. c ntp ==> number of massive bodies (int scalar)
  12. c mass ==> mass of bodies (real array)
  13. c j2rp2,j4rp4 ==> J2*radii_pl^2 and J4*radii_pl^4
  14. c (real scalars)
  15. c xbeg,ybeg,zbeg ==> initial planet position in helio coord
  16. c (real arrays)
  17. c xtmpo,ytmpo,ztmpo ==> position of planet wrt time
  18. c (2d real arrays)
  19. c xht,yht,zht ==> initial tp position in helio coord
  20. c (real arrays)
  21. c vxht,vyht,vzht ==> initial tp velocity in helio coord
  22. c (real arrays)
  23. c istat ==> status of the test paricles
  24. c (2d integer array)
  25. c istat(i,1) = 0 ==> active: = 1 not
  26. c istat(i,2) = -1 ==> Danby did not work
  27. c ienco ==> ienco(j) = 0 if tp j not involved in enc
  28. c in outer region: = planet# if it is.
  29. c (integer array)
  30. c = 0 No (integer scalar)
  31. c dt ==> time step (real sclar)
  32. c Output:
  33. c xht,yht,zht ==> final tp position in helio coord
  34. c (real arrays)
  35. c vxht,vyht,vzht ==> final tp position in helio coord
  36. c (real arrays)
  37. c NOTE: only the tp in the outer region
  38. c will have their x and v's changed
  39. c istat ==> status of the test paricles
  40. c (2d integer array)
  41. c istat(i,1) = 0 ==> active: = 1 not
  42. c istat(i,2) = -1 ==> Danby did not work
  43. c
  44. c
  45. c Remarks: Adopted from martin's nbwh.f program
  46. c Authors: Hal Levison
  47. c Date: 8/25/94
  48. c Last revision:
  49. subroutine rmvs2_step_out(i1st,nbod,ntp,mass,j2rp2,j4rp4,
  50. & xbeg,ybeg,zbeg,xtmpo,ytmpo,ztmpo,xht,yht,zht,
  51. & vxht,vyht,vzht,istat,ienco,dt)
  52. include '../swift.inc'
  53. include '../rmvs/rmvs.inc'
  54. c... Inputs Only:
  55. integer nbod,ntp,i1st
  56. real*8 mass(nbod),dt,j2rp2,j4rp4
  57. real*8 xtmpo(NPLMAX,NTPENC),ytmpo(NPLMAX,NTPENC)
  58. real*8 ztmpo(NPLMAX,NTPENC)
  59. integer ienco(NTPMAX)
  60. real*8 xbeg(NPLMAX),ybeg(NPLMAX),zbeg(NPLMAX)
  61. c... Inputs and Outputs:
  62. integer istat(NTPMAX,NSTAT)
  63. real*8 xht(ntp),yht(ntp),zht(ntp)
  64. real*8 vxht(ntp),vyht(ntp),vzht(ntp)
  65. c... Internals
  66. integer i1sttp,i,j,ic,istattmp(NTPMAX,NSTAT)
  67. real*8 dto
  68. real*8 xbegi(NPLMAX),ybegi(NPLMAX),zbegi(NPLMAX)
  69. real*8 xendi(NPLMAX),yendi(NPLMAX),zendi(NPLMAX)
  70. c----
  71. c... Executable code
  72. i1sttp = i1st
  73. dto = dt/float(NTENC)
  74. c... We only want to integrate the position of test particles in outer region
  75. c... make a temporary istat array ao only they are active
  76. do i=1,ntp
  77. if(ienco(i).eq.0) then
  78. istattmp(i,1) = 1 ! don't integrate it
  79. else
  80. istattmp(i,1) = 0 ! integrate it
  81. endif
  82. do j=2,NSTAT
  83. istattmp(i,j) = 0
  84. enddo
  85. enddo
  86. c... do integration of outer loop
  87. ic = 0
  88. do i=1,NTENC
  89. c... remember the current position of the planets
  90. if(i.eq.1) then
  91. do j=1,nbod
  92. xbegi(j) = xbeg(j)
  93. ybegi(j) = ybeg(j)
  94. zbegi(j) = zbeg(j)
  95. enddo
  96. else
  97. do j=1,nbod
  98. xbegi(j) = xtmpo(j,i-1)
  99. ybegi(j) = ytmpo(j,i-1)
  100. zbegi(j) = ztmpo(j,i-1)
  101. enddo
  102. endif
  103. do j=1,nbod
  104. xendi(j) = xtmpo(j,i)
  105. yendi(j) = ytmpo(j,i)
  106. zendi(j) = ztmpo(j,i)
  107. enddo
  108. call step_kdk_tp(i1sttp,nbod,ntp,mass,j2rp2,j4rp4,
  109. & xbegi,ybegi,zbegi,xendi,yendi,zendi,
  110. & xht,yht,zht,vxht,vyht,vzht,istattmp,dto)
  111. enddo
  112. c... Have to update istat just in case damby had problems
  113. do i=1,ntp
  114. if( (ienco(i).ne.0) .and. (istattmp(i,1).ne.0) ) then
  115. istat(i,1) = 1 ! it had problems
  116. do j=2,NSTAT
  117. istat(i,j) = istattmp(i,j)
  118. enddo
  119. endif
  120. enddo
  121. return
  122. end ! rmvs2_step_out
  123. c----------------------------------------------------------------