6subroutine genvchi0(t3hw,ik,lock,vqpl,gclgq,jlgqr,ylmgq,sfacgq,nm,vchi0)
11logical,
intent(in) :: t3hw
12integer,
intent(in) :: ik
13integer(omp_lock_kind),
intent(inout) :: lock(nwrf)
14real(8),
intent(in) :: vqpl(3),gclgq(ngrf),jlgqr(njcmax,nspecies,ngrf)
15complex(8),
intent(in) :: ylmgq(lmmaxo,ngrf),sfacgq(ngrf,natmtot)
16integer,
intent(in) :: nm
17complex(4),
intent(inout) :: vchi0(nm,nm,nwrf)
20integer isym,jk,jkq,iw,nthd
21integer nst,nstq,ist,jst,kst,lst
22integer nm2,ig0,ig1,ig,jg,i,j
23real(8) vkql(3),ei,ej,eij,t1
27integer idx(nstsv),idxq(nstsv)
28integer ngp(nspnfv),ngpq(nspnfv)
30integer,
allocatable :: igpig(:,:),igpqig(:,:)
31complex(4),
allocatable :: wfmt(:,:,:,:),wfir(:,:,:)
32complex(4),
allocatable :: wfmtq(:,:,:,:),wfirq(:,:,:)
33complex(4),
allocatable :: crhomt(:,:),crhoir(:),cw(:),b(:,:)
34complex(8),
allocatable :: zrhoig(:),pmat(:,:,:)
37if (sum(abs(vqpl(:))) <
epslat) tq0=.true.
39vkql(:)=
vkl(:,ik)+vqpl(:)
57allocate(igpig(
ngkmax,nspnfv))
59call genwfsvp_sp(.false.,.false.,nst,idx,
ngdgc,
igfc,
vkl(:,ik),ngp,igpig,wfmt, &
62allocate(igpqig(
ngkmax,nspnfv))
64call 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)
83allocate(zrhoig(ngrf),cw(nwrf))
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))
182deallocate(crhomt,crhoir,zrhoig,cw,b)
185deallocate(wfmt,wfir,wfmtq,wfirq)
186if (tq0)
deallocate(pmat)
integer, dimension(3) ngdgc
integer, dimension(:,:), allocatable ivk
integer, dimension(:), allocatable igfc
real(8), parameter fourpi
complex(8), dimension(:), allocatable wrf
real(8), dimension(:,:), allocatable vkl
integer, dimension(:,:,:), allocatable ivkik
real(8), dimension(:,:), allocatable occsv
real(8), dimension(:,:), allocatable evalsv