Fortran print allocatable array in gdb

Use

(gdb) print *((real *)A+m)@n

where A is the array, m is the shift in the position (no need to write +m in the case m=0) and n is the number of elements that you want to print. If you’re working with double precision reals then replace real by real_8. Also, for integers replace real by int, and for long integers use long_int. Credit goes to http://numericalnoob.blogspot.fr/2012/08/fortran-allocatable-arrays-and-pointers.html

Leave a Comment