	logical*4 function mafile_write(fname,
     *					title,
     *					tdate,
     *					scaler_file,
     *			      		region_file,
     *					m_info,
     *					lowsignal,
     *					coms,
     *			       		ncols,npts,
     *					offsets,
     *					weights,
     *					labels,
     *					d)
	parameter (ncolmx= 100)
	parameter (nptmax=4096)
	character*80 fname
	character*38 title ,tdate,scaler_file,region_file
	character*78 m_info
	character*38 lowsignal
	character*78 coms(6)
	character*18 labels(ncolmx)
	integer*4    ncol,npts
	real*4        offsets(ncolmx)
	real*4        weights(ncolmx)
	real*4       d(nptmax,ncolmx)
	mafile_write=.true.
	open (1,file=fname,status='new',blank='zero'
     * ,carriagecontrol='list',form='formatted',recl=10240)
	write(1,'(a)')title
	write(1,'(a)')tdate
	write(1,'(''PTS:'',i11,'' COLS:'',i11)')npts,ncol
	write(1,'(a)')scaler_file
	write(1,'(a)')region_file
	write(1,'(a)')m_info
	write(1,'(a)')lowsignal
	do i=1,6
	write(1,'(a)')coms(i)
	end do
	write(1,'(a)')
	write(1,'(''Weights: '')')
	write(1,'(<ncol>(1x,f14.3))')(weights(j),j=1,ncol)
	write(1,'(''Offsets: '')')
	write(1,'(<ncol>(1x,f14.3))')(offsets(j),j=1,ncol)
	write(1,'(''Data: '')')
	do j=1,ncol
	write(1,'(a)')labels(j)
	end do
	write(1,'(a)')
	do i=1,npts
	write(1,'(<ncol>(1x,f14.3))')(d(i,j)    ,j=1,ncol)
	end do
	close(1)
	end

