subroutine ctrest(lp,lev,p)
!-------------------------------------------------------------------------
! this is a poor substitute of a true ctrest routine
! instead of truncation error estimate it selects regions with
! amplitude value grater than a treshold at given level
!------------------------------------------------------------------------
use types
use amr
type(LEVEL_INFO), dimension(maxlev) :: lp
integer(I4B) lev
type(GF3TL), pointer :: p

real(SP),dimension(maxlev) :: treshold

treshold=0
treshold(1)=0.10
do i=2,maxdim
treshold(i)=treshold(i-1)+0.05
enddo

p%gfcn(estre)%tlev(1)%data = 0.0
where(p%gfcn(ampl)%tlev(1)%data > treshold(lev)) &
 p%gfcn(estre)%tlev(1)%data = 10000.0

write(68,*)  p%gfcn(estre)%tlev(1)%data(4,:,1),'---'

return
end subroutine ctrest 
