subroutine NextTLE( lun, SatID, ClsLvl, IntlNo, EltSet, EphTyp, & Orbit, Epoch, dNdT, d2NdT2, bStar, Incl0, Node0, E0, Omega0, & M0, N0, Status ) ! ! Read the next NORAD Two-Line Element (TLE) set from the text ! file open on unit lun. ! ! B. Knapp, 1999-08-17, 2000-05-01, 2000-06-02 ! implicit none ! ! Input integer lun ! ! Output integer SatID, EltSet, Orbit, Status real*8 Epoch, dNdT, d2NdT2, bStar, & Incl0, Node0, E0, Omega0, M0, N0 character*8 IntlNo character*1 ClsLvl, EphTyp ! ! SatID -- NORAD satellite Number ! ClsLvl -- Classification Level ('U' or ' ' = Unclassified) ! IntlNo -- International Designator ! EltSet -- Element set number ! EphTyp -- Ephemeris Type (should be ' ' or '0'?) ! Orbit -- Orbit number [revs] ! Epoch -- yyddd.dddddddd [UT] ! (19yy for yy=57 to 99, 20yy for yy=00 to 56) ! dNdT -- First time derivative of the mean motion, divided ! by 2 [rad/day^2] ! d2NdT2 -- Second time derivative of the mean motion, divided ! by 6 [rad/day^3] ! bStar -- SGP4-type drag coefficient [(earth radii)^-1] ! Incl0 -- Inclination [rad] (0 to pi) ! Node0 -- Right Ascension of ascending node [rad] (0 to 2*pi) ! E0 -- Eccentricity [ ] (0 to 1) ! Omega0 -- Argument of Perigee [rad] (0 to 2*pi) ! M0 -- Mean Anomaly [rad] (0 to 2*pi) ! N0 -- Mean Motion [rad/day] ! ! Status -- -1 = End-of-file ! 0 = Elements successfully read ! >0 = Problem with element set (checksum error,...) ! ! Constants real*8 PI, TWOPI, D2R parameter (PI=3.141592653589793d0, TWOPI=2.d0*PI, D2R=PI/180.d0) ! ! Local variables real*8 Epoch1, dNdTc, d2NdT2c, bStar1, Incl0d, Node0d, E01, & Omega0d, M0d, N0c character*69 Line1, Line2 character*8 IntlNo1 character*1 ClsLvl1, EphTyp1 integer SatID1, SatID2, EltSet1, Orbit1 ! ! Subroutines, functions integer TleChk external TleChk ! ! Initialize SatID = 0 ClsLvl = ' ' IntlNo = ' ' EphTyp = ' ' EltSet = 0 Orbit = 0 Epoch = 0.d0 dNdT = 0.d0 d2NdT2 = 0.d0 bStar = 0.d0 Incl0 = 0.d0 Node0 = 0.d0 E0 = 0.d0 Omega0 = 0.d0 M0 = 0.d0 N0 = 0.d0 ! ! Read the two lines (skip lines that do not have a '1' or '2' in ! column 1--i.e., treat them as comment lines) 1 read( Lun, '(a)', end=90, err=80 ) Line1 if ( Line1(1:1) .ne. '1' ) goto 1 2 read( Lun, '(a)', end=80, err=80 ) Line2 if ( Line2(1:1) .ne. '2' ) goto 2 ! ! Check the checksums if ( TleChk( Line1 ) .ne. 0 .or. TleChk( Line2 ) .ne. 0 ) then Status = 2 return endif ! ! Make sure the LineID's are correct if ( Line1(1:1) .ne. '1' .or. Line2(1:1) .ne. '2' ) then Status = 3 return endif ! ! Decode the two lines read( Line1, 10, err=70 ) SatID1, ClsLvl1, IntlNo1, Epoch1, & dNdTc, d2NdT2c, bStar1, EphTyp1, EltSet1 10 format( 2x, i5, a1, 1x, a8, 1x, f14.8, f11.8, 2e9.5, 1x, a1, i5) read( Line2, 20, err=70 ) & SatID2, Incl0d, Node0d, E01, Omega0d, M0d, N0c, Orbit1 20 format( 2x, i5, 2f9.4, f8.7, 2f9.4, f12.8, i5 ) ! ! Make sure both lines are for the same satellite if ( SatID1 .ne. SatID2 ) then Status = 4 return endif ! ! Finally, Ephemeris Type should be 0 if ( EphTyp1 .ne. '0' .and. EphTyp1 .ne. ' ') then Status = 5 return endif ! ! Good element set, return the data SatID = SatID1 ClsLvl = ClsLvl1 IntlNo = IntlNo1 EphTyp = EphTyp1 EltSet = EltSet1 Orbit = Orbit1 Epoch = Epoch1 bStar = bStar1 E0 = E01 ! ! Convert degrees and revs to radians Incl0 = Incl0d*D2R Node0 = Node0d*D2R Omega0 = Omega0d*D2R M0 = M0d*D2R N0 = N0c*TWOPI dNdT = dNdTc*TWOPI d2NdT2 = d2NdT2c*TWOPI ! ! Normal exit Status = 0 return ! 70 continue Status = 6 !(Decoding, i.e., formatting, problem) return ! 80 continue Status = 1 !(Problem, e.g., first line present, but not second) return ! 90 continue Status = -1 !(End of file) return ! end