      subroutine smud(h,s,ur,wr,norb)
      use bas
      implicit real*8 (a-h,o-z)
      dimension      h(norb,norb)
      dimension      ur(norb,norb)
      dimension      wr(norb)
      dimension      s(norb,norb)
      logical*1 yw
      common/pr/nprint
c      character*8 orbi(nfix)
c      common/bas/ orbi,nbas(nfix),nbast(0:nfix),natom,atom,base
c      character*8 base(nfix)
c      character*4 atom(100)
      yw=.false.
      call hdiag(h,ur,norb,norb)
      do k=1,norb
         wr(k)=h(k,k)
      enddo
      if(yw) then
      write (6,*)
      write (6,*) ' diagonalisation'
      write (6,*)
      write (6,100) (wr(j),j=1,norb)
      write (6,*)
      call scripto(ur,norb,norb,norb,norb,orbi)
      write (6,100)
      endif
c      do i=1,norb
c         do j=1,norb
c            u(i,j)=ur(i,j)
c         enddo
c      enddo	
      do i=1,norb
         wr(i)=1.d0/dsqrt(wr(i))
      enddo
      do i=1,norb
         do j=1,norb
            s(i,j)=0.d0
            do k=1,norb
               s(i,j)=s(i,j)+ur(i,k)*wr(k)*ur(j,k)
            enddo
         enddo
      enddo
      if(yw) then
      write (6,*)
      write (6,*) ' S-1/2'
      write (6,*)
      write (6,100) (wr(j),j=1,norb)
      call scripto(s,norb,norb,norb,norb,orbi)
 100  format (8f10.6)
      endif
      return
      end
