get_corespace_from_buf Subroutine

public subroutine get_corespace_from_buf(buffer, buffer_size)

Arguments

Type IntentOptional Attributes Name
integer(kind=n_int), intent(in), pointer :: buffer(:,:)
integer, intent(in) :: buffer_size

Contents


Source Code

    subroutine get_corespace_from_buf(buffer, buffer_size)
        use core_space_util, only: cs_replicas
        use CalcData, only: ss_space_in
        use semi_stoch_gen, only: generate_space_most_populated
        use semi_stoch_procs, only: store_whole_core_space, write_core_space
        implicit none
        integer, intent(in) :: buffer_size
        integer(n_int), intent(in), pointer :: buffer(:, :)
        integer :: space_size, ierr, i
        integer(MPIArg) :: mpi_buf

        associate(rep => cs_replicas(core_run))
            ! Get the most populated from those determinants that exceeded the threshold once
            space_size = 0
            allocate(rep%determ_sizes(0:nProcessors - 1))
            call generate_space_most_populated(ss_space_in%npops, ss_space_in%tApproxSpace, &
                                               ss_space_in%nApproxSpace, SpawnedParts, space_size, GLOBAL_RUN, buffer, &
                                               int(buffer_size, n_int))

            ! Then, communicate the number of states per core
            mpi_buf = int(space_size, MPIArg)
            call MPIAllGather(mpi_buf, rep%determ_sizes, ierr)
            rep%determ_space_size = sum(rep%determ_sizes)

            ! Prepare the store_whole_core_space communication routine
            allocate(rep%determ_displs(0:nProcessors - 1))

            ! Communciate the newly built corespace and output it
            call store_whole_core_space(rep)

            call write_core_space(rep)
        end associate

    end subroutine get_corespace_from_buf