      SUBROUTINE ISOCAR(XX,YY,VV,VALF,NBOR,VAL,NBCOL,ARET,NDSEL,IMAILL
     &                 ,IBORD,INTERPCENTRE,NNN,NDS,ICOUL,MODTET)
C
      DIMENSION X(3),Y(3),V(3),VAL(*),XX(*),YY(*),VV(*)
      DIMENSION N(3),NN(5),ISUC(4),ISUC3(3),NBOR(4)
      LOGICAL*4 ARET
      INCLUDE 'com_ombreiso.f'
      DATA ISUC  / 2,3,4,1 /
      DATA ISUC3 / 2,3,1 /
C
      DO I=1,NDS
        NN(I) = ICHERCHE(VAL,NBCOL,VV(I))
      ENDDO
      IF (INTERPCENTRE.EQ.0.OR.NDSEL.NE.4) THEN
        NN(5) = 0
      ELSE
        NN(5) = ICHERCHE(VAL,NBCOL,VALF)
      ENDIF
C
      IF ( (NN(1).EQ.NN(2)).AND.(NN(2).EQ.NN(3))
     &.AND.(NN(3).EQ.NN(NDS)).AND.(NN(NDS).EQ.NN(1))
     &.AND.(INTERPCENTRE.EQ.0.OR.NN(5).EQ.NN(1).OR.NDSEL.NE.4)) THEN
        CALL GSPAT(ISOMBRE+NN(1))
        IF (ARET) THEN
          IF (MODTET.EQ.40) THEN
            CALL MY_GSAREA(0,XX,YY,NDS)
            IF (NDS.EQ.4) THEN
              CALL GSMOVE(XX(2),YY(2))
              CALL GSPLNE(2,XX(3),YY(3))
            ELSEIF(MOD(NNN,4).NE.0) THEN
              CALL GSMOVE(XX(1),YY(1))
              CALL GSPLNE(2,XX(2),YY(2))
            ENDIF
          ELSE
            CALL MY_GSAREA(1,XX,YY,NDS)
          ENDIF
          IF (IBORD.EQ.0) CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)        
        ELSE
          CALL MY_GSAREA(0,XX,YY,NDS)
          IF (IMAILL.GT.0) CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)
        ENDIF
      ELSEIF(NDS.EQ.4) THEN
        X(3) = .25*(XX(1)+XX(2)+XX(3)+XX(4))
        Y(3) = .25*(YY(1)+YY(2)+YY(3)+YY(4))
        IF (INTERPCENTRE.EQ.0.OR.NDSEL.NE.4) THEN
          V(3) = .25*(VV(1)+VV(2)+VV(3)+VV(4))
          N(3) = ICHERCHE(VAL,NBCOL,V(3))
        ELSE
          V(3) = VALF
          N(3) = NN(5)
        ENDIF
C
        DO K=1,4
          X(1) = XX(K)
          Y(1) = YY(K)
          V(1) = VV(K)
          N(1) = NN(K)
          K2   = ISUC(K)
          X(2) = XX(K2)
          Y(2) = YY(K2)
          V(2) = VV(K2)
          N(2) = NN(K2)
          CALL ISOTRI(X,Y,V,N,VAL)
        ENDDO
        IF (ARET) THEN
          IF (MODTET.EQ.40) THEN
            CALL GSMOVE(XX(2),YY(2))
            CALL GSPLNE(2,XX(3),YY(3))
          ELSE
            CALL GSPLNEC(4,XX,YY)
          ENDIF
          IF (IBORD.EQ.0) CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)        
        ELSEIF(IMAILL.GT.0) THEN
          CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)
        ENDIF
      ELSE
        IF (INTERPCENTRE.EQ.0.OR.NDSEL.NE.4) THEN
          CALL ISOTRI(XX,YY,VV,NN,VAL)
        ELSE
          X(3) = (XX(1)+XX(2)+XX(3))/3.
          Y(3) = (YY(1)+YY(2)+YY(3))/3.
          V(3) = VALF
          N(3) = NN(5)
          DO K=1,3
            X(1) = XX(K)
            Y(1) = YY(K)
            V(1) = VV(K)
            N(1) = NN(K)
            K2   = ISUC3(K)
            X(2) = XX(K2)
            Y(2) = YY(K2)
            V(2) = VV(K2)
            N(2) = NN(K2)
            CALL ISOTRI(X,Y,V,N,VAL)
          ENDDO
        ENDIF
        IF (ARET) THEN
          IF (MODTET.EQ.40) THEN
            IF (MOD(NNN,4).NE.0) THEN
              CALL GSMOVE(XX(1),YY(1))
              CALL GSPLNE(2,XX(2),YY(2))
            ENDIF
          ELSE
            CALL GSPLNEC(3,XX,YY)
          ENDIF
          IF (IBORD.EQ.0) CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)        
        ELSEIF(IMAILL.GT.0) THEN
          CALL BORD(NBOR,XX,YY,ICOUL,ICOUL,NNN)
        ENDIF
      ENDIF
      END
C======================================================================
      INTEGER FUNCTION ICHERCHE(VAL,NB,V)
      DIMENSION VAL(*)
      DO I=1,NB+1
        IF (VAL(I).GT.V) THEN
          ICHERCHE = I
          RETURN
        ENDIF
      ENDDO
      ICHERCHE = NB+1
      END

