subroutine generate_ras(ras_info, ilut_list, space_size)
! In: ras - Parameters for the RAS space.
! In/Out: ilut_list - List of determinants generated.
! In/Out: space_size - Number of determinants in the generated space.
! If ilut_list is not empty on input and you want to keep
! the states already in it, then on input space_size should
! be equal to the number of states to be kept in ilut_list,
! and new states will be added in from space_size+1.
! Otherwise, space_size must equal 0 on input.
! On output space_size will equal the total number of
! generated plus what space_size was on input.
type(ras_parameters), intent(inout) :: ras_info
integer(n_int), intent(inout) :: ilut_list(0:, :)
integer, intent(inout) :: space_size
type(ras_class_data), allocatable, dimension(:) :: ras_classes
integer(n_int), allocatable, dimension(:, :) :: temp_list
integer :: temp_size, i
tot_nelec = nel / 2
tot_norbs = nbasis / 2
! Do a check that the RAS parameters are possible.
if (ras_info%size_1 + ras_info%size_2 + ras_info%size_3 /= tot_norbs .or. &
ras_info%min_1 > ras_info%size_1 * 2 .or. &
ras_info%max_3 > ras_info%size_3 * 2) &
call stop_all("generate_ras", "RAS parameters are not possible.")
if (mod(nel, 2) /= 0) call stop_all("generate_ras", "RAS space only implmented for &
& closed shell molecules.")
call initialise_ras_space(ras_info, ras_classes)
call find_ras_size(ras_info, ras_classes, temp_size)
allocate(temp_list(0:NIfTot, temp_size))
call generate_entire_ras_space(ras_info, ras_classes, temp_size, temp_list)
do i = 1, temp_size
call add_state_to_space(temp_list(:, i), ilut_list, space_size)
end do
deallocate(ras_classes)
deallocate(temp_list)
end subroutine generate_ras