4
#include <libciomr/libciomr.h>
5
#include <libpsio/psio.h>
7
#include <libiwl/iwl.h>
8
#include <libchkpt/chkpt.h>
9
#include <libdpd/dpd.h>
13
void transtwo_uhf(void)
15
int nirreps, nso, nmo;
16
double ***C, ***C_a, ***C_b, **scratch, **TMP;
17
int h, p, q, r, s, pq, rs, Gs, Gr, PQ, RS;
18
int nrows, ncols, nlinks;
19
unsigned long int memfree, rows_per_bucket, rows_left;
25
nirreps = moinfo.nirreps;
29
/* grab MOs and remove frozen core/virt */
30
C_a = (double ***) malloc(nirreps * sizeof(double **));
31
C_b = (double ***) malloc(nirreps * sizeof(double **));
32
chkpt_init(PSIO_OPEN_OLD);
33
for(h=0; h < nirreps; h++) {
34
scratch = chkpt_rd_alpha_scf_irrep(h);
35
C_a[h] = block_matrix(moinfo.sopi[h],moinfo.mopi[h]);
36
for(q=0; q < moinfo.mopi[h]; q++)
37
for(p=0; p < moinfo.sopi[h]; p++)
38
C_a[h][p][q] = scratch[p][q+moinfo.frdocc[h]];
39
if(params.print_lvl > 2) {
40
fprintf(outfile, "\n\tAlpha MOs for irrep %d:\n",h);
41
mat_print(C_a[h], moinfo.sopi[h], moinfo.mopi[h], outfile);
45
scratch = chkpt_rd_beta_scf_irrep(h);
46
C_b[h] = block_matrix(moinfo.sopi[h],moinfo.mopi[h]);
47
for(q=0; q < moinfo.mopi[h]; q++)
48
for(p=0; p < moinfo.sopi[h]; p++)
49
C_b[h][p][q] = scratch[p][q+moinfo.frdocc[h]];
50
if(params.print_lvl > 2) {
51
fprintf(outfile, "\n\tBeta MOs for irrep %d:\n",h);
52
mat_print(C_b[h], moinfo.sopi[h], moinfo.mopi[h], outfile);
58
TMP = block_matrix(nso,nso);
60
/*** AA/AB two-electron integral transformation ***/
62
if(params.print_lvl) {
63
fprintf(outfile, "\tStarting AA/AB first half-transformation.\n");
67
psio_open(PSIF_SO_PRESORT, PSIO_OPEN_OLD);
68
psio_open(PSIF_HALFT0, PSIO_OPEN_NEW);
70
C = C_a; /* Use alpha MOs for this half-transformation */
72
dpd_buf4_init(&J, PSIF_SO_PRESORT, 0, 3, 0, 3, 3, 0, "SO Ints (pq,rs)");
73
dpd_buf4_init(&K, PSIF_HALFT0, 0, 3, 5, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
74
for(h=0; h < nirreps; h++) {
76
memfree = (unsigned long int) (dpd_memfree() - J.params->coltot[h] - K.params->coltot[h]);
77
rows_per_bucket = memfree/(2 * J.params->coltot[h]);
78
if(rows_per_bucket > J.params->rowtot[h]) rows_per_bucket = (unsigned long int) J.params->rowtot[h];
79
nbuckets = (int) ceil(((double) J.params->rowtot[h])/((double) rows_per_bucket));
80
rows_left = (unsigned long int) (J.params->rowtot[h] % rows_per_bucket);
81
if(params.print_lvl > 1) {
82
fprintf(outfile, "\th = %d; memfree = %lu\n", h, memfree);
83
fprintf(outfile, "\th = %d; rows_per_bucket = %lu\n", h, rows_per_bucket);
84
fprintf(outfile, "\th = %d; rows_left = %lu\n", h, rows_left);
85
fprintf(outfile, "\th = %d; nbuckets = %d\n", h, nbuckets);
89
dpd_buf4_mat_irrep_init_block(&J, h, rows_per_bucket);
90
dpd_buf4_mat_irrep_init_block(&K, h, rows_per_bucket);
92
for(n=0; n < (rows_left ? nbuckets-1 : nbuckets); n++) {
93
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_per_bucket);
94
for(pq=0; pq < rows_per_bucket; pq++) {
95
for(Gr=0; Gr < nirreps; Gr++) {
97
nrows = moinfo.sopi[Gr];
98
ncols = moinfo.mopi[Gs];
99
nlinks = moinfo.sopi[Gs];
100
rs = J.col_offset[h][Gr];
101
if(nrows && ncols && nlinks)
102
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
103
C[Gs][0],ncols,0.0,TMP[0],nso);
105
nrows = moinfo.mopi[Gr];
106
ncols = moinfo.mopi[Gs];
107
nlinks = moinfo.sopi[Gr];
108
rs = K.col_offset[h][Gr];
109
if(nrows && ncols && nlinks)
110
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
111
0.0,&K.matrix[h][pq][rs],ncols);
114
dpd_buf4_mat_irrep_wrt_block(&K, h, n*rows_per_bucket, rows_per_bucket);
117
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_left);
118
for(pq=0; pq < rows_left; pq++) {
119
for(Gr=0; Gr < nirreps; Gr++) {
122
nrows = moinfo.sopi[Gr];
123
ncols = moinfo.mopi[Gs];
124
nlinks = moinfo.sopi[Gs];
125
rs = J.col_offset[h][Gr];
126
if(nrows && ncols && nlinks)
127
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
128
C[Gs][0],ncols,0.0,TMP[0],nso);
130
nrows = moinfo.mopi[Gr];
131
ncols = moinfo.mopi[Gs];
132
nlinks = moinfo.sopi[Gr];
133
rs = K.col_offset[h][Gr];
134
if(nrows && ncols && nlinks)
135
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
136
0.0,&K.matrix[h][pq][rs],ncols);
140
dpd_buf4_mat_irrep_wrt_block(&K, h, n*rows_per_bucket, rows_left);
143
dpd_buf4_mat_irrep_close_block(&J, h, rows_per_bucket);
144
dpd_buf4_mat_irrep_close_block(&K, h, rows_per_bucket);
149
psio_close(PSIF_SO_PRESORT, 1); /* must keep the presort file for the upcoming BB transformation */
151
if(params.print_lvl) {
152
fprintf(outfile, "\tSorting AA/AB half-transformed integrals.\n");
156
psio_open(PSIF_HALFT1, PSIO_OPEN_NEW);
158
dpd_buf4_init(&K, PSIF_HALFT0, 0, 3, 8, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
159
dpd_buf4_sort(&K, PSIF_HALFT1, rspq, 8, 3, "Half-Transformed Ints (ij,pq)");
162
psio_close(PSIF_HALFT0, 0);
164
if(params.print_lvl) {
165
fprintf(outfile, "\tStarting AA second half-transformation.\n");
168
iwl_buf_init(&MBuff, PSIF_MO_AA_TEI, params.tolerance, 0, 0);
170
C = C_a; /* Usa alpha MOs for this half-transformation */
172
dpd_buf4_init(&J, PSIF_HALFT1, 0, 8, 0, 8, 3, 0, "Half-Transformed Ints (ij,pq)");
173
dpd_buf4_init(&K, CC_MISC, 0, 8, 5, 8, 8, 0, "MO Ints (ij,kl)");
174
for(h=0; h < nirreps; h++) {
176
memfree = (unsigned long int) (dpd_memfree() - J.params->coltot[h] - K.params->coltot[h]);
177
rows_per_bucket = memfree/(2 * J.params->coltot[h]);
178
if(rows_per_bucket > J.params->rowtot[h]) rows_per_bucket = (unsigned long int) J.params->rowtot[h];
179
nbuckets = (int) ceil(((double) J.params->rowtot[h])/((double) rows_per_bucket));
180
rows_left = (unsigned long int) (J.params->rowtot[h] % rows_per_bucket);
182
if(params.print_lvl > 1) {
183
fprintf(outfile, "\th = %d; memfree = %lu\n", h, memfree);
184
fprintf(outfile, "\th = %d; rows_per_bucket = %lu\n", h, rows_per_bucket);
185
fprintf(outfile, "\th = %d; rows_left = %lu\n", h, rows_left);
186
fprintf(outfile, "\th = %d; nbuckets = %d\n", h, nbuckets);
190
dpd_buf4_mat_irrep_init_block(&J, h, rows_per_bucket);
191
dpd_buf4_mat_irrep_init_block(&K, h, rows_per_bucket);
193
for(n=0; n < (rows_left ? nbuckets-1 : nbuckets); n++) {
194
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_per_bucket);
195
for(pq=0; pq < rows_per_bucket; pq++) {
196
for(Gr=0; Gr < nirreps; Gr++) {
198
nrows = moinfo.sopi[Gr];
199
ncols = moinfo.mopi[Gs];
200
nlinks = moinfo.sopi[Gs];
201
rs = J.col_offset[h][Gr];
202
if(nrows && ncols && nlinks)
203
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
204
C[Gs][0],ncols,0.0,TMP[0],nso);
206
nrows = moinfo.mopi[Gr];
207
ncols = moinfo.mopi[Gs];
208
nlinks = moinfo.sopi[Gr];
209
rs = K.col_offset[h][Gr];
210
if(nrows && ncols && nlinks)
211
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
212
0.0,&K.matrix[h][pq][rs],ncols);
215
p = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][0]];
216
q = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][1]];
218
for(rs=0; rs < K.params->coltot[h]; rs++) {
219
r = moinfo.act2qt_A[K.params->colorb[h][rs][0]];
220
s = moinfo.act2qt_A[K.params->colorb[h][rs][1]];
222
if(r >= s && RS <= PQ)
223
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
228
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_left);
229
for(pq=0; pq < rows_left; pq++) {
230
for(Gr=0; Gr < nirreps; Gr++) {
232
nrows = moinfo.sopi[Gr];
233
ncols = moinfo.mopi[Gs];
234
nlinks = moinfo.sopi[Gs];
235
rs = J.col_offset[h][Gr];
236
if(nrows && ncols && nlinks)
237
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
238
C[Gs][0],ncols,0.0,TMP[0],nso);
240
nrows = moinfo.mopi[Gr];
241
ncols = moinfo.mopi[Gs];
242
nlinks = moinfo.sopi[Gr];
243
rs = K.col_offset[h][Gr];
244
if(nrows && ncols && nlinks)
245
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
246
0.0,&K.matrix[h][pq][rs],ncols);
249
p = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][0]];
250
q = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][1]];
252
for(rs=0; rs < K.params->coltot[h]; rs++) {
253
r = moinfo.act2qt_A[K.params->colorb[h][rs][0]];
254
s = moinfo.act2qt_A[K.params->colorb[h][rs][1]];
256
if(r >= s && RS <= PQ)
257
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
261
dpd_buf4_mat_irrep_close_block(&J, h, rows_per_bucket);
262
dpd_buf4_mat_irrep_close_block(&K, h, rows_per_bucket);
267
iwl_buf_flush(&MBuff, 1);
268
iwl_buf_close(&MBuff, 1);
270
if(params.print_lvl) {
271
fprintf(outfile, "\tStarting AB second half-transformation.\n");
274
iwl_buf_init(&MBuff, PSIF_MO_AB_TEI, params.tolerance, 0, 0);
276
C = C_b; /* Usa beta MOs for this half-transformation */
278
dpd_buf4_init(&J, PSIF_HALFT1, 0, 8, 0, 8, 3, 0, "Half-Transformed Ints (ij,pq)");
279
dpd_buf4_init(&K, CC_MISC, 0, 8, 5, 8, 8, 0, "MO Ints (ij,kl)");
280
for(h=0; h < nirreps; h++) {
282
memfree = (unsigned long int) (dpd_memfree() - J.params->coltot[h] - K.params->coltot[h]);
283
rows_per_bucket = memfree/(2 * J.params->coltot[h]);
284
if(rows_per_bucket > J.params->rowtot[h]) rows_per_bucket = (unsigned long int) J.params->rowtot[h];
285
nbuckets = (int) ceil(((double) J.params->rowtot[h])/((double) rows_per_bucket));
286
rows_left = (unsigned long int) (J.params->rowtot[h] % rows_per_bucket);
288
if(params.print_lvl > 1) {
289
fprintf(outfile, "\th = %d; memfree = %lu\n", h, memfree);
290
fprintf(outfile, "\th = %d; rows_per_bucket = %lu\n", h, rows_per_bucket);
291
fprintf(outfile, "\th = %d; rows_left = %lu\n", h, rows_left);
292
fprintf(outfile, "\th = %d; nbuckets = %d\n", h, nbuckets);
296
dpd_buf4_mat_irrep_init_block(&J, h, rows_per_bucket);
297
dpd_buf4_mat_irrep_init_block(&K, h, rows_per_bucket);
299
for(n=0; n < (rows_left ? nbuckets-1 : nbuckets); n++) {
300
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_per_bucket);
301
for(pq=0; pq < rows_per_bucket; pq++) {
302
for(Gr=0; Gr < nirreps; Gr++) {
304
nrows = moinfo.sopi[Gr];
305
ncols = moinfo.mopi[Gs];
306
nlinks = moinfo.sopi[Gs];
307
rs = J.col_offset[h][Gr];
308
if(nrows && ncols && nlinks)
309
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
310
C[Gs][0],ncols,0.0,TMP[0],nso);
312
nrows = moinfo.mopi[Gr];
313
ncols = moinfo.mopi[Gs];
314
nlinks = moinfo.sopi[Gr];
315
rs = K.col_offset[h][Gr];
316
if(nrows && ncols && nlinks)
317
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
318
0.0,&K.matrix[h][pq][rs],ncols);
321
p = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][0]];
322
q = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][1]];
324
for(rs=0; rs < K.params->coltot[h]; rs++) {
325
r = moinfo.act2qt_B[K.params->colorb[h][rs][0]];
326
s = moinfo.act2qt_B[K.params->colorb[h][rs][1]];
329
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
334
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_left);
335
for(pq=0; pq < rows_left; pq++) {
336
for(Gr=0; Gr < nirreps; Gr++) {
338
nrows = moinfo.sopi[Gr];
339
ncols = moinfo.mopi[Gs];
340
nlinks = moinfo.sopi[Gs];
341
rs = J.col_offset[h][Gr];
342
if(nrows && ncols && nlinks)
343
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
344
C[Gs][0],ncols,0.0,TMP[0],nso);
346
nrows = moinfo.mopi[Gr];
347
ncols = moinfo.mopi[Gs];
348
nlinks = moinfo.sopi[Gr];
349
rs = K.col_offset[h][Gr];
350
if(nrows && ncols && nlinks)
351
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
352
0.0,&K.matrix[h][pq][rs],ncols);
355
p = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][0]];
356
q = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][1]];
358
for(rs=0; rs < K.params->coltot[h]; rs++) {
359
r = moinfo.act2qt_B[K.params->colorb[h][rs][0]];
360
s = moinfo.act2qt_B[K.params->colorb[h][rs][1]];
363
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
367
dpd_buf4_mat_irrep_close_block(&J, h, rows_per_bucket);
368
dpd_buf4_mat_irrep_close_block(&K, h, rows_per_bucket);
373
iwl_buf_flush(&MBuff, 1);
374
iwl_buf_close(&MBuff, 1);
376
psio_close(PSIF_HALFT1, 0);
378
/*** AA/AB two-electron integral transformation complete ***/
380
/*** BB two-electron integral transformation ***/
382
if(params.print_lvl) {
383
fprintf(outfile, "\tStarting BB first half-transformation.\n");
387
psio_open(PSIF_SO_PRESORT, PSIO_OPEN_OLD);
388
psio_open(PSIF_HALFT0, PSIO_OPEN_NEW);
390
C = C_b; /* Use beta MOs for this half-transformation */
392
dpd_buf4_init(&J, PSIF_SO_PRESORT, 0, 3, 0, 3, 3, 0, "SO Ints (pq,rs)");
393
dpd_buf4_init(&K, PSIF_HALFT0, 0, 3, 5, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
394
for(h=0; h < nirreps; h++) {
396
memfree = (unsigned long int) (dpd_memfree() - J.params->coltot[h] - K.params->coltot[h]);
397
rows_per_bucket = memfree/(2 * J.params->coltot[h]);
398
if(rows_per_bucket > J.params->rowtot[h]) rows_per_bucket = (unsigned long int) J.params->rowtot[h];
399
nbuckets = (int) ceil(((double) J.params->rowtot[h])/((double) rows_per_bucket));
400
rows_left = (unsigned long int) (J.params->rowtot[h] % rows_per_bucket);
401
if(params.print_lvl > 1) {
402
fprintf(outfile, "\th = %d; memfree = %lu\n", h, memfree);
403
fprintf(outfile, "\th = %d; rows_per_bucket = %lu\n", h, rows_per_bucket);
404
fprintf(outfile, "\th = %d; rows_left = %lu\n", h, rows_left);
405
fprintf(outfile, "\th = %d; nbuckets = %d\n", h, nbuckets);
409
dpd_buf4_mat_irrep_init_block(&J, h, rows_per_bucket);
410
dpd_buf4_mat_irrep_init_block(&K, h, rows_per_bucket);
412
for(n=0; n < (rows_left ? nbuckets-1 : nbuckets); n++) {
413
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_per_bucket);
414
for(pq=0; pq < rows_per_bucket; pq++) {
415
for(Gr=0; Gr < nirreps; Gr++) {
417
nrows = moinfo.sopi[Gr];
418
ncols = moinfo.mopi[Gs];
419
nlinks = moinfo.sopi[Gs];
420
rs = J.col_offset[h][Gr];
421
if(nrows && ncols && nlinks)
422
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
423
C[Gs][0],ncols,0.0,TMP[0],nso);
425
nrows = moinfo.mopi[Gr];
426
ncols = moinfo.mopi[Gs];
427
nlinks = moinfo.sopi[Gr];
428
rs = K.col_offset[h][Gr];
429
if(nrows && ncols && nlinks)
430
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
431
0.0,&K.matrix[h][pq][rs],ncols);
434
dpd_buf4_mat_irrep_wrt_block(&K, h, n*rows_per_bucket, rows_per_bucket);
437
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_left);
438
for(pq=0; pq < rows_left; pq++) {
439
for(Gr=0; Gr < nirreps; Gr++) {
442
nrows = moinfo.sopi[Gr];
443
ncols = moinfo.mopi[Gs];
444
nlinks = moinfo.sopi[Gs];
445
rs = J.col_offset[h][Gr];
446
if(nrows && ncols && nlinks)
447
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
448
C[Gs][0],ncols,0.0,TMP[0],nso);
450
nrows = moinfo.mopi[Gr];
451
ncols = moinfo.mopi[Gs];
452
nlinks = moinfo.sopi[Gr];
453
rs = K.col_offset[h][Gr];
454
if(nrows && ncols && nlinks)
455
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
456
0.0,&K.matrix[h][pq][rs],ncols);
460
dpd_buf4_mat_irrep_wrt_block(&K, h, n*rows_per_bucket, rows_left);
463
dpd_buf4_mat_irrep_close_block(&J, h, rows_per_bucket);
464
dpd_buf4_mat_irrep_close_block(&K, h, rows_per_bucket);
469
psio_close(PSIF_SO_PRESORT, 0);
471
if(params.print_lvl) {
472
fprintf(outfile, "\tSorting BB half-transformed integrals.\n");
476
psio_open(PSIF_HALFT1, PSIO_OPEN_NEW);
478
dpd_buf4_init(&K, PSIF_HALFT0, 0, 3, 8, 3, 8, 0, "Half-Transformed Ints (pq,ij)");
479
dpd_buf4_sort(&K, PSIF_HALFT1, rspq, 8, 3, "Half-Transformed Ints (ij,pq)");
482
psio_close(PSIF_HALFT0, 0);
484
if(params.print_lvl) {
485
fprintf(outfile, "\tStarting BB second half-transformation.\n");
488
iwl_buf_init(&MBuff, PSIF_MO_BB_TEI, params.tolerance, 0, 0);
490
C = C_b; /* Usa beta MOs for this half-transformation */
492
dpd_buf4_init(&J, PSIF_HALFT1, 0, 8, 0, 8, 3, 0, "Half-Transformed Ints (ij,pq)");
493
dpd_buf4_init(&K, CC_MISC, 0, 8, 5, 8, 8, 0, "MO Ints (ij,kl)");
494
for(h=0; h < nirreps; h++) {
496
memfree = (unsigned long int) (dpd_memfree() - J.params->coltot[h] - K.params->coltot[h]);
497
rows_per_bucket = memfree/(2 * J.params->coltot[h]);
498
if(rows_per_bucket > J.params->rowtot[h]) rows_per_bucket = (unsigned long int) J.params->rowtot[h];
499
nbuckets = (int) ceil(((double) J.params->rowtot[h])/((double) rows_per_bucket));
500
rows_left = (unsigned long int) (J.params->rowtot[h] % rows_per_bucket);
502
if(params.print_lvl > 1) {
503
fprintf(outfile, "\th = %d; memfree = %lu\n", h, memfree);
504
fprintf(outfile, "\th = %d; rows_per_bucket = %lu\n", h, rows_per_bucket);
505
fprintf(outfile, "\th = %d; rows_left = %lu\n", h, rows_left);
506
fprintf(outfile, "\th = %d; nbuckets = %d\n", h, nbuckets);
510
dpd_buf4_mat_irrep_init_block(&J, h, rows_per_bucket);
511
dpd_buf4_mat_irrep_init_block(&K, h, rows_per_bucket);
513
for(n=0; n < (rows_left ? nbuckets-1 : nbuckets); n++) {
514
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_per_bucket);
515
for(pq=0; pq < rows_per_bucket; pq++) {
516
for(Gr=0; Gr < nirreps; Gr++) {
518
nrows = moinfo.sopi[Gr];
519
ncols = moinfo.mopi[Gs];
520
nlinks = moinfo.sopi[Gs];
521
rs = J.col_offset[h][Gr];
522
if(nrows && ncols && nlinks)
523
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
524
C[Gs][0],ncols,0.0,TMP[0],nso);
526
nrows = moinfo.mopi[Gr];
527
ncols = moinfo.mopi[Gs];
528
nlinks = moinfo.sopi[Gr];
529
rs = K.col_offset[h][Gr];
530
if(nrows && ncols && nlinks)
531
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
532
0.0,&K.matrix[h][pq][rs],ncols);
535
p = moinfo.act2qt_B[K.params->roworb[h][pq+n*rows_per_bucket][0]];
536
q = moinfo.act2qt_B[K.params->roworb[h][pq+n*rows_per_bucket][1]];
538
for(rs=0; rs < K.params->coltot[h]; rs++) {
539
r = moinfo.act2qt_B[K.params->colorb[h][rs][0]];
540
s = moinfo.act2qt_B[K.params->colorb[h][rs][1]];
542
if(r >= s && RS <= PQ)
543
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
548
dpd_buf4_mat_irrep_rd_block(&J, h, n*rows_per_bucket, rows_left);
549
for(pq=0; pq < rows_left; pq++) {
550
for(Gr=0; Gr < nirreps; Gr++) {
552
nrows = moinfo.sopi[Gr];
553
ncols = moinfo.mopi[Gs];
554
nlinks = moinfo.sopi[Gs];
555
rs = J.col_offset[h][Gr];
556
if(nrows && ncols && nlinks)
557
C_DGEMM('n','n',nrows,ncols,nlinks,1.0,&J.matrix[h][pq][rs],nlinks,
558
C[Gs][0],ncols,0.0,TMP[0],nso);
560
nrows = moinfo.mopi[Gr];
561
ncols = moinfo.mopi[Gs];
562
nlinks = moinfo.sopi[Gr];
563
rs = K.col_offset[h][Gr];
564
if(nrows && ncols && nlinks)
565
C_DGEMM('t','n',nrows,ncols,nlinks,1.0,C[Gr][0],nrows,TMP[0],nso,
566
0.0,&K.matrix[h][pq][rs],ncols);
569
p = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][0]];
570
q = moinfo.act2qt_A[K.params->roworb[h][pq+n*rows_per_bucket][1]];
572
for(rs=0; rs < K.params->coltot[h]; rs++) {
573
r = moinfo.act2qt_A[K.params->colorb[h][rs][0]];
574
s = moinfo.act2qt_A[K.params->colorb[h][rs][1]];
576
if(r >= s && RS <= PQ)
577
iwl_buf_wrt_val(&MBuff, p, q, r, s, K.matrix[h][pq][rs], params.print_tei, outfile, 0);
581
dpd_buf4_mat_irrep_close_block(&J, h, rows_per_bucket);
582
dpd_buf4_mat_irrep_close_block(&K, h, rows_per_bucket);
587
iwl_buf_flush(&MBuff, 1);
588
iwl_buf_close(&MBuff, 1);
590
/*** BB two-electron integral transformation complete ***/
594
for(h=0; h < nirreps; h++) {
601
if(params.print_lvl) {
602
fprintf(outfile, "\tTwo-electron integral transformation complete.\n");