The Elk Code
genidxthc.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2024 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 subroutine genidxthc
7 use modmain
8 use modtdhfc
9 implicit none
10 ! local variables
11 integer ik,jk,nst,nmax,ist
12 ! determine the maximum number of states within energy window over all k-points
13 nmax=0
14 do ik=1,nkpt
15  nst=0
16  do ist=1,nstsv
17  if (abs(evalsv(ist,ik)-efermi) < ecutthc) nst=nst+1
18  end do
19  nmax=max(nmax,nst)
20 end do
21 if (nmax == 0) then
22  write(*,*)
23  write(*,'("Error(genidxthc): no states within energy window ecutthc")')
24  write(*,*)
25  stop
26 end if
27 ! allocate global arrays
28 if (allocated(nthck)) deallocate(nthck)
29 allocate(nthck(nkpt))
30 if (allocated(idxthc)) deallocate(idxthc)
31 allocate(idxthc(nmax,nkpt))
32 if (allocated(istthc)) deallocate(istthc)
33 allocate(istthc(nmax,nkptnr))
34 ! determine the number of and index to used states
35 do ik=1,nkpt
36  nst=0
37  do ist=1,nstsv
38  if (abs(evalsv(ist,ik)-efermi) < ecutthc) then
39  nst=nst+1
40  idxthc(nst,ik)=ist
41  end if
42  end do
43  nthck(ik)=nst
44 end do
45 ! calculate the index to and total number of TDHFC states
46 nthc=0
47 do ik=1,nkptnr
48  jk=ivkik(ivk(1,ik),ivk(2,ik),ivk(3,ik))
49  do ist=1,nthck(jk)
50  nthc=nthc+1
51  istthc(ist,ik)=nthc
52  end do
53 end do
54 end subroutine
55 
real(8) efermi
Definition: modmain.f90:907
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
real(8) ecutthc
Definition: modtdhfc.f90:9
integer, dimension(:,:), allocatable istthc
Definition: modtdhfc.f90:17
integer nkpt
Definition: modmain.f90:461
integer, dimension(:,:,:), allocatable ivkik
Definition: modmain.f90:467
integer nkptnr
Definition: modmain.f90:463
integer nstsv
Definition: modmain.f90:889
integer, dimension(:), allocatable nthck
Definition: modtdhfc.f90:13
integer nthc
Definition: modtdhfc.f90:11
integer, dimension(:,:), allocatable idxthc
Definition: modtdhfc.f90:15
subroutine genidxthc
Definition: genidxthc.f90:7
integer, dimension(:,:), allocatable ivk
Definition: modmain.f90:465