Hi Folks,
I posted a few messages last night about how to use GDB to inspect local entries of a Fortran vector. I have cleaned up the instructions a little bit more and also added a tip on how to look at the nth entry of the array, and thought I'd do a new post with
this.
Given a Vec r, first examine (using the gdb 'x' command — see the gdb documentation for what the format string means) the location in memory that its '%data' member points to:
(gdb) x/1xg *((Vec) r)%data
0xaaaaab9d2550: 0x0000aaaaab9d1bd0
Then use the command x/Nfg to print N entries (10 in this example) starting at that above address:
(gdb) x/10fg 0x0000aaaaab9d1bd0
0xaaaaab9d1bd0: 1.7507793726584433e-06 -4.4102733314192253e-09
0xaaaaab9d1be0: -4.3615950165322133e-09 -4.3130382801110155e-09
0xaaaaab9d1bf0: -4.2646017652029213e-09 -4.2162841220914224e-09
0xaaaaab9d1c00: -4.1680840119196081e-09 -4.1200000795427596e-09
0xaaaaab9d1c10: -4.0720309933405922e-09 -4.0241754108366118e-09
You can also inspect the nth (using Fortran indexing) element of the array; just use simple address arithmetic and add multiples of 8 (since we are examining a real*8 array here) using the command "x/1fg <address> + 8*(n-1)". So to examine the 10th element
of the array:
(gdb) x/1fg 0x0000aaaaab9d1bd0 + 8*9
0xaaaaab9d1c18: -4.0241754108366118e-09
--Richard
P.S. I feel like we ought to keep a set of tips on debugging PFLOTRAN somewhere in the developer documentation. I have been re-learning how to use GDB with PFLOTRAN and its modern Fortran elements and making some notes. I think I'll eventually have a useful
document to share. Do Glenn or others have thoughts on where this should go?