Sample program to demostrate the list* module. This modules port lists to fortran 2003.
10 type(integerlist) :: list_int
11 type(reallist) :: list_real
12 type(characterlist) :: list_char
13 type(mixlist) :: list_mix
15 class(*),
pointer :: val
23 type(mytype) :: ir=mytype(3,6.)
26 character(len=10) :: char10
28 type(charmylen) :: mychar
34 print *,
"display real list" 40 call list_char%append(
"hello world")
41 call list_char%append(
"bye bye baby")
42 print *,
"display char list" 43 call list_char%display()
48 call list_int%append(i)
50 print *,
"display integer list" 51 call list_int%display()
53 call list_int%rewind()
55 do while(list_int%element())
56 values(i) = list_int%current()
60 print *,
"display integer vector from list" 64 values =list_int%toarray()
65 print *,
"display integer vector from list with toarray" 69 call list_int%forward()
71 do while(list_int%element())
72 values(i) = list_int%current()
76 print *,
"display inverse integer vector from list" 79 print *,
"seek return status =", list_int%seek(3)
80 print *,
"list index 3 =", list_int%current()
83 print *,
"delete(5) return status =", list_int%delete(5)
84 print *,
"display integer vector with 5 removed" 85 call list_int%display()
87 print *,
"display reverse integer vector with 5 removed" 88 call list_int%forward()
89 do while(list_int%element())
90 print*,
"index:",list_int%currentindex(),
" value:",list_int%current()
95 print *,
"delete(1) return status =", list_int%delete(1)
96 print *,
"display integer vector with 1 removed" 97 call list_int%display()
99 n=list_int%countelements()
100 print *,
"number of list elements=",n
102 print *,
"delete(",n,
")" 103 print *,
"return status =", list_int%delete(n)
104 print *,
"display integer vector with last removed" 105 call list_int%display()
107 print *,
"delete return status =", list_int%delete()
108 print *,
"display integer vector with everithings removed" 109 call list_int%display()
125 mychar%char10=
"ciao ciao" 128 print *,
"display mix list" 131 print *,
"print mix list with cast" 136 select type (x => val)
141 type is (doubleprecision)
143 type is (
integer(kind=int_b))
145 type is (
character(*))
157 end program example_list