      subroutine rootst(anal, unstab, npoles, ifirst, ilast)
      character * 64  anal,unstab
      real * 4 a(40),y(36)
      logical flag
      ndata = 4
      nlocs = (npoles + ndata) * 4
      nall = npoles + ndata
145   format(a20,x,a20,x,i4,x,i4,x,i4)
      print 145,anal,unstab,npoles,ifirst,ilast
	
        open(unit=18,file=anal,status='old',access='direct',
     &  form='unformatted',recl=nlocs)
	open(unit=19,file=unstab,status='old',
     &	access='direct',form='unformatted',recl=4)
      nbad=1
      do 1000 j = ifirst,ilast 
      read(18,rec=j,end=999) (a(jx),jx=1,nall) 
      do 1601 ii=1,npoles
      y(ii)= -a(nall+1-ii)
1601  continue
      call stable(y,npoles,flag)
      if(flag) goto 1000
      write(19,rec=nbad)  j
      nbad = nbad + 1
1000  continue
999   return 
      end
	subroutine stable(frame,n,flag)
	dimension frame(n)
	dimension a(50,50),rk(49)
	logical flag
	flag = .true.
	a(1,n+1)=1.
	do 10 i = 1,n
10	a(i+1,n+1) = frame(i)
	do 25 mm = 1,n
		m = n - mm + 1
		rk(m) = a(m+1,m+1)
		if(abs(rk(m)).lt.1.) goto 20
		flag = .false.
		return
20	do 25 i = 1,m
25	a(i,m) = (a(i,m+1)-rk(m)*a(m-i+2,m+1))/(1.-rk(m)**2)
	return
	end
