cc_hash_add Subroutine

private subroutine cc_hash_add(hash_table, hash_val, tgt, amp)

Arguments

Type IntentOptional Attributes Name
type(cc_hash), intent(inout), pointer :: hash_table(:)
integer, intent(in) :: hash_val
integer(kind=n_int), intent(in) :: tgt(:)
real(kind=dp), intent(in) :: amp

Contents

Source Code


Source Code

    subroutine cc_hash_add(hash_table, hash_val, tgt, amp)
        ! this is a routine to add a hash table entry
        ! it means the entry was not there yet or has to be added to
        ! the linked list
        type(cc_hash), pointer, intent(inout) :: hash_table(:)
        integer, intent(in) :: hash_val
        integer(n_int), intent(in) :: tgt(:)
        real(dp), intent(in) :: amp

        type(cc_hash), pointer :: temp_node

        temp_node => hash_table(hash_val)

        if (.not. temp_node%found) then
            ! this means this entry is empty so we cann fill it here
            temp_node%found = .true.
            allocate(temp_node%ind(0:nifd))
            temp_node%ind = tgt
            temp_node%amp = amp
        else
            ! loop through the linked list
            do while (associated(temp_node%next))
                temp_node => temp_node%next
            end do
            allocate(temp_node%next)
            nullify (temp_node%next%next)
            temp_node%next%found = .true.
            allocate(temp_node%next%ind(0:nifd))
            temp_node%next%ind = tgt
            temp_node%next%amp = amp

            ! for testing cound the number of clashes:
            n_clashes = n_clashes + 1
        end if

        nullify (temp_node)

    end subroutine cc_hash_add