diff --git a/src/lammps.cpp b/src/lammps.cpp index 8e81f785de..fee24e785b 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -382,8 +382,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : if (iarg+3 > narg) error->universe_all(FLERR,"Invalid command-line argument"); if (restart2dump) - error->universe_all(FLERR, - "Cannot use both -restart2data and -restart2dump"); + error->universe_all(FLERR, "Cannot use both -restart2data and -restart2dump"); restart2data = 1; restartfile = arg[iarg+1]; inflag = -1; // skip inflag check @@ -405,8 +404,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : if (iarg+3 > narg) error->universe_all(FLERR,"Invalid command-line argument"); if (restart2data) - error->universe_all(FLERR, - "Cannot use both -restart2data and -restart2dump"); + error->universe_all(FLERR, "Cannot use both -restart2data and -restart2dump"); restart2dump = 1; restartfile = arg[iarg+1]; inflag = -1; // skip inflag check @@ -728,7 +726,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : // if either restart conversion option was used, invoke 2 commands and quit // add args between wfirst and wlast to write_data or write_data command // add "noinit" to write_data to prevent a system init - // write_dump will just give a warning message about no init if (restart2data || restart2dump) { std::string cmd = fmt::format("read_restart {}",restartfile); @@ -738,7 +735,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : else cmd = "write_dump"; for (iarg = wfirst; iarg < wlast; iarg++) cmd += fmt::format(" {}", arg[iarg]); - if (restart2data) cmd += " noinit"; + cmd += " noinit"; input->one(cmd); error->done(0); } diff --git a/src/write_dump.cpp b/src/write_dump.cpp index 6c932735eb..9e9150d10a 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -57,9 +57,17 @@ void WriteDump::command(int narg, char **arg) dumpargs[2] = arg[1]; // dump style dumpargs[3] = utils::strdup(std::to_string(dumpfreq)); // dump frequency - for (int i = 2; i < modindex; ++i) dumpargs[i + 2] = arg[i]; + // copy arguments up to modify, but skip over "noinit" if present + int noinitwarn = 0; + for (int i = 2; i < modindex; ++i) { + if (strcmp(arg[i], "noinit") == 0) { + noinitwarn = 1; + } else { + dumpargs[i + 2 - noinitwarn] = arg[i]; + } + } - auto *dump = output->add_dump(modindex + 2, dumpargs); + auto *dump = output->add_dump(modindex + 2 - noinitwarn, dumpargs); try { if (modindex < narg) dump->modify_params(narg - modindex - 1, &arg[modindex + 1]); @@ -75,7 +83,7 @@ void WriteDump::command(int narg, char **arg) if (strcmp(arg[1], "image") == 0) (dynamic_cast(dump))->multifile_override = 1; if (strcmp(arg[1], "cfg") == 0) (dynamic_cast(dump))->multifile_override = 1; - if ((update->first_update == 0) && (comm->me == 0)) + if ((update->first_update == 0) && (comm->me == 0) && (noinitwarn == 0)) error->warning(FLERR, "Calling write_dump before a full system init."); dump->init();