LAMMPS + MinGW64 + Win7 + MATLAB + Gnumex By R.L. Carino (carino@cavs.msstate.edu) A. Download software 1. MinGW, download installer from http://sourceforge.net/projects/mingw/?source=directory. Install gcc, g++, gfortran and MSYS. We do not use the compilers (these are 32-bit), but we need MSYS for a Unix-like compilation environment. Install to C:\Mingw. Add C:\MinGW\msys\1.0\bin to PATH environment variable. 2. MinGW-w64 and its update (install to C:\MinGW64, add C:\MinGW64\bin to PATH environment variable). I used the following version (other versions might work, but I did not test). (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/sezero_4.5_20111101/mingw-w64-bin_x86_64-mingw_20111101_sezero.zip/download) (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/sezero_4.5_20111101/sezero_20111101-w64-update-rev.5747.zip/download) (http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/sezero_4.5_20111101/README-mingw-w64-20111101_sezero.txt/download) 3. LAMMPS from http://lammps.sandia.gov/download.html (place in C:\lammps-9Dec-14) 4. MATLAB R2014a (Windows 64-bit) download from http://www.its.msstate.edu/software/downloads/. Install to default location. 5. Gnumex 2.06 from http://sourceforge.net/projects/gnumex/files/ (place in C:\Gnumex) B. Compile LAMMPS 1. Unset read-only permissions on C:\lammps-9Dec14\ 2. Copy attached Makefile.mingw64 to C:\lammps-9Dec14\src\STUBS\ 3. Copy attached Makefile.gfortran_w64 to C:\lammps-9Dec14\lib\meam\ 4. Copy attached Makefile.serial_w64 to C:\lammps-9Dec14\src\MAKE\MINE\ 5. Run MSYS as Administrator. In Windows explorer, navigate to C:\MinGW\msys\1.0, right-click msys.bat, then Run as administrator. This opens a command line window. Make sure that PATH is set correctly. On the command line, $ g++ -v should return Using built-in specs. COLLECT_GCC=c:\MinGW64\bin\g++.exe COLLECT_LTO_WRAPPER=c:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.5.4/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc45-svn/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --enabl e-checking=release --prefix=/mingw64 --with-sysroot=/mingw64 --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --enable-libgomp --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --disable-nls --disable-win32-registry Thread model: win32 gcc version 4.5.4 20111030 (prerelease) [svn/rev.180676 - mingw-w64/oz] (GCC) If not, add C:\MinGW64\bin\ to the PATH environment variable. Restart MSYS as administrator. 6. Compile meam.lib. On MSYS command line, cd /c/lammps-9Dec14/lib/meam make -f Makefile.gfortran_w64 7. Compile mpi_stubs.lib. On MSYS command line, cd /c/lammps-9Dec14/src/STUBS make -f Makefile.mingw64 8. Compile LAMMPS executable. On MSYS command line, cd /c/lammps-9Dec14/src make clean-serial_w64 make yes-meam make serial_w64 9. Compile static LAMMPS library. On MSYS command line, cd /c/lammps-9Dec14/src make makelib make -f Makefile.lib serial_w64 (If make complains about write permissions on some file or directory, unset the Read-only flag for those files/directories, then re-run last make) 10. Test the LAMMPS executable cd /c/lammps-9Dec14/examples/meam ../../src/lmp_serial_w64 < in.meam C. Configure MATLAB with Gnumex 1. Run MATLAB 2. Create work directory for LAMMPS-MinGW64. On the MATLAB prompt, >> mkdir LAMMPS-MinGW64 3. Setup Gnumex. On the MATLAB prompt, Open C:\Gnumex\gnumex.m Run gnumex.m (Add C:\Gnumex to path) Use the following settings on the Gnumex GUI: MinGW root directory, navigate to C:\MinGW64 Path to gfortran, (empty) Path to Gnumex utilities, navigate to C:\Gnumex Environment / linking type, select MinGW Language for compilation, select C / C++ Optimization level, select -O3 Generate mex or engine exe?, select Mex Add stub, select No Path for libraries and .def files, navigate to the LAMMPS-MinGW64 directory created above Mex options file to create, navigate to the LAMMPS-MinGW64 directory created above Click 'Make options file', wait (If Gnumex warns about not being able to write files to some MATLAB directories, follow the workarounds) Exit Gnumex GUI 4. Copy the following files to the LAMMPS-MinGW64 directory created above C:\lammps-9Dec14\lib\meam\meam.lib C:\lammps-9Dec14\src\STUBS\mpi_stubs.lib C:\lammps-9Dec14\src\liblammps_serial_w64.a.lib lammps_*.c gateway functions (from Kip Barret) lammps_MPC.m (from Kip Barret) lammps_setup_MinGW64.m (attached; from Kip Barrett, modified) test_run_lammps_MPC.m (attached; from Kip Barrett, modified) library.meam (attached) Al-example.parameter.meam (attached) 5. In MATLAB, change directory to the LAMMPS-MinGW64 directory created above >> mex -v setup (Answer 'n' (No) to "Would you like mex to locate installed compilers [y]/n?" (Answer 'gcc' to "Select a compiler:" (Verify that "Location: C:\MinGW64\bin") (Answer 'y' to "Are these correct [y]/n?") >> lammps_setup_MinGW64 6. Test the *.mexw64 >> test_run_lammps_MPC