C SIGF3DFO  SOURCE    CB215821  16/04/21    21:18:25     8920
      SUBROUTINE sigf3D_forward(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     The relationship for sigmaf is implicit
c       Here, the equation is solved by a FORWARD EULER scheme so explicit

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 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(i6),sigmai(i6)
      dimension sigmaf(i6),sigmai(6)
c     final stress vector
      dimension esigmae(i6),esigmae1(i6)
c     trial stress vector
      dimension H66(i6,i6),pi2(i6)
****  dimension dgc(i6),dgt(i6),vloc(i6),trav6(i6),P2(i6,i6)
      dimension dgc(6),dgt(6),vloc(6),trav6(6),P2(6,6)
      dimension parahot3(idimpara3),rcossigmapr(3,3),U(6,6)



*****
*     MESSAGES D'ERREUR ( SUPPRESSION DES AUTOMATIC OBJECTS)
      IF(I6.GT.6) THEN
         PRINT *, ' SIGF3D_FORWARD - ERREUR  I6 = ', I6, ' > 6 '
      ENDIF
*****



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

      r2 = 2.

      Dlambdat = x1
      Dlambdac = x2

      do iloc=i1,i6
        sigmai(iloc) = esigmae1(iloc)
      end do

      call dsiggc(sigmai,dgc,ag,P2,pi2,i1,i6,fc,fb,lcp)
      call dsigRank(sigmai,dgt,i3,i6,parahot3,idimpara3,rkappait,lcp)

      rloc = 0.
      if (lcp) then
        rloc = (dgt(1))**2 + (dgt(2))**2 + (dgt(4))**2
      else
        do i=1,6
          rloc = rloc + (dgt(i))**2
        enddo
      endif
      if ( (rloc.eq.0.).and.(ABS(Dlambdat).gt.(1.d-14)) ) then
        do iloc=i1,i6
          sigmai(iloc) = esigmae1(iloc)
        end do
c       recalculate dgt with esigmae1, thus dgt.ne.0
        call dsigRank(sigmai,dgt,i3,i6,parahot3,idimpara3,
     .                rkappait,lcp)
      endif

      do iloc=i1,i6
        vloc(iloc) = Dlambdat*dgt(iloc) + Dlambdac*dgc(iloc)
      end do
      call mulAB(H66,VLOC,trav6,i6,i6,i6,i1)

      do iloc=i1,i6
        SIGMAF(iloc) = esigmae(iloc) - trav6(iloc)
      end do
      do iloc=1,6
        test = ABS(sigmaf(iloc))
        if (test.gt.10.E+20) then
          return
        endif
      enddo

      RETURN
      END




