      COMMON/INFO/ANS(500,8),SPECT(500,4,10),NFLAG(500),NC(500),NSPEC   00000100
      COMMON/RATIO/I,RAT(500,3),ERR(500,3),HR(3,500),REST(7500)         00000200
      COMMON/INPDAT/NFC,NCH,ACCTIM,IOUT,GETS(2)                         00000300
      REAL LONG(2),LAT(2),SUMB(3),OUT(500)                              00000400
      DATA PER/.5/,OUTS/'G   '/,OUTB/'    '/                            00000500
      INTEGER*4 HR,SPECT                                                00000600
      READ(5,1001) ACCTIM,NFC,NCH,IOUT,LONG(1),LONG(2),                 00000700
     1LAT(1),LAT(2),(SUMB(K),K=1,3),BACTIM                              00000800
C     LAT(1) IS THE NORTH LIMIT AND LAT(2) IS THE SOUTH LIMIT           00000900
C     LONG(1) IS THE EAST LIMIT AND LONG(2) IS THE WEST LIMIT           00001000
 1001 FORMAT(F6.0,3(1X,I1),4F6.0,4F5.0)                                 00001100
      CORR=ACCTIM/BACTIM                                                00001200
      DO 5 I=1,3                                                        00001300
    5 SUMB(I)=SUMB(I)*CORR                                              00001400
      IEOF=-1                                                           00001500
   10 READ(5,1000,END=900) GETS(1),GETS(2)                              00001600
 1000 FORMAT(2F8.0)                                                     00001700
   20 GETT=GETS(2)-GETS(1)                                              00001800
      IF(GETT.LT.0.0) GO TO 10                                          00001900
      WRITE(6,2025) GETT,GETS(1),GETS(2)                                00002000
 2025 FORMAT('1(IN SECONDS), TOTAL PASS =',F8.0,2X,'FROM ',F8.0,2X,     00002100
     1'TO ',F8.0)                                                       00002200
      WRITE(6,2005) LONG(1),LONG(2),LAT(1),LAT(2)                       00002300
 2005 FORMAT('0DATA PROCESSED FROM LONGITUDE ',F6.1,' TO ',F6.1,        00002400
     1' AND LATITUDE ',F6.1,' TO ',F6.1)                                00002500
      CALL XRY(IEOF,LONG,LAT)                                           00002600
      IF(NSPEC.GT.0) GO TO 22                                           00002700
      WRITE(6,2000)                                                     00002800
 2000 FORMAT(' NO DATA DURING THIS TIME PERIOD')                        00002900
      IF(IEOF.LE.2) GO TO 20                                            00003000
      GO TO 10                                                          00003100
   22 DO 24 I=1,NSPEC                                                   00003200
      HR(1,I)=ANS(I,1)/3600                                             00003300
      TEMP=ANS(I,1)-(HR(1,I)*3600)                                      00003400
      HR(2,I)=TEMP/60.                                                  00003500
   24 HR(3,I)=TEMP+0.5-(HR(2,I)*60)                                     00003600
 2024 FORMAT(1H0,47X,'PERIOD'/41X,'  HR MIN SEC   ORBIT'/2(40X,I5,2I4,  00003700
     XF8.2/))                                                           00003800
      WRITE(6,2017)                                                     00003900
 2017 FORMAT(1H1,///////44X,'PROCESSED DATA')                           00004000
      WRITE(6,2024) (HR(J,1),J=1,3),ANS(1,2),(HR(J,NSPEC),J=1,3),       00004100
     1ANS(NSPEC,2)                                                      00004200
      DO 70 I=1,NSPEC                                                   00004300
      IF(NFLAG(I).NE.16) GO TO 70                                       00004400
      RAT(I,1)=0.0                                                      00004500
      OUT(I)=OUTB                                                       00004600
      IWARN=0                                                           00004700
C     ANS(I,1) IS THE GET IN SECONDS                                    00004800
C     ANS(I,2) IS THE ORBIT NUMBER                                      00004900
C     ANS(I,3) IS THE SELENOGRAPHIC LAT. IN DEGREES                     00005000
C     ANS(I,4) IS THE SELENOGRAPHIC LONG. IN DEGREES                    00005100
C     ANS(I,5) IS THE ALTITUDE IN KILOMETERS                            00005200
C     ANS(I,6) IS THE PITCH ANGLE IN DEGREES                            00005300
C     ANS(I,7) IS THE YAW ANGLE IN DEGREES                              00005400
C     ANS(I,8) IS THE ROLL ANGLE IN DEGREES                             00005500
      WRITE(6,2003) (HR(J,I),J=1,3),(ANS(I,JJ),JJ=1,8)                  00005600
 2003 FORMAT('0  HR MIN SEC = SECONDS   ORBIT   LAT.  LONGITUDE  ALT KM 00005700
     I   PITCH      YAW   ROLL'/3I4,F12.2,2F7.2,F8.2,2F10.2,2F9.2)      00005800
      IF(ABS(ANS(I,7)).GT.10.0) GO TO 40                                00005900
      TEMP=ANS(I,8)+37.75                                               00006000
      IF(ABS(ANS(I,6)).GE.170.0.AND.ABS(TEMP).LE.10.0) GO TO 42         00006100
      TEMP=TEMP-180.0                                                   00006200
      IF(ABS(ANS(I,6)).LE.10.0.AND.ABS(TEMP).LE.10.0) GO TO 42          00006300
   40 WRITE(6,2030)                                                     00006400
 2030 FORMAT(' *****WARNING ROLL/PITCH/YAW OUT OF 10. DEGREE LIMITS')   00006500
      WRITE(6,2031) ANS(I,6),ANS(I,7),TEMP                              00006600
 2031 FORMAT('  (IN DEGREES FROM NORMAL)  PITCH =',F8.2,3X,'YAW =',F8.2,00006700
     X3X,'AND ROLL =',F8.2)                                             00006800
      OUT(I)=OUTS                                                       00006900
      IWARN=1                                                           00007000
   42 IF(IOUT.EQ.0) GO TO 45                                            00007100
      CALL NEWCOR(I,FLAT,FLONG)                                         00007200
      WRITE(6,4000) FLAT,FLONG                                          00007300
 4000 FORMAT('  **CORRECTED LAT. AND LONG.=',2F10.2)                    00007400
      ANS(I,3)=FLAT                                                     00007500
      ANS(I,4)=FLONG                                                    00007600
   45 CALL ELRATE(SUMB)                                                 00007700
   70 CONTINUE                                                          00007800
      CALL SUMRY(LONG,LAT,OUT,PER)                                      00007900
      IF(IEOF.GE.3) GO TO 10                                            00008000
      GO TO 20                                                          00008100
  900 WRITE(6,2012)                                                     00008200
 2012 FORMAT('0END OF DATA ON INPUT UNIT 5')                            00008300
      STOP                                                              00008400
      END                                                               00008500
