      IMPLICIT REAL*8 (A-H,O-Z)
      CHARACTER*5 SCHNAM
      CHARACTER*10 HMNAME
      COMPLEX*16 DB(6,2,6,2)
      CHARACTER*2 NP
      DIMENSION KB(3),KKM(3,1000)
      DIMENSION NDES(12),NDED(12),JTRS(12),JTRD(12),IPAS(12),IPAD(12)
      DIMENSION IRDM(12),NIM(12)

      OPEN(3,FILE='generator',iostat=ISO,STATUS='OLD')
C      OPEN(3,FILE='generator',iostat=ISO,STATUS='OLD')
C      WRITE(6,*) ISO
C      IF(ISO.NE.0) STOP
   90 READ(5,*) NUMBER
      IF(NUMBER.EQ.0) STOP
      CALL TSNTNM(NUMBER,3,NC,SCHNAM,HMNAME)
      DO 91 ICCC=1,NC
      NNC=ICCC
      CALL TSPNGE(NUMBER,NNC,3)
      A=1.0
      B=0.8
      C=2.1
      CA=0.0
      CB=0.0
      CC=-0.5
      CALL TSLATC(A,B,C,CA,CB,CC)
      NX=4
      NY=4
      NZ=4
      write(6,*) nx,ny,nz
      CALL TSKPGN(NX,NY,NZ,KKM,ICC,NK)
      write(6,*) ' Number of k-point',nk
      DO 10 K=1,NK
      KX=KKM(1,K)
      KY=KKM(2,K)
      KZ=KKM(3,K)
      CALL KPNAME(KX,KY,KZ,ICC,NP)
      KB(1)=KKM(1,K)
      KB(2)=KKM(2,K)
      KB(3)=KKM(3,K)
      CALL TSKFBZ(KX,KY,KZ,ICC,IND)
      WRITE(6,600) NP,KX,KY,KZ,ICC,IND
  600 FORMAT(//' NAME OF K-POINT ',A2,3I3,'/',I3,I5)
      INDUB=0
      CALL TSIREP(KB,ICC,INDUB)
      CALL TSPKDS
      CALL TSIRDS
      CALL TSTARK
      CALL TSTRDS
      CALL DGTRST(JDUB,NRS,MMG,NSTR,NDES,JTRS,IPAS)
      WRITE(6,601) MMG,NSTR,NRS
  601 FORMAT(' ORDER OF K-POINT GROUP=',I3,' NUMBER OF STAR=',I3
     &      /' NUMBER OF SINGLE REPRESENTATION=',I3)
      WRITE(6,603) (I,I=1,NRS)
      WRITE(6,604) (NDES(I),I=1,NRS)
      WRITE(6,605) (JTRS(I),I=1,NRS)
      WRITE(6,606) (IPAS(I),I=1,NRS)
  603 FORMAT('    NO      ',12I4)
  604 FORMAT(' DEGENERACY ',12I4)
  605 FORMAT(' HERRING SUM',12I4)
  606 FORMAT(' PARTNER NO ',12I4)
      INDUB=1
      CALL TSIREP(KB,ICC,INDUB)
      CALL TSIRDS
      CALL TSTRDS
      CALL DGTRST(JDUB,NRD,MMG,NSTR,NDED,JTRD,IPAD)
      WRITE(6,602) NRD
  602 FORMAT(' NUMBER OF DOUBLE REPRESENTATION=',I3)
      WRITE(6,603) (I,I=1,NRD)
      WRITE(6,604) (NDED(I),I=1,NRD)
      WRITE(6,605) (JTRD(I),I=1,NRD)
      WRITE(6,606) (IPAD(I),I=1,NRD)
      DO 13 I=1,NRS
      IRS=I
      IM=0
      DO 14 J=1,NRD
      IRD=J
      CALL TSRDSD(IRD,IRS,DB,NI)
      IF(NI.GT.0) THEN
         IM=IM+1
         IRDM(IM)=IRD
         NIM(IM)=NI
      END IF
   14 CONTINUE
      WRITE(6,610) NP,IRS,(IRDM(K1),NIM(K1),K1=1,IM)
  610 FORMAT(1H ,A2,I2,'----->',5(I4,'*',I1))
   13 CONTINUE
C      pause
   10 CONTINUE
   91 CONTINUE
      GO TO 90  
      END


