Skip to content

Instantly share code, notes, and snippets.

@edeprince3
Last active December 19, 2015 21:49
Show Gist options
  • Save edeprince3/6023223 to your computer and use it in GitHub Desktop.
Save edeprince3/6023223 to your computer and use it in GitHub Desktop.
Patch to fix small bug in FNO-DF-CCSD(T) where, when nso is much greater than the number of retained NO's, the code can hang while determining how many rows of a matrix to read from disk. This issue is fixed in the master branch, and I am attaching a patch here to fix issue in psi4.0b5. To apply the patch:
diff --git a/theoryfs2/ds/deprince/ccsd.cc b/src/bin/fnocc/ccsd.cc
index a66ec02..ef0e662 100644
--- a/theoryfs2/ds/deprince/ccsd.cc
+++ b/src/bin/fnocc/ccsd.cc
@@ -3015,7 +3015,6 @@ void DFCoupledCluster::T1Fock(){
nrows++;
rowsize = nQ_scf / nrows;
if (nrows * rowsize < nQ_scf) rowsize++;
- if (rowsize == 1) break;
}
long int lastrowsize = nQ_scf - (nrows - 1L) * rowsize;
long int * rowdims = new long int [nrows];
@@ -3075,7 +3074,6 @@ void DFCoupledCluster::T1Fock(){
nrows++;
rowsize = nQ_scf / nrows;
if (nrows * rowsize < nQ_scf) rowsize++;
- if (rowsize == 1) break;
}
lastrowsize = nQ_scf - (nrows - 1L) * rowsize;
rowdims = new long int [nrows];
@@ -3192,7 +3190,6 @@ void DFCoupledCluster::T1Integrals(){
nrows++;
rowsize = nQ / nrows;
if (nrows * rowsize < nQ) rowsize++;
- if (rowsize == 1) break;
}
long int lastrowsize = nQ - (nrows - 1L) * rowsize;
long int * rowdims = new long int [nrows];
@@ -3435,11 +3432,7 @@ void DFCoupledCluster::AllocateMemory() {
if (nQmax*v*v>dim) dim = nQmax*v*v;
if (nQmax*nso*nso>dim) dim = nQmax*nso*nso;
- long int tempvdim = o*o*v*v+o*v;
- if ( nQ * o * v > tempvdim) tempvdim = nQ * o * v;
- if ( nso * nso > tempvdim) tempvdim = nso * nso;
-
- double total_memory = dim+tempvdim+(o*(o+1)*v*(v+1)+o*v)+o*o*v*v+2.*o*v+2.*v*v;
+ double total_memory = dim+(o*o*v*v+o*v)+(o*(o+1)*v*(v+1)+o*v)+o*o*v*v+2.*o*v+2.*v*v;
long int max = nvirt*nvirt*nQmax > (nfzv+ndocc+nvirt)*ndocc*nQmax ? nvirt*nvirt*nQmax : (nfzv+ndocc+nvirt)*ndocc*nQmax;
double df_memory = nQ*(o*o+o*v)+max;
@@ -3497,6 +3490,8 @@ void DFCoupledCluster::AllocateMemory() {
integrals = (double*)malloc(dim*sizeof(double));
tempt = (double*)malloc((o*(o+1)*v*(v+1)+o*v)*sizeof(double));
+ long int tempvdim = o*o*v*v+o*v;
+ if ( nQ * o * v > tempvdim) tempvdim = nQ * o * v;
tempv = (double*)malloc(tempvdim*sizeof(double));
Abij = (double*)malloc(o*(o+1)/2*v*sizeof(double));
Sbij = (double*)malloc(o*(o+1)/2*v*sizeof(double));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment