spin_purify Subroutine

private subroutine spin_purify(n_excits_in, det_list_in, n_excits_out, det_list_out)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n_excits_in
integer(kind=n_int), intent(in) :: det_list_in(0:NIfTot,n_excits_in)
integer, intent(out) :: n_excits_out
integer(kind=n_int), intent(out), allocatable :: det_list_out(:,:)

Contents

Source Code


Source Code

    subroutine spin_purify(n_excits_in, det_list_in, n_excits_out, det_list_out)
        ! routine to remove determinants, belonging to the same
        ! coupled HPHF function
        integer, intent(in) :: n_excits_in
        integer(n_int), intent(in) :: det_list_in(0:NIfTot, n_excits_in)
        integer, intent(out) :: n_excits_out
        integer(n_int), intent(out), allocatable :: det_list_out(:, :)
        integer :: i, pos, cnt
        integer(n_int) :: ilut(0:NIfTot), ilut_sym(0:NIfTot)
        integer(n_int), allocatable :: temp_dets(:, :)

        allocate(temp_dets(0:NIfTot, n_excits_in))
        temp_dets = 0_n_int

        cnt = 0

        do i = 1, n_excits_in

            ilut = det_list_in(:, i)

            ! ilut will always be the one, which should be stored in the
            ! det-list, if i undertand the function below correctly
            ilut_sym = return_hphf_sym_det(ilut)

            pos = binary_search_ilut(temp_dets(:, 1:cnt), ilut, nifd + 1)

            if (pos < 0) then
                ! then we have to store it
                cnt = cnt + 1
                temp_dets(:, cnt) = ilut_sym
                call sort(temp_dets(:, 1:cnt), ilut_lt, ilut_gt)
            end if
        end do

        n_excits_out = cnt
        allocate(det_list_out(0:NIfTot, n_excits_out), source=temp_dets(:, 1:n_excits_out))

        call sort(det_list_out, ilut_lt, ilut_gt)

    end subroutine spin_purify