1
subroutine dft_scaleMO_so(rtdb, ! IN
2
& g_moso, ! IN : MO vectors
3
& occ, ! IN/OUt : occupancies
4
& g_densso, ! OUT : spin-orbit density matrix
5
& nbf_mo, ! IN : nr. basis functions
6
& nTotOcc, ! IN : nr. occ
7
& switch_sclMO_so)! OUT : switch 1,0=ON,OFF
8
c Purpose: Fractional occupation routine
9
c entered from input script:
15
c Author : Fredy Aquino
20
#include "mafdecls.fh"
26
double precision occ(nbf_mo) ! occupancies
27
integer switch_sclMO_so ! switch 1,0=ON,OFF scaling MOs
29
integer g_densso(2) ! spin-orbit density matrix
30
integer scale_switch ! input
31
integer nbf_mo ! input
32
integer g_moso(2) ! input/output
33
integer g_moso1(2) ! scratch ga array
34
integer i,ispin,iorb,iorb1,nTotOcc,nbf_ao
36
integer l_Iocc,k_Iocc,nfocc_in(2),
37
& nfocc_tot,ind_min,ind_max
38
double precision ac_occ,
41
c +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42
c +++++++ test: occupations keyword -- FA-02-10-11 ++ START
43
c ---- FA-01-31-11 ----- check vars ---- START
44
c +++++++ test reading from rtdb occupations settings +++ START
45
c if (ga_nodeid().eq.0)
46
c & write(*,*) 'In dft_scaleMO:: BEF rtdb_get'
47
status = rtdb_get(rtdb,'focc:occupations',
49
nfocc_tot=nfocc_in(1)+nfocc_in(2)
51
c if (ga_nodeid().eq.0) then
52
c write(*,7) nfocc_in(1),nfocc_in(2),nfocc_tot
53
c7 format('rtdb-check: nfocc=(',i4,',',i4,',',i4,')')
55
if (.not. ma_push_get(mt_dbl,nfocc_tot,'occup1',
57
& call errquit('occ_input ma_push_get fail k_Iocc',
60
status = rtdb_get(rtdb,'focc:occup list',
63
if (status) then ! --- START-fracc-occ-routine
65
if(.not.ga_create(mt_dbl,nbf_mo,nbf_mo,
68
& call errquit('scaleMO_so: error creating Movecs Re',0,
70
call ga_copy(g_moso(i),g_moso1(i))
72
c if (ga_nodeid().eq.0)
73
c & write(*,*) 'In dft_scaleMO:: AFT rtdb_get'
74
c ------- check nel=sum(n_i) + int_mb(k_nIocc+i-1) =[1,nbf_mo]---- START
77
c if (ga_nodeid().eq.0) then
78
c write(*,118) i,dbl_mb(k_Iocc+i-1)
79
c118 format('focc(',i3,')=',f15.8)
81
ac_occ=ac_occ+dbl_mb(k_Iocc+i-1)
83
diff_occ=abs(nTotOcc*1.0d0-ac_occ)
84
c if (ga_nodeid().eq.0) then
85
c write(*,18) nfocc_tot,nTotOcc,ac_occ,diff_occ
86
c 18 format('(nfocc_tot,nTotOcc,ac_occ,diff_occ)=(',
87
c & i3,',',i3,',',f15.8,',',f15.8,')')
90
if (diff_occ .gt. error_Iocc) then ! TRUE IF-commented for the moment
91
write(*,*) 'Error in dft_scf_so:',
92
& ' occupations keyword problem: ',
93
& 'ac_occ from occupations keyword',
94
& ' is not close to nTotOcc'
95
write(*,191) nTotOcc,ac_occ,diff_occ,error_Iocc
96
191 format('(nTotOcc,ac_occ,diff_occ,error_Iocc)=(',i4,',',f15.8,
97
& ',',f15.8,',',f15.8)
100
c ---- Calculate Sqrt(n_i)
101
c if (ga_nodeid().eq.0)
102
c & write(*,*) 'Calculating sqrt(n_i):'
104
c if (ga_nodeid().eq.0) then
105
c write(*,24) i,dbl_mb(k_Iocc+i-1),sqrt(dbl_mb(k_Iocc+i-1))
106
c24 format('(n_i,sqrt(n_i))(',i3,')=(',f15.8,',',f15.8,')')
108
dbl_mb(k_Iocc+i-1)=sqrt(dbl_mb(k_Iocc+i-1))
111
c ------- check nel=sum(n_i) + int_mb(k_nIocc+i-1) =[1,nbf_mo]---- END
112
c write(*,*) 'BEF-scaling check g_moso ---------- START'
113
c call ga_print(g_moso(1))
114
c call ga_print(g_moso(2))
115
c write(*,*) 'BEF-scaling check g_moso ---------- END'
116
c if (ga_nodeid().eq.0) then
117
c write(*,*) 'BEF. updating occupations:'
119
c write(*,1) i,occ(i)
120
c 1 format('occ(',i3,')=',f15.8)
121
occ(i)=0.0d0 ! reset occupations
126
if (nfocc_in(1).lt.nfocc_in(2)) then
132
do i=1,nfocc_in(ind_min)
133
c if (ga_nodeid().eq.0) then
134
c write(*,111) i,iorb,dbl_mb(k_Iocc+iorb-1)
135
c111 format('CHECK-RTDB-occ:occ(',i3,',',i3,')=',f15.8)
137
call ga_scale_patch(g_moso1(1),1,nbf_mo,iorb,iorb,
138
& dbl_mb(k_Iocc+iorb-1))
139
call ga_scale_patch(g_moso1(2),1,nbf_mo,iorb,iorb,
140
& dbl_mb(k_Iocc+iorb-1))
141
occ(iorb)=dbl_mb(k_Iocc+iorb-1)*dbl_mb(k_Iocc+iorb-1) ! update occ
145
c ---- Storing the unpaired electrons ---- START
146
iorb=2*nfocc_in(ind_min)+1
148
if (nfocc_in(1).lt.nfocc_in(2)) then
151
do i=1,nfocc_in(ind_max)-nfocc_in(ind_min)
152
c if (ga_nodeid().eq.0) then
153
c write(*,151) i,iorb,iorb1,dbl_mb(k_Iocc+iorb-1)
154
c151 format('CHECK-RTDB-occ:occ-1(',
155
c & i3,',',i3,',',i3,')=',f15.8)
157
call ga_scale_patch(g_moso1(1),1,nbf_mo,iorb1,iorb1,
158
& dbl_mb(k_Iocc+iorb-1))
159
call ga_scale_patch(g_moso1(2),1,nbf_mo,iorb1,iorb1,
160
& dbl_mb(k_Iocc+iorb-1))
161
occ(iorb1)=dbl_mb(k_Iocc+iorb-1)*dbl_mb(k_Iocc+iorb-1) ! update occ -unpaired electron
165
c ---- Storing the unpaired electrons ---- END
166
c ---- Calculate spin-orbit density matrix
168
c if (ga_nodeid().eq.0)
169
c & write(*,*) 'nbf_ao=',nbf_ao
170
call dft_densm_so(g_densso,g_moso1,nbf_ao,nTotOcc)
171
c----- Update occupations ----------- START
172
c if (ga_nodeid().eq.0) then
173
c write(*,*) 'AFT. updating occupations:'
175
c write(*,2) i,occ(i)
176
c 2 format('occ(',i3,')=',f15.8)
179
c----- Update occupations ----------- END
181
if (.not.ma_pop_stack(l_Iocc)) call
182
& errquit('dft_scaleMO_so: ma_pop_stack l_Iocc',0, MA_ERR)
184
if (.not. ga_destroy(g_moso1(i)))
186
& ('scaleMO_so: could not destroy g_moso_tmp',
189
switch_sclMO_so=1 ! set ON
190
endif ! --- END-fracc-occ-routine
193
c $Id: dft_scaleMO_so.F 21176 2011-10-10 06:35:49Z d3y133 $