[Fortran] 纯文本查看 复制代码
!$OMP PARALLEL DO PRIVATE(i,j,l,m,pf,th,ll,sr,rl,ls,rs,rg,ag,ipiv,work,lwork,info,fd,tr)&
!$OMP SHARED(po,km,kp,nm,nb,ei,ic,tv,lr,ol,ks,ra,k,ch,te) COLLAPSE(2)&
!$OMP REDUCTION(+:t1,t2,t3)
DO i = 1, nm, 1
DO j = 1, km(1)*km(2)*km(3), 1
DO l = 1, nb, 1
DO m = 1, po(1)*po(2)*po(3), 1
pf = EXP(ic*(kp(j,1)*(tv(1,m)*lr(1,1)+tv(2,m)*lr(2,1)+tv(3,m)*lr(3,1))+kp(j,2)*(tv(1,m)*lr(1,2)+tv(2,m)*lr(2,2)+tv(3,m)*lr(3,2))+kp(j,3)*(tv(1,m)*lr(1,3)+tv(2,m)*lr(2,3)+tv(3,m)*lr(3,3))))
th(:,l) = pf*((ei(i)+ic)*ol(:,l,m)-ks(:,l,m))
END DO
END DO
ll(1,:,:) = th(ra(1)-k:ra(2)-k,ra(1)-k*2:ra(2)-k*2)
ll(2,:,:) = th(ra(1)-k:ra(2)-k,ra(1)-k:ra(2)-k)
ll(3,:,:) = th(ra(1)-k*2:ra(2)-k*2,ra(1)-k:ra(2)-k)
ll(4,:,:) = th(ra(1)-k:ra(2)-k,ra(1):ra(2))
ll(5,:,:) = th(ra(1):ra(2),ra(1)-k:ra(2)-k)
sr = th(ra(1):ra(2),ra(1):ra(2))
rl(1,:,:) = th(ra(1)+k:ra(2)+k,ra(1)+k*2:ra(2)+k*2)
rl(2,:,:) = th(ra(1)+k:ra(2)+k,ra(1)+k:ra(2)+k)
rl(3,:,:) = th(ra(1)+k*2:ra(2)+k*2,ra(1)+k:ra(2)+k)
rl(4,:,:) = th(ra(1):ra(2),ra(1)+k:ra(2)+k)
rl(5,:,:) = th(ra(1)+k:ra(2)+k,ra(1):ra(2))
ls = MATMUL(MATMUL(ll(1,:,:),ll(2,:,:)),ll(3,:,:))
ll(2,:,:) = ll(2,:,:) - ls
rs = MATMUL(MATMUL(rl(1,:,:),rl(2,:,:)),rl(3,:,:))
rl(2,:,:) = rl(2,:,:) - rs
rg = DCMPLX(0.0d0, 0.0d0)
rg = sr-ls-rs
CALL ZGETRF(ra(2)-ra(1),ra(2)-ra(1),rg,l,ipiv,info)
CALL ZGETRI(ra(2)-ra(1),rg,ra(2)-ra(1),ipiv,work,lwork,info)
DO l = 1, k, 1
ag(l,:) = DCONJG(rg(:,l))
END DO
fd(1) = 1.0d0/(EXP((ei(i)-ch(1))/te)+1.0d0)
fd(2) = 1.0d0/(EXP((ei(i)-ch(3))/te)+1.0d0)
IF (fd(1) > fd(2)) THEN
fd(3) = fd(1)
fd(1) = fd(2)
fd(2) = fd(3)
fd(3) = fd(2)-fd(1)
ELSE IF (fd(1) == fd(2)) THEN
fd(3) = 1.0d0
ELSE
fd(3) = fd(2)-fd(1)
END IF
t1(i,j,:,:) = t1(i,j,:,:)+fd(3)*MATMUL(MATMUL(rg,ls+rs),ag)/2.0d0-fd(1)*IMAG(rg)
tr = MATMUL(MATMUL(MATMUL(ls,ag),rs),rg)
DO l = 1, k, 1
t2(i) = t2(i)+tr(l,l)
END DO
t2(i) = t2(i)*fd(3)
tr = rg - ag
DO l = 1, k, 1
t3(i) = t3(i)+tr(l,l)
END DO
END DO
END DO
!$OMP END PARALLEL DO