"platforms/hip/tests/TestHipNonbondedForce.cpp" did not exist on "c456dd54e130151bafe3d5f635ca135ab0c018db"
Commit c5329db5 authored by Michael Sherman's avatar Michael Sherman
Browse files

Fixed some portability problems that show up in

- MingW, where "WIN32" is set by CMake but the compiler is not Microsoft's (should use _MSC_VER) in that case, and 
- in gcc 4.4 which is fussy about some issues that earlier versions were silent about, such as passing a string constant to a "char*" rather than a "const char*".
I also fixed a syntax error in CMakeLists that showed up in the OpenMM workshop for some unknown reason.

Brook is not currently building correctly; I think it has not yet been fully converted to the getTime() interface needed for variable step integrators.
parent 3749e84b
......@@ -46,7 +46,7 @@ FOREACH(EX_ROOT ${CPP_EXAMPLES})
INSTALL(FILES ${EX_ROOT}.cpp DESTINATION examples)
ENDFOREACH(EX_PROG ${CPP_EXAMPLES})
ENDFOREACH(EX_ROOT ${CPP_EXAMPLES})
FOREACH(EX_ROOT ${C_EXAMPLES})
IF (BUILD_TESTING_SHARED)
......@@ -71,11 +71,11 @@ FOREACH(EX_ROOT ${C_EXAMPLES})
INSTALL(FILES ${EX_ROOT}.c DESTINATION examples)
ENDFOREACH(EX_PROG ${C_EXAMPLES})
ENDFOREACH(EX_ROOT ${C_EXAMPLES})
FOREACH(EX_ROOT ${F_EXAMPLES})
INSTALL(FILES ${EX_ROOT}.f90 DESTINATION examples)
ENDFOREACH(EX_PROG ${F_EXAMPLES})
ENDFOREACH(EX_ROOT ${F_EXAMPLES})
INSTALL(FILES ${OpenMM_CWRAPPER}.h ${OpenMM_CWRAPPER}.cpp DESTINATION examples)
INSTALL(FILES ${OpenMM_FMODULE}.f90 DESTINATION examples)
......
......@@ -17,6 +17,7 @@
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
// -----------------------------------------------------------------------------
// MOCK MD CODE
......
......@@ -34,7 +34,8 @@
#include "openmm/OpenMMException.h"
#include "openmm/kernels.h"
#include <vector>
#include <math.h>
#include <cmath>
#include <cstdio>
using namespace OpenMM;
using std::vector;
......
......@@ -250,5 +250,5 @@ void BrookIntegrateLangevinStepKernel::execute( OpenMMContextImpl& context, cons
_brookLangevinDynamics->update( *(_openMMBrookInterface.getParticlePositions()), *(_openMMBrookInterface.getParticleVelocities()),
*(_openMMBrookInterface.getParticleForces()), *_brookShakeAlgorithm, *_brookRandomNumberGenerator );
_openMMBrookInterface->setTime(_openMMBrookInterface->getTime(integrator.getStepSize()));
_openMMBrookInterface.setTime(_openMMBrookInterface.getTime(integrator.getStepSize()));
}
......@@ -202,5 +202,5 @@ void BrookIntegrateVerletStepKernel::execute( OpenMMContextImpl& context, const
_brookVerletDynamics->update( *(_openMMBrookInterface.getParticlePositions()), *(_openMMBrookInterface.getParticleVelocities()),
*(_openMMBrookInterface.getParticleForces()), *_brookShakeAlgorithm );
_openMMBrookInterface->setTime(_openMMBrookInterface->getTime(stepSize));
_openMMBrookInterface.setTime(_openMMBrookInterface.getTime(stepSize));
}
......@@ -428,9 +428,9 @@ void gpuSetEwaldParameters(gpuContext gpu)//, float alphaEwald, int kmax )
{
// hard coded alphaEwald and kmax, no interface yet
float alpha = 3.123413;
float alpha = 3.123413f;
float PI = 3.14159265358979323846f;
float TWO_PI = 2.0 * PI;
float TWO_PI = 2.0f * PI;
gpu->sim.recipBoxSizeX = TWO_PI / gpu->sim.periodicBoxSizeX ;
gpu->sim.recipBoxSizeY = TWO_PI / gpu->sim.periodicBoxSizeY ;
......@@ -728,7 +728,7 @@ void gpuSetConstraintParameters(gpuContext gpu, const vector<int>& atom1, const
// Compute the constraint coupling matrix
vector<vector<int> > atomAngles(gpu->natoms);
for (int i = 0; i < gpu->sim.bond_angles; i++)
for (int i = 0; i < (int)gpu->sim.bond_angles; i++)
atomAngles[(*gpu->psBondAngleID1)[i].y].push_back(i);
vector<vector<pair<int, double> > > matrix(numCCMA);
if (numCCMA > 0) {
......@@ -853,8 +853,8 @@ void gpuSetConstraintParameters(gpuContext gpu, const vector<int>& atom1, const
vector<int> inverseOrder(numCCMA);
for (int i = 0; i < numCCMA; ++i)
inverseOrder[constraintOrder[i]] = i;
for (int i = 0; i < matrix.size(); ++i)
for (int j = 0; j < matrix[i].size(); ++j)
for (int i = 0; i < (int)matrix.size(); ++i)
for (int j = 0; j < (int)matrix[i].size(); ++j)
matrix[i][j].first = inverseOrder[matrix[i][j].first];
// Fill in the CUDA streams.
......@@ -902,7 +902,7 @@ void gpuSetConstraintParameters(gpuContext gpu, const vector<int>& atom1, const
(*psCcmaReducedMass)[i] = 0.5f/(invMass1[c]+invMass2[c]);
for (unsigned int j = 0; j < matrix[index].size(); j++) {
(*psConstraintMatrixColumn)[i+j*numCCMA] = matrix[index][j].first;
(*psConstraintMatrixValue)[i+j*numCCMA] = matrix[index][j].second;
(*psConstraintMatrixValue)[i+j*numCCMA] = (float)matrix[index][j].second;
}
(*psConstraintMatrixColumn)[i+matrix[index].size()*numCCMA] = numCCMA;
}
......
......@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <cstring>
#include <sstream>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
......@@ -30,6 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceBrownianDynamics.h"
#include <cstdio>
/**---------------------------------------------------------------------------------------
ReferenceBrownianDynamics constructor
......@@ -266,7 +268,7 @@ int ReferenceBrownianDynamics::writeState( int numberOfAtoms, RealOpenMM** atomC
// open file -- return if unsuccessful
FILE* stateFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &stateFile, stateFileName.str().c_str(), "w" );
#else
stateFile = fopen( stateFileName.str().c_str(), "w" );
......
......@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <cstring>
#include <sstream>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
......@@ -30,6 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceDynamics.h"
#include <cstdio>
const int ReferenceDynamics::DefaultReturn = 0;
const int ReferenceDynamics::ErrorReturn = -1;
......@@ -656,7 +658,7 @@ int ReferenceDynamics::writeState( int numberOfAtoms, RealOpenMM** atomCoordinat
// open file -- return if unsuccessful
FILE* stateFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &stateFile, stateFileName.str().c_str(), "w" );
#else
stateFile = fopen( stateFileName.str().c_str(), "w" );
......
......@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <cstring>
#include <sstream>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
......@@ -30,6 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceForce.h"
#include <cstdio>
/**---------------------------------------------------------------------------------------
ReferenceForce constructor
......@@ -208,7 +210,7 @@ int ReferenceForce::writeForces( int numberOfAtoms, int atomsPerBond,
// open file -- return if unsuccessful
FILE* resultsFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &resultsFile, resultsFileName.c_str(), "w" );
#else
resultsFile = fopen( resultsFileName.c_str(), "w" );
......
......@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <cstring>
#include <sstream>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
......@@ -30,6 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceStochasticDynamics.h"
#include <cstdio>
/**---------------------------------------------------------------------------------------
ReferenceStochasticDynamics constructor
......@@ -626,7 +628,7 @@ int ReferenceStochasticDynamics::writeState( int numberOfAtoms, RealOpenMM** ato
// open file -- return if unsuccessful
FILE* stateFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &stateFile, stateFileName.str().c_str(), "w" );
#else
stateFile = fopen( stateFileName.str().c_str(), "w" );
......
......@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <string.h>
#include <cstring>
#include <sstream>
#include "../SimTKUtilities/SimTKOpenMMCommon.h"
......@@ -30,6 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "ReferenceVerletDynamics.h"
#include <cstdio>
/**---------------------------------------------------------------------------------------
ReferenceVerletDynamics constructor
......@@ -233,7 +235,7 @@ int ReferenceVerletDynamics::writeState( int numberOfAtoms, RealOpenMM** atomCoo
// open file -- return if unsuccessful
FILE* stateFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &stateFile, stateFileName.str().c_str(), "w" );
#else
stateFile = fopen( stateFileName.str().c_str(), "w" );
......
......@@ -30,7 +30,8 @@
// fabs(), ...
#include <math.h>
#include <cmath>
#include <cstdio>
uint32_t SimTKOpenMMUtilities::_randomNumberSeed = 0;
bool SimTKOpenMMUtilities::_randomInitialized = false;
......@@ -320,7 +321,7 @@ FILE* SimTKOpenMMUtilities::writeDebugFile( int numberOfFields, const RealOpenMM
// open file
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &debugFile, debugFileName, "w" );
#else
debugFile = fopen( debugFileName, "w" );
......@@ -800,7 +801,7 @@ void SimTKOpenMMUtilities::matrixCrossProductMatrix3( RealOpenMM* matrixX,
--------------------------------------------------------------------------------------- */
void* SimTKOpenMMUtilities::Xmalloc( const char* name, char* fileName, int line, unsigned int size ){
void* SimTKOpenMMUtilities::Xmalloc( const char* name, const char* fileName, int line, unsigned int size ){
// ---------------------------------------------------------------------------------------
......@@ -827,7 +828,7 @@ void* SimTKOpenMMUtilities::Xmalloc( const char* name, char* fileName, int line,
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::Xfree( const char* name, char* fileName, int line, void* ptr ){
void SimTKOpenMMUtilities::Xfree( const char* name, const char* fileName, int line, void* ptr ){
// ---------------------------------------------------------------------------------------
......@@ -1017,7 +1018,7 @@ int SimTKOpenMMUtilities::readFileIntoStringVector( const std::string& fileName,
// open file
FILE* file = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &file, fileName.c_str(), "r" );
#else
file = fopen( fileName.c_str(), "r" );
......@@ -1167,7 +1168,7 @@ int SimTKOpenMMUtilities::tokenizeString( const std::string& line, StringVector&
lineBuffer = (char*) malloc( bufferSz*sizeof( char ) );
}
#ifdef WIN32
#ifdef _MSC_VER
(void) sprintf_s( lineBuffer, bufferSz, "%s", line.c_str() );
#else
(void) sprintf( lineBuffer, "%s", line.c_str() );
......@@ -1280,7 +1281,7 @@ int SimTKOpenMMUtilities::writeFile( const StringVector& lineVector, const std::
// open file
FILE* file = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &file, fileName.c_str(), "w" );
#else
file = fopen( fileName.c_str(), "w" );
......
......@@ -386,7 +386,7 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
--------------------------------------------------------------------------------------- */
static void* Xmalloc( const char* name, char* fileName, int line, unsigned int size );
static void* Xmalloc( const char* name, const char* fileName, int line, unsigned int size );
/* ---------------------------------------------------------------------------------------
......@@ -399,7 +399,7 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
--------------------------------------------------------------------------------------- */
static void Xfree( const char* name, char* fileName, int line, void* ptr );
static void Xfree( const char* name, const char* fileName, int line, void* ptr );
/* ---------------------------------------------------------------------------------------
......
......@@ -27,6 +27,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "CpuImplicitSolvent.h"
#include <cstdio>
//#define UseGromacsMalloc 1
// Replacement new/delete w/ Gromac's smalloc() and sfree()
......@@ -862,7 +864,7 @@ int CpuImplicitSolvent::writeBornEnergyForces( RealOpenMM** atomCoordinates,
// open file -- return if unsuccessful
FILE* implicitSolventResultsFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &implicitSolventResultsFile, resultsFileName.c_str(), "w" );
#else
implicitSolventResultsFile = fopen( resultsFileName.c_str(), "w" );
......@@ -1023,7 +1025,7 @@ int CpuImplicitSolvent::readInfoFile( const std::string infoFileName ){
// ---------------------------------------------------------------------------------------
FILE* infoFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &infoFile, infoFileName.c_str(), "r" );
#else
infoFile = fopen( infoFileName.c_str(), "r" );
......@@ -1031,7 +1033,7 @@ int CpuImplicitSolvent::readInfoFile( const std::string infoFileName ){
if( infoFile == NULL ){
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &infoFile, _defaultInfoFileName.c_str(), "r" );
#else
infoFile = fopen( _defaultInfoFileName.c_str(), "r" );
......
......@@ -30,7 +30,8 @@
#include "../SimTKUtilities/SimTKOpenMMUtilities.h"
#include "CpuObc.h"
#include "../SimTKReference/ReferenceForce.h"
#include <math.h>
#include <cmath>
#include <cstdio>
/**---------------------------------------------------------------------------------------
......@@ -694,7 +695,7 @@ int CpuObc::writeBornEnergyForces( RealOpenMM** atomCoordinates,
// open file -- return if unsuccessful
FILE* implicitSolventResultsFile = NULL;
#ifdef WIN32
#ifdef _MSC_VER
fopen_s( &implicitSolventResultsFile, resultsFileName.c_str(), "w" );
#else
implicitSolventResultsFile = fopen( resultsFileName.c_str(), "w" );
......
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