      subroutine multipat(coor,sym,natom,multat)
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      character(*) sym
      character(3) sim(3)
      dimension coor(3,natom),yopx(3),yopy(3),yopz(3)
      dimension multat(natom)
      real(8),allocatable,dimension(:,:) :: coorloc
      yw=.false.
      sym=adjustl(sym)
      l=len_trim(sym)
      call fnormaligo(sym,l)
      l=len_trim(sym)
      noper=0
      sim=' '
      if(yw)print*,'sym',sym
      do
         noper=noper+1
         n=index(sym(1:l),' ')
         if(n==0) then
            sim(noper)(1:l)=sym(1:l)
            exit
         else
            sim(noper)(1:n-1)=sym(1:n-1)
            sym(1:n-1)=' '
            sym=adjustl(sym)
            l=len_trim(sym)
         endif
      enddo
      if(yw)print*,'sim',sim(1:noper)
      do iop=1,noper
         iop1=iop
!         if(iop1==3) iop1=4
         yopx(iop)=index(sim(iop1),'X')/=0
         yopy(iop)=index(sim(iop1),'Y')/=0
         yopz(iop)=index(sim(iop1),'Z')/=0
      enddo
      if(yw)print*,'yopx',yopx
      if(yw)print*,'yopy',yopy
      if(yw)print*,'yopz',yopz
!
      allocate (coorloc(3,0:noper))
      do iat=1,natom
         coorloc(:,0)=coor(:,iat)
         n=0
         do iop=1,noper
            coorloc(:,iop)=coor(:,iat)
            if(yopx(iop)) coorloc(1,iop)=-coorloc(1,iop)
            if(yopy(iop)) coorloc(2,iop)=-coorloc(2,iop)
            if(yopz(iop)) coorloc(3,iop)=-coorloc(3,iop)
            do k=0,iop-1
               if(all(coorloc(:,k)== coorloc(:,iop)))  goto 1
            enddo
            n=n+1
 1          continue
         enddo
         multat(iat)=2**n
         if(yw)print'(a,2i4,3f10.6)','iat,n',iat,multat(iat),coor(:,iat)
      enddo
      return
      end
       subroutine fnormaligo(aa,l)
      IMPLICIT REAL*8(A-H,O-X,Z),logical*1(y)
      character(*) aa
      aa=adjustl(aa)
      l=len_trim(aa)
      call repl(aa,' =','=',yrepl)
      call repl(aa,'= ','=',yrepl)
      call maj(aa,l)
      call suppdb(aa,l)
      l=len_trim(aa)
      return
      end
