dbcsr_heap_fill Subroutine

public subroutine dbcsr_heap_fill(heap, values)

Fill heap with given values

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_heap_type), intent(inout) :: heap
integer(kind=valt), intent(in), DIMENSION(:):: values

Contents

Source Code


Source Code

   SUBROUTINE dbcsr_heap_fill(heap, values)
      !! Fill heap with given values
      TYPE(dbcsr_heap_type), INTENT(INOUT)               :: heap
      INTEGER(KIND=valt), DIMENSION(:), INTENT(IN)       :: values

      INTEGER                                            :: first, i, n

      n = SIZE(values)
      DBCSR_ASSERT(heap%n >= n)

      DO i = 1, n
         heap%index(i) = i
         heap%nodes(i)%node%key = i
         heap%nodes(i)%node%value = values(i)
      END DO
      ! Sort from the last full subtree
      first = get_parent(n)
      DO i = first, 1, -1
         CALL bubble_down(heap, i)
      END DO

   END SUBROUTINE dbcsr_heap_fill