3 ! Tests functionality of recursive allocatable derived types.
9 type(stack), allocatable :: next
14 ! Here is how to add a new entry at the top of the stack:
15 type (stack), allocatable :: top, temp, dum
20 if (top%index .ne. 3) call abort
23 if (top%index .ne. 2) call abort
27 subroutine output (arg)
28 type(stack), target, allocatable :: arg
29 type(stack), pointer :: ptr
31 if (.not.allocated (arg)) then
32 print *, "empty stack"
38 do while (associated (ptr))
39 print *, ptr%index, " ", ptr%value
46 if (allocated (top)) then
54 call move_alloc(top,temp%next)
55 call move_alloc(temp,top)
58 call move_alloc(top%next,temp)
59 call move_alloc(temp,top)