allocate memory for work

This commit is contained in:
exapde
2024-05-21 22:39:27 -04:00
parent ac561095b1
commit 5d6db7e434
3 changed files with 6 additions and 12 deletions

View File

@ -2272,6 +2272,7 @@ void EAPOD::eigenvaluedecomposition(double *Phi, double *Lambda, int N)
double *S = (double *) malloc(N*ns*sizeof(double));
double *Q = (double *) malloc(N*ns*sizeof(double));
double *A = (double *) malloc(ns*ns*sizeof(double));
double *work = (double *) malloc(ns*ns*sizeof(double));
double *b = (double *) malloc(ns*sizeof(double));
// Generate the xij array
@ -2294,7 +2295,7 @@ void EAPOD::eigenvaluedecomposition(double *Phi, double *Lambda, int N)
// Compute the eigenvectors and eigenvalues of A
int lwork = ns * ns; // the length of the array work, lwork >= max(1,3*N-1)
int info = 1; // = 0: successful exit
double work[ns*ns];
//double work[ns*ns];
char chv = 'V';
char chu = 'U';
DSYEV(&chv, &chu, &ns, A, &ns, b, work, &lwork, &info);
@ -2331,7 +2332,7 @@ void EAPOD::eigenvaluedecomposition(double *Phi, double *Lambda, int N)
}
// Free temporary arrays
free(xij); free(S); free(A); free(b); free(Q);
free(xij); free(S); free(A); free(work); free(b); free(Q);
}
/**

View File

@ -1301,6 +1301,7 @@ void FitPOD::environment_cluster_calculation(const datastruct &data)
double *basedescmatrix = (double *) malloc(nAtoms*Mdesc*sizeof(double));
double *pca = (double *) malloc(nAtoms*nComponents*sizeof(double));
double *A = (double *) malloc(Mdesc*Mdesc*sizeof(double));
double *work = (double *) malloc(Mdesc*Mdesc*sizeof(double));
double *b = (double *) malloc(Mdesc*sizeof(double));
double *Lambda = (double *) malloc(Mdesc*nelements*sizeof(double));
int *clusterSizes = (int *) malloc(nClusters*nelements*sizeof(int));
@ -1334,12 +1335,6 @@ void FitPOD::environment_cluster_calculation(const datastruct &data)
nElemAtomsCount[elem] = 0;
}
// //std::cout<<nElemAtoms[0]<<" "<<nElemAtoms[1]<<std::endl;
// //std::cout<<nElemAtomsCount[0]<<" "<<nElemAtomsCount[1]<<" "<<nElemAtomsCount[2]<<std::endl;
// printf("%d %d %d\n",comm->me, nElemAtoms[0], nElemAtoms[1]);
// printf("%d %d %d\n",comm->me, nElemAtomsCount[0], nElemAtomsCount[1]);
// printf("%d %d %d %d\n",comm->me, nElemAtomsCumSum[0], nElemAtomsCumSum[1], nElemAtomsCumSum[2]);
MPI_Barrier(MPI_COMM_WORLD);
// loop over each configuration in the data set
@ -1412,7 +1407,6 @@ void FitPOD::environment_cluster_calculation(const datastruct &data)
// Calculate eigenvalues and eigenvectors of A
int lwork = Mdesc * Mdesc; // the length of the array work, lwork >= max(1,3*N-1)
int info = 1; // = 0: successful exit
double work[lwork];
DSYEV(&chv, &chu, &Mdesc, A, &Mdesc, b, work, &lwork, &info);
@ -1454,8 +1448,6 @@ void FitPOD::environment_cluster_calculation(const datastruct &data)
savematrix2binfile(data.filenametag + "_pca_matrix_elem" + std::to_string(elem+1) + "_proc" + std::to_string(comm->me+1) + ".bin", pca, nComponents, nAtoms);
saveintmatrix2binfile(data.filenametag + "_cluster_assignments_elem" + std::to_string(elem+1) + "_proc" + std::to_string(comm->me+1) + ".bin", assignments, nAtoms, 1);
}
//savematrix2binfile(data.filenametag + "_pca_matrix_elem" + std::to_string(elem+1) + "_proc" + std::to_string(comm->me+1) + ".bin", pca, nComponents, nAtoms);
//saveintmatrix2binfile(data.filenametag + "_cluster_assignments_elem" + std::to_string(elem+1) + "_proc" + std::to_string(comm->me+1) + ".bin", assignments, nAtoms, 1);
MPI_Barrier(MPI_COMM_WORLD);
}
@ -1468,6 +1460,7 @@ void FitPOD::environment_cluster_calculation(const datastruct &data)
free(basedescmatrix);
free(pca);
free(A);
free(work);
free(b);
free(clusterSizes);
free(Lambda);

View File

@ -981,7 +981,7 @@ void PairPOD::radialangularsum2(int Ni, int Nij)
int start = numij[i];
int nj = numij[i+1]-start;
double sum[nelements];
double sum[100];
for (int j=0; j<nj; j++) {
int n = start + j;
int ia = k + K3 * n;