      SUBROUTINE ISOTRI(X,Y,V,N,VAL)
C
      DIMENSION X(3),Y(3),V(3),VAL(*),TT(256,3)
      DIMENSION N(3),IRESTE(3,3)
      INCLUDE 'com_ombreiso.f'
      DATA IRESTE / 0 , 3 , 2 , 3 , 0 , 1 , 2 , 1 , 0 /
C
      IF ((N(1).EQ.N(2)).AND.(N(2).EQ.N(3))) THEN
        CALL GSPAT(ISOMBRE+N(1))
        CALL MY_GSAREA(0,X,Y,3)
      ELSE
        IF (N(1).LT.N(2)) THEN
          CALL BARY(VAL,V(1),V(2),N(1),N(2),TT(1,3))
        ELSEIF(N(2).LT.N(1)) THEN
          CALL BARY(VAL,V(2),V(1),N(2),N(1),TT(1,3))
        ENDIF
        IF (N(2).LT.N(3)) THEN
          CALL BARY(VAL,V(2),V(3),N(2),N(3),TT(1,1))
        ELSEIF(N(3).LT.N(2)) THEN
          CALL BARY(VAL,V(3),V(2),N(3),N(2),TT(1,1))
        ENDIF
        IF (N(3).LT.N(1)) THEN
          CALL BARY(VAL,V(3),V(1),N(3),N(1),TT(1,2))
        ELSEIF(N(1).LT.N(3)) THEN
          CALL BARY(VAL,V(1),V(3),N(1),N(3),TT(1,2))
        ENDIF
        N0 = MIN(N(1),N(2),N(3))
        N1 = MAX(N(1),N(2),N(3))
        DO I=1,3
          IF (N0.EQ.N(I)) THEN
            I0 = I
          ELSEIF(N1.EQ.N(I)) THEN
            I1 = I
          ENDIF
        ENDDO
        IM = IRESTE(I0,I1)
        CALL COLORE(N(I0),N(IM),N(I1),
     &              X(I0),X(IM),X(I1),
     &              Y(I0),Y(IM),Y(I1),
     &              TT(1,I0),TT(1,IM),TT(1,I1))
      ENDIF
      END
C===================================================================
      SUBROUTINE COLORE(N1,N2,N3,X1,X2,X3,Y1,Y2,Y3,T1,T2,T3)
      DIMENSION T1(*),T2(*),T3(*)
      DIMENSION X(5),Y(5)
      INCLUDE 'com_ombreiso.f'
C
      IF (N1.EQ.N2) THEN
        II = 0
        X(4) = X1
        Y(4) = Y1
        X(3) = X2
        Y(3) = Y2
        DO I=N1,N3-1
          II = II+1
          X(1) = X(4)
          Y(1) = Y(4)
          X(2) = X(3)
          Y(2) = Y(3)
          X(3) = T1(II)*(X2-X3) + X3
          Y(3) = T1(II)*(Y2-Y3) + Y3
          X(4) = T2(II)*(X1-X3) + X3
          Y(4) = T2(II)*(Y1-Y3) + Y3
          CALL GSPAT(ISOMBRE+I)
          CALL MY_GSAREA(0,X,Y,4)
        ENDDO
        X(2) = X3
        Y(2) = Y3
        CALL GSPAT(ISOMBRE+N3)
        CALL MY_GSAREA(0,X(2),Y(2),3)
      ELSE
        X(2) = X1
        Y(2) = Y1
        X(3) = T3(1)*(X1-X2) + X2
        Y(3) = T3(1)*(Y1-Y2) + Y2
        X(4) = T2(1)*(X1-X3) + X3
        Y(4) = T2(1)*(Y1-Y3) + Y3
        CALL GSPAT(ISOMBRE+N1)
        CALL MY_GSAREA(0,X(2),Y(2),3)
        II = 1
        IF ((N1+2).LE.N2) THEN
          DO I=N1+1,N2-1
            II = II+1
            X(1) = X(4)
            Y(1) = Y(4)
            X(2) = X(3)
            Y(2) = Y(3)
            X(3) = T3(II)*(X1-X2) + X2
            Y(3) = T3(II)*(Y1-Y2) + Y2
            X(4) = T2(II)*(X1-X3) + X3
            Y(4) = T2(II)*(Y1-Y3) + Y3
            CALL GSPAT(ISOMBRE+I)
            CALL MY_GSAREA(0,X,Y,4)
          ENDDO
        ENDIF
        X(1) = X(4)
        Y(1) = Y(4)
        X(2) = X(3)
        Y(2) = Y(3)
        X(3) = X2
        Y(3) = Y2
        CALL GSPAT(ISOMBRE+N2)
        IF (N2.EQ.N3) THEN
          X(4) = X3
          Y(4) = Y3
          CALL MY_GSAREA(0,X,Y,4)
        ELSE
          X(4) = T1(1)*(X2-X3) + X3
          Y(4) = T1(1)*(Y2-Y3) + Y3
          II = II+1
          X(5) = T2(II)*(X1-X3) + X3
          Y(5) = T2(II)*(Y1-Y3) + Y3
          CALL MY_GSAREA(0,X,Y,5)
          X(3) = X(4)
          Y(3) = Y(4)
          X(4) = X(5)
          Y(4) = Y(5)
          II2 = 1
          IF ((N2+2).LE.N3) THEN
            DO I=N2+1,N3-1
              II = II+1
              II2 = II2+1
              X(1) = X(4)
              Y(1) = Y(4)
              X(2) = X(3)
              Y(2) = Y(3)
              X(3) = T1(II2)*(X2-X3) + X3
              Y(3) = T1(II2)*(Y2-Y3) + Y3
              X(4) = T2(II)*(X1-X3) + X3
              Y(4) = T2(II)*(Y1-Y3) + Y3
              CALL GSPAT(ISOMBRE+I)
              CALL MY_GSAREA(0,X,Y,4)
            ENDDO
          ENDIF
          X(2) = X3
          Y(2) = Y3
          CALL GSPAT(ISOMBRE+N3)
          CALL MY_GSAREA(0,X(2),Y(2),3)
        ENDIF
      ENDIF
      END
C===================================================================
      SUBROUTINE BARY(VAL,V1,V2,N1,N2,T)
      DIMENSION VAL(*),T(*)
C
      NN = 0
      DO I=N1,N2-1
        NN = NN+1
        T(NN) = (VAL(I)-V2)/(V1-V2)
      ENDDO
      END

