      program mselect
      character*80 line
      character*6  ziffer
      character*60 fname
      dimension ksel(1000),num(1000),n1(1000),n2(1000)
c     ziffer is the key of 6 characters: ex. ap00k2 or am10k2
      write(6,*) 'ziffer? (6-chars key: ex. ap00k2 or am10k2)'
      read(5,'(a6)') ziffer
      write(6,*) 'How many models do you want?'
      read(5,*) nmodel
      write(6,*) 'write down the model No. of',nmodel,
     $' models in increasing order'
      read(5,*) (ksel(j),j=1,nmodel) 
      write(6,*) 'Output file name?'
      read(5,'(a60)') fname
      open (unit=2,file=ziffer//'.lst')
      rewind 2
      kn=0
      do k=1,1000
      read(2,22,end=98) num(k),n1(k),n2(k)
      kn=kn+1
   22 format(3x,i4,2x,2i6)
      end do
   98 knum=kn
      open (unit=3,file=ziffer//'.dat')
      rewind 3
      open (unit=4,file=fname)
      nc=0
      do 1000 i=1,10000000
      read(3,'(a80)',end=999) line
      nc=nc+1
      do 1200 j=1,nmodel
      if(nc.ge.n1(ksel(j)).and.nc.le.n2(ksel(j))) then
      write(4,'(a80)') line
      go to 1000
      end if
 1200 continue
 1000 continue
  999 continue
      close(2) 
      close(3)
      close(4)
      stop
      end
