I have collected some of my experience on debugging numerical codes here: https://code.google.com/p/dealii/wiki/FrequentlyAskedQuestions deal.II FAQ: debugging. I don't know if that would have helped you in this particular case, but it may in others.
updated the link inside the answer that was given in the comments for convenience.
Anton Menshov
- 8.7k
- 7
- 41
- 94