Commit 55081e21 authored by Peter Eastman's avatar Peter Eastman
Browse files

Tony's changes to error handling in the CUDA platform so it throws exceptions...

Tony's changes to error handling in the CUDA platform so it throws exceptions instead of calling exit()
parent 832794f5
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include <iostream>
#include <sstream>
#include "openmm/OpenMMException.h"
#include "ValidateOpenMMForces.h" #include "ValidateOpenMMForces.h"
using namespace OpenMM; using namespace OpenMM;
...@@ -547,8 +550,10 @@ ForceValidationResult* ValidateOpenMMForces::compareForce(Context& context, std: ...@@ -547,8 +550,10 @@ ForceValidationResult* ValidateOpenMMForces::compareForce(Context& context, std:
for( int ii = 0; ii < system.getNumForces(); ii++ ){ for( int ii = 0; ii < system.getNumForces(); ii++ ){
std::string forceName = getForceName( system.getForce( ii ) ); std::string forceName = getForceName( system.getForce( ii ) );
if( forceName.compare( "NA" ) == 0 ){ if( forceName.compare( "NA" ) == 0 ){
(void) fprintf( stderr, "Force at index=%d not found -- aborting!\n", ii ); std::stringstream message;
exit(-1); message << "Force at index=" << ii << " not found -- aborting!";
std::cerr << message << std::endl;
throw OpenMM::OpenMMException(message.str());
} }
systemForceNameMap[forceName] = ii; systemForceNameMap[forceName] = ii;
systemForceNameIndex[ii] = forceName; systemForceNameIndex[ii] = forceName;
......
...@@ -11,6 +11,7 @@ FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS}) ...@@ -11,6 +11,7 @@ FOREACH(subdir ${OPENMM_SOURCE_SUBDIRS})
CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/platforms/cuda/${subdir}/src) CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/platforms/cuda/${subdir}/src)
ENDFOREACH(subdir) ENDFOREACH(subdir)
CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/jama/include) CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/jama/include)
CUDA_INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/openmmapi/include)
IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug) IF (UNIX AND CMAKE_BUILD_TYPE MATCHES Debug)
SET(MAIN_OPENMM_LIB ${OPENMM_LIBRARY_NAME}_d) SET(MAIN_OPENMM_LIB ${OPENMM_LIBRARY_NAME}_d)
......
...@@ -38,19 +38,18 @@ ...@@ -38,19 +38,18 @@
#include <cufft.h> #include <cufft.h>
#include <builtin_types.h> #include <builtin_types.h>
#include <vector_functions.h> #include <vector_functions.h>
#include "openmm/OpenMMException.h"
#define RTERROR(status, s) \ #define RTERROR(status, s) \
if (status != cudaSuccess) { \ if (status != cudaSuccess) { \
printf("%s %s\n", s, cudaGetErrorString(status)); \ throw OpenMM::OpenMMException(std::string(s) + " " + cudaGetErrorString(status)); \
exit(-1); \
} }
#define LAUNCHERROR(s) \ #define LAUNCHERROR(s) \
{ \ { \
cudaError_t status = cudaGetLastError(); \ cudaError_t status = cudaGetLastError(); \
if (status != cudaSuccess) { \ if (status != cudaSuccess) { \
printf("Error: %s launching kernel %s\n", cudaGetErrorString(status), s); \ throw OpenMM::OpenMMException(std::string("Error: ") + cudaGetErrorString(status) + " launching kernel " + s); \
exit(-1); \
} \ } \
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "SimTKOpenMMLog.h" #include "SimTKOpenMMLog.h"
#include <stdlib.h> #include <stdlib.h>
#include "openmm/OpenMMException.h"
// static settings // static settings
...@@ -291,13 +292,13 @@ void SimTKOpenMMLog::printError( const std::stringstream& message ){ ...@@ -291,13 +292,13 @@ void SimTKOpenMMLog::printError( const std::stringstream& message ){
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
if( _simTKOpenMMLog ){
std::stringstream messageWithHeader; std::stringstream messageWithHeader;
messageWithHeader << "Error: " << message.str(); messageWithHeader << "Error: " << message.str();
if( _simTKOpenMMLog ){
_simTKOpenMMLog->logMessage( messageWithHeader ); _simTKOpenMMLog->logMessage( messageWithHeader );
} else { } else {
(void) fprintf( stderr, "Error: %s", message.str().c_str() ); (void) fprintf( stderr, "%s", messageWithHeader.str().c_str() );
(void) fflush( stderr ); (void) fflush( stderr );
} }
exit(-1); throw OpenMM::OpenMMException(messageWithHeader.str());
} }
...@@ -411,7 +411,6 @@ static int readVectorOfDoubleVectors( FILE* filePtr, const StringVector& tokens, ...@@ -411,7 +411,6 @@ static int readVectorOfDoubleVectors( FILE* filePtr, const StringVector& tokens,
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() ); (void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberToRead = atoi( tokens[1].c_str() ); int numberToRead = atoi( tokens[1].c_str() );
...@@ -435,7 +434,6 @@ static int readVectorOfDoubleVectors( FILE* filePtr, const StringVector& tokens, ...@@ -435,7 +434,6 @@ static int readVectorOfDoubleVectors( FILE* filePtr, const StringVector& tokens,
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s %s tokens incomplete at line=%d\n", methodName.c_str(), typeName.c_str(), *lineCount ); (void) sprintf( buffer, "%s %s tokens incomplete at line=%d\n", methodName.c_str(), typeName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -491,7 +489,6 @@ static int readVectorOfIntVectors( FILE* filePtr, const StringVector& tokens, st ...@@ -491,7 +489,6 @@ static int readVectorOfIntVectors( FILE* filePtr, const StringVector& tokens, st
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() ); (void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberToRead = atoi( tokens[1].c_str() ); int numberToRead = atoi( tokens[1].c_str() );
...@@ -514,7 +511,6 @@ static int readVectorOfIntVectors( FILE* filePtr, const StringVector& tokens, st ...@@ -514,7 +511,6 @@ static int readVectorOfIntVectors( FILE* filePtr, const StringVector& tokens, st
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s %s tokens incomplete at line=%d\n", methodName.c_str(), typeName.c_str(), *lineCount ); (void) sprintf( buffer, "%s %s tokens incomplete at line=%d\n", methodName.c_str(), typeName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -574,7 +570,6 @@ static int readIntVector( FILE* filePtr, const StringVector& tokens, int numberT ...@@ -574,7 +570,6 @@ static int readIntVector( FILE* filePtr, const StringVector& tokens, int numberT
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() ); (void) sprintf( buffer, "%s no %s entries?\n", methodName.c_str(), typeName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberToRead = atoi( tokens[numberTokenIndex].c_str() ); int numberToRead = atoi( tokens[numberTokenIndex].c_str() );
...@@ -630,7 +625,6 @@ static int readParticles( FILE* filePtr, const StringVector& tokens, System& sys ...@@ -630,7 +625,6 @@ static int readParticles( FILE* filePtr, const StringVector& tokens, System& sys
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no particles number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no particles number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberOfParticles = atoi( tokens[1].c_str() ); int numberOfParticles = atoi( tokens[1].c_str() );
...@@ -667,7 +661,6 @@ static int readMasses( FILE* filePtr, const StringVector& tokens, System& system ...@@ -667,7 +661,6 @@ static int readMasses( FILE* filePtr, const StringVector& tokens, System& system
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no particle masses?\n", methodName.c_str() ); (void) sprintf( buffer, "%s no particle masses?\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberOfParticles = atoi( tokens[1].c_str() ); int numberOfParticles = atoi( tokens[1].c_str() );
...@@ -686,7 +679,6 @@ static int readMasses( FILE* filePtr, const StringVector& tokens, System& system ...@@ -686,7 +679,6 @@ static int readMasses( FILE* filePtr, const StringVector& tokens, System& system
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s particle tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s particle tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -741,7 +733,6 @@ static int readAmoebaHarmonicBondParameters( FILE* filePtr, MapStringInt& forceM ...@@ -741,7 +733,6 @@ static int readAmoebaHarmonicBondParameters( FILE* filePtr, MapStringInt& forceM
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no bonds number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no bonds number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaHarmonicBondForce* bondForce = new AmoebaHarmonicBondForce(); AmoebaHarmonicBondForce* bondForce = new AmoebaHarmonicBondForce();
...@@ -771,8 +762,10 @@ static int readAmoebaHarmonicBondParameters( FILE* filePtr, MapStringInt& forceM ...@@ -771,8 +762,10 @@ static int readAmoebaHarmonicBondParameters( FILE* filePtr, MapStringInt& forceM
double k = atof( lineTokens[tokenIndex++].c_str() ); double k = atof( lineTokens[tokenIndex++].c_str() );
bondForce->addBond( particle1, particle2, length, k ); bondForce->addBond( particle1, particle2, length, k );
} else { } else {
(void) fprintf( log, "%s AmoebaHarmonicBondForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaHarmonicBondForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -911,7 +904,6 @@ static int readAmoebaHarmonicAngleParameters( FILE* filePtr, MapStringInt& force ...@@ -911,7 +904,6 @@ static int readAmoebaHarmonicAngleParameters( FILE* filePtr, MapStringInt& force
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no angles number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no angles number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaHarmonicAngleForce* angleForce = new AmoebaHarmonicAngleForce(); AmoebaHarmonicAngleForce* angleForce = new AmoebaHarmonicAngleForce();
...@@ -943,8 +935,10 @@ static int readAmoebaHarmonicAngleParameters( FILE* filePtr, MapStringInt& force ...@@ -943,8 +935,10 @@ static int readAmoebaHarmonicAngleParameters( FILE* filePtr, MapStringInt& force
double k = atof( lineTokens[tokenIndex++].c_str() ); double k = atof( lineTokens[tokenIndex++].c_str() );
angleForce->addAngle( particle1, particle2, particle3, angle, k ); angleForce->addAngle( particle1, particle2, particle3, angle, k );
} else { } else {
(void) fprintf( log, "%s AmoebaHarmonicAngleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaHarmonicAngleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1052,7 +1046,6 @@ static int readAmoebaHarmonicInPlaneAngleParameters( FILE* filePtr, MapStringInt ...@@ -1052,7 +1046,6 @@ static int readAmoebaHarmonicInPlaneAngleParameters( FILE* filePtr, MapStringInt
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no angles number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no angles number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaHarmonicInPlaneAngleForce* angleForce = new AmoebaHarmonicInPlaneAngleForce(); AmoebaHarmonicInPlaneAngleForce* angleForce = new AmoebaHarmonicInPlaneAngleForce();
...@@ -1084,8 +1077,10 @@ static int readAmoebaHarmonicInPlaneAngleParameters( FILE* filePtr, MapStringInt ...@@ -1084,8 +1077,10 @@ static int readAmoebaHarmonicInPlaneAngleParameters( FILE* filePtr, MapStringInt
double k = atof( lineTokens[tokenIndex++].c_str() ); double k = atof( lineTokens[tokenIndex++].c_str() );
angleForce->addAngle( particle1, particle2, particle3, particle4, angle, k ); angleForce->addAngle( particle1, particle2, particle3, particle4, angle, k );
} else { } else {
(void) fprintf( log, "%s AmoebaHarmonicInPlaneAngleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaHarmonicInPlaneAngleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1194,7 +1189,6 @@ static int readAmoebaTorsionParameters( FILE* filePtr, MapStringInt& forceMap, c ...@@ -1194,7 +1189,6 @@ static int readAmoebaTorsionParameters( FILE* filePtr, MapStringInt& forceMap, c
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no torsions number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no torsions number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaTorsionForce* torsionForce = new AmoebaTorsionForce(); AmoebaTorsionForce* torsionForce = new AmoebaTorsionForce();
...@@ -1244,8 +1238,10 @@ static int readAmoebaTorsionParameters( FILE* filePtr, MapStringInt& forceMap, c ...@@ -1244,8 +1238,10 @@ static int readAmoebaTorsionParameters( FILE* filePtr, MapStringInt& forceMap, c
torsionForce->addTorsion( particle1, particle2, particle3, particle4, torsion1, torsion2, torsion3 ); torsionForce->addTorsion( particle1, particle2, particle3, particle4, torsion1, torsion2, torsion3 );
} else { } else {
(void) fprintf( log, "%s AmoebaTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1325,7 +1321,6 @@ static int readAmoebaPiTorsionParameters( FILE* filePtr, MapStringInt& forceMap, ...@@ -1325,7 +1321,6 @@ static int readAmoebaPiTorsionParameters( FILE* filePtr, MapStringInt& forceMap,
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no pi torsions number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no pi torsions number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaPiTorsionForce* piTorsionForce = new AmoebaPiTorsionForce(); AmoebaPiTorsionForce* piTorsionForce = new AmoebaPiTorsionForce();
...@@ -1361,8 +1356,10 @@ static int readAmoebaPiTorsionParameters( FILE* filePtr, MapStringInt& forceMap, ...@@ -1361,8 +1356,10 @@ static int readAmoebaPiTorsionParameters( FILE* filePtr, MapStringInt& forceMap,
piTorsionForce->addPiTorsion( particle1, particle2, particle3, particle4, particle5, particle6, k ); piTorsionForce->addPiTorsion( particle1, particle2, particle3, particle4, particle5, particle6, k );
} else { } else {
(void) fprintf( log, "%s AmoebaPiTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaPiTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1437,7 +1434,6 @@ static int readAmoebaStretchBendParameters( FILE* filePtr, MapStringInt& forceMa ...@@ -1437,7 +1434,6 @@ static int readAmoebaStretchBendParameters( FILE* filePtr, MapStringInt& forceMa
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no stretchBends number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no stretchBends number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -1474,8 +1470,10 @@ static int readAmoebaStretchBendParameters( FILE* filePtr, MapStringInt& forceMa ...@@ -1474,8 +1470,10 @@ static int readAmoebaStretchBendParameters( FILE* filePtr, MapStringInt& forceMa
double k = atof( lineTokens[tokenIndex++].c_str() ); double k = atof( lineTokens[tokenIndex++].c_str() );
stretchBendForce->addStretchBend( particle1, particle2, particle3, lengthAB, lengthCB, angle, k ); stretchBendForce->addStretchBend( particle1, particle2, particle3, lengthAB, lengthCB, angle, k );
} else { } else {
(void) fprintf( log, "%s AmoebaStretchBendForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaStretchBendForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1551,7 +1549,6 @@ static int readAmoebaOutOfPlaneBendParameters( FILE* filePtr, MapStringInt& forc ...@@ -1551,7 +1549,6 @@ static int readAmoebaOutOfPlaneBendParameters( FILE* filePtr, MapStringInt& forc
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no outOfPlaneBends number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no outOfPlaneBends number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -1587,8 +1584,10 @@ static int readAmoebaOutOfPlaneBendParameters( FILE* filePtr, MapStringInt& forc ...@@ -1587,8 +1584,10 @@ static int readAmoebaOutOfPlaneBendParameters( FILE* filePtr, MapStringInt& forc
double k = atof( lineTokens[tokenIndex++].c_str() ); double k = atof( lineTokens[tokenIndex++].c_str() );
outOfPlaneBendForce->addOutOfPlaneBend( particle1, particle2, particle3, particle4, k ); outOfPlaneBendForce->addOutOfPlaneBend( particle1, particle2, particle3, particle4, k );
} else { } else {
(void) fprintf( log, "%s AmoebaOutOfPlaneBendForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaOutOfPlaneBendForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1730,8 +1729,10 @@ static int readAmoebaTorsionTorsionGrid( FILE* filePtr, int numX, int numY, Tors ...@@ -1730,8 +1729,10 @@ static int readAmoebaTorsionTorsionGrid( FILE* filePtr, int numX, int numY, Tors
} }
grid[xIndex][yIndex] = values; grid[xIndex][yIndex] = values;
} else { } else {
(void) fprintf( log, "%s grid tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s grid tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1822,7 +1823,6 @@ static int readAmoebaTorsionTorsionParameters( FILE* filePtr, MapStringInt& forc ...@@ -1822,7 +1823,6 @@ static int readAmoebaTorsionTorsionParameters( FILE* filePtr, MapStringInt& forc
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no torsionTorsions number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no torsionTorsions number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -1860,8 +1860,10 @@ static int readAmoebaTorsionTorsionParameters( FILE* filePtr, MapStringInt& forc ...@@ -1860,8 +1860,10 @@ static int readAmoebaTorsionTorsionParameters( FILE* filePtr, MapStringInt& forc
int gridIndex = atoi( lineTokens[tokenIndex++].c_str() ); int gridIndex = atoi( lineTokens[tokenIndex++].c_str() );
torsionTorsionForce->addTorsionTorsion( particle1, particle2, particle3, particle4, particle5, chiralAtomIndex, gridIndex ); torsionTorsionForce->addTorsionTorsion( particle1, particle2, particle3, particle4, particle5, chiralAtomIndex, gridIndex );
} else { } else {
(void) fprintf( log, "%s AmoebaTorsionTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaTorsionTorsionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -1954,7 +1956,6 @@ static int readAmoebaUreyBradleyParameters( FILE* filePtr, MapStringInt& forceMa ...@@ -1954,7 +1956,6 @@ static int readAmoebaUreyBradleyParameters( FILE* filePtr, MapStringInt& forceMa
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no UB parameter number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no UB parameter number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaUreyBradleyForce* ubForce = new AmoebaUreyBradleyForce(); AmoebaUreyBradleyForce* ubForce = new AmoebaUreyBradleyForce();
...@@ -1987,8 +1988,10 @@ static int readAmoebaUreyBradleyParameters( FILE* filePtr, MapStringInt& forceMa ...@@ -1987,8 +1988,10 @@ static int readAmoebaUreyBradleyParameters( FILE* filePtr, MapStringInt& forceMa
(void) fprintf( log, "%s AmoebaUreyBradleyForce %9d %8d [%8d %8d] %12.4f %12.4f\n", methodName.c_str(), *lineCount, index, particle1, particle2, length, k); (void) fprintf( log, "%s AmoebaUreyBradleyForce %9d %8d [%8d %8d] %12.4f %12.4f\n", methodName.c_str(), *lineCount, index, particle1, particle2, length, k);
(void) fflush( log ); (void) fflush( log );
} else { } else {
(void) fprintf( log, "%s AmoebaUreyBradleyForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaUreyBradleyForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -2153,7 +2156,6 @@ static int readAmoebaMultipoleParameters( FILE* filePtr, int version, MapStringI ...@@ -2153,7 +2156,6 @@ static int readAmoebaMultipoleParameters( FILE* filePtr, int version, MapStringI
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no multipoles number entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no multipoles number entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -2266,9 +2268,11 @@ static int readAmoebaMultipoleParameters( FILE* filePtr, int version, MapStringI ...@@ -2266,9 +2268,11 @@ static int readAmoebaMultipoleParameters( FILE* filePtr, int version, MapStringI
quadrupole[8] = atof( lineTokens[tokenIndex++].c_str() ); quadrupole[8] = atof( lineTokens[tokenIndex++].c_str() );
multipoleForce->addParticle( charge, dipole, quadrupole, axisType, zAxis, xAxis, yAxis, tholeDamp, pdamp, polarity ); multipoleForce->addParticle( charge, dipole, quadrupole, axisType, zAxis, xAxis, yAxis, tholeDamp, pdamp, polarity );
} else { } else {
(void) fprintf( log, "%s AmoebaMultipoleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
(void) sprintf( buffer, "%s AmoebaMultipoleForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
(void) fflush( log ); (void) fflush( log );
exit(-1); throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -2493,7 +2497,6 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt& ...@@ -2493,7 +2497,6 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt&
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no GK terms entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no GK terms entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
AmoebaGeneralizedKirkwoodForce* gbsaObcForce = new AmoebaGeneralizedKirkwoodForce(); AmoebaGeneralizedKirkwoodForce* gbsaObcForce = new AmoebaGeneralizedKirkwoodForce();
...@@ -2526,7 +2529,6 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt& ...@@ -2526,7 +2529,6 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt&
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s GK force tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s GK force tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -2548,13 +2550,11 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt& ...@@ -2548,13 +2550,11 @@ static int readAmoebaGeneralizedKirkwoodParameters( FILE* filePtr, MapStringInt&
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s read past GK block at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s read past GK block at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} else { } else {
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s invalid token count at line=%d?\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s invalid token count at line=%d?\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -2674,7 +2674,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo ...@@ -2674,7 +2674,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no vdw entries???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no vdw entries???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -2711,8 +2710,10 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo ...@@ -2711,8 +2710,10 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo
double reduction = atof( lineTokens[tokenIndex++].c_str() ); double reduction = atof( lineTokens[tokenIndex++].c_str() );
vdwForce->addParticle( indexIV, indexClass, sigma, epsilon, reduction ); vdwForce->addParticle( indexIV, indexClass, sigma, epsilon, reduction );
} else { } else {
(void) fprintf( log, "%s AmoebaVdwForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaVdwForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -2735,7 +2736,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo ...@@ -2735,7 +2736,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo
(void) sprintf( buffer, "Vdw scaling factors different from assummed values [0.0 0.0 1.0 1.0] [%12.5e %12.5e %12.5e %12.5e]\n", (void) sprintf( buffer, "Vdw scaling factors different from assummed values [0.0 0.0 1.0 1.0] [%12.5e %12.5e %12.5e %12.5e]\n",
scale2, scale3, scale4, scale5 ); scale2, scale3, scale4, scale5 );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -2772,8 +2772,10 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo ...@@ -2772,8 +2772,10 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo
} }
vdwForce->setParticleExclusions( ii, exclusions ); vdwForce->setParticleExclusions( ii, exclusions );
} else { } else {
(void) fprintf( log, "%s AmoebaVdwForce exclusion tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaVdwForce exclusion tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
} }
...@@ -2793,7 +2795,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo ...@@ -2793,7 +2795,6 @@ static int readAmoebaVdwParameters( FILE* filePtr, int version, MapStringInt& fo
(void) sprintf( buffer, "Vdw hal values different from assummed values [0.07 0.12 ] [%12.5e %12.5e]\n", (void) sprintf( buffer, "Vdw hal values different from assummed values [0.07 0.12 ] [%12.5e %12.5e]\n",
hal1, hal2 ); hal1, hal2 );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -2895,7 +2896,6 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force ...@@ -2895,7 +2896,6 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no wca entries???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no wca entries???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// create force // create force
...@@ -2936,8 +2936,10 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force ...@@ -2936,8 +2936,10 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force
} }
} else { } else {
(void) fprintf( log, "%s AmoebaWcaDispersionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); char buffer[1024];
exit(-1); (void) sprintf( buffer, "%s AmoebaWcaDispersionForce tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
} }
...@@ -2972,13 +2974,11 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force ...@@ -2972,13 +2974,11 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s read past WcaDispersion block at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s read past WcaDispersion block at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} else { } else {
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s invalid token count at line=%d?\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s invalid token count at line=%d?\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -3091,7 +3091,10 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force ...@@ -3091,7 +3091,10 @@ static int readAmoebaWcaDispersionParameters( FILE* filePtr, MapStringInt& force
} }
} }
if( errors ){ if( errors ){
exit(-1); char buffer[1024];
(void) sprintf( buffer, "%s encountered %d errors in maxDispEnergy\n", methodName.c_str(), errors );
(void) fprintf( log, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} else { } else {
(void) fprintf( log, "No errors detected in maxDispEnergy!\n" ); (void) fprintf( log, "No errors detected in maxDispEnergy!\n" );
} }
...@@ -3130,7 +3133,6 @@ static int readConstraints( FILE* filePtr, const StringVector& tokens, System& s ...@@ -3130,7 +3133,6 @@ static int readConstraints( FILE* filePtr, const StringVector& tokens, System& s
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no constraints terms entry???\n", methodName.c_str() ); (void) sprintf( buffer, "%s no constraints terms entry???\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
setIntFromMap( inputArgumentMap, "applyConstraints", applyConstraints); setIntFromMap( inputArgumentMap, "applyConstraints", applyConstraints);
...@@ -3158,7 +3160,6 @@ static int readConstraints( FILE* filePtr, const StringVector& tokens, System& s ...@@ -3158,7 +3160,6 @@ static int readConstraints( FILE* filePtr, const StringVector& tokens, System& s
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s constraint tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s constraint tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -3221,7 +3222,6 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy ...@@ -3221,7 +3222,6 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s integrator name missing?\n", methodName.c_str() ); (void) sprintf( buffer, "%s integrator name missing?\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
std::string integratorName = tokens[1]; std::string integratorName = tokens[1];
...@@ -3244,9 +3244,11 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy ...@@ -3244,9 +3244,11 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy
} else if( integratorName == "BrownianIntegrator" ){ } else if( integratorName == "BrownianIntegrator" ){
readLines = 5; readLines = 5;
} else { } else {
(void) fprintf( log, "%s integrator=%s not recognized.\n", methodName.c_str(), integratorName.c_str() ); char buffer[1024];
(void) sprintf( buffer, "%s integrator=%s not recognized.\n", methodName.c_str(), integratorName.c_str() );
(void) fprintf( log, "%s", buffer );
(void) fflush( log ); (void) fflush( log );
exit(-1); throwException(__FILE__, __LINE__, buffer );
} }
// read in parameters // read in parameters
...@@ -3275,15 +3277,16 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy ...@@ -3275,15 +3277,16 @@ static Integrator* readIntegrator( FILE* filePtr, const StringVector& tokens, Sy
} else if( lineTokens[0] == "RandomNumberSeed" ){ } else if( lineTokens[0] == "RandomNumberSeed" ){
randomNumberSeed = atoi( lineTokens[1].c_str() ); randomNumberSeed = atoi( lineTokens[1].c_str() );
} else { } else {
(void) fprintf( log, "%s integrator field=%s not recognized.\n", methodName.c_str(), lineTokens[0].c_str() ); char buffer[1024];
(void) sprintf( buffer, "%s integrator field=%s not recognized.\n", methodName.c_str(), lineTokens[0].c_str() );
(void) fprintf( log, "%s", buffer );
(void) fflush( log ); (void) fflush( log );
exit(-1); throwException(__FILE__, __LINE__, buffer );
} }
} else { } else {
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s integrator parameters incomplete at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s integrator parameters incomplete at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -3359,7 +3362,6 @@ static int readVec3( FILE* filePtr, const StringVector& tokens, std::vector<Vec3 ...@@ -3359,7 +3362,6 @@ static int readVec3( FILE* filePtr, const StringVector& tokens, std::vector<Vec3
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s no entries?\n", methodName.c_str() ); (void) sprintf( buffer, "%s no entries?\n", methodName.c_str() );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
int numberOfCoordinates= atoi( tokens[1].c_str() ); int numberOfCoordinates= atoi( tokens[1].c_str() );
...@@ -3380,7 +3382,6 @@ static int readVec3( FILE* filePtr, const StringVector& tokens, std::vector<Vec3 ...@@ -3380,7 +3382,6 @@ static int readVec3( FILE* filePtr, const StringVector& tokens, std::vector<Vec3
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s coordinates tokens incomplete at line=%d\n", methodName.c_str(), *lineCount ); (void) sprintf( buffer, "%s coordinates tokens incomplete at line=%d\n", methodName.c_str(), *lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
...@@ -3945,7 +3946,6 @@ Integrator* readAmoebaParameterFile( const std::string& inputParameterFile, MapS ...@@ -3945,7 +3946,6 @@ Integrator* readAmoebaParameterFile( const std::string& inputParameterFile, MapS
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "Field=<%s> not recognized at line=%d.\n", field.c_str(), lineCount ); (void) sprintf( buffer, "Field=<%s> not recognized at line=%d.\n", field.c_str(), lineCount );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
} }
} }
...@@ -4682,9 +4682,10 @@ void checkIntermediateStatesUsingAmoebaTinkerParameterFile( const std::string& a ...@@ -4682,9 +4682,10 @@ void checkIntermediateStatesUsingAmoebaTinkerParameterFile( const std::string& a
StringVectorVector fileContents; StringVectorVector fileContents;
if( readFile( statesFileName, fileContents, log ) ){ if( readFile( statesFileName, fileContents, log ) ){
(void) fprintf( stderr, "%s: File %s not read.\n", methodName.c_str(), statesFileName.c_str() ); char buffer[1024];
(void) fflush( stderr ); (void) sprintf( buffer, "%s: File %s not read.\n", methodName.c_str(), statesFileName.c_str() );
exit(-1); (void) fprintf( stderr, "%s", buffer );
throwException(__FILE__, __LINE__, buffer );
} }
unsigned int lineIndex = 0; unsigned int lineIndex = 0;
unsigned int stateIndex = 0; unsigned int stateIndex = 0;
...@@ -5961,7 +5962,6 @@ void testEnergyConservation( std::string parameterFileName, MapStringInt& forceM ...@@ -5961,7 +5962,6 @@ void testEnergyConservation( std::string parameterFileName, MapStringInt& forceM
char buffer[1024]; char buffer[1024];
(void) sprintf( buffer, "%s nans detected at time %12.3f -- aborting.\n", methodName.c_str(), currentTime ); (void) sprintf( buffer, "%s nans detected at time %12.3f -- aborting.\n", methodName.c_str(), currentTime );
throwException(__FILE__, __LINE__, buffer ); throwException(__FILE__, __LINE__, buffer );
exit(-1);
} }
// check constraints // check constraints
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment