The Elk Code
reademd.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2014 D. Ernsting, S. Dugdale and J. K. Dewhurst.
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 reademd(emds)
7 use modmain
8 use modpw
9 use modtest
10 implicit none
11 ! arguments
12 real(4), intent(out) :: emds(nhkmax,nkpt)
13 ! local variables
14 integer ik,recl,nhk_
15 real(8) vkl_(3),t1
16 ! allocatable arrays
17 real(8), allocatable :: emd(:)
18 allocate(emd(nhkmax))
19 ! find the record length
20 inquire(iolength=recl) vkl_,nhk_,emd
21 open(250,file='EMD.OUT',form='UNFORMATTED',access='DIRECT',recl=recl)
22 do ik=1,nkpt
23  read(250,rec=ik) vkl_,nhk_,emd
24  t1=abs(vkl(1,ik)-vkl_(1))+abs(vkl(2,ik)-vkl_(2))+abs(vkl(3,ik)-vkl_(3))
25  if (t1 > epslat) then
26  write(*,*)
27  write(*,'("Error(reademd): differing vectors for k-point ",I8)') ik
28  write(*,'(" current : ",3G18.10)') vkl(:,ik)
29  write(*,'(" EMD.OUT : ",3G18.10)') vkl_
30  write(*,*)
31  stop
32  end if
33  if (nhk(1,ik) /= nhk_) then
34  write(*,*)
35  write(*,'("Error(reademd): differing nhk for k-point ",I8)') ik
36  write(*,'(" current : ",I8)') nhk(1,ik)
37  write(*,'(" EMD.OUT : ",I8)') nhk_
38  write(*,*)
39  stop
40  end if
41 ! store momentum density in single-precision array
42  emds(1:nhk_,ik)=real(emd(1:nhk_))
43 end do
44 close(250)
45 ! write the EMD of the last k-point to test file if required
46 call writetest(170,'electron momentum density',nv=nhkmax,tol=1.d-4,rva=emd)
47 deallocate(emd)
48 end subroutine
49 
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition: modtest.f90:16
integer, dimension(:,:), allocatable nhk
Definition: modpw.f90:40
subroutine reademd(emds)
Definition: reademd.f90:7
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
real(8) epslat
Definition: modmain.f90:24
Definition: modpw.f90:6