merge_ilut_lists Subroutine

public subroutine merge_ilut_lists(listA, listB, hashTable, sizeA, sizeB, maxSizeA)


Type IntentOptional Attributes Name
integer(kind=n_int), intent(inout) :: listA(0:,1:)
integer(kind=n_int), intent(in) :: listB(0:,1:)
type(ll_node), intent(inout), pointer :: hashTable(:)
integer, intent(inout) :: sizeA
integer, intent(in) :: sizeB
integer, intent(in) :: maxSizeA


Source Code

Source Code

    subroutine merge_ilut_lists(listA, listB, hashTable, sizeA, sizeB, maxSizeA)
        integer(n_int), intent(in) :: listB(0:, 1:)
        integer(n_int), intent(inout) :: listA(0:, 1:)
        integer, intent(in) :: sizeB, maxSizeA
        integer, intent(inout) :: sizeA
        type(ll_node), pointer, intent(inout) :: hashTable(:)
        integer :: nJ(nel), ilutIndex, hashValue, i, insertPos
        real(dp) :: signA(lenof_sign), signB(lenof_sign)
        logical :: tSuccess
        character(*), parameter :: this_routine = "merge_ilut_lists"

        ! this merges listB into listA. In the current form, empty slots in listA are
        ! not exploited, because it should not make a difference currently (optimization follows)
        do i = 1, sizeB
            call decode_bit_det(nJ, listB(:, i))

            call hash_table_lookup(nJ, listB(:, i), nifd, hashTable, listA, ilutIndex, &
                                   hashValue, tSuccess)

            if (tSuccess) then
                ! the i-th determinant in listB is already present in listA
                ! -> add up the signs
                call extract_sign(listA(:, ilutIndex), signA)
                call extract_sign(listB(:, i), signB)

                ! we do not fill up empty slots, so we do not care if signA == 0
                ! this differs from AnnihilateSpawnedParts
                call encode_sign(listA(:, ilutIndex), signA + signB)

                ! the initiator criterium is checked upon annihilation, no need to do so here
                ! if the entry in listB is not in listA, add it as the last entry
                sizeA = sizeA + 1
                insertPos = sizeA
                if (sizeA > maxSizeA) &
                    call stop_all(this_routine, "Out of memory for merging ilut lists")
                listA(:, insertPos) = listB(:, i)
                call add_hash_table_entry(hashTable, insertPos, hashValue)
            end if
        end do
    end subroutine merge_ilut_lists