git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14072 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -20,8 +20,8 @@ make mode=shlib machine
|
||||
to create the static library liblammps_machine.a or the shared library
|
||||
liblammps_machine.so for your code to link against. A soft link
|
||||
(liblammps.a or liblammps.so) is also created that points to the most
|
||||
recently built static or shared library. Your code can simply use the
|
||||
soft link if you prefer.
|
||||
recently built static or shared library. Your code build can simply
|
||||
use the soft link if you prefer.
|
||||
|
||||
The library interface to LAMMPS is in src/library.cpp. Routines can
|
||||
be easily added to this file so an external program can perform the
|
||||
|
||||
@ -11,36 +11,29 @@ simple.f90 is the Fortran driver
|
||||
libfwrapper.c is the Fortran-to-C wrapper
|
||||
|
||||
The 3 codes do the same thing, so you can compare them to see how to
|
||||
drive LAMMPS in this manner. The C driver is similar in spirit to what
|
||||
one could use to write a scripting language interface. See
|
||||
python/examples/simple.py for an example of using Python as a wrapper
|
||||
in that way. The Fortran driver in addition requires a wrapper
|
||||
library that interfaces the C interface of the LAMMPS library to
|
||||
Fortran and also translates the MPI communicator from Fortran to C.
|
||||
drive LAMMPS from each language. See lammps/python/example/simple.py
|
||||
to do something similar from Python. The Fortran driver requires an
|
||||
additional wrapper library that interfaces the C interface of the
|
||||
LAMMPS library to Fortran and also translates the MPI communicator
|
||||
from Fortran to C.
|
||||
|
||||
First, you must build LAMMPS as a library, either static or shared.
|
||||
See http://lammps.sandia.gov/doc/Section_start.html#start_5 for
|
||||
details. To build it as a static library type this from
|
||||
the src directory:
|
||||
|
||||
make makelib
|
||||
make -f Makefile.lib g++
|
||||
|
||||
You can then build either driver code with a compile lines like these,
|
||||
which include paths to the LAMMPS library interface, MPI, and FFTW
|
||||
(assuming you built LAMMPS as a library with its PPPM solver).
|
||||
Once you have built LAMMPS as a library (see examples/COUPLE/README),
|
||||
you can then build any of the driver codes with compile lines like
|
||||
these, which include paths to the LAMMPS library interface, MPI (an
|
||||
installed MPICH in this case), and FFTW (assuming you built LAMMPS as
|
||||
a library with its PPPM solver).
|
||||
|
||||
This builds the C++ driver with the LAMMPS library using a C++ compiler:
|
||||
|
||||
g++ -I/home/sjplimp/lammps/src -c simple.cpp
|
||||
g++ -L/home/sjplimp/lammps/src simple.o \
|
||||
-llammps_g++ -lfftw -lmpich -lmpl -lpthread -o simpleCC
|
||||
-llammps -lfftw -lmpich -lmpl -lpthread -o simpleCC
|
||||
|
||||
This builds the C driver with the LAMMPS library using a C compiler:
|
||||
|
||||
gcc -I/home/sjplimp/lammps/src -c simple.c
|
||||
gcc -L/home/sjplimp/lammps/src simple.o \
|
||||
-llammps_g++ -lfftw -lmpich -lmpl -lpthread -lstdc++ -o simpleC
|
||||
-llammps -lfftw -lmpich -lmpl -lpthread -lstdc++ -o simpleC
|
||||
|
||||
This builds the Fortran wrapper and driver with the LAMMPS library
|
||||
using a Fortran and C compiler, using the wrapper in the fortran
|
||||
@ -50,12 +43,12 @@ cp ../fortran/libfwrapper.c .
|
||||
gcc -I/home/sjplimp/lammps/src -c libfwrapper.c
|
||||
gfortran -I/home/sjplimp/lammps/src -c simple.f90
|
||||
gfortran -L/home/sjplimp/lammps/src simple.o libfwrapper.o \
|
||||
-llammps_g++ -lfftw -lfmpich -lmpich -lpthread -lstdc++ -o simpleF
|
||||
-llammps -lfftw -lfmpich -lmpich -lpthread -lstdc++ -o simpleF
|
||||
|
||||
You then run simpleCC, simpleC, or simpleF on a parallel machine
|
||||
on some number of processors Q with 2 arguments:
|
||||
|
||||
mpirun -np Q simpleCC P in.lj
|
||||
% mpirun -np Q simpleCC P in.lj
|
||||
|
||||
P is the number of procs you want LAMMPS to run on (must be <= Q) and
|
||||
in.lj is a LAMMPS input script.
|
||||
@ -80,8 +73,8 @@ extend the wrapper if desired.
|
||||
|
||||
The C++ driver does the same thing, except that it instantiates LAMMPS
|
||||
as an object first. Some of the functions in src/library.cpp can be
|
||||
invoked directly as methods within appropriate LAMMPS classes, which
|
||||
is what the driver does. Any public LAMMPS class method could be
|
||||
called from the driver this way. However the get/put functions are
|
||||
only implemented in src/library.cpp, so the C++ driver calls them as
|
||||
C-style functions.
|
||||
by-passed and invoked directly as methods within appropriate LAMMPS
|
||||
classes, which is what the driver does. Any public LAMMPS class
|
||||
method could be called from the driver this way. However the get/put
|
||||
functions are only implemented in src/library.cpp, so the C++ driver
|
||||
calls them as C-style functions.
|
||||
|
||||
Reference in New Issue
Block a user