change skip inflag check logic to avoid error opening non-existant file

This commit is contained in:
Axel Kohlmeyer
2024-01-21 09:42:24 -05:00
parent 795d6e4420
commit aedc061c45

View File

@ -276,8 +276,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
error->universe_all(FLERR,"Invalid command-line argument"); error->universe_all(FLERR,"Invalid command-line argument");
helpflag = 1; helpflag = 1;
citeflag = 0; citeflag = 0;
inflag = 1; // skip inflag check inflag = -1; // skip inflag check
infile = stdin; // and corresponding warning
iarg += 1; iarg += 1;
} else if (strcmp(arg[iarg],"-in") == 0 || } else if (strcmp(arg[iarg],"-in") == 0 ||
@ -387,8 +386,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
"Cannot use both -restart2data and -restart2dump"); "Cannot use both -restart2data and -restart2dump");
restart2data = 1; restart2data = 1;
restartfile = arg[iarg+1]; restartfile = arg[iarg+1];
inflag = 1; // skip inflag check inflag = -1; // skip inflag check
infile = stdin; // and corresponding warning
// check for restart remap flag // check for restart remap flag
if (strcmp(arg[iarg+2],"remap") == 0) { if (strcmp(arg[iarg+2],"remap") == 0) {
if (iarg+4 > narg) if (iarg+4 > narg)
@ -411,8 +409,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
"Cannot use both -restart2data and -restart2dump"); "Cannot use both -restart2data and -restart2dump");
restart2dump = 1; restart2dump = 1;
restartfile = arg[iarg+1]; restartfile = arg[iarg+1];
inflag = 1; // skip inflag check inflag = -1; // skip inflag check
infile = stdin; // and corresponding warning
// check for restart remap flag // check for restart remap flag
if (strcmp(arg[iarg+2],"remap") == 0) { if (strcmp(arg[iarg+2],"remap") == 0) {
if (iarg+4 > narg) if (iarg+4 > narg)
@ -541,7 +538,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
world = universe->uworld; world = universe->uworld;
if (universe->me == 0) { if (universe->me == 0) {
if (inflag == 0) infile = stdin; if (inflag <= 0) infile = stdin;
else if (strcmp(arg[inflag], "none") == 0) infile = stdin; else if (strcmp(arg[inflag], "none") == 0) infile = stdin;
else infile = fopen(arg[inflag],"r"); else infile = fopen(arg[inflag],"r");
if (infile == nullptr) if (infile == nullptr)