Advertisement
Guest User

sub_orbit.f

a guest
Apr 9th, 2019
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         subroutine sub_orbit(iyear,idoy,sec,a,x,y,z,Ek)
  2.         implicit double precision (a-h,o-z)
  3.         dimension a(38)
  4.  
  5. c  -------------------------------------------------------------
  6. c       This subroutine calculates the coordinates (WGS84) of a
  7. c       GPS satellite for a given epoch (iyear,idoy,sec
  8. c       --GPS-time--), from the navigation message parameters.
  9. c
  10. c       INPUT:
  11. c       -----
  12. c        - epoch for which the coordinates must be calculated.
  13. c            iyear: year
  14. c            idoy:  day of year
  15. c            sec:   seconds in the day
  16. c        - Navigation message (broadcast data)
  17. c          (according to RINEX format)
  18. c                                                                
  19. c            [sat, year,mon,day,h,m,sec, a0,a1,a2     ]                            
  20. c            [                    IODE,Crs,dn,xMo,    ]
  21. c            [                    Cuc, e, Cus,a12,    ]
  22. c            [                    toe,Cic,Omgg,Cis,   ]
  23. c            [                    xIo,Crc,omgp,Omgd   ]
  24. c            [                    xIDOT,xx,GPS_Week,xx]
  25. c            [                    SVac,SVh,TGD,IODC   ]              
  26. c            [                    xx, xx , xx ,xx     ]
  27. c
  28. c      OUTPUT:
  29. c      ------
  30. c             Satellite coordinates of the satellite in the reference
  31. c             system tied to the Earth WGS-84
  32. c             (x,y,z): in metres
  33. c             Ek: eccentric anomaly (rad)
  34. c
  35. c      @gAGE (Research group of Astronomy and GEomatics). UPC
  36. c  -------------------------------------------------------------                    
  37.  
  38.  
  39.  
  40. c       Parameters declaration .....
  41. c       Light speed (m/s)
  42.         c=299792458.d0
  43. c       WGS-84 Earth Univ. Grav. parameter (m3/s2)
  44.         xmu=3.986005d+14
  45. c       WGS-84 Earth rotation rate (rad/s)  
  46.         om_e=7.2921151467d-5
  47.         pi=3.1415926535898d0
  48. c       ............................
  49. c       GPS Navigation message parameters:
  50.         xIODE=a(11)
  51.         Crs=a(12)
  52.         dn=a(13)
  53.         xMo=a(14)
  54.         Cuc=a(15)
  55.         e=a(16)
  56.         Cus=a(17)
  57.         a12=a(18)
  58.         toe=a(19)
  59.         Cic=a(20)
  60.         Omgg=a(21)
  61.         Cis=a(22)
  62.         xIo=a(23)
  63.         Crc=a(24)
  64.         omgp=a(25)
  65.         Omgd=a(26)
  66.         xId=a(27)
  67.         iGPSweek=int(a(29))
  68. c       ........................................                                
  69. c       Computing the GPS_week (nw) and second (sW) in the week
  70.         xy=dble(iyear)      
  71. c       In RINEX format year is given with only two digits
  72.         if (xy.lt.100.d0) then
  73.           if (xy.lt.80.d0) then
  74.             xy=xy+2000.d0
  75.            else
  76.             xy=xy+1900.d0
  77.           endif    
  78.         endif                  
  79.  
  80. c       GPS day: (1980jan6.0 => JD=2444244.5 => id_GPS=1.0)
  81.         id_GPS=int(365.25d0*(xy-1.d0))+idoy-722835
  82. c       Day of week:
  83.         idw=mod(id_GPS,7)
  84. c       Number of GPS week:
  85.         nw=(id_GPS-idw)/7
  86. c       seconds in the week:
  87.         sw=dble(idw)*86400.d0+sec
  88.  
  89. c       Control of GPS WEEK
  90.         if (nw.ne.iGPSweek) print *,"ERROR: week",iGPSweek,nw
  91.  
  92. c       Time from current ephemeris epoch
  93.         tk=sw-toe
  94.         if(tk.gt.302400.d0)  tk=tk-604800.d0
  95.         if(tk.lt.-302400.d0) tk=tk+604800.d0      
  96. c       Control of age of this orbits
  97.         if (tk.gt.7200.d0) print *,"WARNING tk=", tk," > 7200sec"
  98.  
  99. c       True anomaly fk:
  100.         xMk=xMo+(dsqrt(xmu)/(a12**3)+dn)*tk
  101.         call sub_nsteffensen(xMk,e,Ek)
  102.         fk=datan2(dsqrt(1.d0-e**2)*dsin(Ek),dcos(Ek)-e)
  103.        
  104. c       Arg. of Latitude uk,radius rk, inclination ik:
  105.         uk=omgp+fk+Cuc*dcos(2.d0*(omgp+fk))+
  106.      *       Cus*dsin(2.d0*(omgp+fk))
  107.         rk=(a12**2)*(1.d0-e*dcos(Ek))+Crc*dcos(2.d0*(omgp+fk))+
  108.      *     Crs*dsin(2.d0*(omgp+fk))
  109.         xIk=xIo+xId*tk+Cic*dcos(2.d0*(omgp+fk))+
  110.      *      Cis*dsin(2.d0*(omgp+fk))                      
  111.  
  112. c       Positions in orbital plane
  113.         xp=rk*dcos(uk)
  114.         yp=rk*dsin(uk)                            
  115.  
  116. c       Longitude of ascending node xlmk:
  117.         xlmk=Omgg+(Omgd-om_e)*tk-om_e*toe
  118.  
  119.  
  120.  
  121. c       CT-System coordinates
  122.         x=xp*dcos(xlmk)-yp*dcos(xIk)*dsin(xlmk)
  123.         y=xp*dsin(xlmk)+yp*dcos(xIk)*dcos(xlmk)
  124.         z=yp*dsin(xIk)
  125.  
  126.         return
  127.         end
  128.  
  129.  
  130. c       -----------------------------------------------------------
  131.  
  132.        subroutine sub_nsteffensen(xm,e,ex)
  133.        implicit double precision (a-h,o-z)
  134.  
  135. c      Method for accelerating the convergence of the Method
  136. c      of Newton-Rapson.
  137. c      Equations of this kind p=g(p)   (==> E=M+e*sin(E))
  138. c      The method requires that g'(p)<>1  (==> p single root)
  139.  
  140.         tol=1.d-15
  141.  
  142.         xm=datan2(dsin(xm),dcos(xm))
  143.         p=xm
  144.  
  145. 10      continue
  146.         p0=p
  147.         p1=xm+e*dsin(p0)
  148.         p2=xm+e*dsin(p1)
  149.         dd=dabs(p2-2.d0*p1+p0)
  150.         if(dd.lt.tol) goto 100    
  151.         p=p0-(p1-p0)**2/(p2-2.d0*p1+p0)
  152.         if(dabs(p-p0).gt.tol) goto 10
  153.  
  154. 100     continue
  155.         ex=p
  156.  
  157.        return
  158.        end
  159.  
  160. c       -----------------------------------------------------------
  161.  
  162.  
  163. c      f77 -c sub_orbit.f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement