      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(*)
	real K
C
      if(kstep.gt.1)then
       CALL GETVRM('E',ARRAY,JARRAY,FLGRAY,JRCD,JMAC,JMATYP,
     1 MATLAYO,LACCFLA)

	 EPS1=ARRAY(1) 
       EPS2=ARRAY(2)
       EPS3=ARRAY(3) 

       EV=EPS1+EPS2+EPS3
	 if(ev.gt.0)then
	 !D means damage
	 D=(0.003-(0.003+EV)/(1+EV))/(0.003-0.1)
	 !Qmeans ratio
       Q=(0.003+EV)/(1+EV)
	 !K means permeability
	 K=4.63*10**(-7.)*(1+EV/0.003)**3/(1+EV)
	 ELSE
	 D=(0.003-(0.003-EV)/(1-EV))/(0.003-0.1)
       Q=(0.003-EV)/(1-EV)
	 K=4.63*10**(-7.)*(1+EV/0.003)**3/(1+EV)
	 ENDIF

	 field(1)=ev
	 statev(1)=field(1)
	 statev(2)=D
	 statev(3)=Q
	 statev(4)=K

c	 if(kstep.eq.2.and.time(1).gt.3000.and.time(1).lt.3600)then
c	   if(dtime.gt.30) dtime=20
c	 endif
	 if(kstep.eq.3.and.time(1).gt.3000.and.time(1).lt.3600)then
	   if(dtime.gt.30) dtime=20
	 endif
	 if(kstep.eq.4.and.time(1).gt.172000.and.time(1).lt.172800)then
	   if(dtime.gt.60) dtime=60
	 endif
	 if(kstep.eq.5.and.time(1).gt.3000.and.time(1).lt.3600)then
	   if(dtime.gt.30) dtime=20
	 endif
	 if(kstep.eq.6.and.time(1).gt.2590000.and.time(1).lt.2592000)then
	   if(dtime.gt.60) dtime=60
	 endif
	 if(kstep.eq.7.and.time(1).gt.3200.and.time(1).lt.3600)then
	   if(dtime.gt.30) dtime=30
       endif

c	IF(NOEL==795)THEN    
c	PRINT*,'E11=,E22,E33:', EPS1,EPS2,EPS3,statev(1)
c	ENDIF
c	if(s.lt.1.)then
c	field(1)=D
c	field(2)=S
c	field(3)=Q
c     endif
	endif

      RETURN
      END
