      SUBROUTINE CHKARA(ISPOT,ILINE,IXCLPT,NMDSPT,NMDLIN,NMAELM,
     &                  ANCBUF,HIRLAT,HIRLON,INSIDE)
C**********************************************************************
C
C   NAME- CHKARA
C
C   LANGUAGE- VS FORTRAN   TYPE- SUBROUTINE        COMPUTER- HDS 9000
C
C   VERSION- 1.0    DATE- 03/10/95    PROGRAMMER- TIM GARDNER (HSTX)
C   VERSION- 2.0    DATE- 06/15/95    PROGRAMMER- LI LU (SMSRC)
C   VERSION- 3.0    DATE- 04/28/96    PROGRAMMER- TIM GARDNER (HSTX)
C
C   FUNCTION- THIS ROUTINE DETERMINES WHETHER A GIVEN SPOT IS WITHIN
C             A TRIANGLE FORMED BY THREE OF FOUR SPOTS SURROUNDING IT.
C
C   VERSION 3.0- DOCUMENTATION AND SYNTAX CHANGES FOR ATOVS BASELINE
C                ON THE CRAY.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE        TYPE  I/O  FUNCTION
C     --------        ----  ---  --------
C     ISPOT           INT    I   DIMENSIONED (4) CONTAINS THE SPOT
C                                NUMBERS OF THE FOUR SURROUNDING SPOTS.
C
C     ILINE           INT    I   DIMENSIONED (4) CONTAINS THE LINE
C                                NUMBERS OF THE FOUR SURROUNDING SPOTS.
C
C     IXCLPT          INT    I   CONTAINS THE MISSING SPOT NUMBER.
C
C     NMDSPT          INT    I   NUMBER OF SPOTS PER LINE IN ANCBUF.
C
C     NMDLIN          INT    I   NUMBER OF LINES PER FRAME IN ANCBUF.
C
C     NMAELM          INT    I   NUMBER OF TYPES OF DATA WITHIN ANCBUF.
C
C     ANCBUF          REAL   I   DIMENSIONED (NMDSPT,NMDLIN,NMAELM)
C                                CONTAINS ANCILLARY INFORMATION FOR
C                                INTERPOLATED/EXTRAPOLATED DATA.
C
C     HIRLAT          REAL   I   LATITUDE OF HIRS SPOT TO BE
C                                INTERPOLATED TO.
C
C     HIRLON          REAL   I   LONGITUDE OF HIRS SPOT TO BE
C                                INTERPOLATED TO.
C
C     INSIDE          LOG    O   IS TRUE IF THE HIRS SPOT IS WITHIN
C                                A TRIANGLE FORMED BY THE THREE GOOD
C                                POINTS.
C
C
C   LOCAL PARAMETERS-
C     VARIABLE                TYPE    FUNCTION
C     --------                ----    --------
C     BLAT                     REAL   BEGINNING LATITUDE OF INTERP.
C                                     TEST LINE.
C
C     BLON                     REAL   BEGINNING LONGITUDE OF INTERP.
C                                     TEST LINE.
C
C     ELAT                     REAL   ENDING LATITUDE OF INTERP. TEST
C                                     LINE.
C
C     ELON                     REAL   ENDING LONGITUDE OF INTERP. TEST
C                                     LINE.
C
C     OPLAT                    REAL   LATITUDE OF OPPOSITE VERTEX FROM
C                                     EXCLUDED POINT.
C
C     SLOPE                    REAL   SLOPE OF INTERP. TEST LINE.
C
C     DELHIR                   REAL   DISPLACEMENT FROM HIRS FOV TO
C                                     Y INTERCEPT.
C
C     DELINT                   REAL   DISPLACEMENT FROM OPPOSITE VERTEX
C                                     POINT TO Y INTERCEPT.
C
C     YLINE                    REAL   Y INTERCEPT POINT.
C
C   SUBPROGRAMS CALLED- NONE
C
C   FUNCTIONS USED- NONE
C
C   EXIT STATES- NONE
C
C*********************************************************************
C
      INTEGER ISPOT(4),ILINE(4)
      INTEGER NMDSPT,NMDLIN,NMAELM,IXCLPT
      REAL    ANCBUF(NMDSPT,NMDLIN,NMAELM),HIRLAT,HIRLON
      LOGICAL INSIDE
C
      REAL BLAT,BLON,ELAT,ELON,OPLAT
      REAL SLOPE,YLINE,DELHIR,DELINT
C
C THERE ARE THREE GOOD SPOTS SO WE MUST DETERMINE WHETHER THE HIRS SPOT
C TO BE INTERPOLATED TO IS WITHIN A TRIANGLE FORMED BY THESE 3 SPOTS.
C THIS IS TRUE IF THE HIRS SPOT TO BE INTERPOLATED TO LIES ON THE
C OPPOSITE SIDE (REGARDING TO THE MISSING SPOT) OF A LINE CONNECTING THE
C TOW CLOSEST SPOTS TO THE MISSING SPOT. FIRST WE MUST DETERMINE WHICH
C SPOTS TO EXTEND A LINE BETWEEN AS WELL AS THE OPPOSITE VERTEX SPOT.
C
      INSIDE = .FALSE.
C
      IF ((IXCLPT .EQ. 2) .OR. (IXCLPT .EQ. 3)) THEN
        BLAT = ANCBUF(ISPOT(4),ILINE(4),1)
        BLON = ANCBUF(ISPOT(4),ILINE(4),2)
        ELAT = ANCBUF(ISPOT(1),ILINE(1),1)
        ELON = ANCBUF(ISPOT(1),ILINE(1),2)
        IF (IXCLPT .EQ. 2) OPLAT = ANCBUF(ISPOT(3),ILINE(3),1)
        IF (IXCLPT .EQ. 3) OPLAT = ANCBUF(ISPOT(2),ILINE(2),1)
      ELSE
        BLAT = ANCBUF(ISPOT(3),ILINE(3),1)
        BLON = ANCBUF(ISPOT(3),ILINE(3),2)
        ELAT = ANCBUF(ISPOT(2),ILINE(2),1)
        ELON = ANCBUF(ISPOT(2),ILINE(2),2)
        IF (IXCLPT .EQ. 1) OPLAT = ANCBUF(ISPOT(4),ILINE(4),1)
        IF (IXCLPT .EQ. 4) OPLAT = ANCBUF(ISPOT(1),ILINE(1),1)
      END IF
C
C USE EQUATION OF A LINE TO FORM A LINE BY CONNECTING BEGINNING AND
C ENDING SPOTS. FIND THE POINT ON THE LINE WHICH HAS THE SAME LONGITUDE
C AS THE HIRS SPOT DOES. DELTA LATITUDE OF THE HIRS SPOT TO THAT POINT
C WILL BE OF THE SAME SIGN AS THE DELTA LATITUDE OF THE OPPOSITE VERTEX
C TO THAT POINT IF THE HIRS SPOT IS WITHIN THE TRIANGLE.
C
      IF (ELON .NE. BLON) THEN
        SLOPE = (ELAT - BLAT) / (ELON - BLON)
        YLINE = BLAT + SLOPE * (HIRLON - BLON)
        DELHIR = HIRLAT - YLINE
        DELINT = OPLAT - YLINE
        IF ((DELHIR * DELINT) .GT. 0.) INSIDE = .TRUE.
      END IF
C
      RETURN
      END
