list_callstackentry_insert Subroutine

public subroutine list_callstackentry_insert(list, value, pos)

Inserts the given value at the given position within the list. Values which lay behind the insertion-position move one position up.

Arguments

Type IntentOptional Attributes Name
type(list_callstackentry_type), intent(inout) :: list
type(callstack_entry_type), intent(in) :: value
integer, intent(in) :: pos

Position in the list - must fulfill 0 < pos < list_size+2 .


Source Code

SUBROUTINE list_callstackentry_insert(list, value, pos)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   !! Inserts the given value at the given position within the list.
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
   !! Values which lay behind the insertion-position move one position up.
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 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"
    TYPE(callstack_entry_type), intent(in) :: value
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    INTEGER, intent(in) :: pos
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
      !! Position in the list - must fulfill 0 < pos < list_size+2 .
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    INTEGER :: i, stat
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    IF(.not. ASSOCIATED(list%arr)) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
       DBCSR_ABORT("list_callstackentry_insert: list is not initialized.")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    IF(pos < 1)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
       DBCSR_ABORT("list_callstackentry_insert: pos < 1")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    IF(pos > list%size+1)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
       DBCSR_ABORT("list_callstackentry_insert: pos > size+1")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    if(list%size == size(list%arr)) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
       call change_capacity_callstackentry(list, 2*size(list%arr)+1)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    list%size = list%size + 1
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    do i=list%size, pos+1, -1
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
       list%arr(i)%p => list%arr(i-1)%p
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    end do
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"

# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    ALLOCATE(list%arr(pos)%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_insert: allocation failed.")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
    list%arr(pos)%p%value = value
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_callstackentry.F"
END SUBROUTINE list_callstackentry_insert