From 267bc7ae2daed4d1c8e71d772e77ed29dd1dce77 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 14 Oct 2021 08:07:43 -0400 Subject: [PATCH] avoid (unlikely) integer overflows with very large systems --- src/REAXFF/fix_acks2_reaxff.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/REAXFF/fix_acks2_reaxff.cpp b/src/REAXFF/fix_acks2_reaxff.cpp index f9a3b384bd..0e26c3e115 100644 --- a/src/REAXFF/fix_acks2_reaxff.cpp +++ b/src/REAXFF/fix_acks2_reaxff.cpp @@ -866,15 +866,14 @@ void FixACKS2ReaxFF::more_reverse_comm(double *vec) double FixACKS2ReaxFF::memory_usage() { double bytes; - - int size = 2*nmax + 2; + const double size = 2.0*nmax + 2.0; bytes = size*nprev * sizeof(double); // s_hist - bytes += nmax*4 * sizeof(double); // storage - bytes += size*11 * sizeof(double); // storage - bytes += n_cap*4 * sizeof(int); // matrix... - bytes += m_cap*2 * sizeof(int); - bytes += m_cap*2 * sizeof(double); + bytes += nmax*4.0 * sizeof(double); // storage + bytes += size*11.0 * sizeof(double); // storage + bytes += n_cap*4.0 * sizeof(int); // matrix... + bytes += m_cap*2.0 * sizeof(int); + bytes += m_cap*2.0 * sizeof(double); return bytes; }