bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't Print Two Dimensional Array Element for Fortran


From: Ingo Krabbe
Subject: Re: Can't Print Two Dimensional Array Element for Fortran
Date: Fri, 16 Apr 2010 23:27:44 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Mar 28, 2010 at 10:50:38PM -0500, lyle lyle wrote:
> Hi Guys,
> 
> I write code in Fortran and found that I couldn't print an element's value
> if the element wasn't in the first column. For example,
> 
> There is an array A and its size is 5x3. In gdb, I can get its first column
> elements' value with the command: p A(1, 1), until A(5, 1), because the
> array is saved in memory according to columns. However, if I want to get
> A(1, 2), then gdb showed the error message: no such vector element.
> 
> I searched online and found that another person had reported this bug,
> https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/500691.
> 
> I confirmed that both the version 6.8 and 7.1 had the same problem.
> 
> I use gfortran 4.4.3, gdb 7.1, and Debian squeeze.
> 
> Is there a patch for this bug? Can someone help me fix  this problem?
> 
> Thanks a lot,
> Lyle

>       program main
>       real a(5, 3)
>       do 12 i=0,4
>       do 12 j=1,3
>       a(i+1,j)=i*3+j
> 12    continue
>       write(*,*)a(2,3)
>       end

Somehow I feel I gave a workaround for this problem before: Each array
regardless of its dimension can be unfolded to a one dimensional array by
calculating the array element position. For your (n,m) dimensions you will get
the one dimensional position k for coordinates (i,j) by k=n*j+i (counted from 
0!).

I haven't tried this and you should test the exact positons, but thats the way
it should work.

bye ingo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]