     	SUBROUTINE RDI05A
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY   FEB-1987
C
C	THIS ROUTINE READS FROM A DIFFRAC-5 (ALFRED) DIFILE
C	AND STORES IN THE CORRESPONDING COMMON BLOCKS
C
     	INCLUDE 'FILECONV.CBS'
     	CHARACTER IQS*1, TEXT*9

     	CLOSE( UNIT=IINP )
     	OPEN( UNIT=IINP, FILE=FILINP, STATUS='OLD', FORM='FORMATTED',
     	1 CARRIAGECONTROL='LIST', READONLY, ERR=888 )

     	DO I=1, 7	!SKIP 7 LINES
     	   READ(IINP,1000,ERR=777,END=777) TEXT(1:1)
     	ENDDO
1000	FORMAT(A)
C
C  READ THE FILE HEADER INFORMATION...
C
     	READ(IINP,1001,ERR=777,END=777) SLID
1001	FORMAT(11X,20A4)
C     	write(6,1001) slid
     	READ(IINP,1002,ERR=777,END=777) TEXT(1:9)
1002	FORMAT(12X,A9)
     	DATM = DATCOD( TEXT(1:9) )
     	READ(IINP,1000,ERR=777,END=777) TEXT(1:1)	!SKIP 1 LINE
     	READ(IINP,1003,ERR=777,END=777) BANG(1),BANG(10)
1003	FORMAT(16X,F9.4,18X,F7.2)
     	READ(IINP,1003,ERR=777,END=777) BANG(2)
     	READ(IINP,1003,ERR=777,END=777) BANG(3)
C     	write(6,1003) bang(1)
C     	write(6,1003) bang(2)
C     	write(6,1003) bang(3)
C     	write(6,1003) bang(10)
     	iele = 4
C
C  SEARCH FOR THE BEGINNING OF PEAK LIST...
C
     	DO I=1, MNK
     	   READ(IINP,1000,ERR=777,END=777) TEXT(1:4)
     	   IF( TEXT(1:4).EQ.'PEAK' .OR. TEXT(1:4).EQ.'peak' ) GOTO 100
     	ENDDO
     	GOTO 777		!WRONG FILE FORMAT ASSUMED
C
C  READ THE PEAK INFORMATION...
C
100	DO I=1, MNK

     	READ(IINP,1100,ERR=777,END=111) ID, F2TH(I), IQS, FDSP(I),
     	1 RELA(I), DUMY, AREA(I,JRES), FWHM(I)
1100	FORMAT(I3,F11.5,A1,F8.3,F8.2,10X,F6.4,F9.1,F9.4)
C     	write(6,1100) ID, F2TH(I), IQS, FDSP(I),
C     	1 RELA(I), DUMY, AREA(I,JRES), FWHM(I)
     	
     	C2TH(I) = F2TH(I)
     	CDSP(I) = FDSP(I)
     	if(area(i,jres) .eq.0.0) area(i,jres) = rela(i)
     	PHGH(I) = AREA(I,JRES)
     	PHKL(1,I) = 0
     	PHKL(2,I) = 0
     	PHKL(3,I) = 0
     	IF( IQS.NE.'*' ) PEAK(I) = 'KA1'
     	IF( IQS.EQ.'*' ) PEAK(I) = 'KA2'
     	   FWHM(I) = .1

     	ENDDO
     	NPKS = MNK
     	GOTO 999
111	NPKS = I - 1
     	GOTO 999
777	IERR = 1
     	GOTO 999
888	IERR = 2
999	RETURN
     	END
