improve error messages
This commit is contained in:
@ -61,7 +61,7 @@ void WriteRestart::command(int narg, char **arg)
|
|||||||
{
|
{
|
||||||
if (domain->box_exist == 0)
|
if (domain->box_exist == 0)
|
||||||
error->all(FLERR,"Write_restart command before simulation box is defined");
|
error->all(FLERR,"Write_restart command before simulation box is defined");
|
||||||
if (narg < 1) error->all(FLERR,"Illegal write_restart command");
|
if (narg < 1) utils::missing_cmd_args(FLERR, "write_restart", error);
|
||||||
|
|
||||||
// if filename contains a "*", replace with current timestep
|
// if filename contains a "*", replace with current timestep
|
||||||
|
|
||||||
@ -154,11 +154,11 @@ void WriteRestart::multiproc_options(int multiproc_caller, int mpiioflag_caller,
|
|||||||
int iarg = 0;
|
int iarg = 0;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"fileper") == 0) {
|
if (strcmp(arg[iarg],"fileper") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal write_restart command");
|
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "write_restart", error);
|
||||||
if (!multiproc)
|
if (!multiproc)
|
||||||
error->all(FLERR,"Cannot use write_restart fileper without % in restart file name");
|
error->all(FLERR,"Cannot use write_restart fileper without % in restart file name");
|
||||||
int nper = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
int nper = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
if (nper <= 0) error->all(FLERR,"Illegal write_restart command");
|
if (nper <= 0) error->all(FLERR,"Invalue write_restart fileper value {}:", nper);
|
||||||
|
|
||||||
multiproc = nprocs/nper;
|
multiproc = nprocs/nper;
|
||||||
if (nprocs % nper) multiproc++;
|
if (nprocs % nper) multiproc++;
|
||||||
@ -171,11 +171,11 @@ void WriteRestart::multiproc_options(int multiproc_caller, int mpiioflag_caller,
|
|||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|
||||||
} else if (strcmp(arg[iarg],"nfile") == 0) {
|
} else if (strcmp(arg[iarg],"nfile") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal write_restart command");
|
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "write_restart nfile", error);
|
||||||
if (!multiproc)
|
if (!multiproc)
|
||||||
error->all(FLERR,"Cannot use write_restart nfile without % in restart file name");
|
error->all(FLERR,"Cannot use write_restart nfile without % in restart file name");
|
||||||
int nfile = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
int nfile = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
if (nfile <= 0) error->all(FLERR,"Illegal write_restart command");
|
if (nfile <= 0) error->all(FLERR,"Invalid write_restart nfile value {}", nfile);
|
||||||
nfile = MIN(nfile,nprocs);
|
nfile = MIN(nfile,nprocs);
|
||||||
|
|
||||||
multiproc = nfile;
|
multiproc = nfile;
|
||||||
@ -195,7 +195,7 @@ void WriteRestart::multiproc_options(int multiproc_caller, int mpiioflag_caller,
|
|||||||
} else if (strcmp(arg[iarg],"noinit") == 0) {
|
} else if (strcmp(arg[iarg],"noinit") == 0) {
|
||||||
noinit = 1;
|
noinit = 1;
|
||||||
iarg++;
|
iarg++;
|
||||||
} else error->all(FLERR,"Illegal write_restart command");
|
} else error->all(FLERR,"Unknown write_restart keyword: {}", arg[iarg]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,8 @@ void WriteRestart::write(const std::string &file)
|
|||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
if (natoms != atom->natoms && output->thermo->lostflag == Thermo::ERROR)
|
if (natoms != atom->natoms && output->thermo->lostflag == Thermo::ERROR)
|
||||||
error->all(FLERR,"Atom count is inconsistent, cannot write restart file");
|
error->all(FLERR,"Atom count is inconsistent: {} vs {}, cannot write restart file",
|
||||||
|
natoms, atom->natoms);
|
||||||
|
|
||||||
// open single restart file or base file for multiproc case
|
// open single restart file or base file for multiproc case
|
||||||
|
|
||||||
@ -231,8 +232,7 @@ void WriteRestart::write(const std::string &file)
|
|||||||
|
|
||||||
fp = fopen(base.c_str(),"wb");
|
fp = fopen(base.c_str(),"wb");
|
||||||
if (fp == nullptr)
|
if (fp == nullptr)
|
||||||
error->one(FLERR, "Cannot open restart file {}: {}",
|
error->one(FLERR, "Cannot open restart file {}: {}", base, utils::getsyserror());
|
||||||
base, utils::getsyserror());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// proc 0 writes magic string, endian flag, numeric version
|
// proc 0 writes magic string, endian flag, numeric version
|
||||||
@ -294,8 +294,7 @@ void WriteRestart::write(const std::string &file)
|
|||||||
if (filewriter) {
|
if (filewriter) {
|
||||||
fp = fopen(multiname.c_str(),"wb");
|
fp = fopen(multiname.c_str(),"wb");
|
||||||
if (fp == nullptr)
|
if (fp == nullptr)
|
||||||
error->one(FLERR, "Cannot open restart file {}: {}",
|
error->one(FLERR, "Cannot open restart file {}: {}", multiname, utils::getsyserror());
|
||||||
multiname, utils::getsyserror());
|
|
||||||
write_int(PROCSPERFILE,nclusterprocs);
|
write_int(PROCSPERFILE,nclusterprocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -348,7 +348,7 @@ TEST_F(FileOperationsTest, write_restart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_FAILURE(".*ERROR: Illegal write_restart command.*", command("write_restart"););
|
TEST_FAILURE(".*ERROR: Illegal write_restart command.*", command("write_restart"););
|
||||||
TEST_FAILURE(".*ERROR: Illegal write_restart command.*",
|
TEST_FAILURE(".*ERROR: Unknown write_restart keyword: xxxx.*",
|
||||||
command("write_restart test.restart xxxx"););
|
command("write_restart test.restart xxxx"););
|
||||||
TEST_FAILURE(".*ERROR on proc 0: Cannot open restart file some_crazy_dir/test.restart:"
|
TEST_FAILURE(".*ERROR on proc 0: Cannot open restart file some_crazy_dir/test.restart:"
|
||||||
" No such file or directory.*",
|
" No such file or directory.*",
|
||||||
|
|||||||
Reference in New Issue
Block a user