From 714a0bc76cd216853c6972721ee1f830cd0d7fde Mon Sep 17 00:00:00 2001 From: Emiliano Deustua Date: Sun, 31 Jul 2022 17:32:19 -0500 Subject: [PATCH 1/3] Fix array dimension types --- src/Cal_D3.f | 2 +- src/cct3.cc | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Cal_D3.f b/src/Cal_D3.f index e35caf7..d7751ad 100644 --- a/src/Cal_D3.f +++ b/src/Cal_D3.f @@ -84,4 +84,4 @@ subroutine Cal_D3(N0,N1,N2,N3, D3D2(b,a,i)=-PP enddo;enddo;enddo C - end + end subroutine diff --git a/src/cct3.cc b/src/cct3.cc index d9fecfa..5bea3b0 100644 --- a/src/cct3.cc +++ b/src/cct3.cc @@ -47,7 +47,8 @@ #include "fortran.h" #include - +#include +#include // This allows us to be lazy in getting the spaces in DPD calls #define ID(x) ints.DPD_ID(x) @@ -229,9 +230,6 @@ SharedWavefunction cct3(SharedWavefunction ref_wfn, Options& options) double corl_e_sec = 0.0; std::array dipole_field = {0.0, 0.0, 0.0}; - // Aux vars - int i; - // Integrals for CC double *onebody = NULL; double *twobody = NULL; @@ -300,10 +298,10 @@ SharedWavefunction cct3(SharedWavefunction ref_wfn, Options& options) int docc = doccpi.sum(); int norbs = norb.sum(); - //std::cout << nalpha << " " << nbeta << "\n"; - //std::cout << socc << " " << docc << " " << norbs << "\n"; + std::size_t onebody_dim = std::pow(norbs, 2); + std::size_t twobody_dim = std::pow(norbs, 4); + - //exit(1); if (froz > docc) { throw PSIEXCEPTION("Number of frozen orbitals is too large!"); } @@ -314,22 +312,22 @@ SharedWavefunction cct3(SharedWavefunction ref_wfn, Options& options) // Initialize integral arrays for Fortran - onebody = new double[norbs*norbs]; - twobody = new double[norbs*norbs*norbs*norbs]; + onebody = new double[onebody_dim]; + twobody = new double[twobody_dim]; sp_eigv = new double[norbs]; sp_ord = new int[norbs]; sp_ord_inv = new int[norbs]; - for (i = 0; i < norbs; i++) { + for (std::size_t i = 0; i < norbs; i++) { sp_eigv[i] = 0; sp_ord[i] = 0; sp_ord_inv[i] = 0; } - for (i = 0; i < norbs*norbs; i++) { + for (std::size_t i = 0; i < onebody_dim; i++) { onebody[i] = 0.0; } - for (i = 0; i < norbs*norbs*norbs*norbs; i++) { + for (std::size_t i = 0; i < twobody_dim; i++) { twobody[i] = 0.0; } From f9c36fe49553d28a1a37f689d8f60ae23b47555a Mon Sep 17 00:00:00 2001 From: Emiliano Deustua Date: Sun, 31 Jul 2022 17:58:32 -0500 Subject: [PATCH 2/3] Fix array creation --- src/cct3.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cct3.cc b/src/cct3.cc index 5bea3b0..a8fb01a 100644 --- a/src/cct3.cc +++ b/src/cct3.cc @@ -98,8 +98,8 @@ void create_oei(int* sp_ord_inv, SharedMatrix moH, double* onebody, double ints_ // Walk through moH and save the non-zero values double tmp_e; int offset = 0; - int i = 0; - int a = 0; + std::size_t i = 0; + std::size_t a = 0; for (int h=0; hnirrep(); ++h) { for (int m=0; mrowdim(h); ++m) { for (int n=0; n<=m; ++n) { @@ -119,12 +119,12 @@ void create_oei(int* sp_ord_inv, SharedMatrix moH, double* onebody, double ints_ } } -void create_tei(int* sp_ord, int nirrep, dpdbuf4& K, double* twobody, double ints_tolerance, int norb) +void create_tei(int* sp_ord, int nirrep, dpdbuf4& K, double* twobody, double ints_tolerance, std::size_t norb) { - int a = 0; - int b = 0; - int i = 0; - int j = 0; + std::size_t a = 0; + std::size_t b = 0; + std::size_t i = 0; + std::size_t j = 0; double tmp_e; for(int h = 0; h < nirrep; ++h){ @@ -357,7 +357,7 @@ SharedWavefunction cct3(SharedWavefunction ref_wfn, Options& options) 0, "MO Ints (AA|AA)"); // Create two electron integral array and sort - create_tei(sp_ord_inv, nirrep, K, twobody, ints_tol, norbs); + create_tei(sp_ord_inv, nirrep, K, twobody, ints_tol, std::static_cast(norbs)); global_dpd_->buf4_close(&K); From 13b51273f4d784bf53ec7dcee7110f95654509ca Mon Sep 17 00:00:00 2001 From: Emiliano Deustua Date: Sun, 31 Jul 2022 18:00:07 -0500 Subject: [PATCH 3/3] Remove std in static_cast --- src/cct3.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cct3.cc b/src/cct3.cc index a8fb01a..79e6f67 100644 --- a/src/cct3.cc +++ b/src/cct3.cc @@ -357,7 +357,7 @@ SharedWavefunction cct3(SharedWavefunction ref_wfn, Options& options) 0, "MO Ints (AA|AA)"); // Create two electron integral array and sort - create_tei(sp_ord_inv, nirrep, K, twobody, ints_tol, std::static_cast(norbs)); + create_tei(sp_ord_inv, nirrep, K, twobody, ints_tol, static_cast(norbs)); global_dpd_->buf4_close(&K);