From c37b5e50b1fa4f7c0dd159c1d37bba0b237758f4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 3 Jul 2020 22:35:53 -0400 Subject: [PATCH] flag error when trying to compute an average of an empty vector --- src/variable.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/variable.cpp b/src/variable.cpp index efdc701c1a..e3733314af 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -4205,6 +4205,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, if (eval_in_progress[ivar]) print_var_error(FLERR,"Variable has circular dependency",ivar); + if ((method == AVE) && (nvec == 0)) + print_var_error(FLERR,"Cannot compute average of empty vector",ivar); + double *vec; nvec = compute_vector(ivar,&vec); nstride = 1;