From 5784fab588adf66ccfd568cbec16661093c7adc4 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 5 May 2022 17:04:50 -0600 Subject: [PATCH] starting to add timer-style variable --- src/info.cpp | 2 +- src/variable.cpp | 16 ++++++++++++++++ src/variable.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/info.cpp b/src/info.cpp index d50c45457b..f81ed06aa7 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -110,7 +110,7 @@ using namespace LAMMPS_NS; static const char *varstyles[] = { "index", "loop", "world", "universe", "uloop", "string", "getenv", "file", "atomfile", "format", "equal", "atom", "vector", "python", - "internal", "(unknown)"}; + "timer", "internal", "(unknown)"}; static const char *mapstyles[] = { "none", "array", "hash", "yes" }; diff --git a/src/variable.cpp b/src/variable.cpp index 8455227ad7..907b8e661a 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -500,6 +500,22 @@ void Variable::set(int narg, char **arg) strcpy(data[nvar][1],"(undefined)"); } + // TIMER + // num = listed args, which = 1st value, data = copied args + + } else if (strcmp(arg[1],"timer") == 0) { + if (narg != 2) error->all(FLERR,"Illegal variable command"); + if (find(arg[0]) >= 0) return; + if (nvar == maxvar) grow(); + style[nvar] = TIMER; + num[nvar] = 1; + which[nvar] = 0; + pad[nvar] = 0; + data[nvar] = new char*[num[nvar]]; + copy(num[nvar],&arg[2],data[nvar]); + + // NOTE: set value to MPI_Wtime() evaulated by proc 0 + // INTERNAL // replace pre-existing var if also style INTERNAL (allows it to be reset) // num = 1, for string representation of dvalue, set by retrieve() diff --git a/src/variable.h b/src/variable.h index 7a79f50582..52632ba6ce 100644 --- a/src/variable.h +++ b/src/variable.h @@ -71,6 +71,7 @@ class Variable : protected Pointers { ATOM, VECTOR, PYTHON, + TIMER, INTERNAL }; static constexpr int VALUELENGTH = 64;