The Elk Code
cpotclmt.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2023 J. K. Dewhurst and S. Sharma.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 pure subroutine cpotclmt(nr,nri,ld,rl,wpr,crhomt,cvclmt)
7 use modmain
8 integer, intent(in) :: nr,nri,ld
9 real(8), intent(in) :: rl(ld,-lmaxo-1:lmaxo+2),wpr(4,nr)
10 complex(4), intent(in) :: crhomt(*)
11 complex(4), intent(out) :: cvclmt(*)
12 ! local variables
13 integer nro,iro,ir
14 integer l,l1,l2,l3
15 integer lm,npi,i0,i
16 real(8) t0
17 complex(4) c1
18 ! automatic arrays
19 complex(4) f1(nr),f2(nr),f3(nr)
20 nro=nr-nri
21 iro=nri+1
22 npi=lmmaxi*nri
23 do l=0,lmaxi
24  l1=l+2
25  l2=-l+1
26  l3=-l-1
27  t0=fourpi/dble(2*l+1)
28  do lm=l**2+1,(l+1)**2
29  do ir=1,nri
30  i=lm+lmmaxi*(ir-1)
31  f1(ir)=rl(ir,l1)*crhomt(i)
32  f2(ir)=rl(ir,l2)*crhomt(i)
33  end do
34  i0=lm+npi
35  do ir=iro,nr
36  i=i0+lmmaxo*(ir-iro)
37  f1(ir)=rl(ir,l1)*crhomt(i)
38  f2(ir)=rl(ir,l2)*crhomt(i)
39  end do
40  call splintwp(nr,wpr,f1,f3)
41  call splintwp(nr,wpr,f2,f1)
42  c1=f1(nr)
43  do ir=1,nri
44  i=lm+lmmaxi*(ir-1)
45  cvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(c1-f1(ir)))
46  end do
47  do ir=iro,nr
48  i=i0+lmmaxo*(ir-iro)
49  cvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(c1-f1(ir)))
50  end do
51  end do
52 end do
53 do l=lmaxi+1,lmaxo
54  l1=l+2
55  l2=-l+1
56  l3=-l-1
57  t0=fourpi/dble(2*l+1)
58  do lm=l**2+1,(l+1)**2
59  i0=lm+npi
60  do ir=iro,nr
61  i=i0+lmmaxo*(ir-iro)
62  f1(ir)=rl(ir,l1)*crhomt(i)
63  f2(ir)=rl(ir,l2)*crhomt(i)
64  end do
65  call splintwp(nro,wpr(1,iro),f1(iro),f3(iro))
66  call splintwp(nro,wpr(1,iro),f2(iro),f1(iro))
67  c1=f1(nr)
68  do ir=iro,nr
69  i=i0+lmmaxo*(ir-iro)
70  cvclmt(i)=t0*(rl(ir,l3)*f3(ir)+rl(ir,l)*(c1-f1(ir)))
71  end do
72  end do
73 end do
74 
75 contains
76 
77 pure subroutine splintwp(n,wp,f,g)
78 implicit none
79 ! arguments
80 integer, intent(in) :: n
81 real(8), intent(in) :: wp(*)
82 complex(4), intent(in) :: f(n)
83 complex(4), intent(out) :: g(n)
84 ! local variables
85 integer i,j
86 complex(8) zsm
87 g(1)=0.e0
88 zsm=wp(5)*f(1)+wp(6)*f(2)+wp(7)*f(3)+wp(8)*f(4)
89 g(2)=zsm
90 do i=2,n-2
91  j=i*4+1
92  zsm=zsm+wp(j)*f(i-1)+wp(j+1)*f(i)+wp(j+2)*f(i+1)+wp(j+3)*f(i+2)
93  g(i+1)=zsm
94 end do
95 j=(n-1)*4+1
96 g(n)=zsm+wp(j)*f(n-3)+wp(j+1)*f(n-2)+wp(j+2)*f(n-1)+wp(j+3)*f(n)
97 end subroutine
98 
99 end subroutine
100 
integer lmmaxo
Definition: modmain.f90:203
integer lmaxo
Definition: modmain.f90:201
pure subroutine splintwp(n, wp, f, g)
Definition: atom.f90:183
integer lmmaxi
Definition: modmain.f90:207
real(8), parameter fourpi
Definition: modmain.f90:1234
pure subroutine cpotclmt(nr, nri, ld, rl, wpr, crhomt, cvclmt)
Definition: cpotclmt.f90:7
integer lmaxi
Definition: modmain.f90:205