subroutine ctrest(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
integer(I4B) lev
type(GF3TL), pointer :: p

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

treshold=0
treshold(1)=0.1
treshold(2)=2.0
treshold(3)=2.0

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


return
end subroutine ctrest 
