      SUBROUTINE Std
C COMPUTES STANDARD ERRORS AND VARIANCE-COVARIANCE MATRIX
      common/qmod/qj(3),mmin,mmax,qmodul,qrefin,nq,iqtype,iq(3)
      COMMON/PPCON/JTYP,ITYP,TOLTH,THEMX,RESOLV
      COMMON/REAL/AO(3),ALO(3),VCO,AD(3),ALS(3),VC,CSA(3),SNA(3)
      COMMON/ALL/N,NUMCYC,ntot
      COMMON/BLKA/A(54),UO(3),B(9),bb(9,9)
      COMMON/SCRT/E(9),ee(9,9),NH(4),qh(3),f(9),ff(9,10)
      COMMON/PPDATA/OBSTH(200),DSP(200),IH(200,4),PWL,
     * NUMOBS,INT(200)
      COMMON/BLKH/NCYC,AA(7),DLST(200),IOC(200),THTMX
      COMMON/HDGEN/ihg(1000,4),DCM(1000),NR,DMIN
      COMMON/IO/NTOUT,NTIN,NEXTN
      COMMON/RECP/Z(10),Q,AR(3),X(4),VR,U(3),W(3),VRO
      COMMON/BLKB/CR(9)
      COMMON/BLKC/THCMP,D,CONST,SWT,DIFF,DOBS,THTSE,THOBS,
     * RSDMAX,IRSD,SUM,MMN,prthtse
      COMMON/SIGMA/SERCE(6),SEDCE(6),VCME(9,9),FACTR,seqm(3)
      DIMENSION TT(6,6), ST(6,6),  DD(3), SS(45)
      dimension tempcos(3),tempsin(3),tempa(3),tempcsa(3),tempsna(3)
      dimension tempal(3)
*      sum = 0
*      mmn = numobs - ntot
*      do i=1,numobs
*        thobs = obsth(i)
*        j = ioc(i)      
*        do k=1,4
*          nh(k) = ihg(j,k)
*        enddo
*        call qcomp(nh,z,x,u,q)
*        tdiff = q - (4.0/(pwl**2))*(sind(thobs)**2)
*        sum = sum + tdiff**2
*      enddo
*      thtse = sqrt(sum/real(mmn))
      FACTR=THTSE*THTSE
      do i=1,9
        if(i.le.6)then 
          serce(i) = 0.0
          sedce(i) = 0.0
        endif
        if(i.le.3)then
          seqm(i) = 0.0
        endif
        do j=1,9
          vcme(i,j) = 0.0
        enddo
      enddo
      do i=1,ntot
        do j=1,ntot
          vcme(i,j) = factr*abs(ff(i,j))
          if(i.eq.j) a(i) = sqrt(vcme(i,j))
        enddo
      enddo
*      write(ntout,1)(a(i),i=1,ntot)
* 1     format(' The standard errors are:'/, 6f13.8)
      do i=1,nq
         seqm(iq(i)-6) = a(i+n)
      enddo
      GO TO (110,120,130,140,120,160,170),ITYP
 110  DO I=1,3                    ! cubic
        Serce(I)=A(1) 
      enddo
      GO TO 180
 120  Serce(1)=A(1)               ! hexagonal/tetragonal
      Serce(2)=A(1)
      Serce(3)=A(2)
      GO TO 180
 130  DO I=1,3                    ! orthorhombic
        Serce(I)=A(I)
      enddo
      GO TO 180
 140  DO I=1,3                    ! monoclinic
        Serce(I)=A(I)
      enddo
      serce(5) = a(4)
      GO TO 180
 160  do i=1,3                   ! triclinic   
        serce(i) = a(i)
        serce(i+3) = a(i+3)
      enddo
 170  do i=1,3                   ! trigonal
        serce(i) = a(1)
        serce(i+3) = a(2)
      enddo
 180  do i=1,3
        tempa(i) = x(i) + serce(i)
        tempcos(i) = u(i) + serce(i+3)
        tempsin(i) = sqrt( 1.0 - tempcos(i)**2 )
        tempal(i) = 57.29578*( 1.5707963 - atan2(tempcos(i),tempsin(i)))
        serce(i+3) = abs( ar(i) - tempal(i) )
      enddo
      tempv = sqrt( 1.0 - tempcos(1)**2 - tempcos(2)**2 - tempcos(3)**2
     * +2.0*tempcos(1)*tempcos(2)*tempcos(3))*tempa(1)*tempa(2)*tempa(3)
      DO I=1,3
        j = mod(i,3) + 1
        k = mod(j,3) + 1
        tempp = tempa(j)*tempa(k)*tempsin(i)/tempv
        sedce(i) = ad(i) - tempp
        tempcsa(i) = ( tempcos(j)*tempcos(k) - tempcos(i) )
     *   / ( tempsin(j)*tempsin(k) )
        tempsna(i) = sqrt( 1.0 - tempcsa(i)**2 )
        Sedce(i+3)=57.29578*(1.5707963-atan2(tempcsa(i),tempsna(i)))
     * - als(i)
      enddo
 999  RETURN
      END
