6 subroutine genvchi0(t3hw,ik,lock,vqpl,gclgq,jlgqr,ylmgq,sfacgq,nm,vchi0)
11 logical,
intent(in) :: t3hw
12 integer,
intent(in) :: ik
13 integer(omp_lock_kind),
intent(inout) :: lock(nwrf)
14 real(8),
intent(in) :: vqpl(3),gclgq(ngrf),jlgqr(njcmax,nspecies,ngrf)
15 complex(8),
intent(in) :: ylmgq(lmmaxo,ngrf),sfacgq(ngrf,natmtot)
16 integer,
intent(in) :: nm
17 complex(4),
intent(inout) :: vchi0(nm,nm,nwrf)
20 integer isym,jk,jkq,iw,nthd
21 integer nst,nstq,ist,jst,kst,lst
22 integer nm2,ig0,ig1,ig,jg,i,j
23 real(8) vkql(3),ei,ej,eij,t1
27 integer idx(nstsv),idxq(nstsv)
28 integer ngp(nspnfv),ngpq(nspnfv)
30 integer,
allocatable :: igpig(:,:),igpqig(:,:)
31 complex(4),
allocatable :: wfmt(:,:,:,:),wfir(:,:,:)
32 complex(4),
allocatable :: wfmtq(:,:,:,:),wfirq(:,:,:)
33 complex(4),
allocatable :: crhomt(:,:),crhoir(:),cw(:),b(:,:)
34 complex(8),
allocatable :: zrhoig(:),pmat(:,:,:)
37 if (sum(abs(vqpl(:))) <
epslat) tq0=.true.
39 vkql(:)=
vkl(:,ik)+vqpl(:)
57 allocate(igpig(
ngkmax,nspnfv))
59 call genwfsvp_sp(.false.,.false.,nst,idx,
ngdgc,
igfc,
vkl(:,ik),ngp,igpig,wfmt, &
62 allocate(igpqig(
ngkmax,nspnfv))
64 call genwfsvp_sp(.false.,.false.,nstq,idxq,
ngdgc,
igfc,vkql,ngpq,igpqig,wfmtq, &
69 allocate(pmat(nstsv,nstsv,3))
73 pmat(1:nstsv,1:nstsv,1:3)=t1*pmat(1:nstsv,1:nstsv,1:3)
83 allocate(zrhoig(ngrf),cw(nwrf))
84 if (tq0.and.t3hw)
then 85 allocate(b(-1:ngrf,-1:ngrf))
87 allocate(b(ngrf,ngrf))
96 if (abs(t1) < 1.d-8) cycle
101 cw(iw)=t1/(eij+
wrf(iw))
104 call gencrho(.true.,.true.,
ngtc,wfmt(:,:,:,ist),wfir(:,:,ist), &
105 wfmtq(:,:,:,jst),wfirq(:,:,jst),crhomt,crhoir)
106 call zftcf(ngrf,jlgqr,ylmgq,ngrf,sfacgq,crhomt,crhoir,zrhoig)
110 b(ig,jg)=conjg(b(jg,ig))
112 z1=gclgq(jg)*conjg(zrhoig(jg))
114 b(ig,jg)=gclgq(ig)*zrhoig(ig)*z1
124 z1=t1*pmat(kst,lst,i+2)
125 b(i,2:ngrf)=z1*conjg(zrhoig(2:ngrf))*gclgq(2:ngrf)
132 t1=sum(dble(pmat(kst,lst,1:3))**2+aimag(pmat(kst,lst,1:3))**2)/3.d0
136 z1=(t1/3.d0)*(pmat(kst,lst,1)+pmat(kst,lst,2)+pmat(kst,lst,3))
137 b(1,2:ngrf)=z1*conjg(zrhoig(2:ngrf))*gclgq(2:ngrf)
138 b(2:ngrf,1)=conjg(b(1,2:ngrf))
142 if (t3hw.or.(
mbwgrf < 0))
then 145 call omp_set_lock(lock(iw))
146 call caxpy(nm2,cw(iw),b,1,vchi0(1,1,iw),1)
147 call omp_unset_lock(lock(iw))
152 call omp_set_lock(lock(iw))
156 vchi0(ig0:ig1,jg,iw)=vchi0(ig0:ig1,jg,iw)+c1*b(ig0:ig1,jg)
158 call omp_unset_lock(lock(iw))
162 if (tq0.and.t3hw)
then 164 cw(1:nwrf)=cw(1:nwrf)/
wrf(1:nwrf)
167 a(i,j)=t1*pmat(kst,lst,i)*conjg(pmat(kst,lst,j))
172 call omp_set_lock(lock(iw))
173 vchi0(1:3,1:3,iw)=vchi0(1:3,1:3,iw)+cw(iw)*a(1:3,1:3)
174 call omp_unset_lock(lock(iw))
182 deallocate(crhomt,crhoir,zrhoig,cw,b)
185 deallocate(wfmt,wfir,wfmtq,wfirq)
186 if (tq0)
deallocate(pmat)
real(8), dimension(:,:), allocatable evalsv
subroutine genwfsvp_sp(tsh, tgp, nst, idx, ngridg_, igfft_, vpl, ngp, igpig, wfmt, ld, wfir)
subroutine gencrho(tsh, tspc, ngt, wfmt1, wfir1, wfmt2, wfir2, crhomt, crhoir)
subroutine getpmat(vpl, pmat)
complex(8), dimension(:), allocatable wrf
integer, dimension(:,:,:), allocatable ivkik
subroutine genvchi0(t3hw, ik, lock, vqpl, gclgq, jlgqr, ylmgq, sfacgq, nm, vchi0)
subroutine zftcf(ngp, jlgpr, ylmgp, ld, sfacgp, cfmt, cfir, zfgp)
integer, dimension(:), allocatable igfc
real(8), dimension(:,:), allocatable occsv
real(8), dimension(:,:), allocatable vkl
integer, dimension(3) ngdgc
subroutine holdthd(nloop, nthd)
real(8), parameter fourpi
subroutine findkpt(vpl, isym, ik)
integer, dimension(:,:), allocatable ivk