exciting-0.9.89
[exciting.git] / src / zfmtinp.f90
blob753379701dd2d12a610af99803f1b9beacf35ea7
2 ! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3 ! This file is distributed under the terms of the GNU Lesser General Public
4 ! License. See the file COPYING for license details.
6 !BOP
7 ! !ROUTINE: zfmtinp
8 ! !INTERFACE:
9 complex(8) function zfmtinp(lmax,nr,r,ld,zfmt1,zfmt2)
10 ! !INPUT/OUTPUT PARAMETERS:
11 ! lmax : maximum angular momentum
12 ! nr : number of radial mesh points (in,integer)
13 ! r : radial mesh (in,real(nr))
14 ! ld : leading dimension (in,integer)
15 ! zfmt1 : first complex function inside muffin-tin (in,complex(ld,nr))
16 ! zfmt2 : second complex function inside muffin-tin (in,complex(ld,nr))
17 ! !DESCRIPTION:
18 ! Calculates the inner product of two complex fuctions in the muffin-tin. In
19 ! other words, given two complex functions of the form
20 ! $$ f({\bf r})=\sum_{l=0}^{l_{\rm max}}\sum_{m=-l}^{l}f_{lm}(r)Y_{lm}
21 ! (\hat{\bf r}), $$
22 ! the function returns
23 ! $$ I=\sum_{l=0}^{l_{\rm max}}\sum_{m=-l}^{l}\int f_{lm}^{1*}(r)
24 ! f_{lm}^2(r)r^2\,dr\;. $$
26 ! !REVISION HISTORY:
27 ! Created November 2003 (Sharma)
28 !EOP
29 !BOC
30 implicit none
31 ! arguments
32 integer, intent(in) :: lmax
33 integer, intent(in) :: nr
34 real(8), intent(in) :: r(nr)
35 integer, intent(in) :: ld
36 complex(8), intent(in) :: zfmt1(ld,nr)
37 complex(8), intent(in) :: zfmt2(ld,nr)
38 ! local variables
39 integer lmmax,ir
40 real(8) t1,t2
41 complex(8) zt1
42 ! automatic arrays
43 real(8) fr1(nr),fr2(nr),gr(nr),cf(3,nr)
44 ! external functions
45 complex(8) zdotc
46 external zdotc
47 if (lmax.lt.0) then
48 write(*,*)
49 write(*,'("Error(zfmtinp): lmax < 0 : ",I8)') lmax
50 write(*,*)
51 stop
52 end if
53 lmmax=(lmax+1)**2
54 do ir=1,nr
55 t1=r(ir)**2
56 zt1=zdotc(lmmax,zfmt1(1,ir),1,zfmt2(1,ir),1)
57 fr1(ir)=t1*dble(zt1)
58 fr2(ir)=t1*aimag(zt1)
59 end do
60 call fderiv(-1,nr,r,fr1,gr,cf)
61 t1=gr(nr)
62 call fderiv(-1,nr,r,fr2,gr,cf)
63 t2=gr(nr)
64 zfmtinp=cmplx(t1,t2,8)
65 return
66 end function
67 !EOC