gather_angles Subroutine

public subroutine gather_angles(this, angles, angle_number)

get the angle constraints data - atom indices and equilibrium values

Arguments

TypeIntentOptionalAttributesName
class(mimic_communicator), intent(inout) :: this
type(angle_type), intent(out), dimension(:,:), allocatable:: angles

list of angle constraints, return value

integer, intent(in), dimension(:):: angle_number

number of angle constraints


Contents

Source Code


Source Code

subroutine gather_angles(this, angles, angle_number)

    class(mimic_communicator), intent(inout) :: this
    !> list of angle constraints, return value
    type(angle_type), dimension(:,:), allocatable, intent(out) :: angles
    !> number of angle constraints
    integer, dimension(:), intent(in) :: angle_number

    integer, dimension(:, :), target, allocatable :: indices
    real(dp), dimension(:, :), target, allocatable :: angle_vals

    !integer, dimension(:, :), allocatable :: act_ind
    integer :: n_client, n_angle!, n_map
    integer :: offset
    !integer :: overlap_id
    !integer, dimension(:) :: temp_angle_number
    !logical :: overlapped

    allocate(indices(3 * maxval(angle_number), this%num_clients))
    allocate(angle_vals(maxval(angle_number), this%num_clients))
    allocate(angles(maxval(angle_number), this%num_clients))

    if (maxval(angle_number) == 0) return

    do n_client = 1, this%num_clients
        if (angle_number(n_client) == 0) cycle

        offset = 1

        call this%send_command(MCL_SEND_ANGLE_ATOMS, n_client)
        call mcl_receive(indices(:, n_client), 3 * angle_number(n_client), MCL_DATA, n_client)
        call this%send_command(MCL_SEND_ANGLE_VALS, n_client)
        call mcl_receive(angle_vals(:, n_client), angle_number(n_client), MCL_DATA, n_client)

        !! @todo check if we need to skip overlapped angles
        ! do n_angle = 1, angle_number(n_client)
        !     overlapped = .false.
        !     do n_map = 1, size(this%overlap_maps(n_client)%maps)
        !         overlap_id = this%overlap_maps(n_client)%maps(n_map)%id
        !         if (overlap_id == indices(n_angle * 2, n_client) .or. &
        !             overlap_id == indices(n_angle * 2 + 1, n_client) .or. &
        !             overlap_id == indices(n_angle * 2 + 2, n_client)) then
        !             temp_angle_number(n_client) = temp_angle_number(n_client) - 1
        !             overlapped = .true.
        !             exit
        !         end if
        !     end do ! n_map
        !     if (.not. overlapped) then
        !         act_ind(offset, n_client) = n_angle
        !         offset = offset + 1
        !     endif
        ! end do ! n_angle
    end do ! n_client

    do n_client = 1, this%num_clients
        do n_angle = 1, angle_number(n_client)
            angles(n_angle, n_client)%atom_i = &
                indices(n_angle * 3 - 2, n_client)
            angles(n_angle, n_client)%atom_j = &
                indices(n_angle * 3 - 1, n_client)
            angles(n_angle, n_client)%atom_k = &
                indices(n_angle * 3, n_client)
            angles(n_angle, n_client)%angle = &
                angle_vals(n_angle, n_client)
        end do ! n_angle
    end do ! n_client

end subroutine gather_angles