C SIGF3DIM  SOURCE    AM        12/02/28    21:15:20     7291
       SUBROUTINE sigf3D_implicit(esigmae,x1,x2,sigmaf,H66,P2,
     .              pi2,ag,i6,fc,fb,
     .              parahot3,idimpara3,lerror,lcp,esigmae1,U)

c     This subroutine calculates the stress SIGMAF obtained by applying the plastic
c       corrector to the elastic predictor. The plastic corrector is calculated from
c       the plastic multipliers Dlambdat = x1 and Dlambdac = x2.
c
c     The relationship for sigmaf is implicit
c     Here, we try to solve it exactly. Strategy of step subdivision in case of non convergency.
c       Finally, if no convergence, we go to sigf3d_forward to calculate sigma with forward euler scheme.
c
c     sigmaf = esigmae - H66 * [Dlambdat*dgt + Dlambdac*dgc]
c
c     Dlambdat *   increment of hardening in tension
c     Dlambdac *   increment of hardening in compression
c     rkappait *   initial hardening in tension
c     rkappaic *   initial hardening in compression
c     esigmae  *   elastic predictor for effective the stress
c     sigmaf   *   calculated vector of final effective stresses

      IMPLICIT REAL*8 (A-B,D-H,O-Z)
      implicit integer (I-K,M,N)
      implicit logical (L)
      implicit character*10 (C)

      dimension sigmaf(6),sigmai(6)
c     final stress vector
      dimension esigmae(6),esigmae1(6),dsigma(6)
c     trial stress vector
      dimension H66(6,6),pi2(6)
      dimension dgc(6),dgt(6),vloc(6),trav6(6),P2(6,6)
      dimension parahot3(idimpara3),rcossigmapr(3,3),B(6,6)
      dimension d2gc(6,6),d2gt(6,6),trav66(6,6),h(6),U(6,6)
      dimension esigmain(6)

      i0 = 0
      i1 = 1
      i2 = 2
      i3 = 3
      i4 = 4
      i5 = 5
      i7 = 7

      r2 = 2.

      ldivide = .false.
      do iloc=1,6
        esigmain(iloc) = esigmae(iloc)
      enddo
      n = 1
  27  continue
      do istep=1,n
        xsub1 = x1/n
        xsub2 = x2/n
        call sigf3d_sub(esigmae,x1,x2,sigmaf,H66,P2,pi2,ag,i6,fc,fb,
     .            parahot3,idimpara3,lerror,lcp,esigmae1,U,ldivide,n,
     .            xsub1,xsub2,esigmain)
        if (ldivide) then
c         no convergence in subroutine sigf3d_sub
          n = n*2
c         back to the initial state => esigmain = esigmae
          do iloc=1,6
            esigmain(iloc) = esigmae(iloc)
          enddo
          if (n.lt.8) go to 27
c         if we arrive here, there is still no convergence even with the step subdivision
c         => we use the explicit algorithm (FORWARD EULER)
          call sigf3D_forward(esigmae,x1,x2,sigmaf,H66,P2,pi2,ag,i6,
     .             fc,fb,parahot3,idimpara3,lerror,lcp,esigmae1,U)
          return
        endif
c       if we arrive here, there was convergence => esigmain = sigmaf
c       in the step-subdivision strategy, start back at the intermediate converfed point: sigmaf
        do iloc=1,6
          esigmain(iloc) = sigmaf(iloc)
        enddo
      enddo

      RETURN
      END






