Difference between revisions of "Debugging"

From SourceWiki
Jump to navigation Jump to search
Line 2: Line 2:
 
'''Debugging you program: Various techniques'''
 
'''Debugging you program: Various techniques'''
 
=Getting the content for the practical=
 
=Getting the content for the practical=
=example 2=
+
=A Common Bug: going beyond the boundaries on array=
  
First using g95 & the Sun compiler...we see the loop stop as soon as we're beyond the boundaries of the 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 the Portland group compiler..not so lucky!

Revision as of 18:54, 29 February 2008

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).