     	SUBROUTINE WRWNIC
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY   FEB-1987
C
C	THIS ROUTINE WRITES OUT A NICOLET RAW DATA FILE
C	FROM THE COMMON BLOCKS
C
     	INCLUDE 'FILECONV.CBS'
     	INTEGER*2 ITIT(40), DATTIM(6), NRNS, IDUM, IBUF(100)
     	EQUIVALENCE (ITIT, SLID)
     	REAL*4 FWAVE(4), DUMY(12), RANGE(9,100)

     	CLOSE( UNIT=IOUT )
     	OPEN( UNIT=IOUT, FILE=FILOUT, STATUS='NEW',
     	1 FORM='UNFORMATTED', ERR=888 )
C
C  INITIALIZE THE FILE HEADER INFORMATION...
C
     	DO I=1, 6
     	   DATTIM(I) = 0
     	ENDDO
     	FWAVE(1) = WAVE(3,IELE)
     	FWAVE(2) = WAVE(1,IELE)
     	FWAVE(3) = WAVE(2,IELE)
     	FWAVE(4) = 0.0
     	DO I=1, 12
     	   DUMY(I) = 0.0
     	ENDDO
     	IDUM = 0
     	NRNS = 1
     	RANGE(1,1) = DANG(1)
     	RANGE(2,1) = DANG(2)
     	RANGE(5,1) = DANG(3)
     	RANGE(7,1) = DANG(10)
     	RANGE(8,1) = NPTS
     	RANGE(9,1) = 1.0
     	DO I=2, 100
     	   DO J=1, 9
     	      RANGE(J,I) = 0.0
     	   ENDDO
     	ENDDO
C
C  WRITE THE FILE HEADER INFORMATION...
C
     	WRITE(IOUT,ERR=888) ITIT, DATTIM, FWAVE, DUMY, DUMY,
     	1 DUMY(1), IDUM, NRNS, RANGE, (RANGE(1,I), I=1,72)
C
C  WRITE THE INTENSITY DATA...
C
     	NRNS = NPTS/100
     	IF( NRNS*100 .LT. NPTS ) NRNS = NRNS + 1
     	IJ = 0
     	DO I=1, NRNS
     	   DO J=1, 100
     	      IJ = IJ + 1
     	      IBUF(J) = YOBS(IJ)
     	   ENDDO
     	   WRITE(IOUT,ERR=888) IBUF
     	ENDDO
     	GOTO 999

888	IERR = 1
999	RETURN
     	END
