       PROGRAM DIFFFREE
 
       IMPLICIT NONE
       
       INTEGER*2  M,K,L,MAXLENGTH
       INTEGER*4  NUMBSURV

C   CHECK FOR K-DIFFERENCE and L-DIFFERENCE SETS
C   IF WE PARTITION [N] into these then R(K+1,L+1) >=N+2
C   THIS VERSION, ONLY K CAN EQUAL 2 (Both 2 => R(3,3)>5)

        PARAMETER (K=5, L=2, M=2,NUMBSURV=1000000, MAXLENGTH=40)

        INTEGER*2  ADDPOINT,FILENUM,FLAG,FLAG2,FLAG4,T
        INTEGER*2  I,SR,I1,I2,I3,I4,I5,I6,I7,I8,I9,NOGOODK,NOGOODL
        INTEGER*4  NUMSURVIVORS,NUMPREADD,D,J
        INTEGER*2  TEMPSET(MAXLENGTH),TEMPM(M-1) 
        INTEGER*2  TEMPK(K-1),TEMPL(L-1),T1(11),ML
        INTEGER*2  SIZERAYPA(3,NUMBSURV),SIZERAYSURV(3,NUMBSURV)
        INTEGER*2  PREADD(3,MAXLENGTH,NUMBSURV)
        INTEGER*2  SURVIVORS(3,MAXLENGTH,NUMBSURV)
        INTEGER*2  DIFFCHECK,NOGOODM
 
        FILENUM=3368
 
 

        DO I=1,3
             DO J=1,NUMBSURV
        	        SIZERAYPA(I,J)=0
      	        SIZERAYSURV(I,J)=0	
	     END DO
        END DO
        SIZERAYPA(1,1)=1
        SIZERAYPA(2,1)=1 
        PREADD(1,1,1)=1
        PREADD(2,1,1)=1
        ADDPOINT=1
  
        FLAG=0
      
       NUMPREADD=1
       NUMSURVIVORS=0   
        DO WHILE(FLAG.EQ.0)
       
	        ADDPOINT=ADDPOINT+1 
           WRITE(FILENUM,*) 'ADDING THE DIFFERENCE' , ADDPOINT
           WRITE(FILENUM,*) 'NUM SURVIVORS' , NUMPREADD 
           FLAG2=0
 	      J= 1
 	      DO  WHILE(J.LT.NUMPREADD+1.AND.FLAG2.EQ.0)
  
             IF (K.EQ.2) THEN
                SR=SIZERAYPA(1,J)
                DO T=1,SIZERAYPA(1,J)
                   TEMPSET(T)=PREADD(1,T,J)
                END DO
                FLAG4=0
                      DO I1=1,SR
                           TEMPK(1)=PREADD(1,I1,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
                      
                 ELSE IF (K.EQ.3) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-1
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR
                                TEMPK(2)=PREADD(1,I2,J)


        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
              
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF

                 ELSE IF (K.EQ.4) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-2
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-1
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR
                                     TEMPK(3)=PREADD(1,I3,J)


        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
              
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF

                 ELSE IF (K.EQ.5) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-3
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-2
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-1
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR
                                          TEMPK(4)=PREADD(1,I4,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0

                                               SR=0

                                          END IF
              
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
                                     
                 ELSE IF (K.EQ.6) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-4
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-3
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-2
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR-1
                                          TEMPK(4)=PREADD(1,I4,J)
                                     DO I5=I4+1,SR
                                          TEMPK(5)=PREADD(1,I5,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
                      

                 ELSE IF (K.EQ.7) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)   
                        TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-5
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-4
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-3
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR-2
                                          TEMPK(4)=PREADD(1,I4,J)
                                     DO I5=I4+1,SR-1
                                          TEMPK(5)=PREADD(1,I5,J)
                                     DO I6=I5+1,SR
                                          TEMPK(6)=PREADD(1,I6,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
 

                 ELSE IF (K.EQ.8) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-6
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-5
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-4
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR-3
                                          TEMPK(4)=PREADD(1,I4,J)
                                     DO I5=I4+1,SR-2
                                          TEMPK(5)=PREADD(1,I5,J)
                                     DO I6=I5+1,SR-1
                                          TEMPK(6)=PREADD(1,I6,J)
                                     DO I7=I6+1,SR
                                          TEMPK(7)=PREADD(1,I7,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
 

                 ELSE IF (K.EQ.9) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-7
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-6
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-5
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR-4
                                          TEMPK(4)=PREADD(1,I4,J)
                                     DO I5=I4+1,SR-3
                                          TEMPK(5)=PREADD(1,I5,J)
                                     DO I6=I5+1,SR-2
                                          TEMPK(6)=PREADD(1,I6,J)
                                     DO I7=I6+1,SR-1
                                          TEMPK(7)=PREADD(1,I7,J)
                                     DO I8=I7+1,SR
                                          TEMPK(8)=PREADD(1,I8,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF


                 ELSE IF (K.EQ.10) THEN
                      SR=SIZERAYPA(1,J)
                      DO T=1,SIZERAYPA(1,J)
                           TEMPSET(T)=PREADD(1,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-8
                           TEMPK(1)=PREADD(1,I1,J)
                           DO I2=I1+1,SR-7
                                TEMPK(2)=PREADD(1,I2,J)
                                DO I3=I2+1,SR-6
                                     TEMPK(3)=PREADD(1,I3,J)
                                     DO I4=I3+1,SR-5
                                          TEMPK(4)=PREADD(1,I4,J)
                                     DO I5=I4+1,SR-4
                                          TEMPK(5)=PREADD(1,I5,J)
                                     DO I6=I5+1,SR-3
                                          TEMPK(6)=PREADD(1,I6,J)
                                     DO I7=I6+1,SR-2
                                          TEMPK(7)=PREADD(1,I7,J)
                                     DO I8=I7+1,SR-1
                                          TEMPK(8)=PREADD(1,I8,J)
                                     DO I9=I8+1,SR
                                         TEMPK(9)=PREADD(1,I9,J)

        IF (DIFFCHECK(TEMPK,TEMPSET,SIZERAYPA(1,J),K,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODK=1
                      ELSE
                           NOGOODK=0
                      END IF
                         
                 END IF 
                 
             IF (L.EQ.2) THEN
                SR=SIZERAYPA(2,J)
                DO T=1,SIZERAYPA(2,J)
                   TEMPSET(T)=PREADD(2,T,J)
                END DO
                FLAG4=0
                      DO I1=1,SR
                           TEMPL(1)=PREADD(2,I1,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF                 
                 
                 ELSE IF (L.EQ.3) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0
                      
                      DO I1=1,SR-1
                           TEMPL(1)=PREADD(2,I1,J)
                             DO I2=I1+1,SR
                                TEMPL(2)=PREADD(2,I2,J)
        
         IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                         END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF

                 ELSE IF (L.EQ.4) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-2
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-1
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR
                                     TEMPL(3)=PREADD(2,I3,J)


        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
              
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF
                 ELSE IF (L.EQ.5) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-3
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-2
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-1
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR
                                          TEMPL(4)=PREADD(2,I4,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
              
                                   END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF
                    
                 ELSE IF (L.EQ.6) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-4
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-3
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-2
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR-1
                                          TEMPL(4)=PREADD(2,I4,J)
                                     DO I5=I4+1,SR
                                          TEMPL(5)=PREADD(2,I5,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF
                      

                 ELSE IF (L.EQ.7) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-5
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-4
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-3
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR-2
                                          TEMPL(4)=PREADD(2,I4,J)
                                     DO I5=I4+1,SR-1
                                          TEMPL(5)=PREADD(2,I5,J)
                                     DO I6=I5+1,SR
                                          TEMPL(6)=PREADD(2,I6,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF
 
                 ELSE IF (L.EQ.8) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-6
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-5
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-4
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR-3
                                          TEMPL(4)=PREADD(2,I4,J)
                                     DO I5=I4+1,SR-2
                                          TEMPL(5)=PREADD(2,I5,J)
                                     DO I6=I5+1,SR-1
                                          TEMPL(6)=PREADD(2,I6,J)
                                     DO I7=I6+1,SR
                                          TEMPL(7)=PREADD(2,I7,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE             
                           NOGOODL=0
                      END IF
 

                 ELSE IF (L.EQ.9) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-7
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-6
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-5
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR-4
                                          TEMPL(4)=PREADD(2,I4,J)
                                     DO I5=I4+1,SR-3
                                          TEMPL(5)=PREADD(2,I5,J)
                                     DO I6=I5+1,SR-2
                                          TEMPL(6)=PREADD(2,I6,J)
                                     DO I7=I6+1,SR-1
                                          TEMPL(7)=PREADD(2,I7,J)
                                     DO I8=I7+1,SR
                                          TEMPL(8)=PREADD(2,I8,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF


                 ELSE IF (L.EQ.10) THEN
                      SR=SIZERAYPA(2,J)
                      DO T=1,SIZERAYPA(2,J)
                           TEMPSET(T)=PREADD(2,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-8
                           TEMPL(1)=PREADD(2,I1,J)
                           DO I2=I1+1,SR-7
                                TEMPL(2)=PREADD(2,I2,J)
                                DO I3=I2+1,SR-6
                                     TEMPL(3)=PREADD(2,I3,J)
                                     DO I4=I3+1,SR-5
                                          TEMPL(4)=PREADD(2,I4,J)
                                     DO I5=I4+1,SR-4
                                          TEMPL(5)=PREADD(2,I5,J)
                                     DO I6=I5+1,SR-3
                                          TEMPL(6)=PREADD(2,I6,J)
                                     DO I7=I6+1,SR-2
                                          TEMPL(7)=PREADD(2,I7,J)
                                     DO I8=I7+1,SR-1
                                          TEMPL(8)=PREADD(2,I8,J)
                                     DO I9=I8+1,SR
                                          TEMPL(9)=PREADD(2,I9,J)

        IF (DIFFCHECK(TEMPL,TEMPSET,SIZERAYPA(2,J),L,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0

                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODL=1
                      ELSE
                           NOGOODL=0
                      END IF
                         
                 END IF
                  
             IF (M.EQ.2) THEN
                SR=SIZERAYPA(3,J)
                DO T=1,SIZERAYPA(3,J)
                   TEMPSET(T)=PREADD(3,T,J)
                END DO
                FLAG4=0
                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)

        IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0
                                          END IF
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF
                      
                 ELSE IF (M.EQ.3) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR-1
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=I1+1,SR
                                TEMPM(2)=PREADD(3,I2,J)


        IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
              
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF

                 ELSE IF (M.EQ.4) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)


       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0



                                          END IF
              
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF



                 ELSE IF (M.EQ.5) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)


       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0

                                              

                                          END IF
              
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF

                 
                      
                 ELSE IF (M.EQ.6) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)
                                     DO I5=1,SR
                                          TEMPM(5)=PREADD(3,I5,J)

       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0



                                          END IF
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF
                      

                 ELSE IF (M.EQ.7) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)
                                     DO I5=1,SR
                                          TEMPM(5)=PREADD(3,I5,J)
                                     DO I6=1,SR
                                          TEMPM(6)=PREADD(3,I6,J)

       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0


                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF
 

                 ELSE IF (M.EQ.8) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)
                                     DO I5=1,SR
                                          TEMPM(5)=PREADD(3,I5,J)
                                     DO I6=1,SR
                                          TEMPM(6)=PREADD(3,I6,J)
                                     DO I7=1,SR
                                          TEMPM(7)=PREADD(3,I7,J)

       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0



                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF
 

                 ELSE IF (M.EQ.9) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)
                                     DO I5=1,SR
                                          TEMPM(5)=PREADD(3,I5,J)
                                     DO I6=1,SR
                                          TEMPM(6)=PREADD(3,I6,J)
                                     DO I7=1,SR
                                          TEMPM(7)=PREADD(3,I7,J)
                                     DO I8=1,SR
                                          TEMPM(8)=PREADD(3,I8,J)

       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0



                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF


                 ELSE IF (M.EQ.10) THEN
                      SR=SIZERAYPA(3,J)
                      DO T=1,SIZERAYPA(3,J)
                           TEMPSET(T)=PREADD(3,T,J)
                      END DO
                      FLAG4=0

                      DO I1=1,SR
                           TEMPM(1)=PREADD(3,I1,J)
                           DO I2=1,SR
                                TEMPM(2)=PREADD(3,I2,J)
                                DO I3=1,SR
                                     TEMPM(3)=PREADD(3,I3,J)
                                     DO I4=1,SR
                                          TEMPM(4)=PREADD(3,I4,J)
                                     DO I5=1,SR
                                          TEMPM(5)=PREADD(3,I5,J)
                                     DO I6=1,SR
                                          TEMPM(6)=PREADD(3,I6,J)
                                     DO I7=1,SR
                                          TEMPM(7)=PREADD(3,I7,J)
                                     DO I8=1,SR
                                          TEMPM(8)=PREADD(3,I8,J)
                                     DO I9=1,SR
                                          TEMPM(9)=PREADD(3,I9,J)

       IF (DIFFCHECK(TEMPM,TEMPSET,SIZERAYPA(3,J),M,ADDPOINT,T1,ML).
     *EQ.0) THEN
                                              FLAG4=1
                                              SR=0



                                          END IF
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                     END DO
                                END DO
                           END DO
                      END DO
            
                      IF (FLAG4.EQ.1) THEN
                           NOGOODM=1
                      ELSE
                           NOGOODM=0
                      END IF

                 END IF                            
            
C     AFTER CHECKING FOR K AND L AND M CLIQUES WE NOW MUST DECIDE WHAT
C     LIVES ON AND WHAT DIES, BEFORE WE GO TO THE NEXT IN THE LIST OF
C     PREADD (I.E. J=J+1), THIS IS CHECKED WITH NOGOODK AND NOGOODL
          IF(NUMSURVIVORS.LT.NUMBSURV-2) THEN
            IF(NOGOODK.EQ.0.AND.NOGOODL.EQ.0.AND.NOGOODM.EQ.0) THEN
                 NUMSURVIVORS=NUMSURVIVORS+3

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS-2)=PREADD(1,T,J)
                 END DO
                   SURVIVORS(1,SIZERAYPA(1,J)+1,NUMSURVIVORS-2)=ADDPOINT
                   SIZERAYSURV(1,NUMSURVIVORS-2)=SIZERAYPA(1,J)+1

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS-2)=PREADD(2,T,J)
                 END DO  
                   SIZERAYSURV(2,NUMSURVIVORS-2)=SIZERAYPA(2,J)   

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS-2)=PREADD(3,T,J)
                 END DO  
                   SIZERAYSURV(3,NUMSURVIVORS-2)=SIZERAYPA(3,J)   

        
                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS-1)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS-1)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS-1)=PREADD(2,T,J)
                 END DO
                   SURVIVORS(2,SIZERAYPA(2,J)+1,NUMSURVIVORS-1)=ADDPOINT 
                   SIZERAYSURV(2,NUMSURVIVORS-1)=SIZERAYPA(2,J)+1
                
                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS-1)=PREADD(3,T,J)
                 END DO
                   SIZERAYSURV(3,NUMSURVIVORS-1)=SIZERAYPA(3,J)

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J)

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SURVIVORS(3,SIZERAYPA(3,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)+1
            

            ELSE IF(NOGOODK.EQ.0.AND.NOGOODL.EQ.1.AND.NOGOODM.EQ.1) THEN
                 NUMSURVIVORS=NUMSURVIVORS+1

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SURVIVORS(1,SIZERAYPA(1,J)+1,NUMSURVIVORS)=ADDPOINT
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)+1

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO  
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J) 

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO  
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J) 


            ELSE IF(NOGOODK.EQ.1.AND.NOGOODL.EQ.0.AND.NOGOODM.EQ.1) THEN
                 NUMSURVIVORS=NUMSURVIVORS+1

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO
                   SURVIVORS(2,SIZERAYPA(2,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J)+1

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)
                   
            ELSE IF(NOGOODK.EQ.1.AND.NOGOODL.EQ.1.AND.NOGOODM.EQ.0) THEN
                 NUMSURVIVORS=NUMSURVIVORS+1
 
                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO  
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J) 
                  
                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SURVIVORS(3,SIZERAYPA(3,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)+1
            
            ELSE IF(NOGOODK.EQ.0.AND.NOGOODL.EQ.0.AND.NOGOODM.EQ.1) THEN
                 NUMSURVIVORS=NUMSURVIVORS+2
            
                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS-1)=PREADD(1,T,J)
                 END DO
                   SURVIVORS(1,SIZERAYPA(1,J)+1,NUMSURVIVORS-1)=ADDPOINT
                   SIZERAYSURV(1,NUMSURVIVORS-1)=SIZERAYPA(1,J)+1

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS-1)=PREADD(2,T,J)
                 END DO  
                   SIZERAYSURV(2,NUMSURVIVORS-1)=SIZERAYPA(2,J) 

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS-1)=PREADD(3,T,J)
                 END DO  
                   SIZERAYSURV(3,NUMSURVIVORS-1)=SIZERAYPA(3,J) 

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO
                   SURVIVORS(2,SIZERAYPA(2,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J)+1

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)
                       
            ELSE IF(NOGOODK.EQ.0.AND.NOGOODL.EQ.1.AND.NOGOODM.EQ.0) THEN
                 NUMSURVIVORS=NUMSURVIVORS+2

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS-1)=PREADD(1,T,J)
                 END DO
                   SURVIVORS(1,SIZERAYPA(1,J)+1,NUMSURVIVORS-1)=ADDPOINT
                   SIZERAYSURV(1,NUMSURVIVORS-1)=SIZERAYPA(1,J)+1

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS-1)=PREADD(2,T,J)
                 END DO  
                   SIZERAYSURV(2,NUMSURVIVORS-1)=SIZERAYPA(2,J) 

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS-1)=PREADD(3,T,J)
                 END DO  
                   SIZERAYSURV(3,NUMSURVIVORS-1)=SIZERAYPA(3,J) 

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J)

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SURVIVORS(3,SIZERAYPA(3,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)+1
            

            ELSE IF(NOGOODK.EQ.1.AND.NOGOODL.EQ.0.AND.NOGOODM.EQ.0) THEN
                 NUMSURVIVORS=NUMSURVIVORS+2

                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS-1)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS-1)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS-1)=PREADD(2,T,J)
                 END DO
                   SURVIVORS(2,SIZERAYPA(2,J)+1,NUMSURVIVORS-1)=ADDPOINT 
                   SIZERAYSURV(2,NUMSURVIVORS-1)=SIZERAYPA(2,J)+1
                
                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS-1)=PREADD(3,T,J)
                 END DO
                   SIZERAYSURV(3,NUMSURVIVORS-1)=SIZERAYPA(3,J)


                 DO T=1,SIZERAYPA(1,J)
                   SURVIVORS(1,T,NUMSURVIVORS)=PREADD(1,T,J)
                 END DO
                   SIZERAYSURV(1,NUMSURVIVORS)=SIZERAYPA(1,J)

                 DO T=1,SIZERAYPA(2,J)
                   SURVIVORS(2,T,NUMSURVIVORS)=PREADD(2,T,J)
                 END DO
                   SIZERAYSURV(2,NUMSURVIVORS)=SIZERAYPA(2,J)

                 DO T=1,SIZERAYPA(3,J)
                   SURVIVORS(3,T,NUMSURVIVORS)=PREADD(3,T,J)
                 END DO
                   SURVIVORS(3,SIZERAYPA(3,J)+1,NUMSURVIVORS)=ADDPOINT 
                   SIZERAYSURV(3,NUMSURVIVORS)=SIZERAYPA(3,J)+1
            
                 
            END IF
         ELSE
           FLAG2=1
         END IF

         J=J+1
            END DO




        IF (NUMSURVIVORS.EQ.0) THEN
            WRITE(FILENUM,*) 'R(k+1,l+1) >' , ADDPOINT
            WRITE(FILENUM,*) 'NUMBER MAX DIFF-SETS:' , NUMPREADD
           FLAG=1       

            DO D=1,NUMPREADD
            DO I=1,3
              WRITE(FILENUM,*) 'COLOR NUMBER' , I
               DO J=1,SIZERAYPA(I,D)
                 WRITE(FILENUM,*) PREADD(I,J,D)
               END DO
              WRITE(FILENUM,*) ' '
           END DO
           END DO     

 
         ELSE
            DO D=1,NUMSURVIVORS
	         DO I=1,3
	              DO J=1,SIZERAYSURV(I,D)
		           PREADD(I,J,D)=SURVIVORS(I,J,D)
	              END DO
	         END DO
 	    END DO
            DO I=1,3
	         DO J=1,NUMSURVIVORS
		       SIZERAYPA(I,J)=SIZERAYSURV(I,J)
		       SIZERAYSURV(I,J)=0
	         END DO
            END DO

        NUMPREADD=NUMSURVIVORS
        NUMSURVIVORS=0
	
        END IF

        END DO

        STOP
        END


        INTEGER*2 FUNCTION MEMBER(ELT,LST2,LNGTH)

        IMPLICIT NONE

        INTEGER*2 LNGTH,F,ELT,LST2(LNGTH)

        DO F=1,LNGTH
            IF (ELT.EQ.LST2(F)) THEN
	          MEMBER=1
		        RETURN
	          END IF
        END DO

        MEMBER=0

        RETURN
        END


        INTEGER*2 FUNCTION
     *DIFFCHECK(LST,TEMPSET,LNGTH,CLIQUE,APOINT,T1,ML)

        IMPLICIT NONE

        INTEGER*2  LNGTH,TEMPSET(LNGTH),CLIQUE,KL,LST(CLIQUE-1)
        INTEGER*2  I,T,S,TMPSUM,FLAG3,APOINT,ML,T1(CLIQUE),MEMBER

        KL=CLIQUE


        DO I=1,KL-1
             T1(I)=LST(I)
        END DO
       
         IF(LNGTH.LT.KL-1) THEN
            DIFFCHECK=1
            RETURN
         END IF

         T1(KL)=APOINT
          FLAG3=0



            T=1
            DO WHILE(FLAG3.EQ.0.AND.T.LT.KL)
                 S=T+1 
                 DO WHILE(FLAG3.EQ.0.AND.S.LT.KL+1)
                    TMPSUM=ABS(T1(S)-T1(T)) 
                    IF (MEMBER(TMPSUM,TEMPSET,LNGTH).EQ.0) THEN
                      FLAG3=1
                    END IF
                 S=S+1 
                 END DO
            T=T+1
            END DO

         IF(FLAG3.EQ.0) THEN
            DIFFCHECK=0
          ELSE
          DIFFCHECK=1
          RETURN
          END IF
          END



