The Elk Code
 
Loading...
Searching...
No Matches
writestate.f90
Go to the documentation of this file.
1
2! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: writestate
8! !INTERFACE:
9subroutine writestate
10! !USES:
11use modmain
12use moddftu
13! !DESCRIPTION:
14! Writes the charge density, potentials and other relevant variables to the
15! file {\tt STATE.OUT}. Note to developers: changes to the way the variables
16! are written should be mirrored in {\tt readstate}.
17!
18! !REVISION HISTORY:
19! Created May 2003 (JKD)
20!EOP
21!BOC
22implicit none
23! local variables
24integer idm,is,ias
25! allocatable arrays
26real(8), allocatable :: rfmt(:,:,:),rvfmt(:,:,:,:),rvfcmt(:,:,:,:)
27open(100,file='STATE'//trim(filext),form='UNFORMATTED',action='WRITE')
28write(100) version
29write(100) spinpol
30write(100) nspecies
31write(100) lmmaxo
32write(100) nrmtmax
33write(100) nrcmtmax
34do is=1,nspecies
35 write(100) natoms(is)
36 write(100) nrmt(is)
37 write(100) rsp(1:nrmt(is),is)
38 write(100) nrcmt(is)
39 write(100) rcmt(1:nrcmt(is),is)
40end do
41write(100) ngridg
42write(100) ngvec
43write(100) ndmag
44write(100) nspinor
45write(100) fsmtype
46write(100) ftmtype
47write(100) dftu
48write(100) lmmaxdm
49write(100) xcgrad
50write(100) efermi
51! muffin-tin functions are unpacked to maintain backward compatibility
52allocate(rfmt(lmmaxo,nrmtmax,natmtot))
53if (spinpol) then
54 allocate(rvfmt(lmmaxo,nrmtmax,natmtot,ndmag))
55 allocate(rvfcmt(lmmaxo,nrcmtmax,natmtot,ndmag))
56end if
57! write the density
58do ias=1,natmtot
59 is=idxis(ias)
60 call rfmtpack(.false.,nrmt(is),nrmti(is),rhomt(:,ias),rfmt(:,:,ias))
61end do
62write(100) rfmt,rhoir
63! write the Coulomb potential
64do ias=1,natmtot
65 is=idxis(ias)
66 call rfmtpack(.false.,nrmt(is),nrmti(is),vclmt(:,ias),rfmt(:,:,ias))
67end do
68write(100) rfmt,vclir
69! write the exchange-correlation potential
70do ias=1,natmtot
71 is=idxis(ias)
72 call rfmtpack(.false.,nrmt(is),nrmti(is),vxcmt(:,ias),rfmt(:,:,ias))
73end do
74write(100) rfmt,vxcir
75! write the Kohn-Sham effective potential
76do ias=1,natmtot
77 is=idxis(ias)
78 call rfmtpack(.false.,nrmt(is),nrmti(is),vsmt(:,ias),rfmt(:,:,ias))
79end do
80write(100) rfmt,vsir
81if (spinpol) then
82! write the magnetisation, exchange-correlation and effective magnetic fields
83 do idm=1,ndmag
84 do ias=1,natmtot
85 is=idxis(ias)
86 call rfmtpack(.false.,nrmt(is),nrmti(is),magmt(:,ias,idm), &
87 rvfmt(:,:,ias,idm))
88 end do
89 end do
90 write(100) rvfmt,magir
91 do idm=1,ndmag
92 do ias=1,natmtot
93 is=idxis(ias)
94 call rfmtpack(.false.,nrmt(is),nrmti(is),bxcmt(:,ias,idm), &
95 rvfmt(:,:,ias,idm))
96 end do
97 end do
98 write(100) rvfmt,bxcir
99 do idm=1,ndmag
100 do ias=1,natmtot
101 is=idxis(ias)
102 call rfmtpack(.false.,nrcmt(is),nrcmti(is),bsmt(:,ias,idm), &
103 rvfcmt(:,:,ias,idm))
104 end do
105 end do
106 write(100) rvfcmt,bsir
107! write fixed spin moment magnetic fields
108 if (fsmtype /= 0) then
109 write(100) bfsmc
110 write(100) bfsmcmt
111 end if
112end if
113! write the meta-GGA exchange-correlation potential
114if (any(xcgrad == [3,4,5,6])) then
115 do ias=1,natmtot
116 is=idxis(ias)
117 call rfmtpack(.false.,nrmt(is),nrmti(is),wxcmt(:,ias),rfmt(:,:,ias))
118 end do
119 write(100) rfmt,wxcir
120end if
121! write the potential matrix in each muffin-tin
122if ((dftu /= 0).or.(ftmtype /= 0)) then
123 write(100) vmatmt
124end if
125! write the fixed tensor moment potential matrix
126if (ftmtype /= 0) then
127 write(100) vmftm
128end if
129close(100)
130deallocate(rfmt)
131if (spinpol) deallocate(rvfmt,rvfcmt)
132end subroutine
133!EOC
134
integer dftu
Definition moddftu.f90:32
integer, parameter lmmaxdm
Definition moddftu.f90:14
integer ftmtype
Definition moddftu.f90:70
complex(8), dimension(:,:,:,:,:), allocatable vmatmt
Definition moddftu.f90:20
complex(8), dimension(:,:,:,:,:), allocatable vmftm
Definition moddftu.f90:82
integer, dimension(maxspecies) nrmti
Definition modmain.f90:211
real(8), dimension(:,:,:), allocatable bxcmt
Definition modmain.f90:636
integer, dimension(3) ngridg
Definition modmain.f90:386
real(8) efermi
Definition modmain.f90:904
integer nspinor
Definition modmain.f90:267
real(8), dimension(:,:,:), pointer, contiguous magmt
Definition modmain.f90:616
integer, dimension(maxspecies) nrmt
Definition modmain.f90:150
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
real(8), dimension(:), pointer, contiguous rhoir
Definition modmain.f90:614
character(256) filext
Definition modmain.f90:1300
real(8), dimension(:,:), allocatable rcmt
Definition modmain.f90:177
logical spinpol
Definition modmain.f90:228
integer fsmtype
Definition modmain.f90:251
integer ngvec
Definition modmain.f90:396
real(8), dimension(:,:), allocatable bfsmcmt
Definition modmain.f90:263
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
real(8), dimension(:,:), allocatable bxcir
Definition modmain.f90:636
real(8), dimension(:,:), allocatable rsp
Definition modmain.f90:135
real(8), dimension(:), allocatable vxcir
Definition modmain.f90:634
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
real(8), dimension(3) bfsmc
Definition modmain.f90:257
integer natmtot
Definition modmain.f90:40
real(8), dimension(:), allocatable vclir
Definition modmain.f90:624
integer, dimension(3), parameter version
Definition modmain.f90:1288
real(8), dimension(:,:), pointer, contiguous magir
Definition modmain.f90:616
real(8), dimension(:,:), pointer, contiguous vsmt
Definition modmain.f90:649
real(8), dimension(:,:), allocatable bsir
Definition modmain.f90:658
real(8), dimension(:,:), allocatable vclmt
Definition modmain.f90:624
real(8), dimension(:,:), allocatable vxcmt
Definition modmain.f90:634
integer nrcmtmax
Definition modmain.f90:175
integer nrmtmax
Definition modmain.f90:152
integer xcgrad
Definition modmain.f90:602
real(8), dimension(:), allocatable vsir
Definition modmain.f90:651
integer lmmaxo
Definition modmain.f90:203
real(8), dimension(:,:,:), pointer, contiguous bsmt
Definition modmain.f90:656
real(8), dimension(:,:), pointer, contiguous rhomt
Definition modmain.f90:614
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211
integer nspecies
Definition modmain.f90:34
real(8), dimension(:), allocatable wxcir
Definition modmain.f90:676
integer ndmag
Definition modmain.f90:238
real(8), dimension(:,:), allocatable wxcmt
Definition modmain.f90:676
pure subroutine rfmtpack(tpack, nr, nri, rfmt1, rfmt2)
Definition rfmtpack.f90:7
subroutine writestate