      SUBROUTINE USDFLD(FIELD,STATEV,PNEWDT,DIRECT,T,CELENT,TIME,DTIME,
     1 CMNAME,ORNAME,NFIELD,NSTATV,NOEL,NPT,LAYER,KSPT,KSTEP,KINC,
     2 NDI,nshr,coord,jmac,jmtyp,matlayo,laccflg)
C
      INCLUDE 'ABA_PARAM.INC'
C
C MATERIAL AND STRENGTH PARAMETERS
      PARAMETER(YT=14.86D3,XC=392.7D3,YC=36.7D3,SC=15.5D3)
      PARAMETER(G12=1.01D6,ALPHA=0.8D-14)
C
      CHARACTER*80 CMNAME,ORNAME
      CHARACTER*3  FLGRAY(15)
      DIMENSION FIELD(NFIELD),STATEV(NSTATV),DIRECT(3,3),T(3,3),TIME(2),
     * coord(*),jmac(*),jmtyp(*)
      DIMENSION ARRAY(15),JARRAY(15)
C
C INITIALIZE FAILURE FLAGS FROM STATEV. 
      EM     = STATEV(1)
      EFS    = STATEV(2)
      DAMAGE = STATEV(3)
C
C GET STRESSES FROM PREVIOUS INCREMENT
      CALL GETVRM('S',ARRAY,JARRAY,FLGRAY,jrcd,
     $     jmac, jmtyp, matlayo, laccflg)
      S11 = ARRAY(1)
      S22 = ARRAY(2)
      S12 = ARRAY(4)
      CALL GETVRM('E',ARRAY,JARRAY,FLGRAY,jrcd,
     $     jmac, jmtyp, matlayo, laccflg)
      E12 = ARRAY(4)
C
C DAMAGE INDEX: = 0 IF NO STRAIN TO PREVENT DIVIDE BY ZERO
C
      IF (E12.NE.0) THEN
         DAMAGE = (3.D0*ALPHA*G12*S12**2 - 2.D0*ALPHA*(S12**3)/E12) / 
     &        (1.D0 + 3.D0*ALPHA*G12*S12**2)
      ELSE 
         DAMAGE = 0.D0
      ENDIF
C
      F1 = S12**2/(2.D0*G12) + 0.75D0*ALPHA*S12**4
      F2 = SC**2 /(2.D0*G12) + 0.75D0*ALPHA*SC**4
C
C MATRIX TENSILE/COMPRESSIVE FAILURE
      IF (EM .LT. 1.D0) THEN
         IF (S22 .LT. 0.D0) THEN
            EM = SQRT((S22/YC)**2 + F1/F2)
         ELSE 
            EM = SQRT((S22/YT)**2 + F1/F2)
         ENDIF
         STATEV(1) = EM
      ENDIF
C
C FIBER-MATRIX SHEAR FAILURE
      IF (EFS .LT. 1.D0) THEN
         IF (S11 .LT. 0.D0) THEN
            EFS = SQRT((S11/XC)**2 + F1/F2)
         ELSE
            EFS = 0.D0
         ENDIF
         STATEV(2) = EFS
      ENDIF
C
C     STATE TRANSITION DIAGRAM
C
C     FV1: MATRIX COMPR/TENS FAILURE
C     FV2: FIBER/MATRIX SHEAR FAILURE
C     FV3: MATERIAL DAMAGE (SHEAR NONLINEARITY)
C                                FV1    FV2    FV3         E1   E2   NU12   G12
C
C     (0) NO FAILURE              0      0      0  ----->  E1   E2   NU12   G12
C     (1) MATRIX (COMPR/TENS)     1      0      0  ----->  E1    0    0     G12
C     (2) FIB/MTX SHEAR           0      1      0  ----->  E1   E2    0      0
C     (3) MATRIX & F/M SHEAR      1      1      0  ----->  E1    0    0      0
C     (4) PURE DAMAGE             0      0      1  ----->  E1   E2   NU12    0
C     (5) MTRX & DAMAGE           1      0      1  ----->  E1    0    0      0
C     (6) F/M SHEAR & DAMAGE      0      1      1  ----->  E1   E2    0      0
C     (7) MTRX, F/M SHR & DAMAGE  1      1      1  ----->  E1    0    0      0
C
C     UPDATE FIELD VARIABLES 
C          
      FIELD(1) = 0.D0
      FIELD(2) = 0.D0
      IF (EM .GT. 1.D0) FIELD(1) = 1.D0
      IF (EFS .GT. 1.D0) FIELD(2) = 1.D0
      FIELD(3) = DAMAGE
      STATEV(3) = FIELD(3)
C
      RETURN
      END

