Page MenuHomec4science

notes.2
No OneTemporary

File Metadata

Created
Tue, Oct 8, 06:24
This is instruction for the modification of LAMMPS for MS Windows
LAMMPS version: Feb 2007
compiled without MPI and FFT in Viusal C++ 6.0
(All packages except for XTC, MEAM appear to work.)
-------------------
1. Create an empty workspace (Win32 console), add all .h and .cpp
files into the project.
2. At about 80 places in the code, variables are redefined. Most of
these variables are loop counters, which can be easily fixed.
Code looks like this:
for (int i=0; i<5; i++) {
something;
}
for (int i=0; i<5; i++) {
something else;
}
This is ok with g++ compiler. But VC thinks the i is redefined in the
second loop. So the variable scope is different. This happens many times
in the code. It can be fixed easily based on the compiling error.
3. At the beginning of fft3d.h, added:
#ifndef FFT_NONE
#define FFT_NONE
#endif
4. In input.cpp, changed the two header files
//#include "unistd.h"
#include "direct.h"
4A. (added by Tim Lau, MIT, ttl@mit.edu)
In variable.cpp, change the header files
//#include "unistd.h"
#include "sleep.h"
Add in the included sleep.h and sleep.cpp files.
4B. (added by Tim Lau, MIT, ttl@mit.edu)
In shell.cpp, change the header file:
//#include "unistd.h"
#include "direct.h"
Change the line in shell.cpp:
mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP);
to:
mkdir(arg[i]);
since Windows obviously does not use UNIX file permissions.
It's also possible that the line has to be changed to:
_mkdir(arg[i]);
depending on the version of the Visual C++ compiler used.
5. Added mpi.h and mpi.cpp (in STUBS folder) to the workspace
In mpi.cpp, commented the time.h header file
//#include <sys/time.h>
commented the original code in MPI_Wtime(), just make it return 0;
6. In system.cpp, two changes due to difference in the input argument
list
Line 83: int iarg = 2;
Line 172: inflag=1; //add this line
The number of input arguments (nargs) is different in g++ and VC when
you give arguments to run a program. This might be related to MPI as
well. The difference is one. Once the above changes are made, the
program is taking the correct argument.
However, it has been observed in the latest versions of sytem.cpp that
no modification needs be made to the file as distributed from the
LAMMPS website to work. The user however, instead of starting LAMMPS
by the command:
lammps in.file
as he would if he implemented the changes detailed here, would launch
in the Unix style:
lammps < in.file
7. The new version LAMMPS calls the error function:
double erfc(double)
This function is in the GNU C library. However, it's not found for
VC++.
Three options:
a. One can try to find erfc() from other libraries.
b. The erfc() is called for pair_modify table option. One can set
the table option to be 0 to avoid calling this function.
c. Write your own functions.
In this code, two files erfc.h, erfc.cpp are created and added to the project.
Files that call erfc() all add
#include "erfc.h" at the beginning.
Note: the functions are not fully tested, use with caution.
8. MSVC does not have a inttypes.h file. The simplest way
to deal with this problem is to download inttypes.h from the
following site:
http://www.koders.com/c/fidDE7D6EFFD475FAB1B7F6A2BBA791401CFA88FFA3.aspx
and add this file into the workspace.
9. MSVC does not have dirent.h. The problem is solved by downloading
a version of it for Windows from the following website:
http://www.softagalleria.net/dirent/index.en.html
10. Every time an error pops up for a line like this:
char *words[params_per_line];
replace to the following type:
char **words = new char*[params_per_line];
The dynamic memory allocation in MSVC requires a line like this.
11. Build the project. Specify appropriate input file to run the code.
The Windows result might be different from Unix results. Be Cautious.

Event Timeline