owns_pair Function

public elemental function owns_pair(partition, iat, jat) result(owned)

Whether this part owns a symmetry-reduced atom pair

Arguments

Type IntentOptional Attributes Name
type(work_partition), intent(in), optional :: partition

Work partition, absent selects the complete work

integer, intent(in) :: iat

Atom indices of the pair, with jat <= iat

integer, intent(in) :: jat

Atom indices of the pair, with jat <= iat

Return Value logical

Whether this part owns the pair


Source Code

elemental function owns_pair(partition, iat, jat) result(owned)

   !> Work partition, absent selects the complete work
   type(work_partition), intent(in), optional :: partition

   !> Atom indices of the pair, with jat <= iat
   integer, intent(in) :: iat, jat

   !> Whether this part owns the pair
   logical :: owned

   integer(i8) :: pair_index

   owned = .true.
   if (.not.present(partition)) return
   if (partition%nparts == 1) return

   ! zero-based index in the lower-triangular sequence (1,1), (2,1), (2,2), ...
   pair_index = int(iat - 1, i8)*int(iat, i8)/2_i8 + int(jat - 1, i8)
   owned = modulo(pair_index, int(partition%nparts, i8)) == int(partition%part, i8)

end function owns_pair