-
Notifications
You must be signed in to change notification settings - Fork 1
/
hfx_libint_interface.F
1953 lines (1826 loc) · 76.4 KB
/
hfx_libint_interface.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Interface to the Libint-Library
!> \par History
!> 11.2006 created [Manuel Guidon]
!> 11.2019 Fixed potential_id initial values (A. Bussy)
!> \author Manuel Guidon
! **************************************************************************************************
MODULE hfx_libint_interface
USE cell_types, ONLY: cell_type,&
real_to_scaled
USE gamma, ONLY: fgamma => fgamma_0
USE hfx_contraction_methods, ONLY: contract
USE hfx_types, ONLY: hfx_pgf_product_list,&
hfx_potential_type
USE input_constants, ONLY: &
do_potential_coulomb, do_potential_gaussian, do_potential_id, do_potential_long, &
do_potential_mix_cl, do_potential_mix_cl_trunc, do_potential_mix_lg, do_potential_short, &
do_potential_truncated
USE kinds, ONLY: dp,&
int_8
USE libint_wrapper, ONLY: cp_libint_get_derivs,&
cp_libint_get_eris,&
cp_libint_set_params_eri,&
cp_libint_set_params_eri_deriv,&
cp_libint_set_params_eri_screen,&
cp_libint_t,&
get_ssss_f_val,&
prim_data_f_size
USE mathconstants, ONLY: pi
USE orbital_pointers, ONLY: nco
USE t_c_g0, ONLY: t_c_g0_n
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
PUBLIC :: evaluate_eri, &
evaluate_deriv_eri, &
evaluate_eri_screen
INTEGER, DIMENSION(12), PARAMETER :: full_perm1 = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm2 = (/4, 5, 6, 1, 2, 3, 7, 8, 9, 10, 11, 12/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm3 = (/1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm4 = (/4, 5, 6, 1, 2, 3, 10, 11, 12, 7, 8, 9/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm5 = (/7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm6 = (/7, 8, 9, 10, 11, 12, 4, 5, 6, 1, 2, 3/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm7 = (/10, 11, 12, 7, 8, 9, 1, 2, 3, 4, 5, 6/)
INTEGER, DIMENSION(12), PARAMETER :: full_perm8 = (/10, 11, 12, 7, 8, 9, 4, 5, 6, 1, 2, 3/)
!***
CONTAINS
! **************************************************************************************************
!> \brief Fill data structure used in libint
!> \param A ...
!> \param B ...
!> \param C ...
!> \param D ...
!> \param Zeta_A ...
!> \param Zeta_B ...
!> \param Zeta_C ...
!> \param Zeta_D ...
!> \param m_max ...
!> \param potential_parameter ...
!> \param libint ...
!> \param R11 ...
!> \param R22 ...
!> \par History
!> 03.2007 created [Manuel Guidon]
!> \author Manuel Guidon
! **************************************************************************************************
SUBROUTINE build_quartet_data_screen(A, B, C, D, Zeta_A, Zeta_B, Zeta_C, Zeta_D, m_max, &
potential_parameter, libint, R11, R22)
REAL(KIND=dp) :: A(3), B(3), C(3), D(3)
REAL(KIND=dp), INTENT(IN) :: Zeta_A, Zeta_B, Zeta_C, Zeta_D
INTEGER, INTENT(IN) :: m_max
TYPE(hfx_potential_type) :: potential_parameter
TYPE(cp_libint_t) :: libint
REAL(dp) :: R11, R22
INTEGER :: i
LOGICAL :: use_gamma
REAL(KIND=dp) :: AB(3), AB2, CD(3), CD2, den, Eta, EtaInv, factor, G(3), num, omega2, &
omega_corr, omega_corr2, P(3), PQ(3), PQ2, Q(3), R, R1, R2, Rho, RhoInv, S1234, ssss, T, &
tmp, W(3), Zeta, ZetaInv, ZetapEtaInv
REAL(KIND=dp), DIMENSION(prim_data_f_size) :: F, Fm
Zeta = Zeta_A + Zeta_B
ZetaInv = 1.0_dp/Zeta
Eta = Zeta_C + Zeta_D
EtaInv = 1.0_dp/Eta
ZetapEtaInv = Zeta + Eta
ZetapEtaInv = 1.0_dp/ZetapEtaInv
Rho = Zeta*Eta*ZetapEtaInv
RhoInv = 1.0_dp/Rho
DO i = 1, 3
P(i) = (Zeta_A*A(i) + Zeta_B*B(i))*ZetaInv
Q(i) = (Zeta_C*C(i) + Zeta_D*D(i))*EtaInv
AB(i) = A(i) - B(i)
CD(i) = C(i) - D(i)
PQ(i) = P(i) - Q(i)
W(i) = (Zeta*P(i) + Eta*Q(i))*ZetapEtaInv
END DO
AB2 = DOT_PRODUCT(AB, AB)
CD2 = DOT_PRODUCT(CD, CD)
PQ2 = DOT_PRODUCT(PQ, PQ)
S1234 = EXP((-Zeta_A*Zeta_B*ZetaInv*AB2) + (-Zeta_C*Zeta_D*EtaInv*CD2))
T = Rho*PQ2
SELECT CASE (potential_parameter%potential_type)
CASE (do_potential_truncated)
R = potential_parameter%cutoff_radius*SQRT(rho)
R1 = R11
R2 = R22
IF (PQ2 > (R1 + R2 + potential_parameter%cutoff_radius)**2) THEN
RETURN
END IF
CALL t_c_g0_n(F(1), use_gamma, R, T, m_max)
IF (use_gamma) CALL fgamma(m_max, T, F(1))
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_coulomb)
CALL fgamma(m_max, T, F(1))
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_short)
R = potential_parameter%cutoff_radius*SQRT(rho)
R1 = R11
R2 = R22
IF (PQ2 > (R1 + R2 + potential_parameter%cutoff_radius)**2) THEN
RETURN
END IF
CALL fgamma(m_max, T, F(1))
omega2 = potential_parameter%omega**2
omega_corr2 = omega2/(omega2 + Rho)
omega_corr = SQRT(omega_corr2)
T = T*omega_corr2
CALL fgamma(m_max, T, Fm)
tmp = -omega_corr
DO i = 1, m_max + 1
F(i) = F(i) + Fm(i)*tmp
tmp = tmp*omega_corr2
END DO
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_long)
omega2 = potential_parameter%omega**2
omega_corr2 = omega2/(omega2 + Rho)
omega_corr = SQRT(omega_corr2)
T = T*omega_corr2
CALL fgamma(m_max, T, F(1))
tmp = omega_corr
DO i = 1, m_max + 1
F(i) = F(i)*tmp
tmp = tmp*omega_corr2
END DO
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_mix_cl)
CALL fgamma(m_max, T, F(1))
omega2 = potential_parameter%omega**2
omega_corr2 = omega2/(omega2 + Rho)
omega_corr = SQRT(omega_corr2)
T = T*omega_corr2
CALL fgamma(m_max, T, Fm)
tmp = omega_corr
DO i = 1, m_max + 1
F(i) = F(i)*potential_parameter%scale_coulomb + Fm(i)*tmp*potential_parameter%scale_longrange
tmp = tmp*omega_corr2
END DO
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_mix_cl_trunc)
! truncated
R = potential_parameter%cutoff_radius*SQRT(rho)
R1 = R11
R2 = R22
IF (PQ2 > (R1 + R2 + potential_parameter%cutoff_radius)**2) THEN
RETURN
END IF
CALL t_c_g0_n(F(1), use_gamma, R, T, m_max)
IF (use_gamma) CALL fgamma(m_max, T, F(1))
! Coulomb
CALL fgamma(m_max, T, Fm)
DO i = 1, m_max + 1
F(i) = F(i)*(potential_parameter%scale_coulomb + potential_parameter%scale_longrange) - &
Fm(i)*potential_parameter%scale_longrange
END DO
! longrange
omega2 = potential_parameter%omega**2
omega_corr2 = omega2/(omega2 + Rho)
omega_corr = SQRT(omega_corr2)
T = T*omega_corr2
CALL fgamma(m_max, T, Fm)
tmp = omega_corr
DO i = 1, m_max + 1
F(i) = F(i) + Fm(i)*tmp*potential_parameter%scale_longrange
tmp = tmp*omega_corr2
END DO
factor = 2.0_dp*Pi*RhoInv
CASE (do_potential_gaussian)
omega2 = potential_parameter%omega**2
T = -omega2*T/(Rho + omega2)
tmp = 1.0_dp
DO i = 1, m_max + 1
F(i) = EXP(T)*tmp
tmp = tmp*omega2/(Rho + omega2)
END DO
factor = (Pi/(Rho + omega2))**(1.5_dp)
CASE (do_potential_mix_lg)
omega2 = potential_parameter%omega**2
omega_corr2 = omega2/(omega2 + Rho)
omega_corr = SQRT(omega_corr2)
T = T*omega_corr2
CALL fgamma(m_max, T, Fm)
tmp = omega_corr*2.0_dp*Pi*RhoInv*potential_parameter%scale_longrange
DO i = 1, m_max + 1
Fm(i) = Fm(i)*tmp
tmp = tmp*omega_corr2
END DO
T = Rho*PQ2
T = -omega2*T/(Rho + omega2)
tmp = (Pi/(Rho + omega2))**(1.5_dp)*potential_parameter%scale_gaussian
DO i = 1, m_max + 1
F(i) = EXP(T)*tmp + Fm(i)
tmp = tmp*omega2/(Rho + omega2)
END DO
factor = 1.0_dp
CASE (do_potential_id)
ssss = -Zeta_A*Zeta_B*ZetaInv*AB2
num = (Zeta_A + Zeta_B)*Zeta_C
den = Zeta_A + Zeta_B + Zeta_C
ssss = ssss - num/den*SUM((P - C)**2)
G(:) = (Zeta_A*A(:) + Zeta_B*B(:) + Zeta_C*C(:))/den
num = den*Zeta_D
den = den + Zeta_D
ssss = ssss - num/den*SUM((G - D)**2)
F(:) = EXP(ssss)
factor = 1.0_dp
IF (S1234 > EPSILON(0.0_dp)) factor = 1.0_dp/S1234
END SELECT
tmp = (Pi*ZetapEtaInv)**3
factor = factor*S1234*SQRT(tmp)
DO i = 1, m_max + 1
F(i) = F(i)*factor
END DO
CALL cp_libint_set_params_eri_screen(libint, A, B, C, D, P, Q, W, ZetaInv, EtaInv, ZetapEtaInv, Rho, m_max, F)
END SUBROUTINE build_quartet_data_screen
! **************************************************************************************************
!> \brief Fill data structure used in libderiv
!> \param libint ...
!> \param A ...
!> \param B ...
!> \param C ...
!> \param D ...
!> \param Zeta_A ...
!> \param Zeta_B ...
!> \param Zeta_C ...
!> \param Zeta_D ...
!> \param ZetaInv ...
!> \param EtaInv ...
!> \param ZetapEtaInv ...
!> \param Rho ...
!> \param RhoInv ...
!> \param P ...
!> \param Q ...
!> \param W ...
!> \param m_max ...
!> \param F ...
!> \par History
!> 03.2007 created [Manuel Guidon]
!> \author Manuel Guidon
! **************************************************************************************************
SUBROUTINE build_deriv_data(libint, A, B, C, D, &
Zeta_A, Zeta_B, Zeta_C, Zeta_D, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, RhoInv, &
P, Q, W, m_max, F)
TYPE(cp_libint_t) :: libint
REAL(KIND=dp), INTENT(IN) :: A(3), B(3), C(3), D(3)
REAL(dp), INTENT(IN) :: Zeta_A, Zeta_B, Zeta_C, Zeta_D, ZetaInv, &
EtaInv, ZetapEtaInv, Rho, RhoInv, &
P(3), Q(3), W(3)
INTEGER, INTENT(IN) :: m_max
REAL(KIND=dp), DIMENSION(:) :: F
MARK_USED(D) ! todo: fix
MARK_USED(Zeta_C)
MARK_USED(RhoInv)
CALL cp_libint_set_params_eri_deriv(libint, A, B, C, D, P, Q, W, zeta_A, zeta_B, zeta_C, zeta_D, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, m_max, F)
END SUBROUTINE build_deriv_data
! **************************************************************************************************
!> \brief Evaluates derivatives of electron repulsion integrals for a primitive quartet
!> \param deriv ...
!> \param nproducts ...
!> \param pgf_product_list ...
!> \param n_a ...
!> \param n_b ...
!> \param n_c ...
!> \param n_d ...
!> \param ncoa ...
!> \param ncob ...
!> \param ncoc ...
!> \param ncod ...
!> \param nsgfa ...
!> \param nsgfb ...
!> \param nsgfc ...
!> \param nsgfd ...
!> \param primitives ...
!> \param max_contraction ...
!> \param tmp_max_all ...
!> \param eps_schwarz ...
!> \param neris ...
!> \param Zeta_A ...
!> \param Zeta_B ...
!> \param Zeta_C ...
!> \param Zeta_D ...
!> \param ZetaInv ...
!> \param EtaInv ...
!> \param s_offset_a ...
!> \param s_offset_b ...
!> \param s_offset_c ...
!> \param s_offset_d ...
!> \param nl_a ...
!> \param nl_b ...
!> \param nl_c ...
!> \param nl_d ...
!> \param nsoa ...
!> \param nsob ...
!> \param nsoc ...
!> \param nsod ...
!> \param sphi_a ...
!> \param sphi_b ...
!> \param sphi_c ...
!> \param sphi_d ...
!> \param work ...
!> \param work2 ...
!> \param work_forces ...
!> \param buffer1 ...
!> \param buffer2 ...
!> \param primitives_tmp ...
!> \param use_virial ...
!> \param work_virial ...
!> \param work2_virial ...
!> \param primitives_tmp_virial ...
!> \param primitives_virial ...
!> \param cell ...
!> \param tmp_max_all_virial ...
!> \par History
!> 03.2007 created [Manuel Guidon]
!> 08.2007 refactured permutation part [Manuel Guidon]
!> \author Manuel Guidon
! **************************************************************************************************
SUBROUTINE evaluate_deriv_eri(deriv, nproducts, pgf_product_list, &
n_a, n_b, n_c, n_d, &
ncoa, ncob, ncoc, ncod, &
nsgfa, nsgfb, nsgfc, nsgfd, &
primitives, max_contraction, tmp_max_all, &
eps_schwarz, neris, &
Zeta_A, Zeta_B, Zeta_C, Zeta_D, ZetaInv, EtaInv, &
s_offset_a, s_offset_b, s_offset_c, s_offset_d, &
nl_a, nl_b, nl_c, nl_d, nsoa, nsob, nsoc, nsod, &
sphi_a, sphi_b, sphi_c, sphi_d, &
work, work2, work_forces, buffer1, buffer2, primitives_tmp, &
use_virial, work_virial, work2_virial, primitives_tmp_virial, &
primitives_virial, cell, tmp_max_all_virial)
TYPE(cp_libint_t) :: deriv
INTEGER, INTENT(IN) :: nproducts
TYPE(hfx_pgf_product_list), DIMENSION(nproducts) :: pgf_product_list
INTEGER, INTENT(IN) :: n_a, n_b, n_c, n_d, ncoa, ncob, ncoc, &
ncod, nsgfa, nsgfb, nsgfc, nsgfd
REAL(dp), &
DIMENSION(nsgfa, nsgfb, nsgfc, nsgfd, 12) :: primitives
REAL(dp) :: max_contraction, tmp_max_all, eps_schwarz
INTEGER(int_8) :: neris
REAL(dp), INTENT(IN) :: Zeta_A, Zeta_B, Zeta_C, Zeta_D, ZetaInv, &
EtaInv
INTEGER :: s_offset_a, s_offset_b, s_offset_c, &
s_offset_d, nl_a, nl_b, nl_c, nl_d, &
nsoa, nsob, nsoc, nsod
REAL(dp), DIMENSION(ncoa, nsoa*nl_a) :: sphi_a
REAL(dp), DIMENSION(ncob, nsob*nl_b) :: sphi_b
REAL(dp), DIMENSION(ncoc, nsoc*nl_c) :: sphi_c
REAL(dp), DIMENSION(ncod, nsod*nl_d) :: sphi_d
REAL(dp) :: work(ncoa*ncob*ncoc*ncod, 12), work2(ncoa, ncob, ncoc, ncod, 12), &
work_forces(ncoa*ncob*ncoc*ncod, 12)
REAL(dp), DIMENSION(ncoa*ncob*ncoc*ncod) :: buffer1, buffer2
REAL(dp), DIMENSION(nsoa*nl_a, nsob*nl_b, nsoc*&
nl_c, nsod*nl_d) :: primitives_tmp
LOGICAL, INTENT(IN) :: use_virial
REAL(dp) :: work_virial(ncoa*ncob*ncoc*ncod, 12, 3), &
work2_virial(ncoa, ncob, ncoc, ncod, 12, 3)
REAL(dp), DIMENSION(nsoa*nl_a, nsob*nl_b, nsoc*&
nl_c, nsod*nl_d) :: primitives_tmp_virial
REAL(dp), &
DIMENSION(nsgfa, nsgfb, nsgfc, nsgfd, 12, 3) :: primitives_virial
TYPE(cell_type), POINTER :: cell
REAL(dp) :: tmp_max_all_virial
INTEGER :: a_mysize(1), i, j, k, l, m, m_max, &
mysize, n, p1, p2, p3, p4, perm_case
REAL(dp) :: A(3), AB(3), B(3), C(3), CD(3), D(3), &
P(3), Q(3), Rho, RhoInv, scoord(12), &
tmp_max, tmp_max_virial, W(3), &
ZetapEtaInv
m_max = n_a + n_b + n_c + n_d
m_max = m_max + 1
mysize = ncoa*ncob*ncoc*ncod
a_mysize = mysize
work = 0.0_dp
work2 = 0.0_dp
IF (use_virial) THEN
work_virial = 0.0_dp
work2_virial = 0.0_dp
END IF
perm_case = 1
IF (n_a < n_b) THEN
perm_case = perm_case + 1
END IF
IF (n_c < n_d) THEN
perm_case = perm_case + 2
END IF
IF (n_a + n_b > n_c + n_d) THEN
perm_case = perm_case + 4
END IF
SELECT CASE (perm_case)
CASE (1)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, A, B, C, D, &
Zeta_A, Zeta_B, Zeta_C, Zeta_D, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, RhoInv, &
P, Q, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_d, n_c, n_b, n_a, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), A, cell)
CALL real_to_scaled(scoord(4:6), B, cell)
CALL real_to_scaled(scoord(7:9), C, cell)
CALL real_to_scaled(scoord(10:12), D, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO i = 1, ncoa
p1 = (i - 1)*ncob
DO j = 1, ncob
p2 = (p1 + j - 1)*ncoc
DO k = 1, ncoc
p3 = (p2 + k - 1)*ncod
DO l = 1, ncod
p4 = p3 + l
work2(i, j, k, l, full_perm1(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN
DO n = 1, 12
tmp_max_virial = 0.0_dp
DO i = 1, mysize
tmp_max_virial = MAX(tmp_max_virial, &
ABS(work_virial(i, n, 1)), ABS(work_virial(i, n, 2)), ABS(work_virial(i, n, 3)))
END DO
tmp_max_virial = tmp_max_virial*max_contraction
tmp_max_all_virial = MAX(tmp_max_all_virial, tmp_max_virial)
DO i = 1, ncoa
p1 = (i - 1)*ncob
DO j = 1, ncob
p2 = (p1 + j - 1)*ncoc
DO k = 1, ncoc
p3 = (p2 + k - 1)*ncod
DO l = 1, ncod
p4 = p3 + l
work2_virial(i, j, k, l, full_perm1(n), 1:3) = work_virial(p4, n, 1:3)
END DO
END DO
END DO
END DO
END DO
END IF
CASE (2)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, B, A, C, D, &
Zeta_B, Zeta_A, Zeta_C, Zeta_D, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, RhoInv, &
P, Q, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_d, n_c, n_a, n_b, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), B, cell)
CALL real_to_scaled(scoord(4:6), A, cell)
CALL real_to_scaled(scoord(7:9), C, cell)
CALL real_to_scaled(scoord(10:12), D, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO j = 1, ncob
p1 = (j - 1)*ncoa
DO i = 1, ncoa
p2 = (p1 + i - 1)*ncoc
DO k = 1, ncoc
p3 = (p2 + k - 1)*ncod
DO l = 1, ncod
p4 = p3 + l
work2(i, j, k, l, full_perm2(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN
DO n = 1, 12
tmp_max_virial = 0.0_dp
DO i = 1, mysize
tmp_max_virial = MAX(tmp_max_virial, &
ABS(work_virial(i, n, 1)), ABS(work_virial(i, n, 2)), ABS(work_virial(i, n, 3)))
END DO
tmp_max_virial = tmp_max_virial*max_contraction
tmp_max_all_virial = MAX(tmp_max_all_virial, tmp_max_virial)
DO j = 1, ncob
p1 = (j - 1)*ncoa
DO i = 1, ncoa
p2 = (p1 + i - 1)*ncoc
DO k = 1, ncoc
p3 = (p2 + k - 1)*ncod
DO l = 1, ncod
p4 = p3 + l
work2_virial(i, j, k, l, full_perm2(n), 1:3) = work_virial(p4, n, 1:3)
END DO
END DO
END DO
END DO
END DO
END IF
CASE (3)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, A, B, D, C, &
Zeta_A, Zeta_B, Zeta_D, Zeta_C, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, RhoInv, &
P, Q, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_c, n_d, n_b, n_a, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), A, cell)
CALL real_to_scaled(scoord(4:6), B, cell)
CALL real_to_scaled(scoord(7:9), D, cell)
CALL real_to_scaled(scoord(10:12), C, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO i = 1, ncoa
p1 = (i - 1)*ncob
DO j = 1, ncob
p2 = (p1 + j - 1)*ncod
DO l = 1, ncod
p3 = (p2 + l - 1)*ncoc
DO k = 1, ncoc
p4 = p3 + k
work2(i, j, k, l, full_perm3(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN
DO n = 1, 12
tmp_max_virial = 0.0_dp
DO i = 1, mysize
tmp_max_virial = MAX(tmp_max_virial, &
ABS(work_virial(i, n, 1)), ABS(work_virial(i, n, 2)), ABS(work_virial(i, n, 3)))
END DO
tmp_max_virial = tmp_max_virial*max_contraction
tmp_max_all_virial = MAX(tmp_max_all_virial, tmp_max_virial)
DO i = 1, ncoa
p1 = (i - 1)*ncob
DO j = 1, ncob
p2 = (p1 + j - 1)*ncod
DO l = 1, ncod
p3 = (p2 + l - 1)*ncoc
DO k = 1, ncoc
p4 = p3 + k
work2_virial(i, j, k, l, full_perm3(n), 1:3) = work_virial(p4, n, 1:3)
END DO
END DO
END DO
END DO
END DO
END IF
CASE (4)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, B, A, D, C, &
Zeta_B, Zeta_A, Zeta_D, Zeta_C, &
ZetaInv, EtaInv, ZetapEtaInv, Rho, RhoInv, &
P, Q, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_c, n_d, n_a, n_b, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), B, cell)
CALL real_to_scaled(scoord(4:6), A, cell)
CALL real_to_scaled(scoord(7:9), D, cell)
CALL real_to_scaled(scoord(10:12), C, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO j = 1, ncob
p1 = (j - 1)*ncoa
DO i = 1, ncoa
p2 = (p1 + i - 1)*ncod
DO l = 1, ncod
p3 = (p2 + l - 1)*ncoc
DO k = 1, ncoc
p4 = p3 + k
work2(i, j, k, l, full_perm4(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN
DO n = 1, 12
tmp_max_virial = 0.0_dp
DO i = 1, mysize
tmp_max_virial = MAX(tmp_max_virial, &
ABS(work_virial(i, n, 1)), ABS(work_virial(i, n, 2)), ABS(work_virial(i, n, 3)))
END DO
tmp_max_virial = tmp_max_virial*max_contraction
tmp_max_all_virial = MAX(tmp_max_all_virial, tmp_max_virial)
DO j = 1, ncob
p1 = (j - 1)*ncoa
DO i = 1, ncoa
p2 = (p1 + i - 1)*ncod
DO l = 1, ncod
p3 = (p2 + l - 1)*ncoc
DO k = 1, ncoc
p4 = p3 + k
work2_virial(i, j, k, l, full_perm4(n), 1:3) = work_virial(p4, n, 1:3)
END DO
END DO
END DO
END DO
END DO
END IF
CASE (5)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, C, D, A, B, &
Zeta_C, Zeta_D, Zeta_A, Zeta_B, &
EtaInv, ZetaInv, ZetapEtaInv, Rho, RhoInv, &
Q, P, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_b, n_a, n_d, n_c, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), C, cell)
CALL real_to_scaled(scoord(4:6), D, cell)
CALL real_to_scaled(scoord(7:9), A, cell)
CALL real_to_scaled(scoord(10:12), B, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO k = 1, ncoc
p1 = (k - 1)*ncod
DO l = 1, ncod
p2 = (p1 + l - 1)*ncoa
DO i = 1, ncoa
p3 = (p2 + i - 1)*ncob
DO j = 1, ncob
p4 = p3 + j
work2(i, j, k, l, full_perm5(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN
DO n = 1, 12
tmp_max_virial = 0.0_dp
DO i = 1, mysize
tmp_max_virial = MAX(tmp_max_virial, &
ABS(work_virial(i, n, 1)), ABS(work_virial(i, n, 2)), ABS(work_virial(i, n, 3)))
END DO
tmp_max_virial = tmp_max_virial*max_contraction
tmp_max_all_virial = MAX(tmp_max_all_virial, tmp_max_virial)
DO k = 1, ncoc
p1 = (k - 1)*ncod
DO l = 1, ncod
p2 = (p1 + l - 1)*ncoa
DO i = 1, ncoa
p3 = (p2 + i - 1)*ncob
DO j = 1, ncob
p4 = p3 + j
work2_virial(i, j, k, l, full_perm5(n), 1:3) = work_virial(p4, n, 1:3)
END DO
END DO
END DO
END DO
END DO
END IF
CASE (6)
DO i = 1, nproducts
A = pgf_product_list(i)%ra
B = pgf_product_list(i)%rb
C = pgf_product_list(i)%rc
D = pgf_product_list(i)%rd
Rho = pgf_product_list(i)%Rho
RhoInv = pgf_product_list(i)%RhoInv
P = pgf_product_list(i)%P
Q = pgf_product_list(i)%Q
W = pgf_product_list(i)%W
AB = pgf_product_list(i)%AB
CD = pgf_product_list(i)%CD
ZetapEtaInv = pgf_product_list(i)%ZetapEtaInv
CALL build_deriv_data(deriv, C, D, B, A, &
Zeta_C, Zeta_D, Zeta_B, Zeta_A, &
EtaInv, ZetaInv, ZetapEtaInv, Rho, RhoInv, &
Q, P, W, m_max, pgf_product_list(i)%Fm)
CALL cp_libint_get_derivs(n_a, n_b, n_d, n_c, deriv, work_forces, a_mysize)
DO k = 4, 6
DO j = 1, mysize
work_forces(j, k) = -1.0_dp*(work_forces(j, k - 3) + &
work_forces(j, k + 3) + &
work_forces(j, k + 6))
END DO
END DO
DO k = 1, 12
DO j = 1, mysize
work(j, k) = work(j, k) + work_forces(j, k)
END DO
END DO
neris = neris + 12*mysize
IF (use_virial) THEN
CALL real_to_scaled(scoord(1:3), C, cell)
CALL real_to_scaled(scoord(4:6), D, cell)
CALL real_to_scaled(scoord(7:9), B, cell)
CALL real_to_scaled(scoord(10:12), A, cell)
DO k = 1, 12
DO j = 1, mysize
DO m = 1, 3
work_virial(j, k, m) = work_virial(j, k, m) + work_forces(j, k)*scoord(INT((k - 1)/3)*3 + m)
END DO
END DO
END DO
END IF
END DO
DO n = 1, 12
tmp_max = 0.0_dp
DO i = 1, mysize
tmp_max = MAX(tmp_max, ABS(work(i, n)))
END DO
tmp_max = tmp_max*max_contraction
tmp_max_all = MAX(tmp_max_all, tmp_max)
DO k = 1, ncoc
p1 = (k - 1)*ncod
DO l = 1, ncod
p2 = (p1 + l - 1)*ncob
DO j = 1, ncob
p3 = (p2 + j - 1)*ncoa
DO i = 1, ncoa
p4 = p3 + i
work2(i, j, k, l, full_perm6(n)) = work(p4, n)
END DO
END DO
END DO
END DO
END DO
IF (use_virial) THEN