7
#include <libciomr/libciomr.h>
10
#define MIN0(a,b) (((a)<(b)) ? (a) : (b))
11
#define MAX0(a,b) (((a)>(b)) ? (a) : (b))
12
#define INDEX(i,j) ((i>j) ? (ioff[(i)]+(j)) : (ioff[(j)]+(i)))
18
** Read from an Integrals With Labels formatted buffer.
19
** The buffer must have been initialized with iwl_buf_init().
22
** \param Buf = IWL Buffer to read from (already initialized)
23
** \param ints = memory buffer to put integrals into
24
** \param ioff_lt = ioff array for the left pair of indices (p and q)
25
** \param ioff_rt = ioff array for the right pair of indices (r and s)
26
** \param no_pq_perm = if 1, do not use p/q or r/s permutational symmetry
27
** \param ioff = the ioff array to figure the total index pqrs from
28
** the pair indices pq and rs
29
** \param printflg = if 1, print integrals as they are read
30
** \param outfile = pointer to output file for printing
32
** Returns: 0 if end of file, otherwise 1
35
int iwl_buf_rd_all(struct iwlbuf *Buf, double *ints,
36
int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff,
37
int printflg, FILE *outfile)
42
int idx, p, q, r, s, pq, rs, pqrs;
47
lastbuf = Buf->lastbuf;
49
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
50
p = fabs((int) lblptr[idx++]);
51
q = (int) lblptr[idx++];
52
r = (int) lblptr[idx++];
53
s = (int) lblptr[idx++];
55
if(no_pq_perm) { /*! I _think_ this will work */
60
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
61
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
66
ints[pqrs] = (double) valptr[Buf->idx];
69
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] [[%3d]] = %20.10lf\n",
70
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
72
} /*! end loop through current buffer */
74
/*! read new PSI buffers */
77
lastbuf = Buf->lastbuf;
79
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
80
p = fabs((int) lblptr[idx++]);
81
q = (int) lblptr[idx++];
82
r = (int) lblptr[idx++];
83
s = (int) lblptr[idx++];
85
if(no_pq_perm) { /*! I _think_ this will work */
90
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
91
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
96
ints[pqrs] = (double) valptr[Buf->idx];
99
fprintf(outfile, "<%d %d %d %d [%d][%d] [[%d]] = %20.10lf\n",
100
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
102
} /*! end loop through current buffer */
104
} /*! end loop over reading buffers */
106
return(0); /*! we must have reached the last buffer at this point */
110
** IWL_BUF_RD_ALL2(): This routine works exactly like
111
** iwl_buf_rd_all(), except that the integral list is not assumed to
112
** have bra-ket permutational symmetry. The list is still required to
113
** have permutational symmetry WITHIN bra and ket, however, unless
114
** no_pq_perm is set. This function requires that the input array be
115
** (double **) rather than (double *). This routine is necessary, for
116
** example, for reading the alpha-beta two-electron integrals from the
123
int iwl_buf_rd_all2(struct iwlbuf *Buf, double **ints,
124
int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff,
125
int printflg, FILE *outfile)
130
int idx, p, q, r, s, pq, rs;
132
lblptr = Buf->labels;
133
valptr = Buf->values;
135
lastbuf = Buf->lastbuf;
137
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
138
p = fabs((int) lblptr[idx++]);
139
q = (int) lblptr[idx++];
140
r = (int) lblptr[idx++];
141
s = (int) lblptr[idx++];
143
if(no_pq_perm) { /*! I _think_ this will work */
148
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
149
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
152
ints[pq][rs] = (double) valptr[Buf->idx];
155
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] = %20.10lf\n",
156
p, q, r, s, pq, rs, ints[pq][rs]) ;
158
} /*! end loop through current buffer */
160
/*! read new PSI buffers */
163
lastbuf = Buf->lastbuf;
165
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
166
p = fabs((int) lblptr[idx++]);
167
q = (int) lblptr[idx++];
168
r = (int) lblptr[idx++];
169
s = (int) lblptr[idx++];
171
if(no_pq_perm) { /*! I _think_ this will work */
176
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
177
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
180
ints[pq][rs] = (double) valptr[Buf->idx];
183
fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10lf\n",
184
p, q, r, s, pq, rs, ints[pq][rs]) ;
186
} /*! end loop through current buffer */
188
} /*! end loop over reading buffers */
190
return(0); /*! we must have reached the last buffer at this point */