diff --git a/src/read_data.cpp b/src/read_data.cpp index 39afcfbcf8..ed9544ade7 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1701,6 +1701,8 @@ void ReadData::pairIJcoeffs() void ReadData::bondcoeffs() { + if (!nbondtypes) return; + char *next; char *buf = new char[nbondtypes*MAXLINE]; @@ -1723,6 +1725,8 @@ void ReadData::bondcoeffs() void ReadData::anglecoeffs(int which) { + if (!nangletypes) return; + char *next; char *buf = new char[nangletypes*MAXLINE]; @@ -1747,6 +1751,8 @@ void ReadData::anglecoeffs(int which) void ReadData::dihedralcoeffs(int which) { + if (!ndihedraltypes) return; + char *next; char *buf = new char[ndihedraltypes*MAXLINE]; @@ -1774,6 +1780,8 @@ void ReadData::dihedralcoeffs(int which) void ReadData::impropercoeffs(int which) { + if (!nimpropertypes) return; + char *next; char *buf = new char[nimpropertypes*MAXLINE]; diff --git a/src/write_data.cpp b/src/write_data.cpp index 5a67c1081e..d8b951dd8c 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -286,19 +286,19 @@ void WriteData::force_fields() force->pair->write_data_all(fp); } } - if (force->bond && force->bond->writedata) { + if (force->bond && force->bond->writedata && atom->nbondtypes) { fprintf(fp,"\nBond Coeffs # %s\n\n", force->bond_style); force->bond->write_data(fp); } - if (force->angle && force->angle->writedata) { + if (force->angle && force->angle->writedata && atom->nangletypes) { fprintf(fp,"\nAngle Coeffs # %s\n\n", force->angle_style); force->angle->write_data(fp); } - if (force->dihedral && force->dihedral->writedata) { + if (force->dihedral && force->dihedral->writedata && atom->ndihedraltypes) { fprintf(fp,"\nDihedral Coeffs # %s\n\n", force->dihedral_style); force->dihedral->write_data(fp); } - if (force->improper && force->improper->writedata) { + if (force->improper && force->improper->writedata && atom->nimpropertypes) { fprintf(fp,"\nImproper Coeffs # %s\n\n", force->improper_style); force->improper->write_data(fp); }