     	SUBROUTINE RRWRIG
C
C  PROGRAMMER:  R. L. SNYDER
C		ALFRED UNIVERSITY,  JUNE-1987
C
C	THIS ROUTINE READS FROM A RIGAKU RAW DATA FILE
C	AND STORES IN THE CORRESPONDING COMMON BLOCKS
C  THIS IS FOR AN ASCII FILE FORMAT.  THE USUAL RIGAKU FILE IS 
C  BINARY AND WILL BE THE DEFAULT.  THOSE WANTIN ASCII SHOULD 
C  SUBSTITUTE THIS SUBROUTINE AND RELINK.
C
     	INCLUDE 'FILECONV.CBS'
     	INTEGER*2 ITIT(40)
     	EQUIVALENCE (ITIT,SLID)

     	CLOSE( UNIT=IINP )
     	OPEN( UNIT=IINP, FILE=FILINP, STATUS='OLD',
     	1 FORM='FORMATTED', READONLY, ERR=888 )
C
C  READ THE FILE HEADER INFORMATION...
C
     	READ(IINP,1,ERR=777,END=777)
     	READ(IINP,1,ERR=777,END=777) ITIT
1	FORMAT(40A2)
     	READ(IINP,2,ERR=777,END=777) BANG(1)
2	FORMAT(G)
     	READ(IINP,2,ERR=777,END=777) BANG(2)
     	READ(IINP,2,ERR=777,END=777) BANG(3)
     	READ(IINP,2,ERR=777,END=777) BANG(10)
     	READ(IINP,2,ERR=777,END=777) DUMMY
     	READ(IINP,3,ERR=777,END=777) NPTS
3	format(i5)
C
C  READ THE INTENSITY DATA...
C
     	DO I=1, NPTS
     	   READ(IINP,2,ERR=777,END=666) YOBS(I)
     	ENDDO
     	GOTO 999
666	NPTS = I-1
     	IF( NPTS.GT.0 ) GOTO 999
777	IERR = 1
     	GOTO 999
888	IERR = 2
999	RETURN
     	END
