      SUBROUTINE ARCLEN(XLAT1,XLON1,YLAT1,YLON1,D)
C
C**********************************************************************
C
C   NAME- ARCLEN
C
C   LANGUAGE- VS FORTRAN     TYPE- SUBROUTINE
C
C   VERSION- 1.0    DATE-  5/11/89   PROGRAMMER- B.GANTI (SMSRC)
C   VERSION- 3.0    DATE-  4/28/96   PROGRAMMER- TIM GARDNER (HSTX)
C   VERSION- 3.1    DATE- 10/06/97   PROGRAMMER- MIKE PETTEY (HSTX)
C
C   FUNCTION- COMPUTES THE DISTANCE BETWEEN TWO POINTS IN KILOMETERS
C
C      VERSION 3.0:  DOCUMENTATION AND SYNTAX CHANGED FOR ATOVS
C                    BASELINE ON THE CRAY
C
C      VERSION 3.1:  THE COMMON AREAS RMPARM AND RMPHSCON WERE
C                    REMOVED.  THE TWO PARAMETERS FROM THESE COMMON
C                    AREAS HAVE BEEN HARD-CODED WITHIN THIS ROUTINE.
C                    THE ORIGINAL CODE CALCULATED THE BOUNDS BY
C                    MULTIPLYING THE VARIABLE 'DEGRAD' BY 180. 
C                    BECAUSE DEGRAD IS PI/180, AND BECAUSE THE
C                    VALUE OF PI IS RATHER UNLIKELY TO EVER CHANGE,
C                    THE AFFECTED CALCULATIONS HAVE BEEN REMOVED
C                    AND REPLACED BY HARD-CODED VALUES.  THIS SHOULD
C                    IMPROVE THE EFFICIENCY SLIGHTLY.
C   
C
C   CALLING PARAMETERS-
C     VARIABLE          TYPE  I/O   DESCRIPTION
C     --------          ----  ---   -----------
C      XLAT1             REAL  I    LATITUDE OF FIRST POINT
C                                   (DEGREES, +=NORTH, -=SOUTH)
C
C      XLON1             REAL  I    LONGITUDE OF FIRST POINT
C                                   (DEGREES, +=EAST, -=WEST)
C
C      YLAT1             REAL  I    LATITUDE OF SECOND POINT
C                                   (DEGREES, +=NORTH, -=SOUTH)
C
C      YLON1             REAL  I    LONGITUDE OF SECOND POINT
C                                   (DEGREES,  +=EAST, -=WEST)
C
C      D                 REAL  O    DISTANCE OF POINTS CONVERTED INTO
C                                   KILOMETERS
C
C
C   COMMON AREAS- NONE
C
C
C   LOCAL VARIABLES-
C     VARIABLE          TYPE  DESCRIPTION
C     --------          ----  -----------
C     XLAT2             REAL  LATITUDE OF FIRST POINT IN RADIANS
C
C     XLON2             REAL  LONGITUDE OF FIRST POINT IN RADIANS
C
C     YLAT2             REAL  LATITUDE OF SECOND POINT IN RADIANS
C
C     YLON2             REAL  LONGITUDE OF SECOND POINT IN RADIANS
C
C     DIFLON            REAL  FIRST LONGITUDE POINT MINUS SECOND
C                             LONGITUDE POINT
C
C     DLON              REAL  THE COMPUTED COSINE DIFFERENCE OF
C                             LONGITUDES
C
C     ARGMNT            REAL  VARIABLE WHICH CONTAINS PARTIAL
C                             DISTANCE COMPUTATION
C
C     RA                REAL  ARC COSINE OF ARGMNT
C
C     DIF360            REAL  VALUE USED TO ADJUST LONGITUDES OUT OF
C                             LONGITUDE LIMITS
C
C     BOUND1            REAL  UPPER LIMIT FOR LONGITUDES
C
C     BOUND2            REAL  LOWER LIMIT FOR LONGITUDES
C
C
C     FUNCTIONS CALLED- ACOS, COS, SIN
C
C
C COMMENTS- THIS SUBROUTINE COMPUTES THE DISTANCE BETWEEN TWO POINTS
C           WHOSE COORDINATES ARE GIVEN IN THE FORM OF LONGITUDES
C           AND LATITUDES.  THESE POINTS ENTER THE SUBROUTINE
C           MULTIPLIED BY THEIR SCALAR.  THE DISTANCE COMPUTED IS
C           CONVERTED INTO KILOMETERS BEFORE IT GET OUTPUT.
C
C**********************************************************************
C
      REAL XLAT1,XLON1,YLAT1,YLON1,D

      REAL XLAT2,XLON2,YLAT2,YLON2,RA,DLON,DIFLON,ARGMNT
      REAL BOUND1,BOUND2,DIF360

      REAL DEGRAD, EMEANR


C-- SET THE VALUES OF DEGRAD AND EMEANR

      DEGRAD = 0.0174532925
      EMEANR = 6371.004

C-- CALCULATE THE BOUNDING VALUES.  THESE VALUE ARE NOW HARD-CODED
C   INSTEAD OF CALCULATED

      BOUND1 =  3.14159265
      BOUND2 = -3.14159265
      DIF360 =  6.2831853

C-- LONGITUDES AND LATITUDES ARE GIVEN IN DEGREES. THEY HAVE TO BE
C   CONVERTED INTO RADIANS

      XLAT2 = XLAT1 * DEGRAD
      XLON2 = XLON1 * DEGRAD
      YLAT2 = YLAT1 * DEGRAD
      YLON2 = YLON1 * DEGRAD

C-- COMPUTE THE DIFFERENCE IN LONGITUDES

      DIFLON = XLON2 - YLON2

      IF (DIFLON.GT.BOUND1) THEN
         DIFLON = DIFLON - DIF360
      END IF

      IF (DIFLON.LT.BOUND2) THEN
         DIFLON = DIFLON + DIF360
      END IF

C-- COMPUTE THE COS OF DIFFERENCE IN LONGITUDES

      DLON = COS(DIFLON)

      ARGMNT = SIN(XLAT2)*SIN(YLAT2)+COS(XLAT2)*COS(YLAT2)*DLON


C-- DECIDE WHETHER ARGUMENT TO BE PASSED TO ACOS IS WITHIN THE
C   LIMITS OR NOT

      IF (ARGMNT .LT. -1.0) ARGMNT = -1.0
      IF (ARGMNT .GT. 1.0) ARGMNT = 1.0

C-- COMPUTE THE ACOS OF THE ARGMNT VALUE

      RA = ACOS(ARGMNT)

C-- CONVERT THE UNITS OF RA FROM RADIANS INTO KILOMETERS

      D = RA * EMEANR

      RETURN
      END




