24#include "../base/base_uses.f90"
34 TYPE private_item_type_callstackentry
37 END TYPE private_item_type_callstackentry
40 TYPE private_item_p_type_callstackentry
42 TYPE(private_item_type_callstackentry),
POINTER :: p => null()
43 END TYPE private_item_p_type_callstackentry
48 TYPE(private_item_p_type_callstackentry),
DIMENSION(:),
POINTER :: arr => null()
65 res =
ASSOCIATED(
list%arr)
80 INTEGER,
INTENT(in),
OPTIONAL :: initial_capacity
82 INTEGER :: initial_capacity_
84 initial_capacity_ = 11
85 If (
PRESENT(initial_capacity)) initial_capacity_ = initial_capacity
87 IF (initial_capacity_ < 0)
THEN
88 cpabort(
"list_callstackentry_create: initial_capacity < 0")
91 IF (
ASSOCIATED(
list%arr))
THEN
92 cpabort(
"list_callstackentry_create: list is already initialized.")
95 ALLOCATE (
list%arr(initial_capacity_), stat=stat)
97 cpabort(
"list_callstackentry_init: allocation failed")
115 IF (.not.
ASSOCIATED(
list%arr))
THEN
116 cpabort(
"list_callstackentry_destroy: list is not initialized.")
120 deallocate (
list%arr(i)%p)
122 deallocate (
list%arr)
140 INTEGER,
intent(in) :: pos
141 IF (.not.
ASSOCIATED(
list%arr))
THEN
142 cpabort(
"list_callstackentry_set: list is not initialized.")
145 cpabort(
"list_callstackentry_set: pos < 1")
147 IF (pos >
list%size)
THEN
148 cpabort(
"list_callstackentry_set: pos > size")
150 list%arr(pos)%p%value =
value
166 IF (.not.
ASSOCIATED(
list%arr))
THEN
167 cpabort(
"list_callstackentry_push: list is not initialized.")
169 IF (
list%size ==
size(
list%arr))
THEN
170 CALL change_capacity_callstackentry (
list, 2*
size(
list%arr) + 1)
174 ALLOCATE (
list%arr(
list%size)%p, stat=stat)
176 cpabort(
"list_callstackentry_push: allocation failed")
194 INTEGER,
intent(in) :: pos
197 IF (.not.
ASSOCIATED(
list%arr))
THEN
198 cpabort(
"list_callstackentry_insert: list is not initialized.")
201 cpabort(
"list_callstackentry_insert: pos < 1")
203 IF (pos >
list%size + 1)
THEN
204 cpabort(
"list_callstackentry_insert: pos > size+1")
207 if (
list%size ==
size(
list%arr))
THEN
208 call change_capacity_callstackentry (
list, 2*
size(
list%arr) + 1)
212 do i =
list%size, pos + 1, -1
216 ALLOCATE (
list%arr(pos)%p, stat=stat)
218 cpabort(
"list_callstackentry_insert: allocation failed.")
220 list%arr(pos)%p%value =
value
236 IF (.not.
ASSOCIATED(
list%arr))
THEN
237 cpabort(
"list_callstackentry_peek: list is not initialized.")
239 IF (
list%size < 1)
THEN
240 cpabort(
"list_callstackentry_peek: list is empty.")
262 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
263 cpabort(
"list_callstackentry_pop: list is not initialized.")
265 IF (
list%size < 1)
THEN
266 cpabort(
"list_callstackentry_pop: list is empty.")
285 IF (.not.
ASSOCIATED(
list%arr))
THEN
286 cpabort(
"list_callstackentry_clear: list is not initialized.")
290 deallocate (
list%arr(i)%p)
307 INTEGER,
intent(in) :: pos
310 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
311 cpabort(
"list_callstackentry_get: list is not initialized.")
314 cpabort(
"list_callstackentry_get: pos < 1")
316 IF (pos >
list%size)
THEN
317 cpabort(
"list_callstackentry_get: pos > size")
320 value =
list%arr(pos)%p%value
334 INTEGER,
intent(in) :: pos
337 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
338 cpabort(
"list_callstackentry_del: list is not initialized.")
341 cpabort(
"list_callstackentry_det: pos < 1")
343 IF (pos >
list%size)
THEN
344 cpabort(
"list_callstackentry_det: pos > size")
347 deallocate (
list%arr(pos)%p)
348 DO i = pos,
list%size - 1
368 IF (.NOT.
ASSOCIATED(
list%arr))
THEN
369 cpabort(
"list_callstackentry_size: list is not initialized.")
383 SUBROUTINE change_capacity_callstackentry (list, new_capacity)
385 INTEGER,
intent(in) :: new_capacity
386 INTEGER :: i, new_cap, stat
387 TYPE(private_item_p_type_callstackentry),
DIMENSION(:),
POINTER :: old_arr
389 new_cap = new_capacity
390 IF (new_cap < 0)
THEN
391 cpabort(
"list_callstackentry_change_capacity: new_capacity < 0")
393 IF (new_cap <
list%size)
THEN
394 cpabort(
"list_callstackentry_change_capacity: new_capacity < size")
396 IF (new_cap > huge(i))
THEN
397 IF (
size(
list%arr) == huge(i))
THEN
398 cpabort(
"list_callstackentry_change_capacity: list has reached integer limit.")
404 allocate (
list%arr(new_cap), stat=stat)
406 cpabort(
"list_callstackentry_change_capacity: allocation failed")
410 allocate (
list%arr(i)%p, stat=stat)
412 cpabort(
"list_callstackentry_change_capacity: allocation failed")
414 list%arr(i)%p%value =old_arr(i)%p%value
415 DEALLOCATE (old_arr(i)%p)
419 END SUBROUTINE change_capacity_callstackentry
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
subroutine, public list_callstackentry_push(list, value)
Appends the given value at the end of the list.
subroutine, public list_callstackentry_set(list, value, pos)
Assings the given value to the given position in the list. Thereby, the former value at that position...
subroutine, public list_callstackentry_del(list, pos)
Removes the value at the given position from the list.
integer function, public list_callstackentry_size(list)
Returns the current size of the list.
type(callstack_entry_type) function, public list_callstackentry_get(list, pos)
Returns the value at the given position from the list.
subroutine, public list_callstackentry_destroy(list)
Deallocated the internal data-structures of the given list. Caution: If the stored values are pointer...
subroutine, public list_callstackentry_insert(list, value, pos)
Inserts the given value at the givenn position within the list. Values which lay behind the insertion...
subroutine, public list_callstackentry_init(list, initial_capacity)
Allocates the internal data-structures of the given list. This has to be called before any of the oth...
type(callstack_entry_type) function, public list_callstackentry_pop(list)
Returns the last element in the list and removes it. Is equivialent to: value = list_callstackentry_g...
subroutine, public list_callstackentry_clear(list)
Removes all values from the list. The list itself is not deallocated.
type(callstack_entry_type) function, public list_callstackentry_peek(list)
Returns the last element in the list. Is equivalent to: list_callstackentry_get(list,...
logical function, public list_callstackentry_isready(list)
Test if the given list has been initialized.
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,...