Skip to content

Commit

Permalink
Fix the issue of ordering in the calls to pawcprj_get or pawcprj_put …
Browse files Browse the repository at this point in the history
…in the wf_mixing set of routines. Bug fix from François Jollet.
  • Loading branch information
gonzex committed Oct 14, 2018
1 parent 7aea031 commit 9ebbae1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/66_wfs/m_cgcprj.F90
Expand Up @@ -140,7 +140,7 @@ subroutine dotprod_set_cgcprj(atindx1,cg1,cg2,cprj1,cprj2,dimcprj,hermitian,&

!Local variables-------------------------------
!scalars
integer :: ia,iat,itypat,ibd1,ibd2,icgb1,icgb2,ier,ig,ii,i1,i2
integer :: ia,iat,itypat,ibd1,ibd2,icgb1,icgb2,ier,ig,ii,i1,i2,iorder
integer :: ilmn1,ilmn2,klmn,max_nbd2,nbd
real(dp) :: dotr,doti
!arrays
Expand Down Expand Up @@ -168,6 +168,7 @@ subroutine dotprod_set_cgcprj(atindx1,cg1,cg2,cprj1,cprj2,dimcprj,hermitian,&
if(usepaw==1) then
ABI_DATATYPE_ALLOCATE(cprj1_k,(natom,nspinor*nbd1))
ABI_DATATYPE_ALLOCATE(cprj2_k,(natom,nspinor*nbd2))
iorder=0 ! There is no change of ordering of cprj when copying wavefunctions
end if
if(usepaw==1 .and. ibg1/=0) then
call pawcprj_alloc(cprj1_k,cprj1(1,1)%ncpgr,dimcprj)
Expand All @@ -185,7 +186,7 @@ subroutine dotprod_set_cgcprj(atindx1,cg1,cg2,cprj1,cprj2,dimcprj,hermitian,&
cwavef1(2,ig)=cg1(2,ig+icgb1)
end do
if(usepaw==1 .and. ibg1/=0) then
call pawcprj_get(atindx1,cprj1_k,cprj1,natom,1,ibg1,ikpt,1,isppol,mband,&
call pawcprj_get(atindx1,cprj1_k,cprj1,natom,1,ibg1,ikpt,iorder,isppol,mband,&
& mkmem,natom,nbd1,nbd1,nspinor,nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand All @@ -205,7 +206,7 @@ subroutine dotprod_set_cgcprj(atindx1,cg1,cg2,cprj1,cprj2,dimcprj,hermitian,&
end do

if(usepaw==1 .and. ibg2/=0) then
call pawcprj_get(atindx1,cprj2_k,cprj2,natom,1,ibg2,ikpt,1,isppol,mband,&
call pawcprj_get(atindx1,cprj2_k,cprj2,natom,1,ibg2,ikpt,iorder,isppol,mband,&
& mkmem,natom,nbd2,nbd2,nspinor,nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand Down Expand Up @@ -487,7 +488,7 @@ subroutine dotprodm_sumdiag_cgcprj(atindx1,cg_set,cprj_set,dimcprj,&

!Local variables-------------------------------
!scalars
integer :: ia,iat,itypat,ibd,icgb,ig
integer :: ia,iat,itypat,ibd,icgb,ig,iorder
integer :: ilmn1,ilmn2,ind_set1,ind_set2,iset1,iset2,klmn
real(dp) :: dotr,doti
!arrays
Expand All @@ -506,8 +507,7 @@ subroutine dotprodm_sumdiag_cgcprj(atindx1,cg_set,cprj_set,dimcprj,&
if(usepaw==1) then
ABI_DATATYPE_ALLOCATE(cprj1_k,(natom,nspinor*nbd))
ABI_DATATYPE_ALLOCATE(cprj2_k,(natom,nspinor*nbd))
end if
if(usepaw==1) then
iorder=0 ! There is no change of ordering in the copy of wavefunctions
call pawcprj_alloc(cprj1_k,cprj_set(1,1,1)%ncpgr,dimcprj)
end if

Expand All @@ -526,7 +526,7 @@ subroutine dotprodm_sumdiag_cgcprj(atindx1,cg_set,cprj_set,dimcprj,&
cwavef1(2,ig)=cg_set(2,ig+icgb,ind_set1)
end do
if(usepaw==1) then
call pawcprj_get(atindx1,cprj1_k,cprj_set(:,:,ind_set1),natom,1,ibg,ikpt,1,isppol,mband,&
call pawcprj_get(atindx1,cprj1_k,cprj_set(:,:,ind_set1),natom,1,ibg,ikpt,iorder,isppol,mband,&
& mkmem,natom,nbd,nbd,nspinor,nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand All @@ -546,7 +546,7 @@ subroutine dotprodm_sumdiag_cgcprj(atindx1,cg_set,cprj_set,dimcprj,&
end do

if(usepaw==1) then
call pawcprj_get(atindx1,cprj2_k,cprj_set(:,:,ind_set2),natom,1,ibg,ikpt,1,isppol,mband,&
call pawcprj_get(atindx1,cprj2_k,cprj_set(:,:,ind_set2),natom,1,ibg,ikpt,iorder,isppol,mband,&
& mkmem,natom,nbd,nbd,nspinor,nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand Down
19 changes: 10 additions & 9 deletions src/94_scfcv/m_scfcv_core.F90
Expand Up @@ -2777,7 +2777,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
integer :: hermitian
integer :: ibdmix,ibdsp,ibg,ibg_hist,icg,icg_hist
integer :: ierr,ikpt,indh,ind_biorthog,ind_biorthog_eff,ind_newwf,ind_residual,inplace
integer :: iset2,isppol,istep_cycle,istep_new,istwf_k,kk,me_distrb,my_nspinor
integer :: iorder,iset2,isppol,istep_cycle,istep_new,istwf_k,kk,me_distrb,my_nspinor
integer :: nband_k,nbdmix,npw_k,nset1,nset2,ntypat
integer :: shift_set1,shift_set2,spaceComm_band,spare_mem,usepaw,wfmixalg
real(dp) :: alpha,beta
Expand Down Expand Up @@ -2837,6 +2837,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
!Useful array
ABI_ALLOCATE(dimcprj,(dtset%natom))
if (usepaw==1) then
iorder=0 ! There is no change of ordering in the mixing of wavefunctions
call pawcprj_getdim(dimcprj,dtset%natom,nattyp,ntypat,dtset%typat,pawtab,'O')
end if

Expand Down Expand Up @@ -2902,10 +2903,10 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
scf_history_wf%cg(:,icg_hist+1:icg_hist+my_nspinor*npw_k*nbdmix,indh)=cg(:,icg+1:icg+my_nspinor*npw_k*nbdmix)
if(usepaw==1) then
! scf_history_wf%cprj(:,ibg_hist+1:ibg_hist+my_nspinor*nbdmix,1)=cprj(:,ibg+1:ibg+my_nspinor*nbdmix)
call pawcprj_get(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,1,isppol,dtset%mband,&
call pawcprj_get(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,iorder,isppol,dtset%mband,&
& dtset%mkmem,dtset%natom,nbdmix,nband_k,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,1,isppol,&
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,dimcprj,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,mpi_comm_band=spaceComm_band,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand Down Expand Up @@ -2954,10 +2955,10 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
! Biorthogonalization

if(usepaw==1) then
call pawcprj_get(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,1,isppol,dtset%mband,&
call pawcprj_get(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,iorder,isppol,dtset%mband,&
& dtset%mkmem,dtset%natom,nbdmix,nband_k,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
call pawcprj_get(atindx1,cprj_kh,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,1,isppol,&
call pawcprj_get(atindx1,cprj_kh,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,proc_distrb=mpi_enreg%proc_distrb)
end if !end usepaw=1
Expand Down Expand Up @@ -3027,7 +3028,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
scf_history_wf%cg(:,icg_hist+1:icg_hist+my_nspinor*npw_k*nbdmix,indh)=cg(:,icg+1:icg+my_nspinor*npw_k*nbdmix)
if(usepaw==1) then
do ibdmix=1,nbdmix
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,1,isppol,&
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,indh),dtset%natom,1,ibg_hist,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,dimcprj,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,mpi_comm_band=spaceComm_band,proc_distrb=mpi_enreg%proc_distrb)
end do ! end loop on ibdmix
Expand All @@ -3041,7 +3042,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
scf_history_wf%cg(:,icg_hist+1:icg_hist+my_nspinor*npw_k*nbdmix,1)=cg(:,icg+1:icg+my_nspinor*npw_k*nbdmix)
if(usepaw==1) then
do ibdmix=1,nbdmix
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,1),dtset%natom,1,ibg_hist,ikpt,1,isppol,&
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,1),dtset%natom,1,ibg_hist,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,dimcprj,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,mpi_comm_band=spaceComm_band,proc_distrb=mpi_enreg%proc_distrb)
end do ! end loop on ibdmix
Expand Down Expand Up @@ -3211,7 +3212,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&
! Store the newly extrapolated wavefunctions for this k point, still bi-orthonormalized, in scf_history_wf
scf_history_wf%cg(:,icg_hist+1:icg_hist+my_nspinor*npw_k*nbdmix,ind_newwf)=cg(:,icg+1:icg+my_nspinor*npw_k*nbdmix)
if(usepaw==1) then
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,ind_newwf),dtset%natom,1,ibg_hist,ikpt,1,isppol,&
call pawcprj_put(atindx1,cprj_k,scf_history_wf%cprj(:,:,ind_newwf),dtset%natom,1,ibg_hist,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,dimcprj,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,mpi_comm_band=spaceComm_band,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand All @@ -3222,7 +3223,7 @@ subroutine wf_mixing(atindx1,cg,cprj,dtset,istep,mcg,mcprj,mpi_enreg,&

! Need to transfer cprj_k to cprj
if(usepaw==1) then
call pawcprj_put(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,1,isppol,&
call pawcprj_put(atindx1,cprj_k,cprj,dtset%natom,1,ibg,ikpt,iorder,isppol,&
& nbdmix,dtset%mkmem,dtset%natom,nbdmix,nbdmix,dimcprj,my_nspinor,dtset%nsppol,0,&
& mpicomm=mpi_enreg%comm_kpt,mpi_comm_band=spaceComm_band,proc_distrb=mpi_enreg%proc_distrb)
end if
Expand Down

0 comments on commit 9ebbae1

Please sign in to comment.