      program main

      parameter(MAXNUM=10000000,MAXQ=100,MAXVAR=100)

      real value(MAXVAR),ind(MAXQ)
	real*8 quant(MAXQ)
	character title(MAXVAR)*40,infl*40,outfl*40
      integer col,nquant


      write(*,*) ' Input file to be coded: '
	read(*,*) infl
      write(*,*) ' Column to be coded: '
	read(*,*) col
	write(*,*) ' Output file with coded data: '
      read(*,*) outfl
      write(*,*) ' Number of thresholds: '
	read(*,*) nquant
	do i=1,nquant
            write(*,100) int(i)
      	read(*,*) quant(i)
	end do
100   format(' Threshold(',i2,') :')
      open(1,file=infl)
      open(2,file=outfl)
      read(1,*)
	read(1,*) nvar
	do i=1,nvar
	      read(1,*) title(i)
	end do
      write(2,*) 'Indicator Coded Data'
      write(2,*) int(col+nquant)
      write(2,*) 'value'
      do i=1,nvar
            write(2,*) title(i)
	end do
	do i=1,nquant
            write(2,*) 'Z',int(i)
      end do
      do i=1,MAXNUM
            read(1,*,end=99) (value(j),j=1,col)
            do q=1,nquant
            if(value(col).lt.quant(q)) then
                  ind(q)=1
                  else
                  ind(q)=0
            end if
            end do
            write(2,101) (value(j),j=1,col),(int(ind(q)),q=1,nquant)
      end do
101   format(<col>(f12.5),<nquant>(i2))
99    continue
      close(1)
      close(2)
      end
