3 ! Tests functionality of recursive allocatable derived types.
6 type(recurses), allocatable :: c
7 integer, allocatable :: ia
10 type(recurses), allocatable, target :: a, d
11 type(recurses), pointer :: b
15 ! Check chained allocation.
24 call move_alloc (d, a%c%c)
26 if (a%ia .ne. 1) call abort
27 if (a%c%ia .ne. 2) call abort
28 if (a%c%c%ia .ne. 3) call abort
30 ! Check that we can point anywhere in the chain
32 if (b%ia .ne. 3) call abort
34 if (b%ia .ne. 2) call abort
36 ! Check that the pointer can be used as if it were an element in the chain.
37 if (.not.allocated (b%c)) call abort
39 if (.not.allocated (b%c)) allocate (b%c)
41 if (a%c%c%c%ia .ne. 4) call abort
43 ! A rudimentary iterator.
45 do while (associated (b))
49 if (total .ne. 10) call abort
51 ! Take one element out of the chain.
52 call move_alloc (a%c%c, d)
53 call move_alloc (d%c, a%c%c)
54 if (d%ia .ne. 3) call abort
57 ! Checkcount of remaining chain.
60 do while (associated (b))
64 if (total .ne. 7) call abort
66 ! Deallocate to check that there are no memory leaks.