change_capacity_callstackentry Subroutine

private subroutine change_capacity_callstackentry(list, new_capacity)

Internal routine for changing the size of the internal array.

Arguments

Type IntentOptional Attributes Name
type(list_callstackentry_type), intent(inout) :: list
integer, intent(in) :: new_capacity

Source Code

SUBROUTINE change_capacity_callstackentry(list, new_capacity)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   !! Internal routine for changing the size of the internal array.
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   TYPE(list_callstackentry_type), intent(inout)  :: list
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   INTEGER, intent(in) :: new_capacity
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   INTEGER :: i, new_cap, stat
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   TYPE(private_item_p_type_callstackentry), DIMENSION(:), POINTER :: old_arr
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   new_cap = new_capacity
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   IF(new_cap < 0) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      DBCSR_ABORT("list_callstackentry_change_capacity: new_capacity < 0")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   IF(new_cap < list%size) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      DBCSR_ABORT("list_callstackentry_change_capacity: new_capacity < size")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   IF(new_cap > HUGE(i)) THEN
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      IF(size(list%arr) == HUGE(i)) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      DBCSR_ABORT("list_callstackentry_change_capacity: list has reached integer limit.")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      new_cap = HUGE(i) ! grow as far as possible
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   END IF
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   old_arr => list%arr
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   allocate(list%arr(new_cap), stat=stat)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   IF (stat/=0)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      DBCSR_ABORT("list_callstackentry_change_capacity: allocation failed")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   do i=1, list%size
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      allocate(list%arr(i)%p, stat=stat)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      IF (stat/=0)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
         DBCSR_ABORT("list_callstackentry_change_capacity: allocation failed")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      list%arr(i)%p%value = old_arr(i)%p%value
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      deallocate(old_arr(i)%p)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   end do
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   deallocate(old_arr)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
END SUBROUTINE change_capacity_callstackentry