1
subroutine CalcPerturbedTDPmat1_opt(
2
& ncomp, ! in : nr. components to calculate
3
& g_pmats, ! out: density matrix symmetrized
4
& g_pmata, ! out: density matrix antisymmetrized -NOT USED
5
& g_amat, ! in : perturbed MO coefficients
6
& g_vectors,! in : unperturbed MO coefficients
8
& nocc, ! in : nr. occupied MOs
9
& nvir, ! in : nr. virtual MOs
11
& lantisym, ! in : = .true. calc. (symm,antisymm)=(pmats,pmata)
12
& lstatic, ! in : = .true. static response, dynamic otherwise
13
& imag, ! in : = .true. if amat is imaginary instead of real
14
& haveocc) ! in : = .true. if amat contains occ-occ block
16
* $Id: CalcPerturbedTDPmat1.F 19707 2010-10-29 17:59:36Z d3y133 $
18
c ==================================================================
20
c calculate frequency-dependent density matrix perturbation
21
c (symmetric and antisymmetric part), linear response,
22
c from a set of perturbed MO coefficients
24
c we assume DOUBLE occupation of all occupied orbitals and
25
c REAL unperturbed orbitals. The perturbation can be either
26
c purely real or purely imaginary
28
c THIS ROUTINE USES TOO MUCH MEMORY; IT COULD DO HE SAME
29
C JOB WITH LESS TEMP SPACE. FIX THIS
32
c ncomp - number of components to be calculated
33
c g_amat - the perturbed MO coefficients are
34
c written as C(+/-) = C(0)*A(+/-),
35
c g_amat contains the elements of matrix A
36
c (only the virt - occ block, or nmo - occ block)
37
c g_vectors - unperturbed MO coefficients C(0)
38
c lantisym - logical switch to calculate symmetric
40
c part separately or just the total density matrix
41
c lstatic - static response, assume that both components
42
c of amat are equal. assumes ncomp = 1 (!)
43
c imag - true if amat is imaginary instad of real
44
c haveocc - true if amat contains occ-occ block, too
46
c output : g_pmats, g_pmata: symmetric and antisymmetric
47
c part of perturbed density matrix, global arrays, if (lantisym),
48
c otherwise the total density matrix is in pmats, and pmata=0
50
c remark : all perturbed matrices are classified by
51
c (+/-) frequency components
53
c remark: the density matrix is given by
54
c transpose(P) = C n C(dagger), i.e. in the end we transpose the
55
c result to get the correct density matrix out
57
c ==================================================================
59
c Author : Fredy W. Aquino
61
c Note.- Modified from original aoresponse source code
62
c for extension to spin-unrestricted case
63
c original aoresponse source code was written by
64
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
65
c Modifying original source code: CalcPerturbedTDPmat1()
66
c --> Experimental (not published yet)
71
#include "mafdecls.fh"
72
c subroutine arguments:
74
integer g_pmats(ncomp),
78
integer naos, nocc, nvir, nmo
80
logical lstatic, imag, haveocc
84
double precision half, one, two,toscl
85
parameter (half = 0.5d0, one = 1.0d0)
89
c debug = .true. ! allow debugging printout
90
debug = .false. ! not allow debugging printout
91
c check range of ncomp
92
if (ncomp.le.0 .or. ncomp.gt.2) then
93
call errquit('CalcPerturbedTDPmat: ncomp out of range',
96
if (ncomp.gt.1 .and. lstatic) then
98
& ('CalcPerturbedTDPmat1: ncomp > 1 but lstatic.eq.true.',
101
c assign + and - components for indexing amat:
112
c if (ga_nodeid().eq.0) then
113
c write(*,190) ip,im,lstatic,imag
114
c 190 format('(ip,im,lstatic,imag)=(',i3,',',i3,',',L1,',',L1,')')
118
call ga_zero(g_pmats(ipm))
119
c call ga_zero(g_pmata(ipm))
122
if (nocc+nvir .ne. nmo) call errquit
123
& ('CalcPerturbedTDPmat1: wrong no. of orbitals',0,CALC_ERR)
125
c -------------------------------------------------------------
126
c First we assemble P(+). Note that A(-) is assumed to be A(-)*
128
c This allows us to use the same algorithm no matter if A is
129
c real and symmetric or imaginary and antisymmetric
130
c -------------------------------------------------------------
131
c ----------------------------
132
c First step: C n C(-,dagger)
133
c Second step: C(+) n C(dagger)
134
c -----------------------------
137
if (ga_nodeid().eq.0)
138
& write(*,*) '---- BEF get_PertDens g_amat(',ipm,')--- START'
139
call ga_print(g_amat(ipm))
140
if (ga_nodeid().eq.0)
141
& write(*,*) '---- BEF get_PertDens g_amat(',ipm,')--- END'
146
& g_pmats(1),!out: symmetrized dens
147
& g_pmata(1),!out: anti symmetrized dens
148
& g_amat, ! in: the u mat
149
& g_vectors, ! in: MO vect
150
& ncomp, ! in: nr. components g_amat
151
& ip,im, ! in: indices of u vect
152
& imag, ! in: = T -> imag
153
& haveocc, ! in: logical flag
154
& lantisym, ! in: logical flag
155
& naos,nmo, ! in: nr. AOs,MOs
156
& nocc,nvir, ! in: nr. (occ,virt) MOs
157
& debug) ! in: =.true. -> show debug printouts
160
if (ga_nodeid().eq.0)
161
& write(*,*) '---- g_pmats-nw-------- START'
162
call ga_print(g_pmats(1))
163
if (ga_nodeid().eq.0)
164
& write(*,*) '---- g_pmats-nw-------- END'
165
c if (ga_nodeid().eq.0)
166
c & write(*,*) '---- g_pmata-nw-------- START'
167
c call ga_print(g_pmata(1))
168
c if (ga_nodeid().eq.0)
169
c & write(*,*) '---- g_pmata-nw-------- END'
171
if (lstatic .or. ncomp.eq.1) then
172
c skip calculation of component 2 of the density matrix
173
if (ga_nodeid().eq.0)
174
& write(*,*) 'FA-Skipping calc of 2nd component'
178
c if (ga_nodeid().eq.0)
179
c & write(*,*) 'FA-calculating 2nd component'
180
c ----------------------------
181
c First step: C n C(+,dagger)
182
c Second step: C(-) n C(dagger)
183
c -----------------------------
184
c Note 1.- I tried calling get_PertDens 2nd time
185
c and swapping (ip,im) --> (im,ip)
186
c and I got the relationship shown below:
188
c g_pmats(2)= -transpose(g_pmats(1))
189
c g_pmata(2)= g_pmata(1)= 0
191
c g_pmats(2)= -transpose(g_pmats(1))
192
c g_pmata(2)= g_pmata(1)
193
c Note 2.- Swapping (ip,im) --> (im,ip)
194
c is equivalent to doing the second
195
c part (e.g. calc. of P(-)
196
call ga_transpose(g_pmats(1),g_pmats(2))
198
if (imag) toscl=-1.0d0
199
c call ga_scale(g_pmats(2),-1.0d0)
200
call ga_scale(g_pmats(2),toscl)
201
c call ga_copy(g_pmata(1),g_pmata(2))
202
c jump here from above in case of static calculation
207
subroutine get_PertDens(
208
& g_pmats, !out: symmetrized dens
209
& g_pmata, !out: anti symmetrized dens -NOT USED
210
& g_amat, ! in: the u mat
211
& g_vectors,! in: MO vect
212
& ncomp, ! in: nr. components g_amat
213
& ip,im, ! in: indices of u vect
214
& imag, ! in: = T -> imag
215
& haveocc, ! in: logical flag
216
& lantisym, ! in: logical flag
217
& naos,nmo, ! in: nr. AOs,MOs
218
& nocc,nvir,! in: nr. (occ,virt) MOs
219
& debug) ! in: =.true. -> show debug printouts
221
c Author : Fredy W. Aquino
223
c Note.- Modified from original aoresponse source code
224
c for extension to spin-unrestricted case
225
c original aoresponse source code was written by
226
c J. Autschbach and appears on nwchem-devtrunk (date:03-02-12)
227
c --> Experimental (not published yet)
230
#include "errquit.fh"
232
#include "mafdecls.fh"
234
c subroutine arguments:
235
c Note.- For (im,ip) --> (g_pmats,g_pmata)(1)
236
c For (ip,im) --> (g_pmats,g_pmata)(2)
238
integer g_pmats,g_pmata,
241
integer naos,nocc,nvir,nmo
242
logical lantisym,imag,haveocc
244
integer g_ptmp,g_eig1,g_work
245
double precision half, one, two
246
parameter (half = 0.5d0, one = 1.0d0)
248
c ------------------------
249
c allocate workspace (GAs)
250
c ------------------------
252
& MT_DBL,naos,naos,'get_PertDens:ptmp',0,0,g_ptmp))
253
& call errquit('get_PertDens:ptmp',0,GA_ERR)
255
& MT_DBL,naos,naos,'get_PertDens:work',0,0,g_work))
256
& call errquit('get_PertDens:work',0,GA_ERR)
258
& MT_DBL,naos,naos,'get_PertDens:eig1',0,0,g_eig1))
259
& call errquit('get_PertDens:eig1',0,GA_ERR)
260
c ----------------------------
261
c First step: C n C(-,dagger)
262
c ----------------------------
263
c calculate C(-,dagger)
266
if (.not.haveocc) then
269
if (ga_nodeid().eq.0)
270
& write(*,*) 'FA-enter-no-haveocc...'
271
if (ga_nodeid().eq.0)
272
& write(*,*) '-----g_vectors-nohaveocc---- START'
273
call ga_print(g_vectors)
274
if (ga_nodeid().eq.0)
275
& write(*,*) '-----g_vectors-nohaveocc---- END'
276
if (ga_nodeid().eq.0) then
278
1 format('-----g_amat(',i3,')-nohaveocc---- START')
280
call ga_print(g_amat(im))
281
if (ga_nodeid().eq.0) then
283
2 format('-----g_amat(',i3,')-nohaveocc---- END')
285
if (ga_nodeid().eq.0) then
287
35 format('-----g_amat(',i3,')-yeshaveocc---- START')
289
call ga_print(g_amat(ip))
290
if (ga_nodeid().eq.0) then
292
36 format('-----g_amat(',i3,')-yeshaveocc---- END')
298
call ga_matmul_patch('n','n', two,0d0,
299
& g_vectors ,1,naos,nocc+1,nmo,
300
& g_amat(im),1,nvir,1 ,nocc,
301
& g_eig1 ,1,naos,1 ,nocc)
303
if (ga_nodeid().eq.0)
304
& write(*,*) '-----g_eig1-nohaveocc---- START'
305
call ga_print(g_eig1)
306
if (ga_nodeid().eq.0)
307
& write(*,*) '-----g_eig1-nohaveocc---- END'
311
if (ga_nodeid().eq.0)
312
& write(*,*) '-----g_vectors-yeshaveocc---- START'
313
call ga_print(g_vectors)
314
if (ga_nodeid().eq.0)
315
& write(*,*) '-----g_vectors-yeshaveocc---- END'
316
if (ga_nodeid().eq.0) then
318
3 format('-----g_amat(',i3,')-yeshaveocc---- START')
320
call ga_print(g_amat(im))
321
if (ga_nodeid().eq.0) then
323
4 format('-----g_amat(',i3,')-yeshaveocc---- END')
325
if (ga_nodeid().eq.0) then
327
33 format('-----g_amat(',i3,')-yeshaveocc---- START')
329
call ga_print(g_amat(ip))
330
if (ga_nodeid().eq.0) then
332
34 format('-----g_amat(',i3,')-yeshaveocc---- END')
338
call ga_matmul_patch('n','n', two,0d0,
339
& g_vectors ,1,naos,1,nmo,
340
& g_amat(im),1,nmo ,1,nocc,
341
& g_eig1 ,1,naos,1,nocc)
344
if (ga_nodeid().eq.0)
345
& write(*,*) '-----g_eig1-yeshaveocc---- START'
346
call ga_print(g_eig1)
347
if (ga_nodeid().eq.0)
348
& write(*,*) '-----g_eig1-yeshaveocc---- END'
351
c note: the dimensioning for array B is that of the transposed
352
c matrix, not of the original matrix.
354
c calculate C(0)C(-,dagger), store in g_ptmp
357
call ga_matmul_patch('n','t', 1d0,0d0,
358
& g_vectors,1,naos,1,nocc,
359
& g_eig1 ,1,nocc,1,naos,
360
& g_ptmp ,1,naos,1,naos)
362
c -----------------------------
363
c Second step: C(+) n C(dagger)
364
c -----------------------------
367
if (.not.haveocc) then
370
call ga_matmul_patch('n','n', two,0d0,
371
& g_vectors ,1,naos,nocc+1,nmo,
372
& g_amat(ip),1,nvir,1 ,nocc,
373
& g_eig1 ,1,naos,1 ,nocc)
376
if (ga_nodeid().eq.0)
377
& write(*,*) '-----g_eig1-nohaveocc-2-- START'
378
call ga_print(g_eig1)
379
if (ga_nodeid().eq.0)
380
& write(*,*) '-----g_eig1-nohaveocc-2-- END'
385
call ga_matmul_patch('n','n', two,0d0,
386
& g_vectors ,1,naos,1,nmo,
387
& g_amat(ip),1,nmo ,1,nocc,
388
& g_eig1 ,1,naos,1,nocc)
391
if (ga_nodeid().eq.0)
392
& write(*,*) '-----g_eig1-yeshaveocc-2---- START'
393
call ga_print(g_eig1)
394
if (ga_nodeid().eq.0)
395
& write(*,*) '-----g_eig1-yeshaveocc-2---- END'
397
endif ! end-if-haveocc
399
c calculate C(+)C(0,dagger), store in g_work
402
call ga_matmul_patch('n','t', 1d0,0d0,
403
& g_eig1 ,1,naos,1,nocc,
404
& g_vectors,1,nocc,1,naos,
405
& g_work ,1,naos,1,naos)
407
c add the two terms together and transpose the density matrix
409
if (ga_nodeid().eq.0)
410
& write(*,*) '---- CC1^t-------- START'
411
call ga_print(g_ptmp)
412
if (ga_nodeid().eq.0)
413
& write(*,*) '---- CC1^t--------- END'
414
if (ga_nodeid().eq.0)
415
& write(*,*) '---- C1C^t-------- START'
416
call ga_print(g_work)
417
if (ga_nodeid().eq.0)
418
& write(*,*) '---- C1C^t--------- END'
420
c Doing: C(Du_q)^T + (Du_p)C^T
421
c (q,p)=(im,ip) --> P(+)
422
c (q,p)=(ip,im) --> P(-)
423
call ga_add(1d0,g_ptmp,1d0,g_work,g_work)
424
call ga_transpose(g_work, g_ptmp)
425
c calculate symmetrized and antisymmetrized part (+ component)
426
c if requested on input:
428
call ga_transpose(g_ptmp,g_work)
429
call ga_add(half,g_ptmp, half,g_work,g_pmats)
431
call ga_copy(g_ptmp, g_pmats)
434
if (ga_nodeid().eq.0)
435
& write(*,*) '---- g_pmats-------- START'
436
call ga_print(g_pmats)
437
if (ga_nodeid().eq.0)
438
& write(*,*) '---- g_pmats-------- END'
439
c if (ga_nodeid().eq.0)
440
c & write(*,*) '---- g_pmata-------- START'
441
c call ga_print(g_pmata)
442
c if (ga_nodeid().eq.0)
443
c & write(*,*) '---- g_pmata-------- END'
445
if (.not.ga_destroy(g_ptmp))
446
& call errquit('get_PertDens: ga_destroy failed g_ptmp',
448
if (.not.ga_destroy(g_work))
449
& call errquit('get_PertDens: ga_destroy failed g_work',
451
if (.not.ga_destroy(g_eig1))
452
& call errquit('get_PertDens: ga_destroy failed g_eig1',
458
c ++++++++++++++++++ Added for debugging ++++++++++++++++ START
460
subroutine CalcPerturbedTDPmat1_deb
461
& (ncomp, g_pmats, g_pmata, g_amat, g_vectors, naos, nocc,
462
& nvir, nmo, lantisym, lstatic, imag, haveocc)
464
* $Id: CalcPerturbedTDPmat1.F 19707 2010-10-29 17:59:36Z d3y133 $
466
c ==================================================================
468
c calculate frequency-dependent density matrix perturbation
469
c (symmetric and antisymmetric part), linear response,
470
c from a set of perturbed MO coefficients
472
c we assume DOUBLE occupation of all occupied orbitals and
473
c REAL unperturbed orbitals. The perturbation can be either
474
c purely real or purely imaginary
476
c THIS ROUTINE USES TOO MUCH MEMORY; IT COULD DO HE SAME
477
C JOB WITH LESS TEMP SPACE. FIX THIS
480
c ncomp - number of components to be calculated
481
c g_amat - the perturbed MO coefficients are
482
c written as C(+/-) = C(0)*A(+/-),
483
c g_amat contains the elements of matrix A
484
c (only the virt - occ block, or nmo - occ block)
485
c g_vectors - unperturbed MO coefficients C(0)
486
c lantisym - logical switch to calculate symmetric
488
c part separately or just the total density matrix
489
c lstatic - static response, assume that both components
490
c of amat are equal. assumes ncomp = 1 (!)
491
c imag - true if amat is imaginary instad of real
492
c haveocc - true if amat contains occ-occ block, too
494
c output : g_pmats, g_pmata: symmetric and antisymmetric
495
c part of perturbed density matrix, global arrays, if (lantisym),
496
c otherwise the total density matrix is in pmats, and pmata=0
498
c remark : all perturbed matrices are classified by
499
c (+/-) frequency components
501
c remark: the density matrix is given by
502
c transpose(P) = C n C(dagger), i.e. in the end we transpose the
503
c result to get the correct density matrix out
505
c ==================================================================
509
#include "errquit.fh"
511
#include "mafdecls.fh"
513
c subroutine arguments:
515
integer g_pmats(ncomp), g_pmata(ncomp), g_amat(*),
517
integer naos, nocc, nvir, nmo
519
logical lstatic, imag, haveocc
522
integer g_ptmp, g_eig1, g_work
523
integer imo, imu, inu, ll, ip, im, ipm
524
double precision rtemp
525
double precision half, one, two
526
parameter (half = 0.5d0, one = 1.0d0)
529
integer type, dim1, dim2
530
external get_PertDens
532
c ==================================================================
533
c ++++++++++++ WARNING -CHECKING lantisym=T +++++++ START
534
c if (ga_nodeid().eq.0)
535
c & write(*,*) 'FA-WARNING: check lantisym=T'
537
c ++++++++++++ WARNING -CHECKING lantisym=T +++++++ TRUE
541
c check range of ncomp
543
if (ncomp.le.0 .or. ncomp.gt.2) then
544
call errquit('CalcPerturbedTDPmat: ncomp out of range',
548
c cowardy refuse so calculate two components of perturbed
549
c density matrix if lstatic switch is set to true
551
if (ncomp.gt.1 .and. lstatic) then
553
& ('CalcPerturbedTDPmat1: ncomp > 1 but lstatic.eq.true.',
558
c assign + and - components for indexing amat:
568
if (ga_nodeid().eq.0) then
569
write(*,190) ip,im,lstatic,imag
570
190 format('(ip,im,lstatic,imag)=(',i3,',',i3,',',L1,',',L1,')')
574
call ga_zero(g_pmats(ipm))
575
call ga_zero(g_pmata(ipm))
578
if (debug) write (6,'(a,4i6)') 'nocc,nvir,nmo',nocc, nvir, nmo
580
if (nocc+nvir .ne. nmo) call errquit
581
& ('CalcPerturbedTDPmat1: wrong no. of orbitals',0,CALC_ERR)
583
c ------------------------
584
c allocate workspace (GAs)
585
c ------------------------
587
if (.not. ga_create(MT_DBL, naos, naos,
588
& 'CalcPerturbedTDPmat1:ptmp',
589
& 0, 0, g_ptmp)) call errquit('CalcPerturbedTDPmat1:ptmp', 0,
592
if (.not. ga_create(MT_DBL, naos, naos,
593
& 'CalcPerturbedTDPmat1:work',
594
& 0, 0, g_work)) call errquit('CalcPerturbedTDPmat1:work', 0,
597
if (.not. ga_create(MT_DBL, naos, nocc,
598
& 'CalcPerturbedTDPmat1:eig1',
599
& 0, 0, g_eig1)) call errquit('CalcPerturbedTDPmat1:eig1', 0,
603
c debug array dimensions
604
call ga_inquire (g_eig1,type, dim1, dim2)
605
write (6,'(a,2i4)') 'g_eig1:',dim1,dim2
606
call ga_inquire (g_ptmp,type, dim1, dim2)
607
write (6,'(a,2i4)') 'g_ptmp:',dim1,dim2
608
call ga_inquire (g_work,type, dim1, dim2)
609
write (6,'(a,2i4)') 'g_work:',dim1,dim2
610
call ga_inquire (g_amat(1),type, dim1, dim2)
611
write (6,'(a,2i4)') 'g_amat(1):',dim1,dim2
612
call ga_inquire (g_vectors,type, dim1, dim2)
613
write (6,'(a,2i4)') 'g_vectors:',dim1,dim2
617
c -------------------------------------------------------------
618
c First we assemble P(+). Note that A(-) is assumed to be A(-)*
620
c This allows us to use the same algorithm no matter if A is
621
c real and symmetric or imaginary and antisymmetric
622
c -------------------------------------------------------------
629
c ----------------------------
630
c First step: C n C(-,dagger)
631
c ----------------------------
633
c calculate C(-,dagger)
637
if (ga_nodeid().eq.0)
638
& write(*,31) imag,two
639
31 format('FA-debug (imag,two)=(',L1,',',f15.8)
641
if (.not.haveocc) then
642
if (ga_nodeid().eq.0)
643
& write(*,*) 'FA-enter-no-haveocc...'
644
if (ga_nodeid().eq.0)
645
& write(*,*) '-----g_vectors-nohaveocc---- START'
646
call ga_print(g_vectors)
647
if (ga_nodeid().eq.0)
648
& write(*,*) '-----g_vectors-nohaveocc---- END'
649
if (ga_nodeid().eq.0) then
651
1 format('-----g_amat(',i3,')-nohaveocc---- START')
653
call ga_print(g_amat(im))
654
if (ga_nodeid().eq.0) then
656
2 format('-----g_amat(',i3,')-nohaveocc---- END')
658
if (ga_nodeid().eq.0) then
660
1070 format('-----g_amat(',i3,')-nohaveocc---- START')
662
call ga_print(g_amat(ip))
663
if (ga_nodeid().eq.0) then
665
1071 format('-----g_amat(',i3,')-nohaveocc---- END')
667
call ga_matmul_patch('n','n', two,0d0,
668
& g_vectors ,1,naos,nocc+1,nmo,
669
& g_amat(im),1,nvir,1 ,nocc,
670
& g_eig1 ,1,naos,1 ,nocc)
672
if (ga_nodeid().eq.0)
673
& write(*,*) '-----g_eig1-nohaveocc---- START'
674
call ga_print(g_eig1)
675
if (ga_nodeid().eq.0)
676
& write(*,*) '-----g_eig1-nohaveocc---- END'
679
if (ga_nodeid().eq.0)
680
& write(*,*) 'FA-enter-yes-haveocc...'
682
if (ga_nodeid().eq.0)
683
& write(*,*) '-----g_vectors-yeshaveocc---- START'
684
call ga_print(g_vectors)
685
if (ga_nodeid().eq.0)
686
& write(*,*) '-----g_vectors-yeshaveocc---- END'
687
if (ga_nodeid().eq.0) then
689
3 format('-----g_amat(',i3,')-yeshaveocc---- START')
691
call ga_print(g_amat(im))
692
if (ga_nodeid().eq.0) then
694
4 format('-----g_amat(',i3,')-yeshaveocc---- END')
697
call ga_matmul_patch('n','n', two,0d0,
698
& g_vectors ,1,naos,1,nmo,
699
& g_amat(im),1,nmo ,1,nocc,
700
& g_eig1 ,1,naos,1,nocc)
702
if (ga_nodeid().eq.0)
703
& write(*,*) '-----g_eig1-yeshaveocc---- START'
704
call ga_print(g_eig1)
705
if (ga_nodeid().eq.0)
706
& write(*,*) '-----g_eig1-yeshaveocc---- END'
710
if (debug) write (6,*) '1'
712
c note: the dimensioning for array B is that of the transposed
713
c matrix, not of the original matrix.
715
c calculate C(0)C(-,dagger), store in g_ptmp
716
call ga_matmul_patch('n','t', 1d0,0d0,
717
& g_vectors,1,naos,1,nocc,
718
& g_eig1,1,nocc,1,naos,
719
& g_ptmp,1,naos,1,naos)
722
if (debug) write (6,*) '2'
724
c -----------------------------
725
c Second step: C(+) n C(dagger)
726
c -----------------------------
730
if (.not.haveocc) then
732
if (ga_nodeid().eq.0)
733
& write(*,*) 'FA-enter-no-haveocc-2...'
735
call ga_matmul_patch('n','n', two,0d0,
736
& g_vectors ,1,naos,nocc+1,nmo,
737
& g_amat(ip),1,nvir,1 ,nocc,
738
& g_eig1 ,1,naos,1 ,nocc)
740
if (ga_nodeid().eq.0)
741
& write(*,*) '-----g_eig1-nohaveocc-2-- START'
742
call ga_print(g_eig1)
743
if (ga_nodeid().eq.0)
744
& write(*,*) '-----g_eig1-nohaveocc-2-- END'
748
if (ga_nodeid().eq.0)
749
& write(*,*) 'FA-enter-yes-haveocc-2...'
751
call ga_matmul_patch('n','n', two,0d0,
752
& g_vectors ,1,naos,1,nmo,
753
& g_amat(ip),1,nmo ,1,nocc,
754
& g_eig1 ,1,naos,1,nocc)
756
if (ga_nodeid().eq.0)
757
& write(*,*) '-----g_eig1-yeshaveocc-2---- START'
758
call ga_print(g_eig1)
759
if (ga_nodeid().eq.0)
760
& write(*,*) '-----g_eig1-yeshaveocc-2---- END'
765
if (debug) write (6,*) '3'
767
c calculate C(+)C(0,dagger), store in g_work
768
call ga_matmul_patch('n','t', 1d0,0d0,
769
& g_eig1 ,1,naos,1,nocc,
770
& g_vectors,1,nocc,1,naos,
771
& g_work ,1,naos,1,naos)
774
if (debug) write (6,*) '4'
776
c add the two terms together and transpose the density matrix
777
if (ga_nodeid().eq.0)
778
& write(*,*) '---- CC1^t-------- START'
779
call ga_print(g_ptmp)
780
if (ga_nodeid().eq.0)
781
& write(*,*) '---- CC1^t--------- END'
782
if (ga_nodeid().eq.0)
783
& write(*,*) '---- C1C^t-------- START'
784
call ga_print(g_work)
785
if (ga_nodeid().eq.0)
786
& write(*,*) '---- C1C^t--------- END'
788
call ga_add(1d0,g_ptmp,1d0,g_work,g_work)
790
c if (ga_nodeid().eq.0)
791
c & write(*,*) '---- g_pmats-0-------- START'
792
c call ga_print(g_work)
793
c if (ga_nodeid().eq.0)
794
c & write(*,*) '---- g_pmats-0-------- END'
797
call ga_transpose(g_work, g_ptmp)
800
c calculate symmetrized and antisymmetrized part (+ component)
801
c if requested on input:
804
call ga_transpose(g_ptmp,g_work)
806
call ga_add(half,g_ptmp,half,g_work,g_pmats(1))
808
call ga_add(half,g_ptmp,-half,g_work,g_pmata(1))
811
call ga_copy(g_ptmp, g_pmats(1))
814
if (ga_nodeid().eq.0)
815
& write(*,*) '---- g_pmats-------- START'
816
call ga_print(g_pmats(1))
817
if (ga_nodeid().eq.0)
818
& write(*,*) '---- g_pmats-------- END'
819
if (ga_nodeid().eq.0)
820
& write(*,*) '---- g_pmata-------- START'
821
call ga_print(g_pmata(1))
822
if (ga_nodeid().eq.0)
823
& write(*,*) '---- g_pmata-------- END'
824
if (ga_nodeid().eq.0)
825
& write(*,*) 'FA-BEF-get_PertDens'
826
if (ga_nodeid().eq.0) then
827
write(*,1000) ip,im,lstatic,imag,
828
& haveocc,lantisym,ncomp,naos,nmo,nocc,nvir
829
1000 format('(ip,im,lstatic,imag,haveocc,lanti)=(',
830
& i2,',',i2,',',L1,',',L1,',',L1,',',L1,') ',
831
& ' (ncomp,naos,nmo,nocc,nvir)=(',
832
& i4,',',i4,',',i4,',',i4,',',i4,')')
836
& g_pmats(1),!out: symmetrized dens
837
& g_pmata(1),!out: anti symmetrized dens
838
& g_amat, ! in: the u mat
839
& g_vectors, ! in: MO vect
840
& ncomp, ! in: nr. components g_amat
841
& ip,im, ! in: indices of u vect
842
& imag, ! in: = T -> imag
843
& haveocc, ! in: logical flag
844
& lantisym, ! in: logical flag
845
& naos,nmo, ! in: nr. AOs,MOs
846
& nocc,nvir, ! in: nr. (occ,virt) MOs
847
& debug) ! in: =.true. -> show debug printouts
849
if (ga_nodeid().eq.0)
850
& write(*,*) '---- g_pmats-nw-------- START'
851
call ga_print(g_pmats(1))
852
if (ga_nodeid().eq.0)
853
& write(*,*) '---- g_pmats-nw-------- END'
854
if (ga_nodeid().eq.0)
855
& write(*,*) '---- g_pmata-nw-------- START'
856
call ga_print(g_pmata(1))
857
if (ga_nodeid().eq.0)
858
& write(*,*) '---- g_pmata-nw-------- END'
859
if (ga_nodeid().eq.0)
860
& write(*,*) 'FA-AFT-get_PertDens'
861
c ====> WARNING-- START
862
c -- Commenting lines below to enter 2nd part of calc
863
if (ga_nodeid().eq.0) write(*,*) 'SKIP lstatic-if'
864
c ====> WARNING-- END
865
c if (lstatic .or. ncomp.eq.1) then
866
c skip calculation of component 2 of the density matrix
867
c if (ga_nodeid().eq.0)
868
c & write(*,*) 'FA-Skipping calc of 2nd component'
873
if (ga_nodeid().eq.0)
874
& write(*,*) 'FA-Doing calc of 2nd component'
876
c -----------------------------------------
877
c Next step: assemble P(-). Same as before,
878
c but +/- interchanged in amat:
879
c -----------------------------------------
886
c ----------------------------
887
c First step: C n C(+,dagger)
888
c ----------------------------
890
c calculate C(+,dagger)
893
if (.not.haveocc) then
894
call ga_matmul_patch('n','n', two,0d0,
895
& g_vectors ,1,naos,nocc+1,nmo,
896
& g_amat(ip),1,nvir,1,nocc,
897
& g_eig1 ,1,naos,1,nocc)
899
call ga_matmul_patch('n','n', two,0d0,
900
& g_vectors ,1,naos,1,nmo,
901
& g_amat(ip),1,nmo,1,nocc,
902
& g_eig1 ,1,naos,1,nocc)
906
if (debug) write (6,*) '5'
908
c calculate C(0)C(+,dagger), store in g_ptmp
909
call ga_matmul_patch('n','t', 1d0,0d0,
910
& g_vectors,1,naos,1,nocc,
911
& g_eig1,1,nocc,1,naos,
912
& g_ptmp,1,naos,1,naos)
915
if (debug) write (6,*) '6'
917
c -----------------------------
918
c Second step: C(-) n C(dagger)
919
c -----------------------------
923
if (.not.haveocc) then
924
call ga_matmul_patch('n','n', two,0d0,
925
& g_vectors,1,naos,nocc+1,nmo,
926
& g_amat(im),1,nvir,1,nocc,
927
& g_eig1,1,naos,1,nocc)
929
call ga_matmul_patch('n','n', two,0d0,
930
& g_vectors,1,naos,1,nmo,
931
& g_amat(im),1,nmo,1,nocc,
932
& g_eig1,1,naos,1,nocc)
936
if (debug) write (6,*) '7'
938
c calculate C(-)C(0,dagger), store in g_work
939
call ga_matmul_patch('n','t', 1d0,0d0,
940
& g_eig1,1,naos,1,nocc,
941
& g_vectors,1,nocc,1,naos,
942
& g_work,1,naos,1,naos)
945
if (debug) write (6,*) '8'
947
c add the two terms together and transpose
948
call ga_add(1d0,g_ptmp,1d0,g_work,g_work)
950
call ga_transpose(g_work, g_ptmp)
953
c calculate symmetrized and antisymmetrized part (- component)
956
call ga_transpose(g_ptmp,g_work)
958
call ga_add(half,g_ptmp, half,g_work,g_pmats(2))
960
call ga_add(half,g_ptmp,-half,g_work,g_pmata(2))
963
call ga_copy(g_ptmp, g_pmats(2))
966
if (ga_nodeid().eq.0)
967
& write(*,*) '---- g_pmats-2-------- START'
968
call ga_print(g_pmats(2))
969
if (ga_nodeid().eq.0)
970
& write(*,*) '---- g_pmats-2-------- END'
971
if (ga_nodeid().eq.0)
972
& write(*,*) '---- g_pmata-2-------- START'
973
call ga_print(g_pmata(2))
974
if (ga_nodeid().eq.0)
975
& write(*,*) '---- g_pmata-2-------- END'
976
if (ga_nodeid().eq.0)
977
& write(*,*) 'FA-BEF-get_PertDens-2'
978
if (ga_nodeid().eq.0) then
979
write(*,1001) ip,im,lstatic,imag,
980
& haveocc,lantisym,ncomp,naos,nmo,nocc,nvir
981
1001 format('(ip,im,lstatic,imag,haveocc,lanti)=(',
982
& i2,',',i2,',',L1,',',L1,',',L1,',',L1,') ',
983
& ' (ncomp,naos,nmo,nocc,nvir)=(',
984
& i4,',',i4,',',i4,',',i4,',',i4,')')
988
& g_pmats(2),!out: symmetrized dens
989
& g_pmata(2),!out: anti symmetrized dens
990
& g_amat, ! in: the u mat
991
& g_vectors, ! in: MO vect
992
& ncomp, ! in: nr. components g_amat
993
& im,ip, ! in: indices of u vect
994
& imag, ! in: = T -> imag
995
& haveocc, ! in: logical flag
996
& lantisym, ! in: logical flag
997
& naos,nmo, ! in: nr. AOs,MOs
998
& nocc,nvir, ! in: nr. (occ,virt) MOs
999
& debug) ! in: =.true. -> show debug printouts
1001
if (ga_nodeid().eq.0)
1002
& write(*,*) '---- g_pmats-2-nw-------- START'
1003
call ga_print(g_pmats(2))
1004
if (ga_nodeid().eq.0)
1005
& write(*,*) '---- g_pmats-2-nw-------- END'
1006
if (ga_nodeid().eq.0)
1007
& write(*,*) '---- g_pmata-2-nw-------- START'
1008
call ga_print(g_pmata(2))
1009
if (ga_nodeid().eq.0)
1010
& write(*,*) '---- g_pmata-2-nw-------- END'
1011
if (ga_nodeid().eq.0)
1012
& write(*,*) 'FA-AFT-get_PertDens'
1016
c ---------------------------------------------
1017
c deallocate temporary arrays, sync, and return
1018
c ---------------------------------------------
1020
c jump here from above in case of static calculation
1023
if (ga_nodeid().eq.0)
1024
& write(*,*) 'FA-AFT-get_PertDens-did-not-enter-2'
1029
if (.not.ga_destroy(g_ptmp))
1031
& errquit('CalcPerturbedTDPmat: ga_destroy failed g_ptmp',
1034
if (.not.ga_destroy(g_work))
1036
& errquit('CalcPerturbedTDPmat: ga_destroy failed g_work',
1039
if (.not.ga_destroy(g_eig1))
1041
& errquit('CalcPerturbedTDPmat: ga_destroy failed g_eig1',
1046
c ==================================================================
1051
c ++++++++++++++++++ Added for debugging ++++++++++++++++ END