forked from cxlsmiles/fanoci_code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_hf_data.f90
138 lines (108 loc) · 3.78 KB
/
read_hf_data.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
module read_hf_data
implicit none
character(len=*), parameter :: HF_ENERGY_FILE = "HForbenergy.txt"
contains
! TODO: Rewrite as a function returning number of MOs
! TODO: Remove n_mo from globals
subroutine read_n_mos()
use globals, only: n_mo
integer :: io, orbindex
character(len=5) :: temp1
double precision :: temp2
open(unit=118, file=HF_ENERGY_FILE, status='old', action="read")
do
read(118,*,iostat=io)orbindex, temp1, temp2
if (io.lt.0) exit
end do
rewind(118)
close(118)
n_mo = orbindex
end subroutine read_n_mos
subroutine read_input()
use strings
use globals
integer :: funit
integer :: stat
integer :: k
integer, parameter :: StrMax=40, Nmax = 80
character(len=1) :: delims
character(len=StrMax), dimension(Nmax) :: h_args
character(len=StrMax), dimension(Nmax) :: p_args
namelist /prop/ prop_type
namelist /init/ hs_in, ps_in
namelist /final/ h_f_min, h_f_max, p_f_min, p_f_max
namelist /control/ n_occ, prnt, gam, moint, eig_thresh, n_mo
funit = 139
open (funit, file='input.txt',status='old', action="read")
read (funit,nml=prop)
read (funit,nml=init)
read (funit,nml=final)
read (funit,nml=control)
close(funit)
call check_input_sanity()
delims = ' '
call parse(hs_in, delims, h_args, n_hs_in)
call parse(ps_in, delims, p_args, n_ps_in)
allocate(holes_arr(n_hs_in), particles_arr(n_ps_in))
do k = 1, n_hs_in
read(h_args(k),*,iostat=stat)holes_arr(k)
end do
do k = 1, n_ps_in
read(p_args(k),*,iostat=stat)particles_arr(k)
end do
end subroutine
subroutine check_input_sanity()
use globals
if (p_f_max.gt.n_mo)then
write(*,*)'ERROR: Parameter p_f_max cannot be greater than total num. of orbitals.'
write(*,*)'p_f_max n_mo', p_f_max, n_mo
stop 1
end if
if (p_f_min.gt.p_f_max.and.p_f_max.ne.0)then
write(*,*)'ERROR: p_f_min > p_f_max'
stop 1
end if
if (h_f_min.gt.h_f_max)then
write(*,*)'ERROR: h_f_min > h_f_max'
stop 1
end if
if (p_f_min.lt.h_f_max)then
write(*,*)'ERROR: p_f_min < h_f_max'
stop 1
end if
end subroutine check_input_sanity
subroutine read_mo_energies (numorb, e_mo)
integer*8, intent(in) :: numorb
double precision, dimension(:), intent(out) :: e_mo
integer*8 :: i, temp
character(3) :: sym
open(unit=117, file=HF_ENERGY_FILE, status='old', action='read')
do i = 1, numorb
read(117,*)temp, sym, e_mo(i)
end do
close(117)
end subroutine read_mo_energies
subroutine read_2e_integrals (n_, int2e_)
integer*8, intent(in) :: n_
integer*8 :: i, j
integer :: io, funit
double precision :: temp
double precision, dimension(n_), intent(out) :: int2e_
int2e_ = 0.d0
funit = 119
open(unit=funit, file='moint.txt', status='old', action="read") !, form='unformatted')
do
read(funit, *, iostat = io)j, temp
if (io.gt.0)then
write(*,*)'ERROR reading file moint.txt. error code = ', io
stop 1
else if (io.lt.0)then ! EOF condition
exit
end if
! Automatically skip unnecessary integrals with big index
if (j.gt.n_) cycle
int2e_(j) = temp
end do
close(funit)
end subroutine read_2e_integrals
end module read_hf_data