34 SUBROUTINE libtetrabz_fermigr(ltetra,bvec,nb,nge,eig1,eig2,ngw,wght,ne,e0,comm)
BIND(C)
40 INTEGER(C_INT),
INTENT(IN) :: ltetra, nb, nge(3), ngw(3), ne
41 REAL(c_double),
INTENT(IN) :: bvec(9), e0(ne), eig1(nb,product(nge(1:3))), eig2(nb,product(nge(1:3)))
42 REAL(c_double),
INTENT(OUT) :: wght(ne*nb*nb,product(ngw(1:3)))
43 INTEGER(C_INT),
INTENT(IN),
OPTIONAL :: comm
46 INTEGER :: nt_local, nk_local, nkbz, ik, kintp(8)
47 INTEGER,
ALLOCATABLE :: ik_global(:,:), ik_local(:,:)
48 REAL(8) :: wlsm(4,20), wintp(1,8)
49 REAL(8),
ALLOCATABLE :: wghtd(:,:,:), kvec(:,:)
51 IF(
PRESENT(comm))
THEN
53 & nt_local,nkbz,ik_global,ik_local,kvec,comm)
56 & nt_local,nkbz,ik_global,ik_local,kvec)
61 ALLOCATE(wghtd(ne*nb*nb,1,nk_local))
62 CALL libtetrabz_fermigr_main(wlsm,nt_local,ik_global,ik_local,nb,nkbz,eig1,eig2,ne,e0,nk_local,wghtd)
66 wght(1:ne*nb*nb,1:product(ngw(1:3))) = 0d0
69 wght(1:ne*nb*nb,kintp(1:8)) = wght(1:ne*nb*nb, kintp(1:8)) &
70 & + matmul(wghtd(1:ne*nb*nb,1:1,ik), wintp(1:1,1:8))
72 DEALLOCATE(wghtd, kvec)
77 CALL libtetrabz_fermigr_main(wlsm,nt_local,ik_global,ik_local,nb,nkbz,eig1,eig2,ne,e0,nk_local,wght)
80 DEALLOCATE(ik_global, ik_local)
86 SUBROUTINE libtetrabz_fermigr_main(wlsm,nt_local,ik_global,ik_local,nb,nkBZ,eig1,eig2,ne,e0,nk_local,fermigr)
95 INTEGER,
INTENT(IN) :: nt_local, nb, nkBZ, nk_local, ne, &
96 & ik_global(20,nt_local), ik_local(20,nt_local)
97 REAL(8),
INTENT(IN) :: wlsm(4,20), eig1(nb,nkBZ), eig2(nb,nkBZ), e0(ne)
98 REAL(8),
INTENT(OUT) :: fermigr(ne*nb,nb,nk_local)
100 INTEGER :: it, ib, indx(4)
101 REAL(8) :: e(4), ei1(4,nb), ei2(4), ej1(4,nb), ej2(4,nb), thr = 1d-10, tsmall(4,4), v, w1(ne*nb,4), w2(ne*nb,4)
103 fermigr(1:ne*nb,1:nb,1:nk_local) = 0d0
112 ei1(1:4, ib) = matmul(wlsm(1:4,1:20), eig1(ib, ik_global(1:20,it)))
113 ej1(1:4, ib) = matmul(wlsm(1:4,1:20), eig2(ib, ik_global(1:20,it)))
119 w1(1:ne*nb,1:4) = 0d0
120 e(1:4) = ei1(1:4, ib)
123 IF(e(1) <= 0d0 .AND. 0d0 < e(2))
THEN
129 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
130 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
132 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
133 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
137 ELSE IF( e(2) <= 0d0 .AND. 0d0 < e(3))
THEN
143 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
144 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
146 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
147 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
155 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
156 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
158 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
159 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
167 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
168 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
170 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
171 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
175 ELSE IF( e(3) <= 0d0 .AND. 0d0 < e(4))
THEN
181 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
182 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
184 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
185 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
193 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
194 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
196 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
197 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
205 ei2(1:4 ) = matmul(tsmall(1:4,1:4), ei1(indx(1:4), ib))
206 ej2(1:4,1:nb) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),1:nb))
208 w1(1:ne*nb,indx(1:4)) = w1(1:ne*nb,indx(1:4)) &
209 & + v * matmul(w2(1:ne*nb, 1:4 ), tsmall(1:4,1:4))
213 ELSE IF(e(4) <= 0d0)
THEN
215 ei2(1:4 ) = ei1(1:4, ib)
216 ej2(1:4,1:nb) = ej1(1:4,1:nb)
218 w1(1:ne*nb,1:4) = w1(1:ne*nb,1:4) + w2(1:ne*nb,1:4)
222 fermigr(1:ne*nb,ib,ik_local(1:20,it)) = fermigr(1:ne*nb,ib, ik_local(1:20,it)) &
223 & + matmul(w1(1:ne*nb,1:4), wlsm(1:4,1:20))
232 fermigr(1:ne*nb,1:nb,1:nk_local) = fermigr(1:ne*nb,1:nb,1:nk_local) / dble(6 * nkbz)
247 INTEGER,
INTENT(IN) :: nb, ne
248 REAL(8),
INTENT(IN) :: e0(ne), ei1(4), ej1(4,nb)
249 REAL(8),
INTENT(OUT) :: w1(ne,nb,4)
251 INTEGER :: ib, indx(4)
252 REAL(8) :: de(4), e(4), thr = 1d-8, tsmall(4,4), v, w2(ne,4)
256 w1(1:ne,ib,1:4) = 0d0
257 e(1:4) = - ej1(1:4, ib)
260 IF((e(1) <= 0d0 .AND. 0d0 < e(2)) .OR. (e(1) < 0d0 .AND. 0d0 <= e(2)))
THEN
266 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
268 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
269 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
273 ELSE IF((e(2) <= 0d0 .AND. 0d0 < e(3)) .OR. (e(2) < 0d0 .AND. 0d0 <= e(3)))
THEN
279 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
281 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
282 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
290 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
292 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
293 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
301 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
303 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
304 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
308 ELSE IF((e(3) <= 0d0 .AND. 0d0 < e(4)) .OR. (e(3) < 0d0 .AND. 0d0 <= e(4)))
THEN
314 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
316 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
317 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
325 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
327 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
328 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
336 de(1:4) = matmul(tsmall(1:4,1:4), ej1(indx(1:4),ib) - ei1(indx(1:4)))
338 w1(1:ne,ib,indx(1:4)) = w1(1:ne,ib,indx(1:4)) &
339 & + v * matmul(w2(1:ne, 1:4 ), tsmall(1:4,1:4))
343 ELSE IF(e(4) <= 0d0)
THEN
345 de(1:4) = ej1(1:4,ib) - ei1(1:4)
347 w1(1:ne,ib,1:4) = w1(1:ne,ib,1:4) + w2(1:ne,1:4)
364 INTEGER,
INTENT(IN) :: ne
365 REAL(8),
INTENT(IN) :: e0(ne), de(4)
366 REAL(8),
INTENT(OUT) :: w1(ne,4)
368 INTEGER :: ie, indx(4)
369 REAL(8) :: e(4), tsmall(3,4), V, w2(3)
379 IF(e(1) < e0(ie) .AND. e0(ie) <= e(2))
THEN
382 w1(ie,indx(1:4)) = w1(ie,indx(1:4)) + v * sum(tsmall(1:3,1:4), 1) / 3d0
384 ELSE IF(e(2) < e0(ie) .AND. e0(ie) <= e(3))
THEN
387 w1(ie,indx(1:4)) = w1(ie,indx(1:4)) + v * sum(tsmall(1:3,1:4), 1) / 3d0
390 w1(ie,indx(1:4)) = w1(ie,indx(1:4)) + v * sum(tsmall(1:3,1:4), 1) / 3d0
392 ELSE IF(e(3) < e0(ie) .AND. e0(ie) < e(4))
THEN
395 w1(ie,indx(1:4)) = w1(ie,indx(1:4)) + v * sum(tsmall(1:3,1:4), 1) / 3d0