| 1 | 
gezelter | 
1652 | 
Compiling OpenMD | 
| 2 | 
  | 
  | 
 | 
| 3 | 
  | 
  | 
  OpenMD is written in C++. Compiling is the process of turning this | 
| 4 | 
gezelter | 
1655 | 
  C++ into instructions that the computer’s processor can understand. | 
| 5 | 
gezelter | 
1652 | 
 | 
| 6 | 
  | 
  | 
Requirements | 
| 7 | 
  | 
  | 
 | 
| 8 | 
  | 
  | 
  To build OpenMD, you need the following: | 
| 9 | 
  | 
  | 
 | 
| 10 | 
  | 
  | 
   * The source code for the latest release of OpenMD | 
| 11 | 
gezelter | 
1840 | 
   * A C++ compiler | 
| 12 | 
gezelter | 
1652 | 
   * CMake 2.6 or newer | 
| 13 | 
  | 
  | 
 | 
| 14 | 
  | 
  | 
  OpenMD uses CMake as its build system. CMake is an open source | 
| 15 | 
  | 
  | 
  cross-platform build system from KitWare. | 
| 16 | 
  | 
  | 
 | 
| 17 | 
  | 
  | 
  You need to install CMake 2.6 or newer. This is available as a | 
| 18 | 
  | 
  | 
  binary package from the KitWare website; alternatively, it may be | 
| 19 | 
  | 
  | 
  available through your package manager (on Linux). If necessary, you | 
| 20 | 
  | 
  | 
  can also compile it yourself from the source code. | 
| 21 | 
  | 
  | 
 | 
| 22 | 
  | 
  | 
  The following are optional when compiling OpenMD, but if they are not | 
| 23 | 
  | 
  | 
  available some features will be missing: | 
| 24 | 
  | 
  | 
 | 
| 25 | 
  | 
  | 
   * OpenMPI – A very good implementation of the MPI-2 specification | 
| 26 | 
  | 
  | 
     for parallel computing.  A version of the MPI library is required | 
| 27 | 
  | 
  | 
     if you want to run the multi-processor version of OpenMD | 
| 28 | 
  | 
  | 
 | 
| 29 | 
  | 
  | 
   * perl and python - interpreted scripting languages that some of | 
| 30 | 
  | 
  | 
     the OpenMD utilities use to parse and process data files. | 
| 31 | 
  | 
  | 
 | 
| 32 | 
  | 
  | 
   * qhull – A computational geometry toolbox for computing convex | 
| 33 | 
  | 
  | 
     hulls and Delaunay triangulations.  qhull is required for the | 
| 34 | 
  | 
  | 
     LangevinHull integrator and for any of the tools that compute the | 
| 35 | 
  | 
  | 
     Hull atoms or hull volumes of nanoparticles and clusters. | 
| 36 | 
  | 
  | 
 | 
| 37 | 
  | 
  | 
   * openbabel – a chemical toolbox for converting between different | 
| 38 | 
  | 
  | 
     data formats.  This is required for building the atom2md program | 
| 39 | 
  | 
  | 
     which helps prepare initial "metadata" or md files for | 
| 40 | 
  | 
  | 
     simulations. | 
| 41 | 
  | 
  | 
 | 
| 42 | 
  | 
  | 
   * fftw - a library for computing discrete Fourier transforms.  This | 
| 43 | 
  | 
  | 
     is required for surface undulation spectra (Hxy in | 
| 44 | 
  | 
  | 
     staticProps). Get version 3. | 
| 45 | 
  | 
  | 
 | 
| 46 | 
  | 
  | 
   * zlib - required to support reading gzipped trajectory files | 
| 47 | 
  | 
  | 
 | 
| 48 | 
  | 
  | 
  You’ll also likely want to download and compile the following useful | 
| 49 | 
  | 
  | 
  tools for interacting with the data: | 
| 50 | 
  | 
  | 
 | 
| 51 | 
  | 
  | 
   * Jmol | 
| 52 | 
  | 
  | 
   * xmgr | 
| 53 | 
  | 
  | 
   * grace | 
| 54 | 
  | 
  | 
   * NumPy | 
| 55 | 
  | 
  | 
   * vmd | 
| 56 | 
  | 
  | 
 | 
| 57 | 
  | 
  | 
  If you are going to be extending or developing OpenMD, you’ll need | 
| 58 | 
  | 
  | 
  the following tools: | 
| 59 | 
  | 
  | 
 | 
| 60 | 
  | 
  | 
   * antlr – our tool for parsing meta-data files.  You’ll want | 
| 61 | 
  | 
  | 
     version 2, not 3.   | 
| 62 | 
  | 
  | 
 | 
| 63 | 
  | 
  | 
   * gengetopt - a tool to generate C code to parse the command line | 
| 64 | 
  | 
  | 
     arguments argc and argv that are part of every C or C++ program | 
| 65 | 
  | 
  | 
 | 
| 66 | 
  | 
  | 
 | 
| 67 | 
  | 
  | 
Basic build procedure | 
| 68 | 
  | 
  | 
 | 
| 69 | 
  | 
  | 
  The recommended way to build OpenMD is to use a separate source and | 
| 70 | 
  | 
  | 
  build directory; for example, openmd-2.0 and build. The first step | 
| 71 | 
  | 
  | 
  is to create these directories: | 
| 72 | 
  | 
  | 
 | 
| 73 | 
  | 
  | 
  $ tar zxf openmd-2.0.tar.gz   # (this creates openmd-2.0) | 
| 74 | 
  | 
  | 
  $ mkdir build | 
| 75 | 
  | 
  | 
 | 
| 76 | 
  | 
  | 
  Now you need to run cmake to configure the build. The following will | 
| 77 | 
  | 
  | 
  configure the build to use all of the default options: | 
| 78 | 
  | 
  | 
 | 
| 79 | 
  | 
  | 
  $ cd build | 
| 80 | 
  | 
  | 
  $ cmake ../openmd-2.0 | 
| 81 | 
  | 
  | 
 | 
| 82 | 
  | 
  | 
  If you need to specify a particular compiler, you can do that with | 
| 83 | 
  | 
  | 
  environment variables before the cmake line | 
| 84 | 
  | 
  | 
 | 
| 85 | 
  | 
  | 
  $ export CC=/opt/local/lib/openmpi/bin/mpicc | 
| 86 | 
  | 
  | 
  $ export CXX=/opt/local/lib/openmpi/bin/mpic++ | 
| 87 | 
  | 
  | 
  $ cmake ../openmd-2.0 | 
| 88 | 
  | 
  | 
 | 
| 89 | 
  | 
  | 
  If you need to specify an option, use the -D switch to cmake. For | 
| 90 | 
  | 
  | 
  example, the following line sets the value of CMAKE_INSTALL_PREFIX | 
| 91 | 
  | 
  | 
  and CMAKE_BUILD_TYPE: | 
| 92 | 
  | 
  | 
 | 
| 93 | 
  | 
  | 
  $ cmake ../openmd-2.0 -DCMAKE_INSTALL_PREFIX=~/Tools -DCMAKE_BUILD_TYPE=DEBUG | 
| 94 | 
  | 
  | 
 | 
| 95 | 
  | 
  | 
  We will discuss various possible options later. | 
| 96 | 
  | 
  | 
 | 
| 97 | 
  | 
  | 
  At this point, it would be a good idea to compile OpenMD: | 
| 98 | 
  | 
  | 
 | 
| 99 | 
  | 
  | 
  $ make | 
| 100 | 
  | 
  | 
 | 
| 101 | 
  | 
  | 
  Have a coffee while the magic happens. If you have a multi-processor | 
| 102 | 
  | 
  | 
  machine and would prefer an espresso, try a parallel build instead: | 
| 103 | 
  | 
  | 
 | 
| 104 | 
  | 
  | 
  $ make -j4    # parallel build across 4 processors | 
| 105 | 
  | 
  | 
 | 
| 106 | 
  | 
  | 
  And finally, as root (or using sudo) you should install it: | 
| 107 | 
  | 
  | 
 | 
| 108 | 
  | 
  | 
  # make install | 
| 109 | 
  | 
  | 
 | 
| 110 | 
  | 
  | 
 | 
| 111 | 
  | 
  | 
Local build | 
| 112 | 
  | 
  | 
 | 
| 113 | 
  | 
  | 
  With the right sort of environment variable magic (see below), you | 
| 114 | 
  | 
  | 
  can actually use OpenMD straight from the build folder. But life is | 
| 115 | 
  | 
  | 
  a bit easier if you install it somewhere, either system-wide or | 
| 116 | 
  | 
  | 
  locally. | 
| 117 | 
  | 
  | 
 | 
| 118 | 
  | 
  | 
  By default, OpenMD is installed in /usr/local on a Unix-like | 
| 119 | 
  | 
  | 
  system. This requires root access (or sudo). Even if you do have | 
| 120 | 
  | 
  | 
  root access, you may not want to overwrite an existing installation | 
| 121 | 
  | 
  | 
  or you may want to avoid conflicts with a version of OpenMD | 
| 122 | 
  | 
  | 
  installed by your package manager. | 
| 123 | 
  | 
  | 
 | 
| 124 | 
  | 
  | 
  The solution to all of these problems is to do a local install into | 
| 125 | 
  | 
  | 
  a directory somewhere in your home folder. An additional advantage | 
| 126 | 
  | 
  | 
  of a local install is that if you ever want to uninstall it, all you | 
| 127 | 
  | 
  | 
  need to do is delete the installation directory; removing the files | 
| 128 | 
  | 
  | 
  from a global install is more work. | 
| 129 | 
  | 
  | 
 | 
| 130 | 
  | 
  | 
  To configure cmake to install into ~/Tools/openmd-install, for | 
| 131 | 
  | 
  | 
  example, you would do the following: | 
| 132 | 
  | 
  | 
 | 
| 133 | 
  | 
  | 
  $ cmake ../openmd-2.0 -DCMAKE_INSTALL_PREFIX=~/Tools/openmd-install | 
| 134 | 
  | 
  | 
 | 
| 135 | 
  | 
  | 
  Then you can run make and make install without needing root access: | 
| 136 | 
  | 
  | 
 | 
| 137 | 
  | 
  | 
  $ make && make install | 
| 138 | 
  | 
  | 
 | 
| 139 | 
  | 
  | 
 | 
| 140 | 
  | 
  | 
Troubleshooting build problems | 
| 141 | 
  | 
  | 
 | 
| 142 | 
  | 
  | 
  * CMake caches some variables from run-to-run. How can I wipe the | 
| 143 | 
  | 
  | 
    cache to start from scratch? | 
| 144 | 
  | 
  | 
 | 
| 145 | 
  | 
  | 
    Delete CMakeCache.txt in the build directory. This is also a very | 
| 146 | 
  | 
  | 
    useful file to look into if you have any problems. | 
| 147 | 
  | 
  | 
 | 
| 148 | 
  | 
  | 
  * What environment variables affect how OpenMD finds force field and | 
| 149 | 
  | 
  | 
    data files? | 
| 150 | 
  | 
  | 
 | 
| 151 | 
  | 
  | 
    FORCE_PARAM_PATH - Used to find the location of the data files | 
| 152 | 
  | 
  | 
                       used for force fields and atom sizes, etc. | 
| 153 | 
  | 
  | 
 | 
| 154 | 
  | 
  | 
    If you get errors about not being able to find some .txt files, | 
| 155 | 
  | 
  | 
    then you should set this to the name of the folder containing | 
| 156 | 
  | 
  | 
    files such as Amber.frc and element.txt. These are typically | 
| 157 | 
  | 
  | 
    installed to /usr/local/openmd/forceFields | 
| 158 | 
  | 
  | 
 | 
| 159 | 
  | 
  | 
Advanced build options  | 
| 160 | 
  | 
  | 
 | 
| 161 | 
  | 
  | 
  * How do I do a debug build? | 
| 162 | 
  | 
  | 
 | 
| 163 | 
  | 
  | 
    -DCMAKE_BUILD_TYPE=Debug does a debug build (gcc -g). To revert to | 
| 164 | 
  | 
  | 
     a regular build use -DCMAKE_BUILD_TYPE=Release. | 
| 165 | 
  | 
  | 
 | 
| 166 | 
  | 
  | 
  * How do I see what commands cmake is using to build? | 
| 167 | 
  | 
  | 
 | 
| 168 | 
  | 
  | 
    Run Make as follows: | 
| 169 | 
  | 
  | 
 | 
| 170 | 
  | 
  | 
    $ VERBOSE=1 make | 
| 171 | 
  | 
  | 
 | 
| 172 | 
  | 
  | 
  * How do I build the Doxygen documentation? | 
| 173 | 
  | 
  | 
 | 
| 174 | 
  | 
  | 
    If CMake found the "doxygen" program in your PATH, an optional | 
| 175 | 
  | 
  | 
    build target called "doc" is created.  If the Doxygen executable | 
| 176 | 
  | 
  | 
    was not on the PATH, you will need to specify its location with | 
| 177 | 
  | 
  | 
    -DDOXYGEN_EXECUTABLE=wherever.  To build the documentation, type: | 
| 178 | 
  | 
  | 
 | 
| 179 | 
  | 
  | 
    $ make doc |