Reputation: 89
I am a beginner in gdb under Linux. When I try to debug my program compiled with ifort and -c, -g options, I would like to check bound of several arrays. Unfortunately I cannot find in Google any information how to print array bound with gdb debugger.
[update]
I have a module with allocatable,public array, which is allocated correctly in a subroutine from this module.
In main program (after calling the subroutine) I try to use whatis
and see (*,*)
instead of shapes.
Upvotes: 4
Views: 2930
Reputation: 50937
You can use the whatis command to view array bounds: e.g.,
program arr
real, dimension(2:41) :: arr1
real, allocatable, dimension(:), target :: arr2
integer :: i
allocate(arr2(40))
forall(i = 2:41) arr1(i) = i
arr2 = arr1 + 2
print *, arr1(2)
deallocate(arr2)
end program are
Running gives
$ gfortran -g foo.f90
$ gdb a.out
[...]
(gdb) break 11
Breakpoint 1 at 0x400b01: file foo.f90, line 11.
(gdb) run
[...]
Breakpoint 1, arr () at foo.f90:11
11 print *, arr1(2)
(gdb) whatis arr1
type = real(kind=4) (2:41)
(gdb) whatis arr2
type = real(kind=4) (40)
Upvotes: 6