1
subroutine occup_input(rtdb)
2
C $Id: occup_input.F 21176 2011-10-10 06:35:49Z d3y133 $
3
C Adapted from geom_input
5
c occupations [nfocc_in]
20
c 2. [focc-1] is integer or float and positive
21
c 3. [nfocc_in] is integer and positive and < nmo*2
22
c Note.- In so-dft the MOs are arranged as
23
c {nmo-alpha-1 nmo-beta-1}{nmo-alpha-2 nmo-beta-2} ...
24
c As an example: In CH2 which is triplet we have for 6-311G*
26
c Default occupations are: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
27
c This means 8 pairs of 1's.
28
c This would be defined in our occupation module scheme as
29
c This scheme is designed for so-dft calculation.
30
c Note.- For other type of calculation is not done yet.
45
#include "nwc_const.fh"
46
#include "mafdecls.fh"
48
integer rtdb ! [input]
49
character*255 field ! for character input
50
integer ac,noccA,noccB ! counts no. of centers as input
51
logical status ! scratch for return codes
52
integer i,ind_min,ind_max
53
integer nfocc_in(2),nfocc_tot ! input of nfocc
57
c read occupations from the input deck
58
c and output it to the rtdb.
60
c current input line should begin 'occupations ...'
62
if (ga_nodeid() .ne. 0) return
64
c Check that this is indeed a occupations line
66
call inp_set_field(0) ! goto start of line
67
if (.not. inp_a(field))
68
$ call errquit('occup_input: no input present', 0, INPUT_ERR)
69
if (.not. inp_compare(.false., 'occup', field))
70
$ call errquit('occup_input: not occup input',
73
status = status .and. inp_i(nfocc_in(1))
74
status = status .and. inp_i(nfocc_in(2))
75
if (status) then ! --------nfocc-in---START
76
c write(*,2) nfocc_in(1),nfocc_in(2)
77
c2 format('nfocc_in=(',i5,',',i5,')')
78
nfocc_tot=nfocc_in(1)+nfocc_in(2)
81
if (nfocc_in(1).lt.nfocc_in(2)) then
85
if (.not. ma_push_get(mt_dbl,nfocc_tot,'occup1',
87
& call errquit('occ_input ma_push_get fail k_Iocc',
89
c----- Start reading <occ-A> <occ-B> sets
93
20 if (inp_read()) then ! --- if-read-focc-START
95
if (inp_compare(.false., 'end', field)) then
98
if (noccA .gt. nfocc_in(ind_max)) call errquit
99
$ ('occup_input: too many occupations?',
102
c style input ... <occ-A> <occ-B>
104
call inp_set_field(0)
106
c ------- Case 1: Reading occ-A occ-B
107
if (noccA .le. nfocc_in(ind_min)) then
108
status = status .and. inp_f(dbl_mb(k_Iocc+ac))
109
status = status .and. inp_f(dbl_mb(k_Iocc+ac+1))
111
c & dbl_mb(k_Iocc+ac),dbl_mb(k_Iocc+ac+1)
112
c 1 format('TEST-occ: fractional occupations(',i3,')=(',
113
c & f15.8,',',f15.8,')')
114
if (.not. status) call errquit
115
$ ('occup_input: <occ>',ac+1,INPUT_ERR)
119
else if (ac/2+1 .gt. nfocc_in(ind_min)) then
120
c ------- Case 2: Reading occ-A (unpaired electrons)
121
status = status .and. inp_f(dbl_mb(k_Iocc+ac))
123
c & dbl_mb(k_Iocc+ac)
124
c 3 format('TEST-occ: fractional occupations(',i3,')=',
126
if (.not. status) call errquit
127
$ ('occup_input: <occ>',ac+1,INPUT_ERR)
128
if (ind_max.eq.1) noccA=noccA+1
129
if (ind_max.eq.2) noccB=noccB+1
135
call errquit('occup_input: premature end of file',
137
end if ! --- if-read-focc-END
140
& 'occup_input: missing nfocc-A -B in occupations',
142
endif ! --------nfocc-in---END
144
c write(*,5) noccA-1,noccB-1
145
c5 format('(noccA,noccB)=(',i5,',',i5,')')
146
if (noccA-1.ne.nfocc_in(1) .or. noccB-1.ne.nfocc_in(2)) then
147
call errquit('occup_input: mismatch noccA-ith or noccB-ith',
150
c ---- check that int_mb(k_nIocc) > 0 and dbl_mb(k_Iocc) > 0
152
c write(*,4) i,dbl_mb(k_Iocc+i-1)
153
c4 format('frac-occ-all(',i5,')=',f15.8)
154
if (dbl_mb(k_Iocc+i-1).le.0.0d0) then
155
call errquit('occup_input: Problem focc input ith val<0',
159
c ----- Store focc in rtdb ----- START
160
switch_focc=1 ! 1 means using occupations keyword
161
if (.not. rtdb_put(rtdb,'focc:occ-switch',
162
& mt_int,1,switch_focc))
163
& call errquit('occ_input: rtdb_put failed', 1201, RTDB_ERR)
164
if (.not. rtdb_put(rtdb,'focc:occupations',
165
& mt_int,2,nfocc_in))
166
& call errquit('occ_input: rtdb_put failed', 1201, RTDB_ERR)
167
if (.not. rtdb_put(rtdb,'focc:occup list',
168
& mt_dbl,nfocc_tot,dbl_mb(k_Iocc)))
169
$ call errquit('occ_input: rtdb_put failed', 0, RTDB_ERR)
170
if (.not.ma_pop_stack(l_Iocc)) ! Free memory
171
& call errquit('occ input: ma_pop_stack failed k_Iocc',
173
c ----- Store focc in rtdb ----- END