File: gendmatmt.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 (74 lines) | stat: -rw-r--r-- 2,227 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

! Copyright (C) 2007 F. Bultmark, F. Cricchio, L. Nordstrom and J. K. Dewhurst.
! This file is distributed under the terms of the GNU General Public License.
! See the file COPYING for license details.

subroutine gendmatmt
use modmain
use moddftu
use modmpi
use modomp
implicit none
! local variables
integer ik,ispn,ist
integer ias,n,nthd
real(8) t1
! allocatable arrays
complex(8), allocatable :: apwalm(:,:,:,:,:)
complex(8), allocatable :: evecfv(:,:,:),evecsv(:,:)
complex(8), allocatable :: dmat(:,:,:,:,:)
! zero the density matrix
dmatmt(:,:,:,:,:)=0.d0
! begin parallel loop over k-points
call omp_hold(nkpt/np_mpi,nthd)
!$OMP PARALLEL DEFAULT(SHARED) &
!$OMP PRIVATE(apwalm,evecfv,evecsv,dmat) &
!$OMP PRIVATE(ispn,ias,ist,t1) &
!$OMP NUM_THREADS(nthd)
!$OMP DO
do ik=1,nkpt
! distribute among MPI processes
  if (mod(ik-1,np_mpi).ne.lp_mpi) cycle
  allocate(apwalm(ngkmax,apwordmax,lmmaxapw,natmtot,nspnfv))
  allocate(evecfv(nmatmax,nstfv,nspnfv),evecsv(nstsv,nstsv))
  allocate(dmat(lmmaxdm,nspinor,lmmaxdm,nspinor,nstsv))
! find the matching coefficients
  do ispn=1,nspnfv
    call match(ngk(ispn,ik),gkc(:,ispn,ik),tpgkc(:,:,ispn,ik), &
     sfacgk(:,:,ispn,ik),apwalm(:,:,:,:,ispn))
  end do
! get the eigenvectors from file
  call getevecfv(filext,ik,vkl(:,ik),vgkl(:,:,:,ik),evecfv)
  call getevecsv(filext,ik,vkl(:,ik),evecsv)
! begin loop over atoms and species
  do ias=1,natmtot
    call gendmat(.false.,.false.,0,lmaxdm,ias,ngk(:,ik),apwalm,evecfv,evecsv, &
     lmmaxdm,dmat)
    do ist=1,nstsv
      t1=wkpt(ik)*occsv(ist,ik)
!$OMP CRITICAL(gendmatmt_)
      dmatmt(:,:,:,:,ias)=dmatmt(:,:,:,:,ias)+t1*dmat(:,:,:,:,ist)
!$OMP END CRITICAL(gendmatmt_)
    end do
  end do
  deallocate(apwalm,evecfv,evecsv,dmat)
end do
!$OMP END DO
!$OMP END PARALLEL
call omp_free(nthd)
! add density matrices from each process and redistribute
if (np_mpi.gt.1) then
  n=((lmmaxdm*nspinor)**2)*natmtot
  call mpi_allreduce(mpi_in_place,dmatmt,n,mpi_double_complex,mpi_sum,mpicom, &
   ierror)
end if
! initialise with symmetry-breaking tensor moments
if (ftmtype.lt.0) then
  dmftm=dmftm*reducebf
  dmatmt=dmatmt+dmftm
endif
! symmetrise the density matrix
call symdmat(lmaxdm,lmmaxdm,dmatmt)
return
end subroutine