fundamental for-loop question.

In the follwing loop:

for(i=0;i<(*Env).Nfreq;i=i+1)
PRS2 = 0.0;

The execution of the program skips completely over it. It does not execute even once. I used the nemiver debugger and put my cursor on the two variables and they are

i=705286624
(*Env).Nfreq = 5

Now as I said it does not execute even once. So what is going on? It seems that i=0 would be set and the the program’s execution would start in the loop. It does not.

I am not sure how n becomes equal to 705286624, but it should not matter. This is really a gcc programming problme not even a pgcc problem. However, I must know why this happens.

Any help appreciated. Thanks in advance.

Newport_j

Hi Newport_j,

Is this optimized code that you’re debugging? Most likely the compiler idiom recognition will be applied here and the loop would be replaced with a call to memset/bzero. The compiler feedback messages (-Minfo) will tell you if this loop was replaced. Also “i” would be put in a register so what’s shown in memory for “i” will be junk.

  • Mat

I think that I know the probelm here. I compiled with optimization level 0 and I used the pgcc compiler. I also used the nemiver debugger to step through the code and to look at the variables, by putting my cursor on them.

This did not happen when I compiled with gcc and then used the nemiver debugger. I guess if I compile with pgcc then I should use only the PGI debugger to step through the code. Maybe there is an incompatibility between pggc -g and nemiver, that does not exist with gcc -g and nemiver?

Thanks in advance.

Newport_j

Maybe there is an incompatibility between pggc -g and nemiver, that does not exist with gcc -g and nemiver?

I’ve never used nemiver so don’t know, but any DWARF 2 compliant debugger should be able to debug a PGI compiled exe.

  • Mat