TestNormalModeLangevin.cpp 1.37 KB
Newer Older
1
2
3
#include "OpenMM.h"
#include <vector>
#include <string>
4
#include <iostream>
5
#include <cstdlib>
6
7
8
9

using namespace OpenMM;
using namespace std;

10
11
12
13
14
15
16
17
18
19
void mysetenv(const char* name, const char* value) {
#ifdef _MSC_VER
    char buffer[1000];
    sprintf(buffer, "%s=%s", name, value);
    putenv(buffer);
#else
    setenv(name, value, 1);
#endif
}

20
21
void testLoadNMLPlugin() 
{
22
23
24
    string pluginDir = Platform::getDefaultPluginsDirectory();
    cout << "Default plugins directory = " << pluginDir << endl;
    Platform::loadPluginsFromDirectory(pluginDir);
25
    vector<string> kernelName;
26
    kernelName.push_back("IntegrateNMLStep");
27
    // Was NormalModeLangevin plugin loaded?
28
    cout << "Searching for kernel IntegrateNMLStep = " << pluginDir << endl;
29
    Platform& platform = Platform::findPlatform(kernelName); // throws if no platform with kernel
30
31
}

32
int main(int argc, const char* argv[]) 
33
{
34
35
    try 
    {
36
37
38
39
40
41
42
        if (argc > 1) {
            const char* plugin_dir = argv[1];
            // 0 => don't set if variable exists
            mysetenv("OPENMM_PLUGIN_DIR", plugin_dir);
            cout << plugin_dir << endl;
            cout << getenv("OPENMM_PLUGIN_DIR") << endl;
        }
43
44
45
46
        testLoadNMLPlugin();
        cout << "tests passed" << endl;
        return 0;
    } 
47
    catch (const std::exception& exc) 
48
    {
49
        cout << "FAILED: " << exc.what() << endl;
50
51
        return 1;
    }
52
}
53