diff --git a/Modules/sort.f90 b/Modules/sort.f90 index d0a83735c..4b98f8936 100644 --- a/Modules/sort.f90 +++ b/Modules/sort.f90 @@ -11,13 +11,13 @@ subroutine hpsort_eps (n, ra, ind, eps) !! Sort an array ra(1:n) into ascending order using heapsort algorithm, !! and considering two elements being equal if their values differ !! for less than "eps". IMPORTANT NOTICE (PG February 2022): - !! Assume you have in input a,b,c, in this order, with |a-b| < eps, - !! |b-c| < eps, but |a-c| > eps. The resulting output order may be a,b,c, - !! not c,a,b as it should. I think this is a bug. I don't know how to fix + !! Assume you have in input a,b,c with c < b < a and a-b < eps, b-c < eps, + !! but a-c > eps. The resulting output order should be c,a,b, but may turn + !! out to be a,b,c instead. I think this is a bug. I don't know how to fix !! it, I am not sure it does any harm, but re-ordering k+G with this same !! routine may yield a different ordering for k+G and G vectors even if k=0. - !! This was definitely a bug that has been around for years and that was - !! worked around by avoiding to recompute the indices for k+G if k=0. + !! This is a bug that has been around for years. The current work-around + !! (in routine gk_sort) is to avoid recomputing indices for k+G if k=0. !! !! \(\text{n}\) is input, \(\text{ra}\) is replaced on output by its !! sorted rearrangement. diff --git a/PW/src/gk_sort.f90 b/PW/src/gk_sort.f90 index e593e9e53..27058c1a7 100644 --- a/PW/src/gk_sort.f90 +++ b/PW/src/gk_sort.f90 @@ -19,8 +19,8 @@ SUBROUTINE gk_sort( k, ngm, g, ecut, ngk, igk, gk ) !! In practice, in some special cases (primitive lattice vectors that !! are close to but not exactly equal to a symmetric Bravais lattice) !! this does not hold, presumably due to a limitation of "hpsort_eps". - !! This is ia source of troouble for Gamma-only calculations, so one - !! explicitly sets igk(i)=i for k=0 + !! This is a source of trouble for Gamma-only calculations, so here + !! we explicitly set igk(i)=i for k=0. ! USE kinds, ONLY: DP USE constants, ONLY: eps8