subroutine generate_space(core_in, run)
! A wrapper to call the correct generating routine.
type(subspace_in) :: core_in
integer, intent(in) :: run
integer :: space_size, i, ierr, c_run
real(dp) :: zero_sign(lenof_sign)
space_size = 0
if(t_global_core_space) then
c_run = GLOBAL_RUN
else
c_run = run
end if
! Call the requested generating routines.
if (core_in%tHF) call add_state_to_space(ilutHF, SpawnedParts, space_size)
if (core_in%tPops) call generate_space_most_populated(core_in%npops, &
core_in%tApproxSpace, core_in%nApproxSpace, &
SpawnedParts, space_size, c_run, t_opt_fast_core=t_fast_pops_core)
if (core_in%tRead) call generate_space_from_file(core_in%read_filename, SpawnedParts, space_size)
if (.not. (tGUGACore)) then
if (core_in%tDoubles) call generate_sing_doub_determinants(SpawnedParts, space_size, core_in%tHFConn)
if (core_in%tTriples) call generate_trip_determinants(SpawnedParts, space_size, &
core_in%tHFConn)
if (core_in%tCAS) call generate_cas(core_in%occ_cas, core_in%virt_cas, SpawnedParts, space_size)
if (core_in%tRAS) call generate_ras(core_in%ras, SpawnedParts, space_size)
if (core_in%tOptimised) call generate_optimised_space(core_in%opt_data, core_in%tLimitSpace, &
SpawnedParts, space_size, core_in%max_size)
if (core_in%tMP1) call generate_using_mp1_criterion(core_in%mp1_ndets, SpawnedParts, space_size)
if (core_in%tFCI) then
if (tAllSymSectors) then
call gndts_all_sym_this_proc(SpawnedParts, .false., space_size)
else
call generate_fci_core(SpawnedParts, space_size)
end if
end if
else if (tGUGACore) then
if (core_in%tDoubles) then
call generate_sing_doub_guga(SpawnedParts, space_size, core_in%tHFConn)
else if (core_in%tCAS) then
call stop_all("init_semi_stochastic", "CAS core space with CSFs is not &
¤tly implemented.")
else if (core_in%tCAS) then
call stop_all("init_semi_stochastic", "Cannot use a RAS core space with &
&CSFs.")
else if (core_in%tOptimised) then
call generate_optimised_space(core_in%opt_data, core_in%tLimitSpace, &
SpawnedParts, space_size, core_in%max_size)
else if (core_in%tLowE) then
call stop_all("init_semi_stochastic", "Low energy core space with CSFs is not &
¤tly implemented.")
else if (core_in%tMP1) then
call generate_using_mp1_criterion(core_in%mp1_ndets, SpawnedParts, space_size)
end if
if (core_in%tFCI) call generate_fci_core(SpawnedParts, space_size)
end if
! If two different deterministic spaces have been called then there may
! be some repeated states. We don't want repeats, so remove them and
! update space_size accordingly.
call remove_repeated_states(SpawnedParts, space_size)
if (tDetermProjApproxHamil) then
var_size_this_proc = space_size
allocate(temp_var_space(0:NIfTot, var_size_this_proc), stat=ierr)
temp_var_space = SpawnedParts(:, 1:var_size_this_proc)
end if
! Create and use the space of all connections to the current space
if (core_in%tAllConnCore) then
call generate_all_conn_space(SpawnedParts, space_size)
call remove_repeated_states(SpawnedParts, space_size)
end if
associate(rep => cs_replicas(run))
zero_sign = 0.0_dp
do i = 1, space_size
call encode_sign(SpawnedParts(:, i), zero_sign)
call set_flag(SpawnedParts(:, i), flag_deterministic(run))
if (tTruncInitiator .and. t_core_inits) then
do c_run = rep%first_run(), rep%last_run()
call set_flag(SpawnedParts(:, i), get_initiator_flag_by_run(c_run))
call set_flag(CurrentDets(:, i), flag_static_init(c_run))
end do
end if
end do
! Set the deterministic space size for this process.
rep%determ_sizes(iProcIndex) = int(space_size, MPIArg)
! If requested, remove high energy orbitals so that the space size is below some max.
if (core_in%tLimitSpace) then
call remove_high_energy_orbs(SpawnedParts(0:NIfTot, 1:space_size), space_size, &
core_in%max_size, .true.)
rep%determ_sizes(iProcIndex) = int(space_size, MPIArg)
end if
end associate
end subroutine generate_space