      PROGRAM TESTIT
	PARAMETER (MNAI=8000)
        DIMENSION IATY(MNAI),ISCI(MNAI),IPAR(MNAI)
        CHARACTER*64 NAME(MNAI)
        CHARACTER*147 CTM1,CTM2
        DO 101 I=1,MNAI
          IATY(I)=0
          ISCI(I)=0
          IPAR(I)=0
          NAME(I)=' '
  101   CONTINUE
  102   READ (5,'(A16)',END=106) CTM1
        IF (CTM1(1:16).NE.'   0   0   0   0') GO TO 102
  103   READ (5,'(A78)',END=106) CTM1
        IF (CTM1(1:13).NE.'   0 0 0    0') THEN
          READ (CTM1,'(I4,2I2,I5,1X,A64)')
     +                                I,IATY(I),ISCI(I),IPAR(I),NAME(I)
          GO TO 103
        END IF
C       CLOSE (11)
        DO 105 I=1,MNAI
          IF (IATY(I).NE.0) THEN
            CTM1=NAME(I)
            ITMP=IPAR(I)
            ICNT=0
  104       IF (ITMP.NE.0) THEN
	      LNAM=IPOLNB(NAME(ITMP))
C             IF (NAME(ITMP)(1:LNAM).NE.CTM1(1:LNAM)) THEN
		CTM2=NAME(ITMP)(1:LNAM)//' - '//CTM1
                CTM1=CTM2
C             END IF
              ITMP=IPAR(ITMP)
              ICNT=ICNT+1
              IF (ICNT.LT.10) GO TO 104
            END IF
            PRINT '(A147,I4,2I2,I5)' , CTM1,I,IATY(I),ISCI(I),IPAR(I)
          END IF
  105   CONTINUE
        STOP
  106   PRINT * , 'Premature end of file.'
        STOP
      END



      INTEGER FUNCTION IPOLNB (CHRS)
        CHARACTER*(*) CHRS
        DO 101 I=LEN(CHRS),1,-1
          IF (CHRS(I:I).NE.' ') THEN
            IPOLNB=I
            RETURN
          END IF
  101   CONTINUE
        IPOLNB=1
        RETURN
      END
