      program resort
      double precision col(1:13),pc,n,tmp
      character filename*99
      integer i,j,k
      integer function iargc

      call inarg(n,filename)

      n=1.0d3
      pc=3.085678d18
      write(*,*) "   z(cm)   A_V_eff      H         H2       C+
     & C        CO        O         O2        CH       OH        e"
      
      open(UNIT=1,file=filename,status="old")
      open(UNIT=3,file="av.basis.new", status="old")
      do j=1,5
         read(1,*)
      end do
      read(3,*) 
  5   read(1,*,err=10) (col(i),i=1,12)
      read(3,*)col(13),tmp
      col(2)=col(2)*pc
      do j=3,12
        col(j)=n*10**col(j)
      enddo
      write(*,'(12(1pe10.3))')col(2),col(13),col(4),col(5),col(9),
     &     col(6),col(8),col(10),col(12),col(7),col(11),col(3)
      goto 5
  10  close(1)
      end

      subroutine inarg(n,filename)

      integer function iargc
      integer argnum
      double precision n
      character progname*20, filename*99
      character*20 infile
      logical ex
      argnum=iargc()
      call getarg(0,progname)
      proglen= index(progname,' ')  - 1
      if(argnum.ne.1) then
         write(*,*)"USAGE:"
         write(*,*)progname(1:proglen),"datafile "
         write(*,*)
         stop
      end if
      call getarg(1,filename)
      inquire(file=filename, exist=ex)
      if (.not. ex) then
         write(*,*) "ERROR: ",filename,"  not found !"
         write(*,*) "Please check name and path."
         stop
      end if
      return

      end
