util_peri.f 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. c*************************************************************************
  2. c UTIL_PERI.F
  3. c*************************************************************************
  4. c This subroutine determines whether peri has taken place
  5. c
  6. c Input:
  7. c iflg ==> = 0 if first step; = 1 not (int scalar)
  8. c ntp ==> number of bodies (int scalar)
  9. c xt,yt,zt ==> planocantric position of tp's
  10. c (real arrays)
  11. c vxt,vyt,vzt ==> planocantric velcocities of tp's
  12. c (real arrays)
  13. c massc ==> mass of the central body (real scalar)
  14. c
  15. c Output:
  16. c isperi ==> = 0 if tp went through peri
  17. c =-1 if tp pre peri
  18. c = 1 if tp post peri
  19. c (integer array)
  20. c peri ==> set to pericenter dist. if isperi=0
  21. c (real array)
  22. c lperi ==> set to .true. if isperi=0
  23. c (logical*2 array)
  24. c
  25. c
  26. c Remarks:
  27. c Authors: Hal Levison
  28. c Date: 2/25/94
  29. c Last revision: 7/14/94
  30. subroutine util_peri(iflg,ntp,xt,yt,zt,vxt,vyt,vzt,
  31. & massc,isperi,peri,lperi)
  32. include '../swift.inc'
  33. c... Inputs Only:
  34. integer ntp,iflg
  35. real*8 xt(ntp),yt(ntp),zt(ntp),massc
  36. real*8 vxt(ntp),vyt(ntp),vzt(ntp)
  37. c... Outputs:
  38. real*8 peri(NTPMAX)
  39. integer isperi(NTPMAX)
  40. logical*2 lperi(NTPMAX)
  41. c... Internals
  42. integer i,ialpha
  43. real*8 vdotr,a,e
  44. c----
  45. c... Executable code
  46. if(iflg.eq.0) then ! are we just setting thing up?
  47. do i=1,ntp
  48. vdotr = xt(i)*vxt(i) + yt(i)*vyt(i) + zt(i)*vzt(i)
  49. if (vdotr .gt. 0.d0) then
  50. isperi(i) = 1
  51. else
  52. isperi(i) =-1
  53. endif
  54. enddo
  55. else
  56. do i=1,ntp
  57. vdotr = xt(i)*vxt(i) + yt(i)*vyt(i) + zt(i)*vzt(i)
  58. if(isperi(i).eq.-1) then ! was coming in
  59. if (vdotr .lt. 0.d0) then ! still coming in
  60. isperi(i) = -1
  61. else ! turned around
  62. isperi(i) = 0
  63. lperi(i) = .true.
  64. call orbel_xv2aeq(xt(i),yt(i),zt(i),vxt(i),vyt(i),
  65. & vzt(i),massc,ialpha,a,e,peri(i))
  66. endif
  67. else
  68. if (vdotr .lt. 0.d0) then ! coming in
  69. isperi(i) = -1
  70. else
  71. isperi(i) = 1 ! going out
  72. endif
  73. endif
  74. enddo
  75. endif
  76. return
  77. end ! util_peri
  78. c------------------------------------------------------------------