!+ Subroutine to perform optional checks on archives for joining.
!
! Method:
!	Those properties of two entries which may optionally differ 
!	without precluding their being joined are checked. If 
!	differences which are not permitted are found L_POSSIBLE is
!	reset to .FALSE.
!
! 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_OPTIONAL(L_POSSIBLE
     &   , DATABASE_1, LBL_CODE_1, LINESHAPE_1, CUTOFF_1
     &   , CONTINUUM_1, LINE_COUPLE_1
     &   , DATABASE_2, LBL_CODE_2, LINESHAPE_2, CUTOFF_2
     &   , CONTINUUM_2, LINE_COUPLE_2
     &   , L_IGNORE_DATABASE, L_IGNORE_LBL_CODE, L_IGNORE_CUTOFF
     &   , L_IGNORE_LINESHAPE, L_IGNORE_CONTINUUM, L_IGNORE_LCOUPLE
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/prec_machine.ucf'
      INCLUDE 'incl/precision_pp.tcf'
!
!     DUMMY ARGUMENTS.
      LOGICAL	!, INTENT(INOUT)
     &     L_POSSIBLE
!             FLAG FOR POSSIBLE MERGING
      LOGICAL	!, INTENT(IN)
     &     L_IGNORE_DATABASE
!             IGNORE DATABASE IN MERGING
     &   , L_IGNORE_LBL_CODE
!             IGNORE LBL CODE IN MERGING
     &   , L_IGNORE_LINESHAPE
!             IGNORE CUTOFF IN MERGING
     &   , L_IGNORE_CUTOFF
!             IGNORE CUTOFF IN MERGING
     &   , L_IGNORE_CONTINUUM
!             IGNORE CONTINUUM IN MERGING
     &   , L_IGNORE_LCOUPLE
!             IGNORE LINE COUPLING IN MERGING
      INTEGER	!, INTENT(IN)
     &     DATABASE_1
!             DATABASE OF FIRST ENTRY
     &   , LBL_CODE_1
!             LBL CODE OF FIRST ENTRY
     &   , LINESHAPE_1
!             LINESHAPE OF FIRST ENTRY
     &   , DATABASE_2
!             DATABASE OF SECOND ENTRY
     &   , LBL_CODE_2
!             LBL CODE OF SECOND ENTRY
     &   , LINESHAPE_2
!             LINESHAPE OF SECOND ENTRY
      LOGICAL	!, INTENT(IN)
     &     CONTINUUM_1
!             CONTINUUM OF FIRST ENTRY
     &   , LINE_COUPLE_1
!             LINE COUPLING OF FIRST ENTRY
     &   , CONTINUUM_2
!             CONTINUUM OF SECOND ENTRY
     &   , LINE_COUPLE_2
!             LINE COUPLING OF SECOND ENTRY
      REAL*8	!, INTENT(IN)
     &     CUTOFF_1
!             CUTOFF OF FIRST ENTRY
     &   , CUTOFF_2
!             CUTOFF OF SECOND ENTRY
!
!
      IF (.NOT.L_IGNORE_DATABASE) THEN
         IF (DATABASE_1.NE.DATABASE_2) L_POSSIBLE=.FALSE.
      ENDIF
      IF (.NOT.L_IGNORE_LBL_CODE) THEN
         IF (LBL_CODE_1.NE.LBL_CODE_2) L_POSSIBLE=.FALSE.
      ENDIF
      IF (.NOT.L_IGNORE_LINESHAPE) THEN
         IF (LINESHAPE_1.NE.LINESHAPE_2) L_POSSIBLE=.FALSE.
      ENDIF
      IF (.NOT.L_IGNORE_CUTOFF) THEN
         IF (ABS(CUTOFF_1-CUTOFF_2).GT.CUTOFF_1*TOL_CUTOFF_PP)
     &      L_POSSIBLE=.FALSE.
      ENDIF
      IF (.NOT.L_IGNORE_CONTINUUM) THEN
         IF (CONTINUUM_1.NEQV.CONTINUUM_2) L_POSSIBLE=.FALSE.
      ENDIF
      IF (.NOT.L_IGNORE_LCOUPLE) THEN
         IF (LINE_COUPLE_1.NEQV.LINE_COUPLE_2) L_POSSIBLE=.FALSE.
      ENDIF
!
!
      RETURN
      END
