From ecf7c24e874cb70c19888811b09838d42cd1912b Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 9 Jun 2023 00:06:00 -0600 Subject: [PATCH] Avoid static int in lammps_last_thermo --- src/library.cpp | 15 ++------------- src/lmptype.h | 3 ++- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/library.cpp b/src/library.cpp index 0fcedfc20b..a94e385148 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -794,7 +794,7 @@ argument string. - yes * - type - data type of thermo output column; see :cpp:enum:`_LMP_DATATYPE_CONST` - - pointer to static int + - pointer to int - yes * - data - actual field data for column @@ -815,7 +815,6 @@ void *lammps_last_thermo(void *handle, const char *what, int index) Thermo *th = lmp->output->thermo; if (!th) return nullptr; const int nfield = *th->get_nfield(); - static int datatype; BEGIN_CAPTURE { @@ -833,17 +832,7 @@ void *lammps_last_thermo(void *handle, const char *what, int index) } else if (strcmp(what, "type") == 0) { if ((index < 0) || (index >= nfield)) return nullptr; const auto &field = th->get_fields()[index]; - if (field.type == multitype::INT) { - datatype = LAMMPS_INT; - val = (void *) &datatype; - } else if (field.type == multitype::BIGINT) { - datatype = LAMMPS_INT64; - val = (void *) &datatype; - } else if (field.type == multitype::DOUBLE) { - datatype = LAMMPS_DOUBLE; - val = (void *) &datatype; - } - + val = (void *) &field.type; } else if (strcmp(what, "data") == 0) { if ((index < 0) || (index >= nfield)) return nullptr; const auto &field = th->get_fields()[index]; diff --git a/src/lmptype.h b/src/lmptype.h index 6e0b54d988..e559bd9416 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -276,7 +276,8 @@ union ubuf { \endverbatim */ struct multitype { - enum { NONE, DOUBLE, INT, BIGINT }; + // same values as LAMMPS_INT, LAMMPS_DOUBLE, and LAMMPS_INT64 in library.h + enum { NONE = -1, INT = 0, DOUBLE = 2, BIGINT = 4 }; int type; union {