Line data Source code
1 : c*************************c
2 : c routine to set up the c
3 : c composite matrix anglmom c
4 : c*************************c
5 : module m_wann_gwf_anglmom
6 : use m_juDFT
7 : implicit none
8 : contains
9 :
10 0 : subroutine wann_gwf_anglmom(nkpts,nqpts,l_unformatted)
11 : use m_wann_gwf_tools
12 :
13 : implicit none
14 :
15 : ! input parameters
16 : logical,intent(in) :: l_unformatted
17 : integer,intent(in) :: nkpts,nqpts
18 :
19 : integer :: nwfs,nbnd,nkqpts
20 : integer :: d,i,j,k,q,kq,t1,t2,t3,t4
21 : real :: tempr,tempi
22 :
23 : complex,allocatable :: anglmom(:,:,:,:)
24 : character(len=12) :: fending
25 :
26 0 : call timestart("wann_gwf_anglmom")
27 0 : nkqpts = nkpts*nqpts
28 :
29 : ! get number of bands and wfs from proj
30 0 : open(405,file='proj',status='old')
31 0 : read(405,*)nwfs,nbnd
32 0 : close(405)
33 0 : write(*,*)'nbnd=',nbnd
34 0 : write(*,*)'nwfs=',nwfs
35 :
36 0 : allocate(anglmom(3,nbnd,nbnd,nkqpts))
37 :
38 : ! read in separate files
39 0 : do q=1,nqpts
40 0 : WRITE(fending,'("_",i4.4)')q
41 0 : open(405,file='WF1'//trim(fending)//'.anglmom')
42 0 : read(405,*) !header
43 0 : read(405,*) !nbnd and nkpts
44 0 : do k=1,nkpts
45 0 : kq=get_index_kq(k,q,nkpts)
46 0 : do i=1,nbnd
47 0 : do j=1,nbnd
48 0 : do d=1,3
49 0 : read(405,*)t1,t2,t3,t4,tempr,tempi
50 0 : anglmom(d,j,i,kq) = cmplx(tempr,tempi)
51 : enddo
52 : enddo
53 : enddo
54 : enddo
55 0 : close(405,status='delete')
56 : enddo
57 :
58 : ! write file either unformatted or formatted
59 0 : if(l_unformatted) then
60 0 : open(405,file='WF1_gwf.anglmom',form='unformatted')
61 0 : write(405)anglmom
62 0 : close(405)
63 : else
64 0 : open(405,file='WF1_gwf.anglmom')
65 0 : write(405,*)'Matrix elements of angular momentum'
66 0 : write(405,'(3i5)')nbnd,nbnd,nkqpts
67 0 : do kq=1,nkqpts
68 0 : do i=1,nbnd
69 0 : do j=1,nbnd
70 0 : do d=1,3
71 0 : write(405,'(4i5,3x,2f18.12)')d,j,i,kq,
72 0 : > anglmom(d,j,i,kq)
73 : enddo
74 : enddo
75 : enddo
76 : enddo
77 0 : close(405)
78 : endif
79 :
80 0 : deallocate(anglmom)
81 :
82 0 : call timestop("wann_gwf_anglmom")
83 0 : end subroutine wann_gwf_anglmom
84 : end module m_wann_gwf_anglmom
|