!+ Subroutine to test frequncies for joining  archives.
!
! Method:
!	The ranges are checked to see that they do not overlap,
!	and then to see whether they abutt directly.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE TEST_FREQUENCY(L_POSSIBLE
     &   , L_DIRECT, L_SECOND_FIRST
     &   , FREQ_ENTRY_LOW_1, FREQ_ENTRY_HIGH_1
     &   , FREQ_ENTRY_LOW_2, FREQ_ENTRY_HIGH_2
     &   , TOL_JOIN
     &   )
!
!
      IMPLICIT NONE
!
!
!     DUMMY ARGUMENTS.
      LOGICAL	!, INTENT(OUT)
     &     L_POSSIBLE
!             FLAG FOR MERGING ENTRIES
     &   , L_DIRECT
!             TRUE IF DIRECT MERGING
     &   , L_SECOND_FIRST
!             TRUE IF SECOND ENTRY COMES FIRST
      REAL*8	!, INTENT(IN)
     &     FREQ_ENTRY_LOW_1
!             BOTTOM FREQUENCY OF 1ST ENTRY
     &   , FREQ_ENTRY_HIGH_1
!             TOP FREQUENCY OF 1ST ENTRY
     &   , FREQ_ENTRY_LOW_2
!             BOTTOM FREQUENCY OF 2ND ENTRY
     &   , FREQ_ENTRY_HIGH_2
!             TOP FREQUENCY OF 2ND ENTRY
     &   , TOL_JOIN
!             TOLERANCE FOR DIRECT JOINING
!
!
!     FIRST FIND THE WHICH ENTRY BEGINS WITH HIGHER FREQUENCIES
      IF (FREQ_ENTRY_LOW_1.GT.FREQ_ENTRY_LOW_2) THEN
         L_SECOND_FIRST=.TRUE.
!        CHECK FOR NON-OVERLAPPING BANDS
         IF (FREQ_ENTRY_LOW_1.LT.FREQ_ENTRY_HIGH_2) THEN
            L_POSSIBLE=.FALSE.
         ELSE
            L_POSSIBLE=.TRUE.
            IF ( (FREQ_ENTRY_LOW_1-FREQ_ENTRY_HIGH_2).LT.TOL_JOIN ) THEN
               L_DIRECT=.TRUE.
            ELSE
               L_DIRECT=.FALSE.
            ENDIF
         ENDIF
      ELSE
         L_SECOND_FIRST=.FALSE.
!        CHECK FOR NON-OVERLAPPING BANDS
         IF (FREQ_ENTRY_LOW_2.LT.FREQ_ENTRY_HIGH_1) THEN
            L_POSSIBLE=.FALSE.
         ELSE
            L_POSSIBLE=.TRUE.
            IF ( (FREQ_ENTRY_LOW_2-FREQ_ENTRY_HIGH_1).LT.TOL_JOIN ) THEN
               L_DIRECT=.TRUE.
            ELSE
               L_DIRECT=.FALSE.
            ENDIF
         ENDIF
      ENDIF
!
!
      RETURN
      END
