diff --git a/src/read_data.cpp b/src/read_data.cpp index e44c6b741740ed524577895b370b9c599f9ad783..b1a42608c050a1214fb3eed63df2f19554159e1c 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -968,6 +968,7 @@ void ReadData::header(int firstpass) // search line for header keyword and set corresponding variable // customize for new header lines // check for triangles before angles so "triangles" not matched as "angles" + int extra_flag_value = 0; if (strstr(line,"atoms")) { sscanf(line,BIGINT_FORMAT,&natoms); @@ -1029,17 +1030,26 @@ void ReadData::header(int firstpass) atom->nimpropertypes = nimpropertypes + extra_improper_types; // these settings only used by first data file + // also, these are obsolescent. we parse them to maintain backward + // compatibility, but the recommended way is to set them via keywords + // in the LAMMPS input file. In case these flags are set in both, + // the input and the data file, we use the larger of the two. } else if (strstr(line,"extra bond per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_bond_per_atom); + if (addflag == NONE) sscanf(line,"%d",&extra_flag_value); + atom->extra_bond_per_atom = MAX(atom->extra_bond_per_atom,extra_flag_value); } else if (strstr(line,"extra angle per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_angle_per_atom); + if (addflag == NONE) sscanf(line,"%d",&extra_flag_value); + atom->extra_angle_per_atom = MAX(atom->extra_angle_per_atom,extra_flag_value); } else if (strstr(line,"extra dihedral per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_dihedral_per_atom); + if (addflag == NONE) sscanf(line,"%d",&extra_flag_value); + atom->extra_dihedral_per_atom = MAX(atom->extra_dihedral_per_atom,extra_flag_value); } else if (strstr(line,"extra improper per atom")) { - if (addflag == NONE) sscanf(line,"%d",&atom->extra_improper_per_atom); + if (addflag == NONE) sscanf(line,"%d",&extra_flag_value); + atom->extra_improper_per_atom = MAX(atom->extra_improper_per_atom,extra_flag_value); } else if (strstr(line,"extra special per atom")) { - if (addflag == NONE) sscanf(line,"%d",&force->special_extra); + if (addflag == NONE) sscanf(line,"%d",&extra_flag_value); + force->special_extra = MAX(force->special_extra,extra_flag_value); // local copy of box info // so can treat differently for first vs subsequent data files diff --git a/src/read_data.h b/src/read_data.h index 5463c86f08e2fa849c9254f13f1feec008e203d9..5f83b78c61345da54862a6d2337f534c309f0099 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -472,8 +472,8 @@ outside a non-periodic simulation box. E: Subsequent read data induced too many bonds per atom -See the create_box extra/bond/per/atom or read_data "extra bond per -atom" header value to set this limit larger. +See the create_box extra/bond/per/atom or the read_data +extra/bond/per/atom keyword to set this limit larger. E: Bonds assigned incorrectly @@ -482,8 +482,8 @@ This means there is something invalid about the topology definitions. E: Subsequent read data induced too many angles per atom -See the create_box extra/angle/per/atom or read_data "extra angle per -atom" header value to set this limit larger. +See the create_box extra/angle/per/atom or the read_data +extra/angle/per/atom keyword to set this limit larger. E: Angles assigned incorrectly @@ -493,8 +493,8 @@ definitions. E: Subsequent read data induced too many dihedrals per atom -See the create_box extra/dihedral/per/atom or read_data "extra -dihedral per atom" header value to set this limit larger. +See the create_box extra/dihedral/per/atom or the read_data +extra/dihedral/per/atom keyword to set this limit larger. E: Dihedrals assigned incorrectly @@ -504,8 +504,8 @@ definitions. E: Subsequent read data induced too many impropers per atom -See the create_box extra/improper/per/atom or read_data "extra -improper per atom" header value to set this limit larger. +See the create_box extra/improper/per/atom or the read_data +extra/improper/per/atom keyword to set this limit larger. E: Impropers assigned incorrectly