Skip to content

Commit c8162e4

Browse files
author
gitpeterwind
committed
bug fix dft energy printouts
1 parent 1e7ea8e commit c8162e4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/mrdft/MRDFT.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,18 @@ mrcpp::FunctionTreeVector<3> MRDFT::evaluate(mrcpp::FunctionTreeVector<3> &inp)
7878
int n_start = (mrcpp::mpi::wrk_rank * nNodes) / mrcpp::mpi::wrk_size;
7979
int n_end = ((mrcpp::mpi::wrk_rank + 1) * nNodes) / mrcpp::mpi::wrk_size;
8080
DoubleVector XCenergy = DoubleVector::Zero(1);
81+
double sum = 0.0;
8182
#pragma omp parallel
8283
{
83-
#pragma omp for schedule(guided)
84+
#pragma omp for schedule(guided) reduction (+: sum)
8485
for (int n = n_start; n < n_end; n++) {
8586
vector<mrcpp::FunctionNode<3> *> xcNodes = xc_utils::fetch_nodes(n, PotVec);
8687
functional().makepot(inp, xcNodes);
87-
XCenergy[0] += xcNodes[0]->integrate();
88+
sum += xcNodes[0]->integrate();
8889
}
8990
}
91+
XCenergy[0] = sum;
92+
9093
// each mpi only has part of the results. All send their results to bank and then fetch
9194
if(mrcpp::mpi::wrk_size > 1) {
9295
// sum up the energy contrbutions from all mpi

0 commit comments

Comments
 (0)