      IMPLICIT REAL*8 (A-H,O-Z)
      CHARACTER*5 SCHNAM
      CHARACTER*10 HMNAME
      COMPLEX*16 V
      CHARACTER*2 NP
      DIMENSION KB(3),KKM(3,1000),ND(12)
      DIMENSION NDES(12),JTRS(12),IPAS(12)
      DIMENSION KO(2000),IND(4,500),V(2000),BB(500),D(500)
C      OPEN(3,FILE='generator',iostat=ISO,STATUS='OLD')
C      WRITE(6,*) ISO
C      IF(ISO.NE.0) STOP
      READ(1,*) NUMBER
      IF(NUMBER.EQ.0) STOP
      CALL TSNTNM(NUMBER,3,NC,SCHNAM,HMNAME)
      DO 20 INC=1,NC
      NNC=INC
      CALL TSPNGE(NUMBER,NNC,3)
      IF(NNC.EQ.1) READ(1,*) A,B,C
      IF(NNC.EQ.1)READ(1,*) CA,CB,CC
      CALL TSLATC(A,B,C,CA,CB,CC)
      IF(NNC.EQ.1)READ(1,*) NX,NY,NZ
      IF(NNC.EQ.1)READ(1,*) AM
      CALL TSKPGN(NX,NY,NZ,KKM,ICC,NK)
      DO 10 K=1,NK
      KX=KKM(1,K)
      KY=KKM(2,K)
      KZ=KKM(3,K)
      CALL TSNMKP(KX,KY,KZ,ICC,NP)
      CALL TSKFBZ(KX,KY,KZ,ICC,INDZB)
      KB(1)=KKM(1,K)
      KB(2)=KKM(2,K)
      KB(3)=KKM(3,K)
      WRITE(6,600) NP,KX,KY,KZ,ICC,INDZB
  600 FORMAT(//' NAME OF K-POINT ',A2,3I3,'/',I3
     &        ,' IN OR ON B.Z',I2)
      CALL TSIREP(KB,ICC,0)
      CALL TSPKDS
      CALL TSIRDS
      CALL DGTRST(JDUB,NRS,MMG,NSTR,NDES,JTRS,IPAS)
      WRITE(6,607) MMG,NSTR,NRS
  607 FORMAT(' ORDER OF K-POINT GROUP=',I3,' NUMBER OF STAR=',I3
     &      /' NUMBER OF REPRESENTATION=',I3)
      WRITE(6,608) (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)
  608 FORMAT('    NO      ',12I4)
  604 FORMAT(' DEGENERACY ',12I4)
  605 FORMAT(' HERRING SUM',12I4)
  606 FORMAT(' PARTNER NO ',12I4)
      CALL TSIRNR(NR,NH,ND)
      CALL ZZZY41(KB,ICC,AM)
      DO 13 I=1,NR
      IR=I
      CALL TSPWA(KB,ICC,IR,NDI,KO,V,BB,D,IND,ND1,ND2,NNWW)
      CALL TSPWDS
      IF(ND(IR).GT.1) THEN
         CALL TSPWAM(KB,ICC,IR,NDI,KO,V,BB,D,IND,ND1,ND2,NNWW)
         CALL TSPMDS
      END IF
      pause
   13 CONTINUE
      pause
   10 CONTINUE
   20 CONTINUE
      STOP
      END
