     	SUBROUTINE WRWMAC
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY   FEB-1987
C
C	THIS ROUTINE WRITES OUT AN X-RAY RIETVELD RAW DATA FILE
C	FROM THE COMMON BLOCKS
C
     	INCLUDE 'FILECONV.CBS'
     	CHARACTER IQS*1, DAY*9, TIM*8

     	CALL COLORS(1)
     	CALL PUTEXT('Writing the output file... Please wait...',41,24,1)
C
C  WRITE OUT AN ASCII FILE...
C
     	CLOSE( UNIT=IOUT )
     	OPEN( UNIT=IOUT, FILE=FILOUT, STATUS='NEW', ERR=888,
     	1 FORM='FORMATTED', CARRIAGECONTROL='LIST' )

     	WRITE(IOUT,1000,ERR=888) SLID
1000	FORMAT(20A4)
     	WRITE(IOUT,1001,ERR=888) DANG(10)
1001	FORMAT('Raw Data',/,'Count time=',f10.4)
        write(iout,1002)dang(1),dang(2),dang(3)
1002    format('1.5418',/,'1',/,'0',/,'0',/,f10.4,/,f10.4,/,f10.4)
     	WRITE(IOUT,1003,ERR=888) (YOBS(I), I=1, NPTS)
1003	FORMAT(F7.0)
     	GOTO 999

777	IERR = 3		!BAIL OUT
     	GOTO 999
888	IERR = 1
999	RETURN
     	END
