You can show structures—Fortran 95 derived types—and pointers with dbx.
demo% f95 -o debstr -g DebStruc.f95
demo% dbx debstr
(dbx) stop in main
(2) stop in main
(dbx) list 1,99
1 PROGRAM DebStruPtr! Debug structures & pointers
Declare a derived type.
2 TYPE product
3 INTEGER id
4 CHARACTER*16 name
5 CHARACTER*8 model
6 REAL cost
7 REAL price
8 END TYPE product
9
Declare prod1 and prod2 targets.
10 TYPE(product), TARGET :: prod1, prod2
Declare curr and prior pointers.
11 TYPE(product), POINTER :: curr, prior
12
Make curr point to prod2.
13 curr => prod2
Make prior point to prod1.
14 prior => prod1
Initialize prior.
15 prior%id = 82
16 prior%name = "Coffee Cup"
17 prior%model = "XL"
18 prior%cost = 24.0
19 prior%price = 104.0
Set curr to prior.
20 curr = prior
Print name from curr and prior.
21 WRITE ( *, * ) curr%name, " ", prior%name
22 END PROGRAM DebStruPtr
(dbx) stop at 21
(1) stop at "DebStruc.f95":21
(dbx) run
Running: debstr
(process id 10972)
stopped in main at line 21 in file "DebStruc.f95"
21 WRITE ( *, * ) curr%name, " ", prior%name
(dbx) print prod1
prod1 = (
id = 82
name = "Coffee Cup"
model = "XL"
cost = 24.0
price = 104.0
)
|
Above, dbx displays all fields of the derived type, including field names.
You can use structures—inquire about an item of an Fortran 95 derived type.
Ask about the variable
(dbx) whatis prod1
product prod1
Ask about the type (-t)
(dbx) whatis -t product
type product
integer*4 id
character*16 name
character*8 model
real cost
real price
end type product
|
dbx displays the contents of a pointer, which is an address. This address can be different with every run.
(dbx) print prior
prior = (
id = 82
name = ’Coffee Cup’
model = ’XL’
cost = 24.0
price = 104.0
)
|