From 2c6e177d5c55e640deef3bdf451b46380fdf0049 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 22 Jul 2017 23:14:17 -0400 Subject: [PATCH] avoid reporting negative memory allocation when memory_usage() is called before initialized --- src/USER-TALLY/compute_force_tally.cpp | 2 +- src/USER-TALLY/compute_heat_flux_tally.cpp | 2 +- src/USER-TALLY/compute_pe_tally.cpp | 2 +- src/USER-TALLY/compute_stress_tally.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/USER-TALLY/compute_force_tally.cpp b/src/USER-TALLY/compute_force_tally.cpp index cb7e3a4f23..5f29aea5b2 100644 --- a/src/USER-TALLY/compute_force_tally.cpp +++ b/src/USER-TALLY/compute_force_tally.cpp @@ -215,7 +215,7 @@ void ComputeForceTally::compute_peratom() double ComputeForceTally::memory_usage() { - double bytes = nmax*size_peratom_cols * sizeof(double); + double bytes = (nmax < 0) ? 0 : nmax*size_peratom_cols * sizeof(double); return bytes; } diff --git a/src/USER-TALLY/compute_heat_flux_tally.cpp b/src/USER-TALLY/compute_heat_flux_tally.cpp index b366b92be3..c090050b15 100644 --- a/src/USER-TALLY/compute_heat_flux_tally.cpp +++ b/src/USER-TALLY/compute_heat_flux_tally.cpp @@ -275,7 +275,7 @@ void ComputeHeatFluxTally::compute_vector() double ComputeHeatFluxTally::memory_usage() { - double bytes = nmax*comm_reverse * sizeof(double); + double bytes = (nmax < 0) ? 0 : nmax*comm_reverse * sizeof(double); return bytes; } diff --git a/src/USER-TALLY/compute_pe_tally.cpp b/src/USER-TALLY/compute_pe_tally.cpp index e7c0bdd03c..5b4644d4e1 100644 --- a/src/USER-TALLY/compute_pe_tally.cpp +++ b/src/USER-TALLY/compute_pe_tally.cpp @@ -199,7 +199,7 @@ void ComputePETally::compute_peratom() double ComputePETally::memory_usage() { - double bytes = nmax*size_peratom_cols * sizeof(double); + double bytes = (nmax < 0) ? 0 : nmax*size_peratom_cols * sizeof(double); return bytes; } diff --git a/src/USER-TALLY/compute_stress_tally.cpp b/src/USER-TALLY/compute_stress_tally.cpp index 28baafb9f8..32253d2cad 100644 --- a/src/USER-TALLY/compute_stress_tally.cpp +++ b/src/USER-TALLY/compute_stress_tally.cpp @@ -242,7 +242,7 @@ void ComputeStressTally::compute_peratom() double ComputeStressTally::memory_usage() { - double bytes = nmax*size_peratom_cols * sizeof(double); + double bytes = (nmax < 0) ? 0 : nmax*size_peratom_cols * sizeof(double); return bytes; }