From e210f07dd1b154275ba6ba74fa76a4fab64b3ea3 Mon Sep 17 00:00:00 2001 From: giannozz Date: Fri, 4 Apr 2008 13:58:13 +0000 Subject: [PATCH] There was a nasty bug in the real-space approach to Q(r) of USPP: if the physical and true dimensions of the charge density array were different, the algorithm was filling non physical locations of the array as well git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@4772 c92efa57-630b-4861-b058-cf58834340f0 --- PW/realus.f90 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PW/realus.f90 b/PW/realus.f90 index 51f882226..02d59454e 100644 --- a/PW/realus.f90 +++ b/PW/realus.f90 @@ -155,14 +155,10 @@ MODULE realus ! ! ... now we find the points ! - idx0 = 0 - ! #if defined (__PARA) - ! - DO i = 1, me_pool - idx0 = idx0 + nrx1*nrx2*dfftp%npp(i) - END DO - ! + idx0 = nrx1*nrx2 * SUM ( dfftp%npp(1:me_pool) ) +#else + idx0 = 0 #endif ! inv_nr1 = 1.D0 / DBLE( nr1 ) @@ -183,7 +179,7 @@ MODULE realus ! DO ir = 1, nrxx ! - ! ... three dimensional indexes + ! ... three dimensional indices (i,j,k) ! idx = idx0 + ir - 1 k = idx / (nrx1*nrx2) @@ -192,6 +188,10 @@ MODULE realus idx = idx - nrx1*j i = idx ! + ! ... do not include points outside the physical range! + ! + IF ( i >= nr1 .or. j >= nr2 .or. k >= nr3 ) CYCLE + ! DO ipol = 1, 3 posi(ipol) = DBLE( i )*inv_nr1*at(ipol,1) + & DBLE( j )*inv_nr2*at(ipol,2) + &