c       program sak2prof
c       written by Jeff Phillips
	dimension id(14),pgm(2),x(2000),obs(2000),z(2000)
	character*50 ifile,ofile,ifile2
        data zil/0.0/
        data id/14*'    '/,pgm/'sak2','prof'/
c
        print 16,' ascii input file: '
16	format(1x,a,$)
	read (5,10) ifile
10	format (a50)
        open (10,file=ifile,form='formatted',status='old')
        nc=0
40      nc=nc+1
        read(10,*,end=41) x(nc),z(nc),obs(nc)
        z(nc)=z(nc)*1000.
        go to 40
41      nc=nc-1
        print 16,' binary profile output file: '
	read (5,10) ofile
        open (11,file=ofile,form='unformatted',status='new')
        nr=1
        nz=1
        xo=x(1)
        dx=x(2)-x(1)
        yo=0.
        dy=0.
        write (11) id,pgm,nc,nr,nz,xo,dx,yo,dy
        print 16,' binary altitude file:'
	read (5,10) ifile2
        open (12,file=ifile2,form='unformatted',status='new')
        write (12) id,pgm,nc,nr,nz,xo,dx,yo,dy
        write(11) zil,(obs(i),i=1,nc)
        write(12) zil,(z(i),i=1,nc)
999	stop
	end
