Can GDB be used to print values of allocatable arrays of a derived type in Fortran 90?

Neal Kruis
Wed May 8 19:54:00 GMT 2013

GDB users,

I just posted this question to Stack Overflow:

I have the following data structure in a Fortran90 program:

TYPE derivedType
  CHARACTER(100)     :: name      = ' '
  INTEGER            :: type      = 0
  REAL(KIND(1.0D0))  :: property  = 0.0
END TYPE derivedType

TYPE (derivedType), ALLOCATABLE, DIMENSION(:) :: arrayOfDerivedTypes

When I try to debug and print values in GDB like:

(gdb) p arrayOfDerivedTypes(1)%name

I get non-sensical values (often stings of zeros, forward slashes and
letters), or completely wrong values (like arrayOfDerivedTypes(1)%name
= 9, when I know that it is = 2). How can I get GDB to print the
correct values?


I am aware of:

this bug:
this branch of GDB:
and this blog post on printing allocatable arrays:

I don't want to go through the trouble of compiling a separate branch
of GDB to test if it solves this problem if someone already knows that
it won't or if there is a better solution available.

Please let me know (either here or on Stack Overflow) if you have any

Neal Kruis
Big Ladder Software

More information about the Gdb mailing list