     	SUBROUTINE RRW05A
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY   FEB-1987
C
C	THIS ROUTINE READS FROM A DIFFRAC-5 (ALFRED) RAW DATA FILE
C	AND STORES IN THE CORRESPONDING COMMON BLOCKS
C
     	INCLUDE 'FILECONV.CBS'
     	CHARACTER DAY*9, TIM*8
C
C  TRY TO OPEN THE INPUT FILE AS UNFORMATTED FILE FIRST...
C
     	CLOSE( UNIT=IINP )
     	OPEN( UNIT=IINP, FILE=FILINP, STATUS='OLD',
     	1 FORM='UNFORMATTED', READONLY, ERR=888 )
C
C  READ THE FILE HEADER INFORMATION...
C
     	READ(IINP,ERR=111,END=777) SLID
     	READ(IINP,ERR=111,END=777) DAY, TIM
     	DATM = DATCOD( DAY )
     	TIMM = TIMCOD( TIM )
     	READ(IINP,ERR=111,END=777) BANG(1),BANG(2),BANG(3),BANG(10)
C
C  READ THE INTENSITY DATA...
C
     	NPTS = INT((BANG(2)-BANG(1))/BANG(3)+0.1) + 1
     	IF( NPTS.LT.1 ) GOTO 777
     	NLINE = NPTS/10
     	IF( NLINE*10 .LT. NPTS ) NLINE = NLINE + 1
     	DO I=1, NLINE
     	   READ(IINP,ERR=111,END=777) (YOBS(J), J=1+10*(I-1), 10*I)
     	ENDDO
     	GOTO 999
C
C  OPEN THE INPUT FILE AS FORMATTED FILE NEXT...
C
111	CLOSE( UNIT=IINP )
     	OPEN( UNIT=IINP, FILE=FILINP, STATUS='OLD', READONLY,
     	1 FORM='FORMATTED', CARRIAGECONTROL='LIST', ERR=888 )
C
C  READ THE FILE HEADER INFORMATION...
C
     	READ(IINP,1000,ERR=777,END=777) SLID
1000	FORMAT(20A4)
     	READ(IINP,1001,ERR=777,END=777) DAY, TIM
1001	FORMAT(A9,3X,A8)
     	DATM = DATCOD( DAY )
     	TIMM = TIMCOD( TIM )
     	READ(IINP,1100,ERR=777,END=777) BANG(1),BANG(2),BANG(3),BANG(10)
1100	FORMAT(4F10.4)
C
C  READ THE INTENSITY DATA...
C
     	NPTS = INT((BANG(2)-BANG(1))/BANG(3)+0.1) + 1
     	IF( NPTS.LT.1 ) GOTO 777
     	READ(IINP,1200,ERR=777,END=777) (YOBS(I),I=1, NPTS)
1200	FORMAT(10F8.1)
     	GOTO 999

777	IERR = 1
     	GOTO 999
888	IERR = 2
999	RETURN
     	END
