c*****PROGRAN PR2XYZ
c*****FORMS AN X,Y,Z FILE FROM FILE PROFILE.DAT
      parameter(max=640)
      dimension x(max),y(max),z(max)
      character*16 fmt
      character*40 ofile
      character*80 dum
      write(*,'(a\)') ' enter output file name:'
      read(*,'(a)') ofile
      open(11,file=ofile,status='unknown')
      open(10,file='profile.dat',status='old')
10    read(10,'(a)',end=50) dum
      read(10,'(a)') dum
      read(10,*) np,xs,dx,ys,dy
      do 20 i = 1,np
      x(i) = xs + (i-1) * dx
      y(i) = ys + (i-1) * dy
20    continue
      inc = np/5
      left = np - (inc *5)
      write(fmt,'(''('',i1,''e15.7)'')') left
      k = 1
      do 30 i =1,inc
      read(10,*) z(k),z(k+1),z(k+2),z(k+3),z(k+4)
      k = k + 5
30    continue
      if(left.ne.0) read(10,fmt) (z(j),j=k,np)
      do 40 i = 1,np
      write(11,*) x(i),y(i),z(i)
40    continue
      go to 10
50    stop
      end
