Debugging

From SourceWiki
Revision as of 19:11, 29 February 2008 by GethinWilliams (talk | contribs)
Jump to navigation Jump to search

Debugging you program: Various techniques

Getting the content for the practical

A Common Bug: going beyond the boundaries on array

We will start with a pretty common coding problem: we have an array and a loop which access elements of that array in turn. The problem is that we've made a mistake with our loop and it tries to access elements beyond the boundaries of our array.

Let's take a look and compile up the code using the open-source g95 and gfortran, and compilers.

We get a segmentation fault.

Now the Portland group compiler..not so lucky!

Now using the ifort compiler...different again.

Interesting, huh?

Still using ifort, let's look at the difference when we add:

  • -traceback
  • -CB

to the compilation flags (see Makefile).


Argument Mismatch

The best way to combat this is to put the subroutines into a module.