From d748f1b334272166d45f695092fb3218b6c7e5b3 Mon Sep 17 00:00:00 2001 From: Ben Hourahine Date: Sat, 6 Apr 2024 12:29:44 +0100 Subject: [PATCH] Correct real to int in helper routine Change to epsilon in test and check for non-negativity --- src/dftbp/dftb/hybridxc.F90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dftbp/dftb/hybridxc.F90 b/src/dftbp/dftb/hybridxc.F90 index d3d218e3c2..ecb4ff04ca 100644 --- a/src/dftbp/dftb/hybridxc.F90 +++ b/src/dftbp/dftb/hybridxc.F90 @@ -1066,14 +1066,14 @@ subroutine updateCoords_kpts(this, env, symNeighbourList, nNeighbourCamSym, skOv contains - !> Returns the number of non-zero elements in a descending array of reals. + !> Returns the number of non-zero elements in a descending array of non-negative reals. function getNumberOfNonZeroElements(array) result(nNonZeroEntries) !> Descending, one-dimensional, real-valued array to search real(dp), intent(in) :: array(:) !> Number of non-zero entries - real(dp) :: nNonZeroEntries + integer :: nNonZeroEntries !! iterates over all array elements integer :: ii @@ -1081,7 +1081,10 @@ function getNumberOfNonZeroElements(array) result(nNonZeroEntries) nNonZeroEntries = 0 do ii = 1, size(array) - if (array(ii) < 1e-16_dp) return + if (array(ii) < epsilon(1.0_dp)) then + @:ASSERT(all(array(ii:) >= 0.0_dp)) + return + end if nNonZeroEntries = ii end do