1
subroutine rhoofd( NO, endC, listC, C, NSPmax, NSP,
1
subroutine rhoofd( NO, indxuo, endC, listC, C, NSPmax, NSP,
2
2
. NP, endCt, listCt, CtoCt,
3
3
. NDmax, numDs, listDs, Dscf,
4
. RHOscf, MaxAux, ilocal )
6
6
C ********************************************************************
7
7
C Finds the SCF density at the mesh points from the density matrix.
8
8
C Written by P.Ordejon and J.M.Soler. May'95.
9
C Re-ordered so that mesh is the outer loop and the orbitals are
10
C handled as lower-half triangular. J.D.Gale and J.M.Soler, Feb'99
9
11
C *********************** INPUT **************************************
10
12
C integer NO : Number of basis orbitals
13
C integer indxuo(NO) : Index of equivalent atom in unit cell
11
14
C integer endC(NO) : Accumulated umber of nonzero elements in
13
16
C integer listC(*) : List of nonzero elements in each row of C
26
29
C integer numDs(NO) : Number of nonzero elemts in each row of Dscf
27
30
C integer listDs(NVmax,NO): List of nonzero elements in each row of Dscf
28
31
C real*8 Dscf(NVmax,NO) : Value of nonzero elemens in each row of Dscf
29
C integer MaxDi : Dimension of auxiliary array Di
32
C integer MaxAux : Dimension of auxiliary array ilocal
30
33
C *********************** OUTPUT **************************************
31
34
C real*4 RHOscf(NSP,NP) : SCF density at mesh points
32
35
C ********************* AUXILIARY *************************************
33
C real*8 Di(MaxDi) : Space that can be used freely between calls
34
C MaxDi must be at least NO
36
C integer ilocal(MaxAux) : Space that can be used freely between calls
37
C MaxAux must be at least NO
35
38
C *********************************************************************
40
. NO, NP, NDmax, NSP, NSPmax, MaxDi,
41
. endC(0:NO), listC(*),
43
. NO, NP, NDmax, NSP, NSPmax, MaxAux,
44
. endC(0:NO), listC(*),
42
45
. endCt(0:NP), listCt(*), CtoCt(*),
43
. numDs(NO), listDs(NDmax,NO)
46
. numDs(NO), listDs(NDmax,NO), ilocal(MaxAux), indxuo(NO)
45
48
. C(NSPmax,*), RHOscf(NSP,NP)
47
. Dscf(NDmax,NO), Di(NO)
49
integer i, in, ip, isp, j, jn, kn
50
double precision Ci, Cj, Dij
54
parameter ( maxloc = 300 )
56
integer i, ii, il, imp, in, iorb(0:maxloc), ip, isp, iu,
57
. j, jl, jn, jmp, last
59
double precision Ci, Cj, Dij, Dlocal(0:maxloc,0:maxloc)
52
61
call timer('rhoofd',1)
54
C Check size of auxiliary array
55
if (NO .gt. MaxDi) stop 'RHOOFD: dimension MaxDi too small'
63
C Check size of auxiliary array
64
if (NO .gt. MaxAux) then
65
stop 'RHOOFD: dimension MaxAux too small'
68
C Full initialization of arrays ilocal and iorb done only once
77
C Loop over grid points
60
82
RHOscf(isp,ip) = 0.d0
64
C Full initialization of array Di done only once
72
C Copy row i of Dij from sparse format in Dscf to
73
C full-row format in Di
74
do 100 in = 1, numDs(i)
79
C Loop on mesh points of orbital i
80
do 120 in = 1+endC(i-1), endC(i)
83
C Loop over non-zero orbitals in mesh point
84
do 110 kn = 1+endCt(ip-1), endCt(ip)
88
* write(6,'(a,i3,5i6,i3,i6)')
89
* . 'rhoofd: i,endC(i-1),in,ip,endCt(ip-1),kn,j,jn=',
90
* . i, endC(i-1), in, ip, endCt(ip-1), kn, j, jn
92
C Loop over sub-points
85
C Check that Dlocal can contain Dij for this point.
86
if (endCt(ip)-endCt(ip-1) .gt. maxloc)
87
. stop 'RHOOFD: parameter maxloc too small'
89
C iorb(il)>0 means that row il of Dlocal must not be overwritten
90
C iorb(il)=0 means that row il of Dlocal is empty
91
C iorb(il)<0 means that row il of Dlocal contains a valid row of
92
C Dscf, but which is not required at this point
93
do imp = 1+endCt(ip-1), endCt(ip)
96
if (il.gt.0) iorb(il) = i
99
C Look for required rows of Dscf not yet stored in Dlocal
100
do imp = 1+endCt(ip-1), endCt(ip)
102
if (ilocal(i) .eq. 0) then
104
C Look for an available row in Dlocal
106
C last runs circularly over rows of Dlocal
108
if (last .gt. maxloc) last = 1
109
if (iorb(last) .le. 0) goto 10
111
stop 'rhoofd: no slot available in Dlocal'
114
C Copy row i of Dscf into row last of Dlocal
116
if (j.ne.0) ilocal(j) = 0
135
C Loop on first orbital of mesh point
136
do imp = 1+endCt(ip-1), endCt(ip)
142
C Loop on second orbital of mesh point
143
do jmp = 1+endCt(ip-1), imp
149
C Loop over sub-points
96
153
RHOscf(isp,ip) = RHOscf(isp,ip) + Dij * Ci * Cj
103
C Restore Di(j) for next orbital i
104
do 150 in = 1, numDs(i)
159
C Restore iorb for next point
160
do imp = 1+endCt(ip-1), endCt(ip)
111
168
call timer('rhoofd',2)