diff --git a/src/fix.cpp b/src/fix.cpp index 2ec28be0a5..657d69a918 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -69,6 +69,7 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) scalar_flag = vector_flag = array_flag = 0; peratom_flag = local_flag = 0; + size_array_rows_variable = 0; comm_forward = comm_reverse = comm_border = 0; restart_reset = 0; diff --git a/src/fix.h b/src/fix.h index 04920df238..7adb3a9b4b 100644 --- a/src/fix.h +++ b/src/fix.h @@ -57,6 +57,7 @@ class Fix : protected Pointers { int size_vector; // length of global vector int size_array_rows; // rows in global array int size_array_cols; // columns in global array + int size_array_rows_variable; // 1 if row count is unknown in advance int global_freq; // frequency s/v data is available at int peratom_flag; // 0/1 if per-atom data is stored diff --git a/src/thermo.cpp b/src/thermo.cpp index a3d14af479..b120642cf1 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -893,8 +893,11 @@ void Thermo::parse_fields(char *str) if (argindex1[nfield] > 0 && argindex2[nfield] > 0) { if (modify->fix[n]->array_flag == 0) error->all(FLERR,"Thermo fix does not compute array"); - if (argindex1[nfield] > modify->fix[n]->size_array_rows || - argindex2[nfield] > modify->fix[n]->size_array_cols) + if (argindex1[nfield] > modify->fix[n]->size_array_rows) { + if (modify->fix[n]->size_array_rows_variable == 0) + error->all(FLERR,"Thermo fix array is accessed out-of-range"); + } + if (argindex2[nfield] > modify->fix[n]->size_array_cols) error->all(FLERR,"Thermo fix array is accessed out-of-range"); }