PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Debugging pgf90 array subscript out of bounds

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
liamg



Joined: 18 Apr 2006
Posts: 1

PostPosted: Tue Apr 18, 2006 12:54 pm    Post subject: Debugging pgf90 array subscript out of bounds Reply with quote

I've compiled a F90 main program with array subscript checking enabled (-Mbounds). I get the following error message at runtime:

0: Subscript out of range for array c (spline_module.f90: 19)
subscript=1, lower bound=1, upper bound=-1073798060, dimension=1

I'm trying to figure out how to use pgdbg to pinpoint the error. Can anyone give me some pointers? I can run the code in pgdbg, but I can't backtrack from the program exit. The subroutine in question executes about 25 times before the error condition occurs.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6146
Location: The Portland Group Inc.

PostPosted: Tue Apr 18, 2006 1:39 pm    Post subject: Reply with quote

Hi liamg,

While you can simply set a break point at this line and then click "continue" 25 times, consider adding a counter to the subroutine which counts the number of times it has been called. Use an if statement to test if the counter has reached 25 and then print something. You can set a breakpoint inside the if statement and skip past the working portions.

A very simple example:
Code:

        program test
        integer i

        do i=1, 30
          call foo()
        end do
        end program test

        subroutine foo
          integer, save :: count

          count = count + 1;
          print *, "SUB COUNT=", count
          if ( count .eq. 25 ) then
            print *, "SET BREAKPOINT HERE"
          end if
       end subroutine foo


Compile your program with "-O0 -g -Mbounds" and run using pgdbg. Set the break point in the if statement, and run the program. Once halted at the breakpoint, type "where" to get a stack trace. The stack trace will tell you who called your subroutine. You can also use "print" to print the contents of the local variables.

My guess is that your subroutine has an assumed shape array as a dummy argument and it is this array that's causing the array bounds error. Since the upper bounds value is garbage, the actual array argument could be corrupt. If the actual array is an Allocatable or Pointer, then it might not have been allocated?

Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group