      subroutine umfail(failaw,a,n)
#ifdef ACC
c
c     user material model for belytschko-tsay shell
c
c     Haeng-Ki Lee
c     Srdan Simunovic
c     lockheed martin energy systems, inc.
c     p.o. box 2008, ms-6140
c     phone: (423) 241-3863
c     fax: (423) 574-4839
c     email: qs9@ornl.gov
c
c     disclaimer: your mileage may vary.
c

      implicit none

      integer failaw,n,i,ndm,imax
#ifdef DP
      double precision a(n),dtot,dmax,zero,one
#else
      real a(n),dtot,dmax,zero,one
#endif

      data zero /0.d0/, one /1.d0/

      if (failaw .eq. 1) then

c     a(1)  - # of damage variables (in)
c     a(2)  - damage variable (in)
c     a(3)  - c0 (in)
c     a(4)  - fact (in)
c     a(5)  - min. time (in)
c     a(6)  - el. time (in)
c     a(7)  - problem time (in)
c     a(8)  - time when deletion starts (in/out)
c     a(9)  - increment of failure (in)
c     a(10)  - current failure level (in/out)
c     a(11) - failure indicator (-1=dt, 1-ndm= d. v.) (out) 

         ndm = nint(a(1))
         dmax = 0.
         a(11) = 0.
         dmax = max(dmax, a(2))


         if (dmax .gt. a(4)*a(3)) then
               a(11) = 1.
               if (a(8) .eq. 0.)then
                  a(8) = a(7)
                  a(10) = 1.
               endif
               a(10) = a(10) - a(9)
               a(10) = max(zero, a(10))
         endif
      endif

#endif
      return
      end
