Fortran print allocatable array in gdb

前端 未结 3 1412
梦谈多话
梦谈多话 2020-11-29 12:58

I\'m adding some functionality on to an open-source scientific code. I work with a lot of allocatables, but I\'m having some trouble printing them properly. For example, I d

3条回答
  •  天涯浪人
    2020-11-29 13:21

    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

提交回复
热议问题