2
\file buf_rd_all_mp2r12a.c
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) ? (((i)*((i)+1))/2+(j)) : (((j)*((j)+1))/2+(i)))
16
** iwl_buf_rd_all_mp2r12a()
18
** Read from an Integrals With Labels formatted buffer.
19
** The buffer must have been initialized with iwl_buf_init().
21
** \param Buf = IWL Buffer to read from (already initialized)
22
** \param ints = memory buffer to put integrals into
23
** \param ioff_lt = ioff array for the left pair of indices (p and q)
24
** \param ioff_rt = ioff array for the right pair of indices (r and s)
25
** \param bra_ket_symm = if 1, then these are ERI or R12 integrals, read
26
** them in as usual, else these are [r12,T2] integrals -
27
** form [T1+T2,r12] out of these.
29
** WARNING - if bra_ket_symm = 0 - ints must be zeroed out!
31
** \param ioff = the ioff array to figure the total index pqrs
32
** from the pair indices pq and rs
33
** \param printflg = if 1, print integrals as they are read
34
** \param outfile = pointer to output file for printing
36
** Returns: 0 if end of file, otherwise 1
39
int iwl_buf_rd_all_mp2r12a(struct iwlbuf *Buf, double *ints,
40
int *ioff_lt, int *ioff_rt, int bra_ket_symm,
41
int *ioff, int printflg, FILE *outfile)
47
long int pq, rs, pqrs;
52
lastbuf = Buf->lastbuf;
54
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
55
p = (int) lblptr[idx++];
56
q = (int) lblptr[idx++];
57
r = (int) lblptr[idx++];
58
s = (int) lblptr[idx++];
65
if (bra_ket_symm) /*! ERIs or R12-integrals */
66
ints[pqrs] = (double) valptr[Buf->idx];
67
else { /*! (ip|[T1+T2,r12]|jq) = -[(ip|[r12,T1]|jq) + (jq|[r12,T2]|ip)] */
69
ints[pqrs] -= (double) valptr[Buf->idx];
71
ints[pqrs] -= (double) 2.0*valptr[Buf->idx];
75
fprintf(outfile, "<%2d %2d %2d %2d [%2ld][%2ld] [[%3ld]] = %20.10lf\n",
76
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
78
} /*! end loop through current buffer */
80
/*! read new PSI buffers */
83
lastbuf = Buf->lastbuf;
85
for (idx=4*Buf->idx; Buf->idx<Buf->inbuf; Buf->idx++) {
86
p = (int) lblptr[idx++];
87
q = (int) lblptr[idx++];
88
r = (int) lblptr[idx++];
89
s = (int) lblptr[idx++];
96
if (bra_ket_symm) /*! ERIs or R12-integrals */
97
ints[pqrs] = (double) valptr[Buf->idx];
98
else { /*! (ip|[T1+T2,r12]|jq) = -[(ip|[r12,T2]|jq)+(jq|[r12,T2]|ip)] */
100
ints[pqrs] -= (double) valptr[Buf->idx];
102
ints[pqrs] -= (double) 2.0*valptr[Buf->idx];
106
fprintf(outfile, "<%d %d %d %d [%ld][%ld] [[%ld]] = %20.10lf\n",
107
p, q, r, s, pq, rs, pqrs, ints[pqrs]) ;
109
} /*! end loop through current buffer */
111
} /*! end loop over reading buffers */
113
return(0); /*! we must have reached the last buffer at this point */