assign_dets_to_procs_buff Subroutine

private subroutine assign_dets_to_procs_buff(block_size, temp_ilut, temp_sgns, gdata_buf, gdata_loc, gdata_comm, sendcount)

Arguments

Type IntentOptional Attributes Name
integer(kind=hsize_t), intent(in) :: block_size
integer(kind=hsize_t), dimension(:, :) :: temp_ilut
integer(kind=hsize_t), dimension(:, :) :: temp_sgns
integer(kind=hsize_t), dimension(:, :) :: gdata_buf
integer(kind=hsize_t), dimension(:, :) :: gdata_loc
integer(kind=hsize_t), dimension(:, :) :: gdata_comm
integer(kind=MPIArg) :: sendcount(0:nProcessors-1)

Contents


Source Code

    subroutine assign_dets_to_procs_buff(block_size, temp_ilut, temp_sgns, &
                                         gdata_buf, gdata_loc, gdata_comm, sendcount)

        use load_balance_calcnodes, only: DetermineDetNode
        use FciMCData, only: SpawnedParts2, SpawnedParts

        use DeterminantData, only: write_det
        use SystemData, only: nel

        integer(hsize_t), intent(in) :: block_size
        integer(hsize_t), dimension(:, :) :: temp_ilut, temp_sgns, gdata_buf, gdata_comm
        integer(hsize_t), dimension(:, :) :: gdata_loc
        integer(hsize_t) :: onepart(0:IlutBits%len_bcast)
        integer :: det(nel), p, j, proc, sizeilut, targetproc(block_size)
        integer(MPIArg) :: sendcount(0:nProcessors - 1)
        integer :: index, index2
        logical :: t_read_gdata

        sizeilut = size(temp_ilut, 1)
        t_read_gdata = size(gdata_buf, dim=1) > 0

        ! Iterate through walkers in temp_ilut+temp_sgns and determine the target processor.
        onepart = 0
        sendcount = 0
        do j = 1, int(block_size)
            onepart(0:sizeilut - 1) = temp_ilut(:, j)
            onepart(sizeilut:sizeilut + int(lenof_sign) - 1) = temp_sgns(:, j)
            ! Which processor does this determinant live on?
            call decode_bit_det(det, onepart)
            proc = DetermineDetNode(nel, det, 0)
            targetproc(j) = proc
            sendcount(proc) = sendcount(proc) + 1
        end do

        ! Write the elements to SpawnedParts in the correct order for sending
        index = 1
        index2 = 1
        do p = 0, nProcessors - 1
#ifdef localfirst
            if (p == iProcIndex) then
#else
            if (.false.) then
#endif
                !elements that don't have to be communicated are written to SpawnedParts2
                do j = 1, int(block_size)
                    if (targetproc(j) == p) then
                        onepart(0:sizeilut - 1) = temp_ilut(:, j)
                        onepart(sizeilut:sizeilut + int(lenof_sign) - 1) = temp_sgns(:, j)
                        SpawnedParts2(:, index2) = onepart
                        if (t_read_gdata) &
                            gdata_loc(:, index2) = gdata_buf(:, j)
                        index2 = index2 + 1
                    end if
                end do
            else
                !elements that have to be sent to other procs are written to SpawnedParts
                do j = 1, int(block_size)
                    if (targetproc(j) == p) then
                        onepart(0:sizeilut - 1) = temp_ilut(:, j)
                        onepart(sizeilut:sizeilut + int(lenof_sign) - 1) = temp_sgns(:, j)
                        SpawnedParts(:, index) = onepart
                        if (t_read_gdata) &
                            gdata_comm(:, index) = gdata_buf(:, j)
                        index = index + 1
                    end if
                end do
            end if
        end do

    end subroutine assign_dets_to_procs_buff