7
#include <libciomr/libciomr.h>
13
#define MIN0(a,b) (((a)<(b)) ? (a) : (b))
14
#define MAX0(a,b) (((a)>(b)) ? (a) : (b))
15
#define INDEX(i,j) ((i>j) ? (ioff[(i)]+(j)) : (ioff[(j)]+(i)))
17
int IWL::read_all(double *ints, int *ioff_lt, int *ioff_rt, int no_pq_perm,
18
int *ioff, int printflg, FILE *outfile)
23
int idx, p, q, r, s, pq, rs, pqrs;
30
for (idx=4*idx_; idx_ < inbuf_; idx_++) {
31
p = fabs((int) lblptr[idx++]);
32
q = (int) lblptr[idx++];
33
r = (int) lblptr[idx++];
34
s = (int) lblptr[idx++];
36
if(no_pq_perm) { /*! I _think_ this will work */
41
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
42
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
47
ints[pqrs] = (double) valptr[idx_];
50
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] [[%3d]] = %20.10f\n",
51
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
53
} /*! end loop through current buffer */
55
/*! read new PSI buffers */
60
for (idx=4*idx_; idx_ < inbuf_; idx_++) {
61
p = fabs((int) lblptr[idx++]);
62
q = (int) lblptr[idx++];
63
r = (int) lblptr[idx++];
64
s = (int) lblptr[idx++];
66
if(no_pq_perm) { /*! I _think_ this will work */
71
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
72
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
77
ints[pqrs] = (double) valptr[idx_];
80
fprintf(outfile, "<%d %d %d %d [%d][%d] [[%d]] = %20.10f\n",
81
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
83
} /*! end loop through current buffer */
85
} /*! end loop over reading buffers */
87
return(0); /*! we must have reached the last buffer at this point */
90
int IWL::read_all2(double **ints, int *ioff_lt, int *ioff_rt, int no_pq_perm,
91
int *ioff, int printflg, FILE *outfile)
96
int idx, p, q, r, s, pq, rs;
103
for (idx=4*idx_; idx_ < inbuf_; idx_++) {
104
p = fabs((int) lblptr[idx++]);
105
q = (int) lblptr[idx++];
106
r = (int) lblptr[idx++];
107
s = (int) lblptr[idx++];
109
if(no_pq_perm) { /*! I _think_ this will work */
114
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
115
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
118
ints[pq][rs] = (double) valptr[idx_];
121
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] = %20.10f\n",
122
p, q, r, s, pq, rs, ints[pq][rs]) ;
124
} /*! end loop through current buffer */
126
/*! read new PSI buffers */
131
for (idx=4*idx_; idx_ < inbuf_; idx_++) {
132
p = fabs((int) lblptr[idx++]);
133
q = (int) lblptr[idx++];
134
r = (int) lblptr[idx++];
135
s = (int) lblptr[idx++];
137
if(no_pq_perm) { /*! I _think_ this will work */
142
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
143
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
146
ints[pq][rs] = (double) valptr[idx_];
149
fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10f\n",
150
p, q, r, s, pq, rs, ints[pq][rs]) ;
152
} /*! end loop through current buffer */
154
} /*! end loop over reading buffers */
156
return(0); /*! we must have reached the last buffer at this point */
164
** Read from an Integrals With Labels formatted buffer.
165
** The buffer must have been initialized with iwl_buf_init().
168
** \param Buf = IWL Buffer to read from (already initialized)
169
** \param ints = memory buffer to put integrals into
170
** \param ioff_lt = ioff array for the left pair of indices (p and q)
171
** \param ioff_rt = ioff array for the right pair of indices (r and s)
172
** \param no_pq_perm = if 1, do not use p/q or r/s permutational symmetry
173
** \param ioff = the ioff array to figure the total index pqrs from
174
** the pair indices pq and rs
175
** \param printflg = if 1, print integrals as they are read
176
** \param outfile = pointer to output file for printing
178
** Returns: 0 if end of file, otherwise 1
181
int iwl_buf_rd_all(struct iwlbuf *Buf, double *ints,
182
int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff,
183
int printflg, FILE *outfile)
188
int idx, p, q, r, s, pq, rs, pqrs;
190
lblptr = Buf->labels;
191
valptr = Buf->values;
193
lastbuf = Buf->lastbuf;
195
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
196
p = fabs((int) lblptr[idx++]);
197
q = (int) lblptr[idx++];
198
r = (int) lblptr[idx++];
199
s = (int) lblptr[idx++];
201
if(no_pq_perm) { /*! I _think_ this will work */
206
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
207
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
212
ints[pqrs] = (double) valptr[Buf->idx];
215
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] [[%3d]] = %20.10lf\n",
216
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
218
} /*! end loop through current buffer */
220
/*! read new PSI buffers */
223
lastbuf = Buf->lastbuf;
225
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
226
p = fabs((int) lblptr[idx++]);
227
q = (int) lblptr[idx++];
228
r = (int) lblptr[idx++];
229
s = (int) lblptr[idx++];
231
if(no_pq_perm) { /*! I _think_ this will work */
236
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
237
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
242
ints[pqrs] = (double) valptr[Buf->idx];
245
fprintf(outfile, "<%d %d %d %d [%d][%d] [[%d]] = %20.10lf\n",
246
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
248
} /*! end loop through current buffer */
250
} /*! end loop over reading buffers */
252
return(0); /*! we must have reached the last buffer at this point */
256
** IWL_BUF_RD_ALL2(): This routine works exactly like
257
** iwl_buf_rd_all(), except that the integral list is not assumed to
258
** have bra-ket permutational symmetry. The list is still required to
259
** have permutational symmetry WITHIN bra and ket, however, unless
260
** no_pq_perm is set. This function requires that the input array be
261
** (double **) rather than (double *). This routine is necessary, for
262
** example, for reading the alpha-beta two-electron integrals from the
269
int iwl_buf_rd_all2(struct iwlbuf *Buf, double **ints,
270
int *ioff_lt, int *ioff_rt, int no_pq_perm, int *ioff,
271
int printflg, FILE *outfile)
276
int idx, p, q, r, s, pq, rs;
278
lblptr = Buf->labels;
279
valptr = Buf->values;
281
lastbuf = Buf->lastbuf;
283
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
284
p = fabs((int) lblptr[idx++]);
285
q = (int) lblptr[idx++];
286
r = (int) lblptr[idx++];
287
s = (int) lblptr[idx++];
289
if(no_pq_perm) { /*! I _think_ this will work */
294
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
295
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
298
ints[pq][rs] = (double) valptr[Buf->idx];
301
fprintf(outfile, "<%2d %2d %2d %2d [%2d][%2d] = %20.10lf\n",
302
p, q, r, s, pq, rs, ints[pq][rs]) ;
304
} /*! end loop through current buffer */
306
/*! read new PSI buffers */
309
lastbuf = Buf->lastbuf;
311
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
312
p = fabs((int) lblptr[idx++]);
313
q = (int) lblptr[idx++];
314
r = (int) lblptr[idx++];
315
s = (int) lblptr[idx++];
317
if(no_pq_perm) { /*! I _think_ this will work */
322
pq = ioff_lt[MAX0(p,q)] + MIN0(p,q);
323
rs = ioff_rt[MAX0(r,s)] + MIN0(r,s);
326
ints[pq][rs] = (double) valptr[Buf->idx];
329
fprintf(outfile, "<%d %d %d %d [%d][%d] = %20.10lf\n",
330
p, q, r, s, pq, rs, ints[pq][rs]) ;
332
} /*! end loop through current buffer */
334
} /*! end loop over reading buffers */
336
return(0); /*! we must have reached the last buffer at this point */
b'\\ No newline at end of file'