c     pos2xyz
c
c     converts unformatted post file to ascii or binary xyz file
c
      character*4 idd(2)
      character*56 name,name1
      character*1 ans
      dimension z(30)
      data icount/0/
      write(6,1000)
 1000 format(' enter input file name: '$)
      read(5,1100) name
      write(6,1050)
 1050 format(' enter output file name: '$)
      read(5,1100) name1
 1100 format(a)
710   print*,'Enter channel desired (1 to 6):'
      read*,iz
      if(iz.lt.1.or.iz.gt.6)go to 710
      iz=iz+2
720   print*,'Want ascii or binary xyz output file (a or b):'
      read(5,1100)ans
      mode=0
      if(ans.eq.'a')mode=1
      if(ans.eq.'b')mode=2
      if(mode.eq.0)go to 720
      open(8,file=name,status='old',form='unformatted')
      if(mode.eq.1)open(9,file=name1,form='formatted',status='unknown')
      if(mode.eq.2)open(9,file=name1,form='unformatted',
     & status='unknown')
   10 read(8,end=15) idd,(z(i),i=1,8)
      goto(20,30),mode
20    write(9,21) z(1),z(2),z(iz)
21    format(3e16.5)
      icount=icount+1
      go to 10
30    write(9)z(1),z(2),z(iz)
      icount=icount+1
      go to 10
   15 close(8)
      print *,icount,' records converted'
      stop
      end
