      SUBROUTINE NEWCOR(INUM,FLAT,FLON)                                 00000100
      COMMON/INFO/ANS(500,8),SPECT(500,4,10),NFLAG(500),NC(500),NSPEC   00000200
      INTEGER*4 HR,SPECT                                                00000300
      REAL*4 KMDEG,KMDG2                                                00000400
      DATA RDDEG/.017453/,RADM/1738.1/,KMDEG/30.3355/,SLOPE/0./,        00000500
     1ANGL1/.69812/                                                     00000600
C ***** PROGRAM DETERMINES NEW LONG & LAT DUE TO ROLL, PITCH, & YAW     00000700
C ***** & DIRECTION OF SATELLITE. THE INPUT PARAMETERS NECESSARY FOR    00000800
C ***** USE ARE INITIAL LAT, INITIAL LONG, ALT, PITCH, YAW, ROLL, &     00000900
C ***** # OF SPECTRA.IN THE PROGRAM THESE PARAMETERS SHOULD BE LOCATED  00001000
C ***** IN THE MATRIX ANS AND THE VARIABLE NSPEC RESPECTIVELY.          00001100
C ***** PROGRAM DESIGNED BY KAREN MAALE, CODE 682, GODDARD SPACE FLIGHT 00001200
C ***** CENTER, GREENBELT, MD., APRIL 1974.                             00001300
      IF(INUM.GT.NSPEC) GO TO 800                                       00001400
      IF(INUM.EQ.1) GO TO 100                                           00001500
      IT=INUM-1                                                         00001600
      XLON0=ANS(IT,4)                                                   00001700
      YLAT0=ANS(IT,3)                                                   00001800
  100 XLON=ANS(INUM,4)                                                  00001900
      YLAT=ANS(INUM,3)                                                  00002000
      ALT=ANS(INUM,5)                                                   00002100
      THETA=ANS(INUM,6)*RDDEG                                           00002200
      PSI=ANS(INUM,7)*RDDEG                                             00002300
      PHI=ANS(INUM,8)-142.25                                            00002400
      IF(ABS(THETA).GT.90.0) PHI=PHI-180.0                              00002500
      IF (PHI.LT.-180.) PHI=PHI+360.                                    00002600
      PHI=PHI*RDDEG                                                     00002700
C ***** IF LOOK ANGLE IS > 40 DEGREES LAT & LONG WILL BE ASSIGNED       00002800
C ***** THE VALUE ZERO. HOWEVER IF ANGLE CORRECTIONS FROM NADIR TO      00002900
C ***** THE HORIZON ARE DESIRED REMOVE COMMENTS FROM THE NEXT TWO       00003000
C ***** STATEMENTS.                                                     00003100
C     TLINE=SQRT((RADM+ALT)**2-RADM*RADM)                               00003200
C     ANGL1=ATAN(RADM/TLINE)                                            00003300
      D33=-SIN(PSI)*SIN(THETA)*SIN(PHI)+COS(THETA)*COS(PHI)             00003400
      ANGL2=ARCOS(D33)                                                  00003500
      IF ((ANGL2.GE.ANGL1).OR.(D33.LE.0.)) GO TO 800                    00003600
C ***** X & Y COORDINATES FOUND DUE TO ROLL, PITCH, & YAW               00003700
      XNUM=SIN(PSI)*COS(THETA)*SIN(PHI)+SIN(THETA)*COS(PHI)             00003800
      X=(XNUM/D33)*ALT                                                  00003900
      YNUM=-COS(PSI)*SIN(PHI)                                           00004000
      Y=(YNUM/D33)*ALT                                                  00004100
C ***** ROTATION OF X & Y DUE TO INCLINATION OF SATELLITE               00004200
      IF (INUM.EQ.1) GO TO 700                                          00004300
      DX=XLON-XLON0                                                     00004400
      IF (DX.GT.0.) DX=DX-360                                           00004500
      DY=YLAT-YLAT0                                                     00004600
      SLOPE=-ATAN(DY/DX)                                                00004700
      XNEW=COS(SLOPE)*X-SIN(SLOPE)*Y                                    00004800
      YNEW=SIN(SLOPE)*X+COS(SLOPE)*Y                                    00004900
C ***** NEW LAT & LONG ARE FOUND FROM X & Y COORDINATES                 00005000
  600 FLAT=YLAT+YNEW/KMDEG                                              00005100
      XLON1=XLON-XNEW/KMDEG                                             00005200
      KMDG2=RADM*COS(FLAT*RDDEG)*RDDEG                                  00005300
      XLON2=XLON-XNEW/KMDG2                                             00005400
      FLON=(XLON1+XLON2)/2.                                             00005500
      GO TO 900                                                         00005600
  700 XNEW=X                                                            00005700
      YNEW=Y                                                            00005800
      GO TO 600                                                         00005900
  800 FLAT=0.                                                           00006000
      FLON=0.                                                           00006100
  900 RETURN                                                            00006200
      END                                                               00006300
