add_single_trial_ht_entry Subroutine

public subroutine add_single_trial_ht_entry(ht_entry, hash_val, source_ht)

Arguments

Type IntentOptional Attributes Name
integer(kind=n_int), intent(in) :: ht_entry(0:NConEntry)
integer, intent(in) :: hash_val
type(trial_hashtable), intent(inout) :: source_ht(:)

Contents


Source Code

    subroutine add_single_trial_ht_entry(ht_entry, hash_val, source_ht)
        implicit none
        integer(n_int), intent(in) :: ht_entry(0:NConEntry)
        integer, intent(in) :: hash_val
        type(trial_hashtable), intent(inout) :: source_ht(:)
        integer :: clashes, ntrial, ncon
        integer(n_int), allocatable :: tmp(:, :)

        ! add a single entry to trial_ht with hash_val
        clashes = source_ht(hash_val)%nclash
        ! store the current entries in a temporary
        allocate(tmp(0:NConEntry, clashes + 1))
        ! if there are any, copy them now
        if (allocated(source_ht(hash_val)%states)) then
            tmp(:, :clashes) = source_ht(hash_val)%states(:, :)
            ! then deallocate
            deallocate(source_ht(hash_val)%states)
        end if
        ! add the new entry
        tmp(:, clashes + 1) = ht_entry

        ! and allocoate the new entry
        allocate(source_ht(hash_val)%states(0:NConEntry, clashes + 1))
        ! fill it
        source_ht(hash_val)%states = tmp
        deallocate(tmp)
        ! and update the nclashes info
        source_ht(hash_val)%nclash = clashes + 1

    end subroutine add_single_trial_ht_entry