      SUBROUTINE COLX2Y(YSPOT,YLINE,LCM,YLNOLP,XLNOLP,YANG,XANG,YTIM,
     1        XTIM,NSPOT,NLINE,XSPOT,XLINE,DELSPT,DELSCN)
C
C********************************************************************
C
C   NAME- COLX2Y
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- CEMSCS
C
C   VERSION- 2.0    DATE- 08/30/94   PROGRAMMER- SURYA JANDHYALA, SMSRC
C   VERSION- 2.1    DATE- 11/07/94   PROGRAMMER- CARLA NEIGH, SMSRC
C    ** ATOVS-37:  REMOVED SET OF PARENTHESES TO CORRECT COMPUTATION OF
C                  LOCAL VARIABLE XSPOT1.
C   VERSION- 2.2    DATE- 07/07/95   PROGRAMMER- LI LU, SMSRC
C    ** ATOVS-136: SPOT AND SCAN LINE DISPLACEMENTS, DELSPT AND DELSCN
C                  ARE ADDED. THESE VALUES WILL BE NEEDED AS INPUT FOR
C                  BILINEAR INTERPOLATION.
C   VERSION- 2.3    DATE- 09/20/95   PROGRAMMER- LI LU, SMSRC
C    ** ATOVS-217: ADD CALLING ARGUMENTS FOR THE NUMBER OF LINES AND
C                  NUMBER OF SPOTS PER LINE IN A DATA FRAME FOR THE
C                  INSTRUMENT BEING COLLOCATED. IF THE CALCULATED
C                  XSPOT IS GREATER THAN THE NUMBER OF SPOTS PER LINE
C                  FOR THE INSTRUMENT, SET IT TO THE MAXIMUM NUMBER OF
C                  SPOTS PER LINE. IF THE CALCULATED XLINE IS GREATER
C                  THAN THE NUMBER OF LINES PER DATA FRAME FOR THE
C                  INSTRUMENT, SET XLINE TO THE MAXIMUM NUMBER OF LINES
C                  FOR THE INSTRUMENT. IF THE CALCULATED LINE OR SPOT
C                  IS LESS THAN 1, SET IT TO 1.
C   VERSION- 3.0    DATE- 04/28/96   PROGRAMMER- TIM GARDNER (HSTX)
C   VERSION- 3.1    DATE- 12/09/97   PROGRAMMER- LEAH WILSON (HSTX)
C
C   FUNCTION- THIS IS A GENERIC ROUTINE THAT FINDS THE FIELD OF VIEW FOR
C             INSTRUMENT X THAT IS CLOSEST TO THE CENTER OF THE FIELD OF
C             VIEW GIVEN FOR INSTRUMENT Y, AND THE DISPLACEMENTS OF THE
C             TWO FOVS ALONG A SCAN LINE AND ALONG A SCAN POSITION.
C
C   VERSION 3.0- DOCUMENTATION AND SYNTAX CHANGES FOR ATOVS BASELINE
C                ON THE CRAY.
C   VERSION 3.1- REMOVE YTIM(1) FROM CALCULATION OF YTIME, AND CHANGE
C                CALCULATION OF DELSCN TO NOT DIVIDE BY XTIM(3).
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE   TYPE   I/O     DESCRIPTION
C     --------   ----   ---     -----------
C     YSPOT       INT    I      INSTRUMENT Y SPOT NUMBER.
C     YLINE       INT    I      INSTRUMENT Y LINE NUMBER.
C     LCM         INT    I      LEAST COMMON MULTIPLE OF INSTRUMENT
C                               SCAN TO SCAN TIMES.
C     YLNOLP      INT    I      NUMBER OF LINES IN INSTRUMENT Y DATA
C                               FRAME OVERLAP.
C     XLNOLP      INT    I      NUMBER OF LINES IN INSTRUMENT X DATA
C                               FRAME OVERLAP.
C     YANG        REAL   I      INSTRUMENT Y SCAN LINE ANGULAR POSITION
C                               COEFFICIENTS ARRAY (RADIANS).
C     XANG        REAL   I      INSTRUMENT X SCAN LINE ANGULAR POSITION
C                               COEFFICIENTS ARRAY (RADIANS).
C     YTIM        INT    I      INSTRUMENT Y SCAN LINE TIME ARRAY.
C     XTIM        INT    I      INSTRUMENT X SCAN LINE TIME ARRAY.
C     NSPOT       INT    I      NUMBER OF SPOTS PER LINE FOR THE
C                               COLLOCATED INSTRUMENT.
C     NLINE       INT    I      NUMBER OF LINES PER FRAME FOR THE
C                               COLLOCATED INSTRUMENT.
C     XSPOT       INT    O      COLLOCATED INSTRUMENT X SPOT NUMBER.
C     XLINE       INT    O      COLLOCATED INSTRUMENT X LINE NUMBER.
C     DELSPT      REAL   O      DISPLACEMENT OF COLLOCATED INSTRUMENT
C                               X SPOT FROM THE INSTRUMENT Y FOV ALONG
C                               A SCAN LINE.
C     DELSCN      REAL   O      DISPLACEMENT OF COLLOCATED INSTRUMENT
C                               X SPOT FROM THE INSTRUMENT Y FOV ALONG
C                               A SCAN POSITION.
C
C   LOCAL PARAMETERS-
C     VARIABLE   TYPE    DESCRIPTION
C     --------   ----    -----------
C     YSC2        INT    INSTRUMENT Y SCAN LINE BASED ON THE PREVIOUS
C                        SYNCHRONIZATION POINT.
C     XSPOT1      REAL   THE INSTRUMENT X SPOT NUMBER (TYPED REAL)
C                        TO BE USED TO MORE ACCURATELY COMPUTE THE
C                        INSTRUMENT X SCAN LINE NUMBER.
C     XLINE1      REAL   THE INSTRUMENT X SCAN LINE NUMBER
C                        (TYPED REAL) TO BE USED TO MORE ACCURATELY
C                        COMPUTE THE FINAL INSTRUMENT X SCAN LINE
C                        NUMBER.
C     YNAD        REAL   INSTRUMENT Y NADIR ANGLE.
C     YTIME       REAL   AN INTERMEDIATE VALUE CONTAINING THE
C                        TIME FROM THE PREVIOUS SYNC. POINT TO
C                        THE CENTER OF DWELL FOR THE INSTRUMENT Y
C                        SPOT.
C
C   SUBROUTINE USED- NONE
C
C   FUNCTIONS USED- NADANG, NINT, REAL
C
C   EXIT STATES- NONE
C
C   ASSUMPTIONS: 1. IT IS ASSUMED THAT THE SPOT AND LINE NUMBER INPUT
C                   FOR INSTRUMENT Y MUST BE WITHIN THE BOUNDS OF THE
C                   INSTRUMENT Y EXTENDED DATA FRAME, OTHERWISE THE
C                   OUTPUT VALUES CANNOT BE TRUSTED.
C                2. IT IS ASSUMED THAT THE INSTRUMENT SCAN TIMES ARRAY
C                   AND THE LEAST COMMON MULTIPLE HAVE THE SAME UNITS.
C
C   COMMENTS-
C       A. ELEMENTS OF ANGULAR POSITION ARRAYS ARE AS FOLLOWS:
C          1 - HALF THE CROSS-TRACK SCAN ANGLE FOR THE INSTRUMENT
C          2 - STEP ANGLE FOR THE INSTRUMENT
C          3 - ANGLE CORRECTION FOR THE INSTRUMENT
C
C       B. ELEMENTS OF TIME COEFFICIENT ARRAYS ARE AS FOLLOWS:
C          1 - TIME OFFSET FROM THE START OF SCAN TO THE CENTER OF
C              THE FIRST DWELL PERIOD
C          2 - THE TIME OF ONE STEP AND DWELL
C          3 - THE TOTAL TIME FOR THE SCAN AND RETRACE (SCAN-TO-SCAN
C              TIME)
C          4 - TIME CORRECTION FOR INSTRUMENT MISALIGNMENT
C
C********************************************************************
C
      INTEGER YSPOT,YLINE,LCM,YLNOLP,XLNOLP,XSPOT,XLINE
      INTEGER YTIM(4), XTIM(4), NSPOT, NLINE
      REAL YANG(3),XANG(3),DELSPT,DELSCN
C
      INTEGER YSC2
      REAL XSPOT1,XLINE1,YNAD,YTIME
      REAL NADANG
C
C     CONVERT THE SCAN LINE FOR INSTRUMENT Y TO WHAT THE SCAN LINE
C     NUMBER WOULD BE IF THE PREVIOUS SYNCHRONIZATION POINT WAS SCAN
C     LINE 1.
C
      YSC2 = YLINE + ( NINT( REAL(LCM)/REAL(YTIM(3)) ) - YLNOLP/2)
C
C     GET THE INSTRUMENT Y NADIR ANGLE.
C
      YNAD = NADANG(YANG(1),YANG(2),YANG(3),YSPOT)
C
C     COMPUTE THE TIME DIFFERENCE BETWEEN THE SYNCHRONIZATION POINT AND
C     THE INSTRUMENT Y FIELD OF VIEW.
C
      YTIME = YTIM(1) + YTIM(2)*(YSPOT - 1) + YTIM(3)*(YSC2 - 1) +
     1        YTIM(4)
cclw - this is what ran for n-14 sim:
cclw  YTIME = YTIM(2)*(YSPOT - 1) + YTIM(3)*(YSC2 - 1) + YTIM(4)
C
C     COMPUTE THE COLLOCATED SPOT NUMBER FOR INSTRUMENT X.
C
      XSPOT = 1 + NINT((YNAD - XANG(1) - XANG(3))/XANG(2))
      XSPOT1 = 1 + (YNAD - XANG(1) - XANG(3))/XANG(2)
C
C     COMPUTE THE COLLOCATED LINE NUMBER FOR INSTRUMENT X.
C
      XLINE1 = YTIME - (XTIM(2) * XSPOT1) - XTIM(1)
      XLINE = 1 + NINT(XLINE1/XTIM(3))
C
C     COMPUTE THE SPOT AND SCAN LINE DISPLACEMENTS.
C
      DELSPT = XSPOT1 - REAL(XSPOT)
      DELSCN = ( XLINE1/REAL(XTIM(3)) ) + 1 - REAL(XLINE)
cclw - this is what ran for n-14 sim:
cclw  DELSCN = XLINE1 - REAL(XLINE)
C
C     CONVERT THE COLLOCATED LINE NUMBER FOR INSTRUMENT X TO START
C     FROM THE BEGINNING OF THE EXTENDED DATA FRAME RATHER THAN THE
C     PREVIOUS SYNCHRONIZATION POINT.
C
      XLINE = XLINE - ( NINT( REAL(LCM)/REAL(XTIM(3)) ) - XLNOLP/2)
C
C     CHECK THE RANGE OF THE CALCULATED SPOT AND LINE
C
      IF (XSPOT .LT. 1) XSPOT = 1
      IF (XLINE .LT. 1) XLINE = 1
      IF (XSPOT .GT. NSPOT) XSPOT = NSPOT
      IF (XLINE .GT. NLINE) XLINE = NLINE
C
C     RETURN TO CALLING ROUTINE.
C
      RETURN
      END
