diff --git a/src/input.cpp b/src/input.cpp index 697095c4ed..5435d66e10 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -186,7 +186,10 @@ void Input::file() if (n == 0) { if (label_active) error->all(FLERR,"Label wasn't found in input script"); if (me == 0) { - if (infile != stdin) fclose(infile); + if (infile != stdin) { + fclose(infile); + infile = NULL; + } nfile--; } MPI_Bcast(&nfile,1,MPI_INT,0,world); diff --git a/src/lammps.cpp b/src/lammps.cpp index 76d2280b1e..210baab5d8 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -71,6 +71,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) screen = NULL; logfile = NULL; + infile = NULL; // parse input switches @@ -261,7 +262,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) screen = universe->uscreen; logfile = universe->ulogfile; world = universe->uworld; - infile = NULL; if (universe->me == 0) { if (inflag == 0) infile = stdin;