subroutine ps_NonlocalProjectors_Filter(ps,&
indexes_in,&
l,j,seq,set, &
indexes,number)
type(ps_t), intent(in), target :: ps
integer, intent(in), optional :: indexes_in(:)
integer, intent(in), optional :: set
integer, intent(in), optional :: l
real(dp), intent(in), optional :: j
integer, intent(in), optional :: seq
integer, intent(out), allocatable, optional :: indexes(:)
integer, intent(out), optional :: number
integer :: i, ii, num
integer, allocatable :: idx(:), range(:)
type(nl_table_t), pointer :: q(:)
q => ps%nl_table
!
! If we specify an initial domain, we
! only loop over it for the rest of
! the operations
!
if (present(indexes_in)) then
allocate(range(size(indexes_in)))
range(:) = indexes_in(:)
else
allocate(range(size(q)))
do ii = 1, size(q)
range(ii) = ii
enddo
endif
num = 0
do ii = 1, size(range)
i = range(ii)
if (present(set)) then
if (iand(q(i)%p%set,set) == 0) cycle
endif
if (present(l)) then
if (l_of_sym(q(i)%p%l,"pot") /= l) cycle
endif
if (present(j)) then
! A negative p%j signals the absence of j...
if (q(i)%p%j < 0.0) cycle
! Perform integer comparison
if (nint(10*q(i)%p%j) /= nint(10*j)) cycle
endif
if (present(seq)) then
if (q(i)%p%seq /= seq) cycle
endif
num = num + 1
enddo
allocate(idx(num))
num = 0
do ii = 1, size(range)
i = range(ii)
if (present(set)) then
if (iand(q(i)%p%set,set) == 0) cycle
endif
if (present(j)) then
! A negative p%j signals the absence of j...
if (q(i)%p%j < 0.0) cycle
! Perform integer comparison
if (nint(10*q(i)%p%j) /= nint(10*j)) cycle
endif
if (present(l)) then
if (l_of_sym(q(i)%p%l,"pot") /= l) cycle
endif
if (present(seq)) then
if (q(i)%p%seq /= seq) cycle
endif
num = num + 1
idx(num) = i
enddo
if (present(indexes)) then
if (allocated(indexes)) deallocate(indexes)
allocate(indexes(num))
indexes(:) = idx(:)
endif
if (present(number)) then
number = num
endif
deallocate(idx,range)
end subroutine ps_NonlocalProjectors_Filter