6subroutine gwsefmk(ikp,vmt,vir,bmt,bir,se)
12integer,
intent(in) :: ikp
13real(8),
intent(in) :: vmt(npcmtmax,natmtot),vir(ngtc)
14real(8),
intent(in) :: bmt(npcmtmax,natmtot,ndmag),bir(ngtc,ndmag)
15complex(8),
intent(out) :: se(nstsv,nstsv,0:nwfm)
17integer ik,jk,ist1,ist2,ist3
18integer iv(3),iq,ig0,ig1,ig,jg
20real(8) vl(3),vc(3),wo,t1,t2
23integer(omp_lock_kind) lock(nwgw)
24real(8) vgqc(3,ngvc),gqc(ngvc),gclgq(ngvc)
26complex(4) cvclmt(npcmtmax,natmtot),cvclir(ngtc)
27complex(4) y(max(nstsv,nwgw))
29real(8),
allocatable :: jlgqr(:,:,:),jlgqrmt(:,:,:)
30complex(8),
allocatable :: apwalm(:,:,:,:),evecfv(:,:),evecsv(:,:)
31complex(8),
allocatable :: ylmgq(:,:),sfacgq(:,:)
32complex(4),
allocatable :: wfmt1(:,:,:,:),wfir1(:,:,:)
33complex(4),
allocatable :: wfmt2(:,:,:,:),wfir2(:,:,:)
34complex(4),
allocatable :: crhomt(:,:,:),crhoir(:,:)
35complex(4),
allocatable :: crgq(:,:,:),gs(:,:),stau(:,:,:),wc(:,:)
36complex(8),
allocatable :: epsi(:,:,:),v(:,:)
38complex(8),
external :: zcfinp
42allocate(ylmgq(
lmmaxo,ngvc),sfacgq(ngvc,natmtot))
44allocate(wfmt1(npcmtmax,natmtot,
nspinor,nstsv),wfir1(ngtc,
nspinor,nstsv))
45allocate(wfmt2(npcmtmax,natmtot,
nspinor,nstsv),wfir2(ngtc,
nspinor,nstsv))
46allocate(crhomt(npcmtmax,natmtot,nstsv),crhoir(ngtc,nstsv))
47allocate(crgq(nstsv,ngrf,nstsv),gs(nwgw,nstsv),stau(nstsv,nstsv,nwgw))
48allocate(epsi(ngrf,ngrf,
nwrf),v(nstsv,nstsv))
51 call omp_init_lock(lock(it))
57call match(
ngk(1,ikp),
vgkc(:,:,1,ikp),
gkc(:,1,ikp),
sfacgk(:,:,1,ikp),apwalm)
59call genwfsv_sp(.false.,.true.,nstsv,[0],
ngdgc,
igfc,
ngk(1,ikp),
igkig(:,1,ikp), &
60 apwalm,evecfv,evecsv,wfmt1,ngtc,wfir1)
63 call genvbmatk(vmt,vir,bmt,bir,
ngk(1,ikp),
igkig(:,1,ikp),wfmt1,ngtc,wfir1,v)
65 call genvmatk(vmt,vir,
ngk(1,ikp),
igkig(:,1,ikp),wfmt1,ngtc,wfir1,v)
72stau(1:nstsv,1:nstsv,1:nwgw)=0.e0
78 iv(1:3)=
ivk(1:3,ikp)-
ivk(1:3,ik)
79 iv(1:3)=modulo(iv(1:3),
ngridk(1:3))
81 iv(1:3)=iv(1:3)*
ngridq(1:3)
82 if (any(mod(iv(1:3),
ngridk(1:3)) /= 0)) cycle
83 iv(1:3)=iv(1:3)/
ngridk(1:3)
84 iq=
ivqiq(iv(1),iv(2),iv(3))
85 vl(1:3)=
vkl(1:3,ikp)-
vkl(1:3,ik)
86 vc(1:3)=
vkc(1:3,ikp)-
vkc(1:3,ik)
89 vgqc(1:3,ig)=
vgc(1:3,ig)+vc(1:3)
91 gqc(ig)=sqrt(vgqc(1,ig)**2+vgqc(2,ig)**2+vgqc(3,ig)**2)
98 call gengclgq(.true.,iq,ngvc,gqc,gclgq)
103 call match(
ngk(1,ik),
vgkc(:,:,1,ik),
gkc(:,1,ik),
sfacgk(:,:,1,ik),apwalm)
108 call genwfsv_sp(.false.,.false.,nstsv,[0],
ngdgc,
igfc,
ngk(1,ik),
igkig(:,1,ik),&
109 apwalm,evecfv,evecsv,wfmt2,ngtc,wfir2)
119 call gencrho(.true.,.true.,ngtc,wfmt2(:,:,:,ist3),wfir2(:,:,ist3), &
120 wfmt1(:,:,:,ist1),wfir1(:,:,ist1),crhomt(:,:,ist1),crhoir(:,ist1))
121 call zftcf(ngrf,jlgqr,ylmgq,ngvc,sfacgq,crhomt(:,:,ist1),crhoir(:,ist1), &
123 crgq(ist1,1:ngrf,ist3)=conjg(zfgq(1:ngrf))
130 if (abs(wo) <
epsocc) cycle
135 crhomt(:,:,ist2),cvclmt)
137 gclgq,ngvc,jlgqrmt,ylmgq,sfacgq,crhoir(:,ist2),npcmtmax,cvclmt,cvclir)
138 cvclir(1:ngtc)=cvclir(1:ngtc)*
cfrc(1:ngtc)
140 v(ist1,ist2)=v(ist1,ist2) &
141 -wo*zcfinp(crhomt(:,:,ist1),crhoir(:,ist1),cvclmt,cvclir)
155 gs(
iwfft(iw),ist1)=1.e0/cmplx(t1,
wgw(iw),4)
157 call cfftifc(1,nwgw,1,gs(:,ist1))
166 gclgq(1:ngrf)=sqrt(gclgq(1:ngrf))
172 allocate(wc(nwgw,ngrf))
177 if (dble(epsi(jg,jg,1)) == 0.d0) cycle
186 epsi(jg,jg,1:
nwrf)=epsi(jg,jg,1:
nwrf)-1.d0
194 wc(
iwfft(iw),ig)=t2*epsi(ig,jg,jw)
197 call cfftifc(1,nwgw,1,wc(:,ig))
206 y(1:nstsv)=y(1:nstsv)+c2*crgq(1:nstsv,ig,ist3)
208 call omp_set_lock(lock(it))
212 c2=conjg(crgq(ist2,jg,ist3))
213 stau(ist2,ist2,it)=stau(ist2,ist2,it)+c2*y(ist2)
218 c2=conjg(crgq(ist2,jg,ist3))
219 stau(1:nstsv,ist2,it)=stau(1:nstsv,ist2,it)+c2*y(1:nstsv)
222 call omp_unset_lock(lock(it))
234 call omp_destroy_lock(lock(it))
246 y(1:nwgw)=stau(ist1,ist2,1:nwgw)
250 se(ist1,ist2,jw)=t1*y(
iwfft(iw))
266 se(ist1,ist2,iw)=se(ist1,ist2,iw)+v(ist1,ist2)
269 se(ist1,ist2,iw)=se(ist1,ist2,iw)+conjg(v(ist2,ist1))
275deallocate(jlgqr,jlgqrmt)
276deallocate(ylmgq,sfacgq,apwalm,evecfv,evecsv)
277deallocate(wfmt1,wfir1,wfmt2,wfir2)
278deallocate(crhomt,crhoir,gs,stau,crgq,epsi,v)