A refinement and coarsening indicator algorithm for finding sparse solutions of inverse problems