      SUBROUTINE TRIAGE(M1,M2,M3,M4,ICPT,ICPT0,NFC,IOPT,NUM,NR,NODC)
C
      INCLUDE 'com_faces.f'
C
C Ce programme recherche une face deja apparue
C dans l'etude des faces precedentes et "oublie"
C ces 2 faces si tel est le cas.
C
C
C Creation du premier element de la liste des faces
C
      IF (IOPT.EQ.0.OR.ICPT.LT.ICPT0) GOTO 110
C
C Boucle de recherche
C
      IF (IOPT.EQ.8) THEN
        DO 100 I=ICPT,ICPT0,-1
          IF (M1.EQ.ITAB(I)) THEN
            IF (ICLAS(3,I).EQ.M3) THEN
              ITAB(I)    = 0
              ICLAS(1,I) = 0
              NFC = NFC+1
              GOTO 120
            ENDIF
          ENDIF
  100   CONTINUE
      ELSEIF (IOPT.EQ.4) THEN
        DO 101 I=ICPT,ICPT0,-1
          IF (M1.EQ.ITAB(I)) THEN
            IF (ICLAS(2,I).EQ.M3) THEN
              IF (ICLAS(3,I).EQ.M2) THEN
                ITAB(I)    = 0
                ICLAS(1,I) = 0
                NFC = NFC+1
                GOTO 120
              ENDIF
            ENDIF
          ENDIF
  101   CONTINUE
      ELSE
        DO 102 I=ICPT,ICPT0,-1
          IF (M1.EQ.ITAB(I)) THEN
            ITAB(I)    = 0
            ICLAS(1,I) = 0
            NFC = NFC+1
            GOTO 120
          ENDIF
  102   CONTINUE
      ENDIF
C
C Creation d'un element de la liste
C
  110 ICPT = ICPT+1
      IF (ICPT.GT.NCMAX) THEN
        PRINT*,'ERREUR DANS TRIAGE - AUGMENTEZ NCMAX (',NCMAX,')'
        STOP
      ENDIF
      ITAB(ICPT) = M1
      ICLAS(1,ICPT) = M1
      ICLAS(2,ICPT) = M2
      ICLAS(3,ICPT) = M3
      ICLAS(4,ICPT) = M4
      ICLAS(5,ICPT) = NUM
      ICLAS(6,ICPT) = NR
      ICLAS(7,ICPT) = NODC
      IF (IOPT.NE.8.AND.IOPT.NE.4) IOPT=0
 120  END
C======================================================================
      SUBROUTINE COMPAC(ICPT,ICPT0,NFC)
C
      INCLUDE 'com_faces.f'
C
      IBON = ICPT0-1
      DO I=ICPT0,ICPT
        IF (ITAB(I).NE.0) THEN
          IBON = IBON+1
          ITAB(IBON) = ITAB(I)
          DO K=1,7
            ICLAS(K,IBON) = ICLAS(K,I)
          ENDDO
          ISD2(IBON) = ISD2(I)
          ISD3(IBON) = ISD3(I)
        ENDIF
      ENDDO
      ICPT = IBON
      NFC = 0
      END
