	SUBROUTINE ELREAD (INUMB,BFMU,ILFRM,BNAME,ILNAM,ICELL,NCELL,
     *		BCELL,BCREF,BJOUR,IYEAR,BREFNO,ILINT,LERR)
C	READ THE NAME, FORMULA AND PATTERN CHAR FROM THE TN07xx.EXT
C	FILE
C
C	INUMB   COMPOUND # IN THE FILE
C	BFMU	RETURNED AS THE COMPOUND FORMULA
C	ILFRM	LENGTH OF THE FORMULA
C	BNAME	COMPOUND NAME
C	ILNAM	LENGTH OF NAME
C	ICELL	UNIT CELL VALUES
C	NCELL	# BYTES OF CELL VALUES
C	BCELL	UNIT CELL FLAGS
C	BCREF	PEARSON SYMBOL AND REFERENCE INFO.
C	LERR	ERROR FLAG
C
C	THE TN07xx.EXT FILE FORMAT IS AS FOLLOWS:
C		x - # BYTES TO STORE THE NAME (1 BYTE)
C		y - # CHAR IN FORMULA (1 BYTE)
C		z - # INTENSITIES (1 BYTE)
C		UCANG (FIRST NIBBLE), RCANG (SECOND NIBBLE)
C			(BIT CODE:  100=ALPHA, 010=BETA, 001-GAMMA)
C		PEARSON SYMBOL (4 BYTES)
C			1 - AMOTRHC CODES
C			1 - PABCIFR CODES
C			2 - # ATOMS IN UNIT CELL ROUNDED TO INTEGER
C		JOURNAL REF (19 BYTES)
C			4 - JOURNAL CODE (RAD 50)
C			6 - VOL, PAGE # (RAD 50)
C			6 - FIRST NINE LETTER FOR AUTHORS (RAD 50)
C			1 - YEAR - 1800
C		COMPOUND REF # (CD OR PDF)
C		UNIT CELL ANGLES (0-6) - DEGREES * 100
C		REDUCED CELL ANGLES (0-6) - DEGREES * 100
C		NAME (RADIX 50, x/2 WORDS)
C		FORMULA (y BYTES)
C		INTENSITIES (z NIBBLES)
C
	IMPLICIT BYTE (B), LOGICAL*1 (L), INTEGER*2 (I-K,M,N)
	DIMENSION BFMU(1),IBUF(512),BBUF(1),BCNT(2),BNAME(1),BCREF(1),
     *		INDREC(170),BINDEX(170),B2(2)
	EQUIVALENCE (ICNT,BCNT),(I2,B2)
	EQUIVALENCE (BBUF,IBUF)
	DATA BLANK/' '/,B0/'0'/
	DO 5 I=1,256
5	BNAME(I) = BLANK
C FIND LOCATION IN CHEM FILE INDEX  - EACH INDEX ENTRY IS 3 BYTES 
C THERE ARE 170 ENTRIES PER BLOCK
	IREC = (INUMB-1)/170 + 1		!HEADER RECORD TO READ
	READ (1'IREC) (INDREC(I),BINDEX(I),I=1,170)	!READ HEADER
	ILOC = INUMB - (IREC-1)*170		!LOCATION OF ENTRY IN HEADER
	IREC = INDREC(ILOC) 			!RECORD WITH FORMULA
	IWD = 255 .AND. BINDEX(ILOC) 		!WORD LOCATION FOR ENTRY
	IBY = (IWD-1)*2 + 1			!BYTE LOCATION OF ENTRY
	IF (IREC .EQ. 0) GOTO 1000
C READ BUFFER WITH ENTRY
	READ (1'IREC) (IBUF(I),I=1,256)
	ICNT = IBUF(IWD)
	ILNAM = 255 .AND. BBUF(IBY)		!# BYTES IN NAME
	ILFRM = 255 .AND. BBUF(IBY+1)		!# BYTES IN FORMULA
	IF (IBY .GT. 226) THEN
	  IREC = IREC + 1
	  READ (1'IREC) (IBUF(I),I=257,512)
	END IF
	ILINT = 255 .AND. BBUF(IBY+2)	  	!# BYTES OF INTENSITIES
	BCELL = 255 .AND. BBUF(IBY+3)		!UNIT CELL FLAGS
	NCELL = 0
	DO 80 I=1,8
80	IF ((BCELL.AND.2**(I-1)) .NE. 0) NCELL = NCELL + 2
C FIND SIZE OF ENTRY
	IEND = (IBY + 30 + ILNAM + ILFRM + ILINT + NCELL)
	IF (IEND .LE. 512) GOTO 100	!NO NEED TO READ MORE
	IF (IBY .LE. 226) THEN
	  IREC = IREC + 1
	  READ (1'IREC) (IBUF(I),I=257,512)
	END IF
C
100	IPTR = IBY + 4
	CALL BCOPY (BBUF(IPTR),BCREF,4)	!COPY PEARSON
	IPTR = IPTR + 4
	CALL R50ASC (24,BBUF(IPTR),BJOUR)		!JOURNAL CODE
	IPTR = IPTR + 16
	IYEAR = ( 255 .AND. BBUF(IPTR)) + 1800
	IPTR = IPTR + 1
C PDF# OR C.D. #
	I1 = 255 .AND. BBUF(IPTR)
	B2(1) = BBUF(IPTR+1)
	B2(2) = BBUF(IPTR+2)
	ENCODE (6,110,BREFNO) I1,I2
110	FORMAT (I2,I4)
	DO 115 I=1,6
115	IF (BREFNO .EQ. BLANK) BREFNO = B0
	IPTR = IPTR + 3
C
	IF (NCELL .GT. 0) CALL BCOPY (BBUF(IPTR),ICELL,NCELL)
	IPTR = IPTR + NCELL
C	BYTE LOC OF NAME IN BLOCK
	NCHAR = ILNAM/2*3			!# OF CHAR
	CALL R50ASC (NCHAR,BBUF(IPTR),BNAME)	!GET NAME
	IPTR = IPTR + ILNAM
	ILNAM = NCHAR				!SET NEW NAME LENGTH
C	TRANSFER FORMULA TO INTERNAL BUFFER
	IF (ILFRM .GT. 0) THEN
	  CALL BCOPY (BBUF(IPTR),BFMU,ILFRM)
	ELSE
	  BFMU(1) = BLANK
	  ILFRM = 1
	END IF
	LERR = .FALSE.
	RETURN
1000	BFMU(1) = BLANK
	ILFRM = 1
	LERR = .TRUE.
	RETURN
	END
