File: gradwfcr2.f90

package info (click to toggle)
elkcode 5.4.24-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 12,840 kB
  • sloc: f90: 48,415; fortran: 22,457; perl: 965; makefile: 384; sh: 369; python: 105; ansic: 67
file content (54 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
! This file is distributed under the terms of the GNU General Public License.
! See the file COPYING for license details.

subroutine gradwfcr2(gwf2mt)
use modmain
implicit none
! arguments
real(8), intent(inout) :: gwf2mt(npmtmax,natmtot)
! local variables
integer ist,is,ias
integer nr,nri,iro,ir
integer np,l,m,lm,i
! allocatable arrays
complex(8), allocatable :: wfmt(:),gwfmt(:,:),zfmt(:)
allocate(wfmt(npmtmax),gwfmt(npmtmax,3),zfmt(npmtmax))
do ias=1,natmtot
  is=idxis(ias)
  nr=nrmt(is)
  nri=nrmti(is)
  iro=nri+1
  np=npmt(is)
  do ist=1,nstsp(is)
    if (spcore(ist,is).and.(ksp(ist,is).eq.lsp(ist,is)+1)) then
      l=lsp(ist,is)
      do m=-l,l
        lm=idxlm(l,m)
        wfmt(1:np)=0.d0
        i=lm
        do ir=1,nri
          wfmt(i)=rwfcr(ir,1,ist,ias)/rsp(ir,is)
          i=i+lmmaxi
        end do
        do ir=iro,nr
          wfmt(i)=rwfcr(ir,1,ist,ias)/rsp(ir,is)
          i=i+lmmaxo
        end do
        call gradzfmt(nr,nri,rsp(:,is),wfmt,npmtmax,gwfmt)
        do i=1,3
          call zbsht(nr,nri,gwfmt(:,i),zfmt)
! factor of 2 from spin
          gwf2mt(1:np,ias)=gwf2mt(1:np,ias) &
           +2.d0*(dble(zfmt(1:np))**2+aimag(zfmt(1:np))**2)
        end do
      end do
    end if
  end do
! end loops over atoms
end do
deallocate(wfmt,gwfmt,zfmt)
return
end subroutine