Inserts the given value at the given position within the list. Values which lay behind the insertion-position move one position up.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(list_routinereport_type), | intent(inout) | :: | list | |||
type(routine_report_type), | intent(in), | POINTER | :: | value | ||
integer, | intent(in) | :: | pos |
Position in the list - must fulfill 0 < pos < list_size+2 . |
SUBROUTINE list_routinereport_insert(list, value, pos)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
!! Inserts the given value at the given position within the list.
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
!! Values which lay behind the insertion-position move one position up.
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
TYPE(list_routinereport_type), intent(inout) :: list
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
TYPE(routine_report_type), POINTER, intent(in) :: value
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
INTEGER, intent(in) :: pos
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
!! Position in the list - must fulfill 0 < pos < list_size+2 .
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
INTEGER :: i, stat
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
IF(.not. ASSOCIATED(list%arr)) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
DBCSR_ABORT("list_routinereport_insert: list is not initialized.")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
IF(pos < 1)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
DBCSR_ABORT("list_routinereport_insert: pos < 1")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
IF(pos > list%size+1)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
DBCSR_ABORT("list_routinereport_insert: pos > size+1")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
if(list%size == size(list%arr)) &
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
call change_capacity_routinereport(list, 2*size(list%arr)+1)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
list%size = list%size + 1
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
do i=list%size, pos+1, -1
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
list%arr(i)%p => list%arr(i-1)%p
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
end do
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
ALLOCATE(list%arr(pos)%p, stat=stat)
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
IF (stat/=0)&
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
DBCSR_ABORT("list_routinereport_insert: allocation failed.")
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
list%arr(pos)%p%value => value
# 21 "/__w/dbcsr/dbcsr/src/core/dbcsr_list_routinereport.F"
END SUBROUTINE list_routinereport_insert