C---------------------------------------------------------------------------
	SUBROUTINE WRITNIST(nfil,filename,STATUS)
C---------------------------------------------------------------------------
C	Write out a file in NIST (NBS) Format
C
C---------------------------------------------------------------------------
	INTEGER STATUS
	CHARACTER*(*) filename

	include 'shared$common'

	OPEN(UNIT=OUT,NAME=filename,TYPE='NEW',FORM='FORMATTED',
	1	CARRIAGECONTROL='LIST',err=99,defaultfile='.NBS')
	WRITE (OUT,'(a)',err=3) ATITLE(nfil)
	NPT = NPOINT(nfil)
	WRITE(OUT,16,err=3) date(1,nfil),date(2,nfil),date(3,nfil),
	1	INST(nfil),SOURCE(nfil),IRAD(nfil),WAVE(nfil),NPT,
	2	START(nfil),DELTA(nfil),FINISH(nfil)
16	FORMAT(1X,I2,'/',I2,'/',I2,5X,A2,1X,A2,5X,A2,5X,F8.5,/,
     1 1X,I5,3F10.3)
	WRITE(OUT,18,err=3) (B(I,nfil),I=1,NPT)
18	FORMAT (10F8.2)
	CLOSE(UNIT=OUT)
	STATUS = 0
	RETURN

99	STATUS = 1
	RETURN

3	STATUS = 2
	CLOSE(UNIT=OUT)
	RETURN
	END
