From 7da8f12d33862735fc2004ccae2056c4b9f84b7f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 17 Feb 2014 08:12:42 -0500 Subject: [PATCH] better checking of missing coeff entries in a data file --- src/read_data.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/read_data.cpp b/src/read_data.cpp index c563f6b620..29936f5bb4 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1363,6 +1363,7 @@ void ReadData::paircoeffs() next = strchr(buf,'\n'); *next = '\0'; parse_coeffs(buf,NULL,1); + if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); force->pair->coeff(narg,arg); buf = next + 1; } @@ -1388,6 +1389,7 @@ void ReadData::pairIJcoeffs() next = strchr(buf,'\n'); *next = '\0'; parse_coeffs(buf,NULL,0); + if (narg == 0) error->all(FLERR,"Unexpected end of PairCoeffs section"); force->pair->coeff(narg,arg); buf = next + 1; } @@ -1409,6 +1411,7 @@ void ReadData::bondcoeffs() next = strchr(buf,'\n'); *next = '\0'; parse_coeffs(buf,NULL,0); + if (narg == 0) error->all(FLERR,"Unexpected end of BondCoeffs section"); force->bond->coeff(narg,arg); buf = next + 1; } @@ -1432,6 +1435,7 @@ void ReadData::anglecoeffs(int which) if (which == 0) parse_coeffs(buf,NULL,0); else if (which == 1) parse_coeffs(buf,"bb",0); else if (which == 2) parse_coeffs(buf,"ba",0); + if (narg == 0) error->all(FLERR,"Unexpected end of AngleCoeffs section"); force->angle->coeff(narg,arg); buf = next + 1; } @@ -1458,6 +1462,7 @@ void ReadData::dihedralcoeffs(int which) else if (which == 3) parse_coeffs(buf,"at",0); else if (which == 4) parse_coeffs(buf,"aat",0); else if (which == 5) parse_coeffs(buf,"bb13",0); + if (narg == 0) error->all(FLERR,"Unexpected end of DihedralCoeffs section"); force->dihedral->coeff(narg,arg); buf = next + 1; } @@ -1480,6 +1485,7 @@ void ReadData::impropercoeffs(int which) *next = '\0'; if (which == 0) parse_coeffs(buf,NULL,0); else if (which == 1) parse_coeffs(buf,"aa",0); + if (narg == 0) error->all(FLERR,"Unexpected end of ImproperCoeffs section"); force->improper->coeff(narg,arg); buf = next + 1; }