write out and check for unit settings marker in data files
This commit is contained in:
@ -1154,6 +1154,14 @@ void ReadData::header(int firstpass)
|
|||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
char *eof = utils::fgets_trunc(line, MAXLINE, fp);
|
char *eof = utils::fgets_trunc(line, MAXLINE, fp);
|
||||||
if (eof == nullptr) error->one(FLERR, "Unexpected end of data file");
|
if (eof == nullptr) error->one(FLERR, "Unexpected end of data file");
|
||||||
|
|
||||||
|
// check for units keyword in first line and print warning on mismatch
|
||||||
|
auto units = Tokenizer(utils::strfind(line, "units = \\w+")).as_vector();
|
||||||
|
if (units.size() > 2) {
|
||||||
|
if (units[2] != update->unit_style)
|
||||||
|
error->warning(FLERR, "Inconsistent units in data file: current = {}, data file = {}",
|
||||||
|
update->unit_style, units[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@ -245,8 +245,8 @@ void WriteData::write(const std::string &file)
|
|||||||
|
|
||||||
void WriteData::header()
|
void WriteData::header()
|
||||||
{
|
{
|
||||||
fmt::print(fp,"LAMMPS data file via write_data, version {}, "
|
fmt::print(fp,"LAMMPS data file via write_data, version {}, timestep = {}, units = {}\n\n",
|
||||||
"timestep = {}\n\n",lmp->version,update->ntimestep);
|
lmp->version, update->ntimestep, update->unit_style);
|
||||||
|
|
||||||
fmt::print(fp,"{} atoms\n{} atom types\n",atom->natoms,atom->ntypes);
|
fmt::print(fp,"{} atoms\n{} atom types\n",atom->natoms,atom->ntypes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user