check whether total number of replica is too large for 32-bit int

This commit is contained in:
Axel Kohlmeyer
2024-01-11 11:12:27 -05:00
parent 62cf534de0
commit 4bda4621bb

View File

@ -57,7 +57,12 @@ void Replicate::command(int narg, char **arg)
error->all(FLERR, "Illegal replication grid {}x{}x{}. All replications must be > 0",
nx, ny, nz);
int nrep = nx*ny*nz;
bigint nrepbig = (bigint) nx * ny * nz;
if (nrepbig > MAXSMALLINT)
error->all(FLERR, "Total # of replica is too large: {}x{}x{} = {}. "
"Please use replicate multiple times", nx, ny, nz, nrepbig);
int nrep = (int) nrepbig;
if (me == 0)
utils::logmesg(lmp, "Replication is creating a {}x{}x{} = {} times larger system...\n",
nx, ny, nz, nrep);