24#include "../base/base_uses.f90"
33 TYPE private_item_type_routinestat
35 TYPE(routine_stat_type),
POINTER ::
value => null()
36 END TYPE private_item_type_routinestat
39 TYPE private_item_p_type_routinestat
41 TYPE(private_item_type_routinestat),
POINTER :: p => null()
42 END TYPE private_item_p_type_routinestat
47 TYPE(private_item_p_type_routinestat),
DIMENSION(:),
POINTER :: arr => null()
64 res =
ASSOCIATED(
list%arr)
79 INTEGER,
INTENT(in),
OPTIONAL :: initial_capacity
81 INTEGER :: initial_capacity_
83 initial_capacity_ = 11
84 If (
PRESENT(initial_capacity)) initial_capacity_ = initial_capacity
86 IF (initial_capacity_ < 0)
THEN
87 cpabort(
"list_routinestat_create: initial_capacity < 0")
90 IF (
ASSOCIATED(
list%arr))
THEN
91 cpabort(
"list_routinestat_create: list is already initialized.")
94 ALLOCATE (
list%arr(initial_capacity_), stat=stat)
96 cpabort(
"list_routinestat_init: allocation failed")
114 IF (.not.
ASSOCIATED(
list%arr))
THEN
115 cpabort(
"list_routinestat_destroy: list is not initialized.")
119 deallocate (
list%arr(i)%p)
121 deallocate (
list%arr)
139 INTEGER,
intent(in) :: pos
140 IF (.not.
ASSOCIATED(
list%arr))
THEN
141 cpabort(
"list_routinestat_set: list is not initialized.")
144 cpabort(
"list_routinestat_set: pos < 1")
146 IF (pos >
list%size)
THEN
147 cpabort(
"list_routinestat_set: pos > size")
149 list%arr(pos)%p%value =>
value
165 IF (.not.
ASSOCIATED(
list%arr))
THEN
166 cpabort(
"list_routinestat_push: list is not initialized.")
168 IF (
list%size ==
size(
list%arr))
THEN
169 CALL change_capacity_routinestat (
list, 2*
size(
list%arr) + 1)
173 ALLOCATE (
list%arr(
list%size)%p, stat=stat)
175 cpabort(
"list_routinestat_push: allocation failed")
193 INTEGER,
intent(in) :: pos
196 IF (.not.
ASSOCIATED(
list%arr))
THEN
197 cpabort(
"list_routinestat_insert: list is not initialized.")
200 cpabort(
"list_routinestat_insert: pos < 1")
202 IF (pos >
list%size + 1)
THEN
203 cpabort(
"list_routinestat_insert: pos > size+1")
206 if (
list%size ==
size(
list%arr))
THEN
207 call change_capacity_routinestat (
list, 2*
size(
list%arr) + 1)
211 do i =
list%size, pos + 1, -1
215 ALLOCATE (
list%arr(pos)%p, stat=stat)
217 cpabort(
"list_routinestat_insert: allocation failed.")
219 list%arr(pos)%p%value =>
value
235 IF (.not.
ASSOCIATED(
list%arr))
THEN
236 cpabort(
"list_routinestat_peek: list is not initialized.")
238 IF (
list%size < 1)
THEN
239 cpabort(
"list_routinestat_peek: list is empty.")
261 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
262 cpabort(
"list_routinestat_pop: list is not initialized.")
264 IF (
list%size < 1)
THEN
265 cpabort(
"list_routinestat_pop: list is empty.")
284 IF (.not.
ASSOCIATED(
list%arr))
THEN
285 cpabort(
"list_routinestat_clear: list is not initialized.")
289 deallocate (
list%arr(i)%p)
306 INTEGER,
intent(in) :: pos
309 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
310 cpabort(
"list_routinestat_get: list is not initialized.")
313 cpabort(
"list_routinestat_get: pos < 1")
315 IF (pos >
list%size)
THEN
316 cpabort(
"list_routinestat_get: pos > size")
319 value =>
list%arr(pos)%p%value
333 INTEGER,
intent(in) :: pos
336 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
337 cpabort(
"list_routinestat_del: list is not initialized.")
340 cpabort(
"list_routinestat_det: pos < 1")
342 IF (pos >
list%size)
THEN
343 cpabort(
"list_routinestat_det: pos > size")
346 deallocate (
list%arr(pos)%p)
347 DO i = pos,
list%size - 1
367 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
368 cpabort(
"list_routinestat_size: list is not initialized.")
382 SUBROUTINE change_capacity_routinestat (list, new_capacity)
384 INTEGER,
intent(in) :: new_capacity
385 INTEGER :: i, new_cap, stat
386 TYPE(private_item_p_type_routinestat),
DIMENSION(:),
POINTER :: old_arr
388 new_cap = new_capacity
389 IF (new_cap < 0)
THEN
390 cpabort(
"list_routinestat_change_capacity: new_capacity < 0")
392 IF (new_cap <
list%size)
THEN
393 cpabort(
"list_routinestat_change_capacity: new_capacity < size")
395 IF (new_cap > huge(i))
THEN
396 IF (
size(
list%arr) == huge(i))
THEN
397 cpabort(
"list_routinestat_change_capacity: list has reached integer limit.")
403 allocate (
list%arr(new_cap), stat=stat)
405 cpabort(
"list_routinestat_change_capacity: allocation failed")
409 allocate (
list%arr(i)%p, stat=stat)
411 cpabort(
"list_routinestat_change_capacity: allocation failed")
413 list%arr(i)%p%value =>old_arr(i)%p%value
414 DEALLOCATE (old_arr(i)%p)
418 END SUBROUTINE change_capacity_routinestat
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
subroutine, public list_routinestat_init(list, initial_capacity)
Allocates the internal data-structures of the given list. This has to be called before any of the oth...
integer function, public list_routinestat_size(list)
Returns the current size of the list.
subroutine, public list_routinestat_set(list, value, pos)
Assings the given value to the given position in the list. Thereby, the former value at that position...
logical function, public list_routinestat_isready(list)
Test if the given list has been initialized.
subroutine, public list_routinestat_insert(list, value, pos)
Inserts the given value at the givenn position within the list. Values which lay behind the insertion...
subroutine, public list_routinestat_clear(list)
Removes all values from the list. The list itself is not deallocated.
type(routine_stat_type) function, pointer, public list_routinestat_pop(list)
Returns the last element in the list and removes it. Is equivialent to: value = list_routinestat_get(...
subroutine, public list_routinestat_push(list, value)
Appends the given value at the end of the list.
subroutine, public list_routinestat_destroy(list)
Deallocated the internal data-structures of the given list. Caution: If the stored values are pointer...
subroutine, public list_routinestat_del(list, pos)
Removes the value at the given position from the list.
type(routine_stat_type) function, pointer, public list_routinestat_peek(list)
Returns the last element in the list. Is equivalent to: list_routinestat_get(list,...
type(routine_stat_type) function, pointer, public list_routinestat_get(list, pos)
Returns the value at the given position from the list.
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Types used by timings.F and timings_report.F The types in this module are used within dict or list,...