The Elk Code
genidxelo.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2025 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 genidxelo
7 use modmain
8 implicit none
9 ! local variables
10 integer is,n,i,j,k,l
11 ! automatic arrays
12 integer idx(nlomax)
13 real(8) e0(nlomax)
14 ! generate the index which arranges the local-orbitals in ascending energy
15 do is=1,nspecies
16  n=nlorb(is)
17  do i=1,n
18  e0(i)=minval(lorbe0(1:lorbord(i,is),i,is))
19  idx(i)=i
20  end do
21  do i=1,n
22  k=i
23  do j=i+1,n
24  if (e0(idx(j)) < e0(idx(k))) k=j
25  end do
26  if (k /= i) then
27  l=idx(i)
28  idx(i)=idx(k)
29  idx(k)=l
30  end if
31  end do
32  idxelo(1:n,is)=idx(1:n)
33 end do
34 end subroutine
35 
subroutine genidxelo
Definition: genidxelo.f90:7
integer, dimension(maxspecies) nlorb
Definition: modmain.f90:786
real(8), dimension(maxlorbord, maxlorb, maxspecies) lorbe0
Definition: modmain.f90:804
integer, dimension(maxlorb, maxspecies) lorbord
Definition: modmain.f90:792
integer nspecies
Definition: modmain.f90:34
integer, dimension(maxlorb, maxspecies) idxelo
Definition: modmain.f90:806