     	SUBROUTINE WRWDBW
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, label*56
*
*     	CALL COLORS(1)
*     	CALL PUTEXT('Write the output file in (A)SCII or (B)INARY <A> ',
*     	1 49, 23, 1 )
*     	READ(5,1000,ERR=777,END=777) IQS
     	CALL COLORS(-1)
     	CALL PUTEXT('Writing the output file... Please wait...',41,24,1)
       
c        TYPE 1003 , (YOBS(I),I=1,100)

        do i=1,14
          j= 4*(i-1) + 1
          label(j:j+3) = slid(i)
        enddo
*     	IF( IQS.EQ.'B' .OR. IQS.EQ.'b' ) GOTO 111
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) DANG(1),DANG(3),DANG(2),label
1000	FORMAT(3f8.2,A56)

     	WRITE(IOUT,1003,ERR=888) (YOBS(I), I=1, NPTS)
1003	FORMAT(8(F7.0,1x))
     	GOTO 999

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