|
From: xunxun <xun...@gm...> - 2014-08-24 04:28:59
|
于 2014/8/23 10:32, 孔涛 写道: > Hi, everyone. How to print fortran allocatable array in GDB? For > example, the source file reads > -- > > program main > implicit none > real,dimension(5) :: a > real,dimension(:),allocatable :: b > > allocate(b(10) ) > > call random_number(a) > call random_number(b) > > deallocate(b) > end program > > > -- > I use 'gfortran -g arr.f90 ' and use 'gdb ./a.exe' Then I got the > following debug info > --------------------------------- > > (gdb) b 6 > (gdb) b 10 > (gdb) r > Starting program: D:\Documents\Projects\test/a.exe > [New Thread 6844.0x1a40] > > Breakpoint 1, MAIN__ () at array.f90:6 > 6 allocate(b(10) ) > (gdb) p a > $8 = (3.76478451e-039, 1.54142831e-044, 1.03794626e-038, > -nan(0x7ffffe), 0) > (gdb) p b > $9 = (0) > (gdb) c > Continuing. > > Breakpoint 2, MAIN__ () at array.f90:11 > 11 deallocate(b) > (gdb) p a > $10 = (0.997559547, 0.566824675, 0.965915322, 0.747927666, > 0.367390871) > (gdb) p b > $11 = (0) > (gdb) > ---------------------------------------- > > So why? How to show the variable b? > > > > > -- > Have a nice day! > > Kayneo > > ---- > I saw, I came, I conquered! > > You should use archer gdb, which support fortran dynamic array. -- Best Regards, xunxun |