Commit d1bb578d authored by giannozz's avatar giannozz

Minor and not-so-minor bugs and bugs-not-bugs:

- unused array mexx0 was allocated and never deallocated (noticed by
  Massimiaino Fatica)
- a temporary variable was not correctly initialized (most compilers set
  initial values to zero but this is not guaranteed)
- occupancies of Hubbard manifold (variable "ns") were computed independently
  on all processors, but their consistency was not ensured. Now there is a
  broadcast in "new_ns" that ensures consistency. While not a bug in principle,
  in practice this could lead to small divergencies buiding up between the
  ns on different processors, leading to small divergences of the
  self-consistency error (dr2), leading to small divergencies of the
  diagonalization threshold (ethr), leading to different numbers of
  unconverged eigenvalues on different processors, leading to mysterious MPI
  crashes. I am not sure about the origin of the divergence, but broadcasting
  ns seems to fix the problem.
parent b14728bf
......@@ -3044,7 +3044,7 @@ USE noncollin_module, ONLY : npol
IMPLICIT NONE
INTEGER :: nnpw,nbnd,i
COMPLEX(DP) :: phi(npwx*npol,nbnd),xitmp(npwx*npol,nbndproj)
COMPLEX(DP), ALLOCATABLE :: mexx(:,:), mexx0(:,:)
COMPLEX(DP), ALLOCATABLE :: mexx(:,:)
real(DP) :: exxe, exxe0
real(DP), PARAMETER :: Zero=0.0d0, One=1.0d0, Two=2.0d0, Pt5=0.50d0
TYPE(bec_type), INTENT(in) :: becpsi
......@@ -3054,10 +3054,9 @@ TYPE(bec_type), INTENT(in) :: becpsi
IF(nbndproj>nbnd) CALL errore('aceinit_k','nbndproj greater than nbnd.',1)
IF(nbndproj<=0) CALL errore('aceinit_k','nbndproj le 0.',1)
ALLOCATE( mexx(nbndproj,nbndproj), mexx0(nbndproj,nbndproj) )
ALLOCATE( mexx(nbndproj,nbndproj) )
xitmp = (Zero,Zero)
mexx = (Zero,Zero)
mexx0 = (Zero,Zero)
! |xi> = Vx[phi]|phi>
CALL vexx(npwx, nnpw, nbndproj, phi, xitmp, becpsi)
! mexx = <phi|Vx[phi]|phi>
......
......@@ -36,8 +36,8 @@ SUBROUTINE new_ns(ns)
USE wavefunctions, ONLY : evc
USE io_files, ONLY : nwordwfc, iunwfc, nwordwfcU, iunhub
USE buffers, ONLY : get_buffer
USE mp_pools, ONLY : inter_pool_comm
USE mp, ONLY : mp_sum
USE mp_pools, ONLY : inter_pool_comm, intra_pool_comm, root_pool
USE mp, ONLY : mp_sum, mp_bcast
USE becmod, ONLY : bec_type, calbec, &
allocate_bec_type, deallocate_bec_type
......@@ -63,7 +63,6 @@ SUBROUTINE new_ns(ns)
! Offset of atomic wavefunctions initialized in setup and stored in offsetU
!
nr (:,:,:,:) = 0.d0
ns (:,:,:,:) = 0.d0
!
! we start a loop on k points
!
......@@ -133,6 +132,7 @@ SUBROUTINE new_ns(ns)
ENDDO
! symmetrize the quantities nr -> ns
ns (:,:,:,:) = 0.d0
DO na = 1, nat
nt = ityp (na)
IF ( is_hubbard(nt) ) THEN
......@@ -171,6 +171,7 @@ SUBROUTINE new_ns(ns)
ENDDO
ENDIF
ENDDO
DEALLOCATE ( nr )
! Now we make the matrix ns(m1,m2) strictly hermitean
DO na = 1, nat
......@@ -196,7 +197,9 @@ SUBROUTINE new_ns(ns)
ENDIF
ENDDO
DEALLOCATE ( nr )
! the following broadcast ensures consistency on different processors
! of the same pool
CALL mp_bcast( ns, root_pool, intra_pool_comm )
CALL stop_clock('new_ns')
RETURN
......@@ -299,8 +302,8 @@ SUBROUTINE new_ns_nc(ns)
USE io_files, ONLY : nwordwfc, iunwfc, nwordwfcU, iunhub
USE buffers, ONLY : get_buffer
USE mp_bands, ONLY : intra_bgrp_comm
USE mp_pools, ONLY : inter_pool_comm
USE mp, ONLY : mp_sum
USE mp_pools, ONLY : inter_pool_comm, intra_pool_comm, root_pool
USE mp, ONLY : mp_sum, mp_bcast
IMPLICIT NONE
!
......@@ -514,6 +517,9 @@ loopisym: do isym = 1, nsym
ENDDO
!--
DEALLOCATE ( nr, nr1 )
! the following broadcast ensures consistency on different processors
! of the same pool
CALL mp_bcast( ns, root_pool, intra_pool_comm )
CALL stop_clock('new_ns')
RETURN
......
......@@ -147,6 +147,7 @@ MODULE dftd3_qe
tau(:,:) = tau(:,:) / alat
at(:,:) = at(:,:) / alat
!
x = 0.d0
do ata = 1, nat
z = get_atomic_number(trim(atm(ityp(ata))))
CALL getc6(maxc,max_elem,this%c6ab,this%mxc, &
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment