diff --git a/src/lammps.cpp b/src/lammps.cpp index ce4fea2e95..73419d06b6 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -442,6 +442,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) // if restartflag set, process 2 command and quit // add args between wdfirst and wdlast to write_data + // also add "noinit" to prevent write_data from doing system init if (restartflag) { char cmd[128]; @@ -450,7 +451,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) sprintf(cmd,"write_data %s",dfile); for (iarg = wdfirst; iarg < wdlast; iarg++) sprintf(&cmd[strlen(cmd)]," %s",arg[iarg]); - strcat(cmd,"\n"); + strcat(cmd," noinit\n"); input->one(cmd); error->done(); } diff --git a/src/write_data.cpp b/src/write_data.cpp index 415b9e320a..a0868d700b 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -71,8 +71,10 @@ void WriteData::command(int narg, char **arg) } else strcpy(file,arg[0]); // read optional args + // noinit is a hidden arg, only used by -r command-line switch pairflag = II; + int noinit = 0; int iarg = 1; while (iarg < narg) { @@ -82,29 +84,40 @@ void WriteData::command(int narg, char **arg) else if (strcmp(arg[iarg+1],"ij") == 0) pairflag = IJ; else error->all(FLERR,"Illegal write_data command"); iarg += 2; + } else if (strcmp(arg[iarg],"noinit") == 0) { + noinit = 1; + iarg++; } else error->all(FLERR,"Illegal write_data command"); } // init entire system since comm->exchange is done // comm::init needs neighbor::init needs pair::init needs kspace::init, etc + // exception is when called by -r command-line switch + // then write_data immediately follows reading of restart file + // assume that read_restart initialized necessary values + // if don't make exception: + // pair->init() can fail due to various unset values: + // e.g. pair hybrid coeffs, dpd ghost-atom velocity setting - if (comm->me == 0 && screen) - fprintf(screen,"System init for write_data ...\n"); - lmp->init(); + if (noinit == 0) { + if (comm->me == 0 && screen) + fprintf(screen,"System init for write_data ...\n"); + lmp->init(); - // move atoms to new processors before writing file - // do setup_pre_exchange to force update of per-atom info if needed - // enforce PBC in case atoms are outside box - // call borders() to rebuild atom map since exchange() destroys map + // move atoms to new processors before writing file + // do setup_pre_exchange to force update of per-atom info if needed + // enforce PBC in case atoms are outside box + // call borders() to rebuild atom map since exchange() destroys map - modify->setup_pre_exchange(); - if (domain->triclinic) domain->x2lamda(atom->nlocal); - domain->pbc(); - domain->reset_box(); - comm->setup(); - comm->exchange(); - comm->borders(); - if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + modify->setup_pre_exchange(); + if (domain->triclinic) domain->x2lamda(atom->nlocal); + domain->pbc(); + domain->reset_box(); + comm->setup(); + comm->exchange(); + comm->borders(); + if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost); + } write(file);