     	SUBROUTINE WRWRIG
C
C  PROGRAMMER:  R. L. SNYDER
C		ALFRED UNIVERSITY,  JUNE-1987
C
C	THIS ROUTINE WRITES OUT A RIGAKU RAW DATA FILE
C	FROM THE COMMON BLOCKS
C   THIS IS FOR THE ASCII VERSION OF RIGAKU'S FILES.  THE 
C   DEFAULT WILL BE THE BINARY VERSION
C
     	INCLUDE 'FILECONV.CBS'
     	INTEGER*2 ITIT(40)
     	EQUIVALENCE (ITIT,SLID)

     	CLOSE( UNIT=IOUT )
     	OPEN( UNIT=IOUT, FILE=FILOUT, STATUS='NEW',
     	1 FORM='FORMATTED', ERR=888 )
C
C  WRITE THE FILE HEADER INFORMATION...
C
     	WRITE(IOUT,1,ERR=888) FILOUT
1	FORMAT(A32)
     	WRITE(IOUT,2,ERR=888) ITIT
2	FORMAT(1X,40A2)
     	WRITE(IOUT,3,ERR=888) DANG(1),DANG(2),DANG(3),DANG(10)
3	FORMAT(1X,F7.3)
     	WRITE(IOUT,4,ERR=888) WAVE(IELE,3)
4	FORMAT(1X,F8.5)
     	WRITE(IOUT,2,ERR=888) NPTS
5	FORMAT(1X,I5)
C
C  WRITE THE INTENSITY DATA...
C
     	DO I=1, NPTS
     	   WRITE(IOUT,6,ERR=888) YOBS(I)
6	FORMAT(1X,F8.1)
     	ENDDO
     	GOTO 999

888	IERR = 1
999	RETURN
     	END
