C PSTRES    SOURCE    CB215821  17/07/21    21:15:29     9513           
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=====================================================================
      IMPLICIT INTEGER(I-N)
      integer   nstr1
      real*8    sigma (nstr1), sgpri (3)
c
      real*8    avalu, bvalu
c
      if      (nstr1 .eq. 4)  then
        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

 
