guard against not setting extscalar, extvector, or extarray when required

This commit is contained in:
Axel Kohlmeyer
2024-04-22 19:55:52 -04:00
parent d896f307ba
commit a88e8757e3
4 changed files with 38 additions and 3 deletions

View File

@ -59,6 +59,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) :
// set child class defaults
scalar_flag = vector_flag = array_flag = 0;
extscalar = extvector = extarray = -1;
peratom_flag = local_flag = pergrid_flag = 0;
size_vector_variable = size_array_rows_variable = 0;
@ -116,6 +117,16 @@ void Compute::init_flags()
initialized_flag = 1;
invoked_scalar = invoked_vector = invoked_array = -1;
invoked_peratom = invoked_local = -1;
if (scalar_flag && (extscalar < 0))
error->all(FLERR, "Must set 'extscalar' when setting 'scalar_flag' for compute {}. "
"Contact the developer.", style);
if (vector_flag && (extvector < 0))
error->all(FLERR, "Must set 'extvector' when setting 'vector_flag' for compute {}. "
"Contact the developer.", style);
if (array_flag && (extarray < 0))
error->all(FLERR, "Must set 'extarray' when setting 'array_flag' for compute {}. "
"Contact the developer.", style);
}
/* ---------------------------------------------------------------------- */