       subroutine ebrckt(n,x,xi,nb,ib)
	  
c***********************************************************************
c      Extended BRaCKeT subroutine
c     (bracketting with non uniform ordered data)
c      Written by Orlando Camargo Rodriguez
c      orodrig@ualg.pt
c      Universidade do Algarve
c      Physics Department
c      Signal Processing Laboratory
c      Faro, 25/11/2010 at 13:30
c*********************************************************************** 

       integer*4 ib(51)
       integer*4 i,nb
       
       real*8 x(n)
       real*8 xi,a,b

       ib(1) = 0
       nb    = 0
       
       do i = 1,n-1

           a = min(x(i),x(i+1))
	   b = max(x(i),x(i+1))

	   if ((xi.ge.a).and.(xi.lt.b).and.(nb.lt.51)) then
	   nb = nb + 1
	   ib(nb) = i
	   end if

       end do

       return

       end 
