C PSTRES    SOURCE    GOUNAND   26/08/19    21:15:03     12620          
c---------------------------------------------------------------------
c
      SUBROUTINE PSTRES (NSTR1, SIGMA, SGPRI)
c
c=====================================================================
c                                                                    =
c   This routine calculates the principal stress values of           =
c   sigma (nstr1) and puts the results in sgpri (3).                 =
c                                                                    =
c   Note:    sigma = (Sxx, Syy, Szz, Sxy, Sxz, Syz)   for NSTR1=6    =
c            sgpri = (S11, S22, S33)                                 =
c            sigma = (Sxx, Syy, Szz, Sxy)             for NSTR1=4    =
c            sgpri = (S11, S22, Szz)                                 =
c                                                                    =
C Gounand 2026/08 On renvoie sur jacob3.eso, plus robuste et precise =
c=====================================================================
      IMPLICIT INTEGER(I-N)
      IMPLICIT REAL*8 (A-H,O-Z)
      integer   nstr1
      real*8    sigma (nstr1), sgpri (3),A(3,3)
      real*8    avalu, bvalu
c
      if      (nstr1 .eq. 4)  then
         a(1,1)=sigma(1)
         a(2,2)=sigma(2)
         a(1,2)=sigma(4)
         a(2,1)=sigma(4)
         a(3,3)=sigma (3)
         call jacod2(a,sgpri)
         return
* Old source
        avalu = (sigma (1) + sigma (2)) * 0.5 d0
        bvalu = SQRT (0.25d0*(sigma(1)-sigma(2))**2+sigma(4)**2)
c
        sgpri (1) = avalu + bvalu
        sgpri (2) = avalu - bvalu
        sgpri (3) = sigma (3)
c        write(6,*)'sgpri',(sgpri(ie1),ie1=1,3)
      else if (nstr1 .eq. 6)  then
        call pstre3 (sigma, sgpri)
      end if
c
      return
      end
 
