The Elk Code
writew90amn.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 writew90amn
7 use modmain
8 use modw90
9 use modrandom
10 implicit none
11 ! local variables
12 integer ik,ist,i
13 real(8) a,b
14 character(256) fname
15 ! allocatable arrays
16 complex(8), allocatable :: amn(:,:)
17 if (projw90) allocate(amn(num_bands,num_wann))
18 fname=trim(seedname)//'.amn'
19 open(50,file=trim(fname),action='WRITE',form='FORMATTED')
20 write(50,'("Generated by Elk version ",I0,".",I0,".",I0)') version
21 write(50,'(3I6)') num_bands,nkptnr,num_wann
22 do ik=1,nkptnr
23 ! automatically generate the projections from the wavefunctions if required
24  if (projw90) call projkw90(ik,amn)
25  do i=1,num_wann
26  do ist=1,num_bands
27  if (projw90) then
28 ! calculated projections
29  a=amn(ist,i)%re
30  b=amn(ist,i)%im
31  else
32 ! random projections
33  a=0.5d0-randomu()
34  b=0.5d0-randomu()
35  end if
36  write(50,'(3I8,2G18.10)') ist,i,ik,a,b
37  end do
38  end do
39 end do
40 close(50)
41 write(*,*)
42 write(*,'("Info(writew90amn): created file ",A)') trim(fname)
43 if (projw90) deallocate(amn)
44 end subroutine
45 
integer num_bands
Definition: modw90.f90:22
logical projw90
Definition: modw90.f90:26
integer num_wann
Definition: modw90.f90:20
integer nkptnr
Definition: modmain.f90:463
character(256) seedname
Definition: modw90.f90:14
Definition: modw90.f90:6
real(8) function randomu()
Definition: modrandom.f90:18
integer, dimension(3), parameter version
Definition: modmain.f90:1281
subroutine projkw90(ik, amn)
Definition: projkw90.f90:7
subroutine writew90amn
Definition: writew90amn.f90:7