setup_temp_det_list Subroutine

public subroutine setup_temp_det_list()

Arguments

None

Contents

Source Code


Source Code

    subroutine setup_temp_det_list()
        ! setup the second list to temporaly store the list of determinants
        ! necessary in the real-time fciqmc list
        ! determine the necessary size from the already setup CurrentDets
        character(*), parameter :: this_routine = "setup_temp_det_list"
        integer :: ierr, tmp_siz1, tmp_siz2, i, spawn_ht_mem

        tmp_siz1 = size(WalkVecDets, dim=1)
        tmp_siz2 = size(WalkVecDets, dim=2)

        ! allocate the array
        allocate(temp_det_list(0:tmp_siz1 - 1, tmp_siz2), stat=ierr)
        if (ierr /= 0) call stop_all(this_routine, "Error in allocation")

        ! and init it
        temp_det_list(0:tmp_siz1 - 1, 1:tmp_siz2) = 0

        ! and point to it
        temp_det_pointer => temp_det_list

        ! and also allocate the hash-table
        tmp_siz1 = size(HashIndex)
        allocate(temp_det_hash(tmp_siz1), stat=ierr)
        if (ierr /= 0) call stop_all(this_routine, "Error in allocation")

        ! and initialize it to 0
        do i = 1, tmp_siz1
            temp_det_hash(i)%ind = 0
        end do

        ! also use the spawn_ht hash table, so also allocate it here!

        ! Allocate the hash table to the spawning array.
        ! The number of MB of memory required to allocate spawn_ht.
        ! Each node requires 16 bytes.
        nhashes_spawn = int(0.8_dp * real(MaxSpawned, dp))
        spawn_ht_mem = nhashes_spawn * 16 / 1000000
        write(stdout, '(a78,'//int_fmt(spawn_ht_mem, 1)//')') "About to allocate hash table to the spawning array. &
                                       &Memory required (MB):", spawn_ht_mem
        write(stdout, '(a13)', advance='no') "Allocating..."; call neci_flush(stdout)
        allocate(spawn_ht(nhashes_spawn), stat=ierr)
        if (ierr /= 0) then
            write(stdout, '(1x,a11,1x,i5)') "Error code:", ierr
            call stop_all(this_routine, "Error allocating spawn_ht array.")
        else
            write(stdout, '(1x,a5)') "Done."
            write(stdout, '(a106)') "Note that the hash table uses linked lists, and the memory usage will &
                              &increase as further nodes are added."
        end if

        call init_hash_table(spawn_ht)

    end subroutine setup_temp_det_list