      SUBROUTINE USDFLD(FIELD,STATEV,PNEWDT,DIRECT,T,CELENT,
     1 TIME,DTIME,CMNAME,ORNAME,NFIELD,NSTATV,NOEL,NPT,LAYER,
     2 KSPT,KSTEP,KINC,NDI,NSHR,COORD,JMAC,JMATYP,MATLAYO,
     3 LACCFLA)
C
      INCLUDE 'ABA_PARAM.INC'
C
      CHARACTER*80 CMNAME,ORNAME
      CHARACTER*3  FLGRAY(15)
      DIMENSION FIELD(NFIELD),STATEV(NSTATV),DIRECT(3,3),
     1 T(3,3),TIME(2)
      DIMENSION ARRAY(15),JARRAY(15),JMAC(*),JMATYP(*),COORD(*)
C
C Absolute value of current strain:
      CALL GETVRM('EE',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP,
     1 MATLAYO,LACCFLA)
      E11 = ABS( ARRAY(1) )
      E22 = ABS( ARRAY(2) )
      E33 = ABS( ARRAY(3) )
      E12 = ABS( ARRAY(4) )
      ETOT=E11*E11+E22*E22+2*E12*E12
	ETOT=SQRT(ETOT)
      CALL GETVRM('PE',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP,
     1 MATLAYO,LACCFLA)
      PEEQ = ABS( ARRAY(7) )

C Maximum value of visco plastic strain up to this point in time:
      CALL GETVRM('CE',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP,
     1 MATLAYO,LACCFLA)
      CREEP=ARRAY(7)
      IF(PEEQ.eq.0) then
	DAMAGE=0
	ELSE
      DAMAGE=1-abs(CREEP)/(abs(CREEP)+abs(PEEQ)+ABS(ETOT))
	ENDIF
	
	STATEV(1)=DAMAGE
C	WRITE(*,*)'PLA=',STATEV(3)

C If error, write comment to .DAT file:
      IF(JRCD.NE.0)THEN
       WRITE(6,*) 'REQUEST ERROR IN USDFLD FOR ELEMENT NUMBER ',
     1     NOEL,'INTEGRATION POINT NUMBER ',NPT
      ENDIF
C
      RETURN
      END
