Merge branch 'master' into lammps-icms
This commit is contained in:
@ -58,12 +58,13 @@ operations within LAMMPS, such as running a simulation for a
|
|||||||
reasonable number of timesteps, then the overhead cost of invoking
|
reasonable number of timesteps, then the overhead cost of invoking
|
||||||
LAMMPS thru Python will be negligible.
|
LAMMPS thru Python will be negligible.
|
||||||
</P>
|
</P>
|
||||||
<P>Before using LAMMPS from a Python script, you have to do two things.
|
<P>Before using LAMMPS from a Python script, you need to do two things.
|
||||||
You need to set two environment variables. And you need to build
|
You need to build LAMMPS as a dynamic shared library, so it can be
|
||||||
LAMMPS as a dynamic shared library, so it can be loaded by Python.
|
loaded by Python. And you need to tell Python how to find the library
|
||||||
Both these steps are discussed below. If you wish to run LAMMPS in
|
and the Python wrapper file python/lammps.py. Both these steps are
|
||||||
parallel from Python, you also need to extend your Python with MPI.
|
discussed below. If you wish to run LAMMPS in parallel from Python,
|
||||||
This is also discussed below.
|
you also need to extend your Python with MPI. This is also discussed
|
||||||
|
below.
|
||||||
</P>
|
</P>
|
||||||
<P>The Python wrapper for LAMMPS uses the amazing and magical (to me)
|
<P>The Python wrapper for LAMMPS uses the amazing and magical (to me)
|
||||||
"ctypes" package in Python, which auto-generates the interface code
|
"ctypes" package in Python, which auto-generates the interface code
|
||||||
@ -131,7 +132,7 @@ python/lammps.py file.
|
|||||||
</P>
|
</P>
|
||||||
<P>You can invoke install.py from the python directory as
|
<P>You can invoke install.py from the python directory as
|
||||||
</P>
|
</P>
|
||||||
<PRE>% python install.py <B>libdir</B> <B>pydir</B>
|
<PRE>% python install.py [libdir] [pydir]
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>The optional libdir is where to copy the LAMMPS shared library to; the
|
<P>The optional libdir is where to copy the LAMMPS shared library to; the
|
||||||
default is /usr/local/lib. The optional pydir is where to copy the
|
default is /usr/local/lib. The optional pydir is where to copy the
|
||||||
@ -146,12 +147,12 @@ non-standard locations, such as within your own user space, you will
|
|||||||
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
|
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
|
||||||
accordingly, as above.
|
accordingly, as above.
|
||||||
</P>
|
</P>
|
||||||
<P>If the instally.py script does not allow you to copy files into system
|
<P>If the install.py script does not allow you to copy files into system
|
||||||
directories, prefix the python command with "sudo". If you do this,
|
directories, prefix the python command with "sudo". If you do this,
|
||||||
make sure that the Python that root runs is the same as the Python you
|
make sure that the Python that root runs is the same as the Python you
|
||||||
run. E.g. you may need to do something like
|
run. E.g. you may need to do something like
|
||||||
</P>
|
</P>
|
||||||
<PRE>% sudo /usr/local/bin/python install.py <B>libdir</B> <B>pydir</B>
|
<PRE>% sudo /usr/local/bin/python install.py [libdir] [pydir]
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>You can also invoke install.py from the make command in the src
|
<P>You can also invoke install.py from the make command in the src
|
||||||
directory as
|
directory as
|
||||||
@ -269,20 +270,27 @@ and type:
|
|||||||
<PRE>>>> from lammps import lammps
|
<PRE>>>> from lammps import lammps
|
||||||
>>> lmp = lammps()
|
>>> lmp = lammps()
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>If you get no errors, you're ready to use LAMMPS from Python.
|
<P>If you get no errors, you're ready to use LAMMPS from Python. If the
|
||||||
If the load fails, the most common error to see is
|
2nd command fails, the most common error to see is
|
||||||
</P>
|
</P>
|
||||||
<PRE>OSError: Could not load LAMMPS dynamic library
|
<PRE>OSError: Could not load LAMMPS dynamic library
|
||||||
</PRE>
|
</PRE>
|
||||||
<P>which means Python was unable to load the LAMMPS shared library. This
|
<P>which means Python was unable to load the LAMMPS shared library. This
|
||||||
typically occurs if the system can't find the LAMMMPS shared library
|
typically occurs if the system can't find the LAMMPS shared library or
|
||||||
or one of the auxiliary shared libraries it depends on.
|
one of the auxiliary shared libraries it depends on, or if something
|
||||||
|
about the library is incompatible with your Python. The error message
|
||||||
|
should give you an indication of what went wrong.
|
||||||
</P>
|
</P>
|
||||||
<P>Python (actually the operating system) isn't verbose about telling you
|
<P>You can also test the load directly in Python as follows, without
|
||||||
why the load failed, so carefully go through the steps above regarding
|
first importing from the lammps.py file:
|
||||||
environment variables, and the instructions in <A HREF = "Section_start.html#start_5">Section_start
|
</P>
|
||||||
5</A> about building a shared library and
|
<PRE>>>> from ctypes import CDLL
|
||||||
about setting the LD_LIBRARY_PATH envirornment variable.
|
>>> CDLL("liblammps.so")
|
||||||
|
</PRE>
|
||||||
|
<P>If an error occurs, carefully go thru the steps in <A HREF = "Section_start.html#start_5">Section_start
|
||||||
|
5</A> and above about building a shared
|
||||||
|
library and about insuring Python can find the necessary two files
|
||||||
|
it needs.
|
||||||
</P>
|
</P>
|
||||||
<H5><B>Test LAMMPS and Python in serial:</B>
|
<H5><B>Test LAMMPS and Python in serial:</B>
|
||||||
</H5>
|
</H5>
|
||||||
|
|||||||
@ -55,12 +55,13 @@ operations within LAMMPS, such as running a simulation for a
|
|||||||
reasonable number of timesteps, then the overhead cost of invoking
|
reasonable number of timesteps, then the overhead cost of invoking
|
||||||
LAMMPS thru Python will be negligible.
|
LAMMPS thru Python will be negligible.
|
||||||
|
|
||||||
Before using LAMMPS from a Python script, you have to do two things.
|
Before using LAMMPS from a Python script, you need to do two things.
|
||||||
You need to set two environment variables. And you need to build
|
You need to build LAMMPS as a dynamic shared library, so it can be
|
||||||
LAMMPS as a dynamic shared library, so it can be loaded by Python.
|
loaded by Python. And you need to tell Python how to find the library
|
||||||
Both these steps are discussed below. If you wish to run LAMMPS in
|
and the Python wrapper file python/lammps.py. Both these steps are
|
||||||
parallel from Python, you also need to extend your Python with MPI.
|
discussed below. If you wish to run LAMMPS in parallel from Python,
|
||||||
This is also discussed below.
|
you also need to extend your Python with MPI. This is also discussed
|
||||||
|
below.
|
||||||
|
|
||||||
The Python wrapper for LAMMPS uses the amazing and magical (to me)
|
The Python wrapper for LAMMPS uses the amazing and magical (to me)
|
||||||
"ctypes" package in Python, which auto-generates the interface code
|
"ctypes" package in Python, which auto-generates the interface code
|
||||||
@ -127,7 +128,7 @@ python/lammps.py file.
|
|||||||
|
|
||||||
You can invoke install.py from the python directory as
|
You can invoke install.py from the python directory as
|
||||||
|
|
||||||
% python install.py [libdir] [pydir] :pre
|
% python install.py \[libdir\] \[pydir\] :pre
|
||||||
|
|
||||||
The optional libdir is where to copy the LAMMPS shared library to; the
|
The optional libdir is where to copy the LAMMPS shared library to; the
|
||||||
default is /usr/local/lib. The optional pydir is where to copy the
|
default is /usr/local/lib. The optional pydir is where to copy the
|
||||||
@ -142,12 +143,12 @@ non-standard locations, such as within your own user space, you will
|
|||||||
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
|
need to set your PYTHONPATH and LD_LIBRARY_PATH environment variables
|
||||||
accordingly, as above.
|
accordingly, as above.
|
||||||
|
|
||||||
If the instally.py script does not allow you to copy files into system
|
If the install.py script does not allow you to copy files into system
|
||||||
directories, prefix the python command with "sudo". If you do this,
|
directories, prefix the python command with "sudo". If you do this,
|
||||||
make sure that the Python that root runs is the same as the Python you
|
make sure that the Python that root runs is the same as the Python you
|
||||||
run. E.g. you may need to do something like
|
run. E.g. you may need to do something like
|
||||||
|
|
||||||
% sudo /usr/local/bin/python install.py [libdir] [pydir] :pre
|
% sudo /usr/local/bin/python install.py \[libdir\] \[pydir\] :pre
|
||||||
|
|
||||||
You can also invoke install.py from the make command in the src
|
You can also invoke install.py from the make command in the src
|
||||||
directory as
|
directory as
|
||||||
@ -265,20 +266,27 @@ and type:
|
|||||||
>>> from lammps import lammps
|
>>> from lammps import lammps
|
||||||
>>> lmp = lammps() :pre
|
>>> lmp = lammps() :pre
|
||||||
|
|
||||||
If you get no errors, you're ready to use LAMMPS from Python.
|
If you get no errors, you're ready to use LAMMPS from Python. If the
|
||||||
If the load fails, the most common error to see is
|
2nd command fails, the most common error to see is
|
||||||
|
|
||||||
OSError: Could not load LAMMPS dynamic library :pre
|
OSError: Could not load LAMMPS dynamic library :pre
|
||||||
|
|
||||||
which means Python was unable to load the LAMMPS shared library. This
|
which means Python was unable to load the LAMMPS shared library. This
|
||||||
typically occurs if the system can't find the LAMMMPS shared library
|
typically occurs if the system can't find the LAMMPS shared library or
|
||||||
or one of the auxiliary shared libraries it depends on.
|
one of the auxiliary shared libraries it depends on, or if something
|
||||||
|
about the library is incompatible with your Python. The error message
|
||||||
|
should give you an indication of what went wrong.
|
||||||
|
|
||||||
Python (actually the operating system) isn't verbose about telling you
|
You can also test the load directly in Python as follows, without
|
||||||
why the load failed, so carefully go through the steps above regarding
|
first importing from the lammps.py file:
|
||||||
environment variables, and the instructions in "Section_start
|
|
||||||
5"_Section_start.html#start_5 about building a shared library and
|
>>> from ctypes import CDLL
|
||||||
about setting the LD_LIBRARY_PATH envirornment variable.
|
>>> CDLL("liblammps.so") :pre
|
||||||
|
|
||||||
|
If an error occurs, carefully go thru the steps in "Section_start
|
||||||
|
5"_Section_start.html#start_5 and above about building a shared
|
||||||
|
library and about insuring Python can find the necessary two files
|
||||||
|
it needs.
|
||||||
|
|
||||||
[Test LAMMPS and Python in serial:] :h5
|
[Test LAMMPS and Python in serial:] :h5
|
||||||
|
|
||||||
|
|||||||
@ -850,7 +850,7 @@ should be the file /usr/local/lib/libmpich.so.
|
|||||||
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
|
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
|
||||||
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
|
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
|
||||||
the system can find it by default, such as /usr/local/lib, or you may
|
the system can find it by default, such as /usr/local/lib, or you may
|
||||||
wish to add the lammps src directory to LD_LIBRARY_PATH, so that the
|
wish to add the LAMMPS src directory to LD_LIBRARY_PATH, so that the
|
||||||
current version of the shared library is always available to programs
|
current version of the shared library is always available to programs
|
||||||
that use it.
|
that use it.
|
||||||
</P>
|
</P>
|
||||||
|
|||||||
@ -844,7 +844,7 @@ The operating system finds shared libraries to load at run-time using
|
|||||||
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
|
the environment variable LD_LIBRARY_PATH. So you may wish to copy the
|
||||||
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
|
file src/liblammps.so or src/liblammps_g++.so (for example) to a place
|
||||||
the system can find it by default, such as /usr/local/lib, or you may
|
the system can find it by default, such as /usr/local/lib, or you may
|
||||||
wish to add the lammps src directory to LD_LIBRARY_PATH, so that the
|
wish to add the LAMMPS src directory to LD_LIBRARY_PATH, so that the
|
||||||
current version of the shared library is always available to programs
|
current version of the shared library is always available to programs
|
||||||
that use it.
|
that use it.
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include <compute.h>
|
#include <compute.h>
|
||||||
#include <modify.h>
|
#include <modify.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
|||||||
@ -21,12 +21,6 @@
|
|||||||
library.h. All prototypes herein COULD be added to library.h instead of
|
library.h. All prototypes herein COULD be added to library.h instead of
|
||||||
including this as a separate file. See the README for instructions. */
|
including this as a separate file. See the README for instructions. */
|
||||||
|
|
||||||
/* These prototypes probably belong in mpi.h in the src/STUBS directory. */
|
|
||||||
#ifndef OPEN_MPI
|
|
||||||
#define MPI_Comm_f2c(a) a
|
|
||||||
#define MPI_Fint int
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -38,7 +32,7 @@ int lammps_extract_compute_vectorsize (void*, char*, int);
|
|||||||
void lammps_extract_compute_arraysize (void*, char*, int, int*, int*);
|
void lammps_extract_compute_arraysize (void*, char*, int, int*, int*);
|
||||||
int lammps_extract_fix_vectorsize (void*, char*, int);
|
int lammps_extract_fix_vectorsize (void*, char*, int);
|
||||||
void lammps_extract_fix_arraysize (void*, char*, int, int*, int*);
|
void lammps_extract_fix_arraysize (void*, char*, int, int*, int*);
|
||||||
void lammps_error_all (void *ptr, const char*, int, const char*);
|
void lammps_error_all (void*, const char*, int, const char*);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,8 +39,8 @@
|
|||||||
!! subroutine lammps_extract_compute (compute, ptr, id, style, type)
|
!! subroutine lammps_extract_compute (compute, ptr, id, style, type)
|
||||||
!! subroutine lammps_extract_variable (variable, ptr, name, group)
|
!! subroutine lammps_extract_variable (variable, ptr, name, group)
|
||||||
!! function lammps_get_natoms (ptr)
|
!! function lammps_get_natoms (ptr)
|
||||||
!! subroutine lammps_get_coords (ptr, coords)
|
!! subroutine lammps_gather_atoms (ptr, name, count, data)
|
||||||
!! subroutine lammps_put_coords (ptr, coords)
|
!! subroutine lammps_scatter_atoms (ptr, name, data)
|
||||||
|
|
||||||
#define FLERR __FILE__,__LINE__
|
#define FLERR __FILE__,__LINE__
|
||||||
! The above line allows for similar error checking as is done with standard
|
! The above line allows for similar error checking as is done with standard
|
||||||
@ -55,8 +55,9 @@ module LAMMPS
|
|||||||
public :: lammps_open, lammps_open_no_mpi, lammps_close, lammps_file, &
|
public :: lammps_open, lammps_open_no_mpi, lammps_close, lammps_file, &
|
||||||
lammps_command, lammps_free, lammps_extract_global, &
|
lammps_command, lammps_free, lammps_extract_global, &
|
||||||
lammps_extract_atom, lammps_extract_compute, lammps_extract_fix, &
|
lammps_extract_atom, lammps_extract_compute, lammps_extract_fix, &
|
||||||
lammps_extract_variable, lammps_get_natoms, lammps_get_coords, &
|
lammps_extract_variable, lammps_get_natoms, lammps_gather_atoms, &
|
||||||
lammps_put_coords, lammps_instance
|
lammps_scatter_atoms
|
||||||
|
public :: lammps_instance
|
||||||
|
|
||||||
!! Functions supplemental to the prototypes in library.h. {{{1
|
!! Functions supplemental to the prototypes in library.h. {{{1
|
||||||
!! The function definitions (in C++) are contained in LAMMPS-wrapper.cpp.
|
!! The function definitions (in C++) are contained in LAMMPS-wrapper.cpp.
|
||||||
@ -204,18 +205,21 @@ module LAMMPS
|
|||||||
integer (C_int) :: natoms
|
integer (C_int) :: natoms
|
||||||
end function lammps_get_natoms
|
end function lammps_get_natoms
|
||||||
|
|
||||||
subroutine lammps_actual_get_coords (ptr, coords) &
|
subroutine lammps_actual_gather_atoms (ptr, name, type, count, data) &
|
||||||
bind (C, name='lammps_get_coords')
|
bind (C, name='lammps_gather_atoms')
|
||||||
import :: C_ptr
|
import :: C_ptr, C_int, C_char
|
||||||
type (C_ptr), value :: ptr, coords
|
type (C_ptr), value :: ptr, data
|
||||||
end subroutine lammps_actual_get_coords
|
character (kind=C_char), dimension(*) :: name
|
||||||
|
integer (C_int), value :: type, count
|
||||||
|
end subroutine lammps_actual_gather_atoms
|
||||||
|
|
||||||
subroutine lammps_actual_put_coords (ptr, coords) &
|
subroutine lammps_actual_scatter_atoms (ptr, name, type, count, data) &
|
||||||
bind (C, name='lammps_put_coords')
|
bind (C, name='lammps_scatter_atoms')
|
||||||
import :: C_ptr, C_double
|
import :: C_ptr, C_int, C_char
|
||||||
type (C_ptr), value :: ptr
|
type (C_ptr), value :: ptr, data
|
||||||
real (C_double), dimension(*) :: coords
|
character (kind=C_char), dimension(*) :: name
|
||||||
end subroutine lammps_actual_put_coords
|
integer (C_int), value :: type, count
|
||||||
|
end subroutine lammps_actual_scatter_atoms
|
||||||
end interface
|
end interface
|
||||||
|
|
||||||
! Generic functions for the wrappers below {{{1
|
! Generic functions for the wrappers below {{{1
|
||||||
@ -258,6 +262,16 @@ module LAMMPS
|
|||||||
lammps_extract_variable_dpa
|
lammps_extract_variable_dpa
|
||||||
end interface lammps_extract_variable
|
end interface lammps_extract_variable
|
||||||
|
|
||||||
|
interface lammps_gather_atoms
|
||||||
|
module procedure lammps_gather_atoms_ia, lammps_gather_atoms_dpa, &
|
||||||
|
lammps_gather_atoms_ra
|
||||||
|
end interface lammps_gather_atoms
|
||||||
|
|
||||||
|
interface lammps_scatter_atoms
|
||||||
|
module procedure lammps_scatter_atoms_ia, lammps_scatter_atoms_dpa, &
|
||||||
|
lammps_scatter_atoms_ra
|
||||||
|
end interface lammps_scatter_atoms
|
||||||
|
|
||||||
contains !! Wrapper functions local to this module {{{1
|
contains !! Wrapper functions local to this module {{{1
|
||||||
|
|
||||||
subroutine lammps_open (command_line, communicator, ptr)
|
subroutine lammps_open (command_line, communicator, ptr)
|
||||||
@ -374,7 +388,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
integer (C_int), pointer :: Fptr
|
integer (C_int), pointer :: Fptr
|
||||||
integer :: natoms
|
integer :: natoms
|
||||||
natoms = lammps_get_natoms (ptr)
|
natoms = lammps_get_natoms (ptr)
|
||||||
if ( allocated (atom) ) deallocate (atom)
|
|
||||||
allocate (atom(natoms))
|
allocate (atom(natoms))
|
||||||
Cptr = lammps_extract_atom_Cptr (ptr, name)
|
Cptr = lammps_extract_atom_Cptr (ptr, name)
|
||||||
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
||||||
@ -399,7 +412,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
! Everything else we can get is probably nlocal units long
|
! Everything else we can get is probably nlocal units long
|
||||||
call lammps_extract_global_i (nelements, ptr, 'nlocal')
|
call lammps_extract_global_i (nelements, ptr, 'nlocal')
|
||||||
end if
|
end if
|
||||||
if ( allocated (atom) ) deallocate (atom)
|
|
||||||
allocate (atom(nelements))
|
allocate (atom(nelements))
|
||||||
Cptr = lammps_extract_atom_Cptr (ptr, name)
|
Cptr = lammps_extract_atom_Cptr (ptr, name)
|
||||||
if ( name == 'mass' ) then
|
if ( name == 'mass' ) then
|
||||||
@ -417,7 +429,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
character (len=*), intent(in) :: name
|
character (len=*), intent(in) :: name
|
||||||
double precision, dimension(:), allocatable :: d_atom
|
double precision, dimension(:), allocatable :: d_atom
|
||||||
call lammps_extract_atom_dpa (d_atom, ptr, name)
|
call lammps_extract_atom_dpa (d_atom, ptr, name)
|
||||||
if ( allocated (atom) ) deallocate (atom)
|
|
||||||
allocate (atom(size(d_atom)))
|
allocate (atom(size(d_atom)))
|
||||||
atom = real(d_atom)
|
atom = real(d_atom)
|
||||||
deallocate (d_atom)
|
deallocate (d_atom)
|
||||||
@ -428,7 +439,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
character (len=*), intent(in) :: name
|
character (len=*), intent(in) :: name
|
||||||
type (C_ptr) :: Cptr
|
type (C_ptr) :: Cptr
|
||||||
integer :: nelements
|
integer :: nelements
|
||||||
if ( allocated (atom) ) deallocate (atom)
|
|
||||||
if ( name /= 'x' .and. name /= 'v' .and. name /= 'f' ) then
|
if ( name /= 'x' .and. name /= 'v' .and. name /= 'f' ) then
|
||||||
call lammps_error_all (ptr, FLERR, 'You cannot extract ' // name // &
|
call lammps_error_all (ptr, FLERR, 'You cannot extract ' // name // &
|
||||||
' into a rank 2 array.')
|
' into a rank 2 array.')
|
||||||
@ -445,7 +455,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
character (len=*), intent(in) :: name
|
character (len=*), intent(in) :: name
|
||||||
double precision, dimension(:,:), allocatable :: d_atom
|
double precision, dimension(:,:), allocatable :: d_atom
|
||||||
call lammps_extract_atom_dp2a (d_atom, ptr, name)
|
call lammps_extract_atom_dp2a (d_atom, ptr, name)
|
||||||
if ( allocated (atom) ) deallocate (atom)
|
|
||||||
if ( allocated (d_atom) ) then
|
if ( allocated (d_atom) ) then
|
||||||
allocate (atom(size(d_atom,1), size(d_atom,2)))
|
allocate (atom(size(d_atom,1), size(d_atom,2)))
|
||||||
else
|
else
|
||||||
@ -515,7 +524,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
type (C_ptr) :: Cptr
|
type (C_ptr) :: Cptr
|
||||||
real (C_double), dimension(:), pointer :: Fptr
|
real (C_double), dimension(:), pointer :: Fptr
|
||||||
integer :: nelements
|
integer :: nelements
|
||||||
if ( allocated (compute) ) deallocate (compute)
|
|
||||||
! Check for the correct dimensionality
|
! Check for the correct dimensionality
|
||||||
if ( type == 0 ) then
|
if ( type == 0 ) then
|
||||||
call lammps_error_all (ptr, FLERR, 'You cannot extract a compute&
|
call lammps_error_all (ptr, FLERR, 'You cannot extract a compute&
|
||||||
@ -541,7 +549,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
integer, intent(in) :: style, type
|
integer, intent(in) :: style, type
|
||||||
double precision, dimension(:), allocatable :: d_compute
|
double precision, dimension(:), allocatable :: d_compute
|
||||||
call lammps_extract_compute_dpa (d_compute, ptr, id, style, type)
|
call lammps_extract_compute_dpa (d_compute, ptr, id, style, type)
|
||||||
if ( allocated (compute) ) deallocate (compute)
|
|
||||||
allocate (compute(size(d_compute)))
|
allocate (compute(size(d_compute)))
|
||||||
compute = real(d_compute)
|
compute = real(d_compute)
|
||||||
deallocate (d_compute)
|
deallocate (d_compute)
|
||||||
@ -554,7 +561,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
type (C_ptr) :: Cptr
|
type (C_ptr) :: Cptr
|
||||||
real (C_double), dimension(:,:), pointer :: Fptr
|
real (C_double), dimension(:,:), pointer :: Fptr
|
||||||
integer :: nr, nc
|
integer :: nr, nc
|
||||||
if ( allocated (compute) ) deallocate (compute)
|
|
||||||
! Check for the correct dimensionality
|
! Check for the correct dimensionality
|
||||||
if ( type == 0 ) then
|
if ( type == 0 ) then
|
||||||
call lammps_error_all (ptr, FLERR, 'You cannot extract a compute&
|
call lammps_error_all (ptr, FLERR, 'You cannot extract a compute&
|
||||||
@ -580,7 +586,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
integer, intent(in) :: style, type
|
integer, intent(in) :: style, type
|
||||||
double precision, dimension(:,:), allocatable :: d_compute
|
double precision, dimension(:,:), allocatable :: d_compute
|
||||||
call lammps_extract_compute_dp2a (d_compute, ptr, id, style, type)
|
call lammps_extract_compute_dp2a (d_compute, ptr, id, style, type)
|
||||||
if ( allocated (compute) ) deallocate (compute)
|
|
||||||
allocate (compute(size(d_compute,1), size(d_compute,2)))
|
allocate (compute(size(d_compute,1), size(d_compute,2)))
|
||||||
compute = real(d_compute)
|
compute = real(d_compute)
|
||||||
deallocate (d_compute)
|
deallocate (d_compute)
|
||||||
@ -658,7 +663,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
type (C_ptr) :: Cptr
|
type (C_ptr) :: Cptr
|
||||||
real (C_double), dimension(:), pointer :: Fptr
|
real (C_double), dimension(:), pointer :: Fptr
|
||||||
integer :: fix_len
|
integer :: fix_len
|
||||||
if ( allocated (fix) ) deallocate (fix)
|
|
||||||
! Check for the correct dimensionality
|
! Check for the correct dimensionality
|
||||||
if ( style == 0 ) then
|
if ( style == 0 ) then
|
||||||
call lammps_error_all (ptr, FLERR, 'You can''t extract the&
|
call lammps_error_all (ptr, FLERR, 'You can''t extract the&
|
||||||
@ -692,7 +696,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
integer, intent(in) :: style, type, i, j
|
integer, intent(in) :: style, type, i, j
|
||||||
double precision, dimension(:), allocatable :: d_fix
|
double precision, dimension(:), allocatable :: d_fix
|
||||||
call lammps_extract_fix_dpa (d_fix, ptr, id, style, type, i, j)
|
call lammps_extract_fix_dpa (d_fix, ptr, id, style, type, i, j)
|
||||||
if ( allocated (fix) ) deallocate (fix)
|
|
||||||
allocate (fix(size(d_fix)))
|
allocate (fix(size(d_fix)))
|
||||||
fix = real(d_fix)
|
fix = real(d_fix)
|
||||||
deallocate (d_fix)
|
deallocate (d_fix)
|
||||||
@ -705,7 +708,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
type (C_ptr) :: Cptr
|
type (C_ptr) :: Cptr
|
||||||
real (C_double), dimension(:,:), pointer :: Fptr
|
real (C_double), dimension(:,:), pointer :: Fptr
|
||||||
integer :: nr, nc
|
integer :: nr, nc
|
||||||
if ( allocated (fix) ) deallocate (fix)
|
|
||||||
! Check for the correct dimensionality
|
! Check for the correct dimensionality
|
||||||
if ( style == 0 ) then
|
if ( style == 0 ) then
|
||||||
call lammps_error_all (ptr, FLERR, 'It is not possible to extract the&
|
call lammps_error_all (ptr, FLERR, 'It is not possible to extract the&
|
||||||
@ -735,7 +737,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
integer, intent(in) :: style, type, i, j
|
integer, intent(in) :: style, type, i, j
|
||||||
double precision, dimension(:,:), allocatable :: d_fix
|
double precision, dimension(:,:), allocatable :: d_fix
|
||||||
call lammps_extract_fix_dp2a (d_fix, ptr, id, style, type, i, j)
|
call lammps_extract_fix_dp2a (d_fix, ptr, id, style, type, i, j)
|
||||||
if ( allocated (fix) ) deallocate (fix)
|
|
||||||
allocate (fix(size(d_fix,1), size(d_fix,2)))
|
allocate (fix(size(d_fix,1), size(d_fix,2)))
|
||||||
fix = real(d_fix)
|
fix = real(d_fix)
|
||||||
deallocate (d_fix)
|
deallocate (d_fix)
|
||||||
@ -824,7 +825,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
||||||
end if
|
end if
|
||||||
natoms = lammps_get_natoms (ptr)
|
natoms = lammps_get_natoms (ptr)
|
||||||
if ( allocated (variable) ) deallocate (variable)
|
|
||||||
allocate (variable(natoms))
|
allocate (variable(natoms))
|
||||||
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
||||||
variable = Fptr
|
variable = Fptr
|
||||||
@ -845,7 +845,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
||||||
end if
|
end if
|
||||||
natoms = lammps_get_natoms (ptr)
|
natoms = lammps_get_natoms (ptr)
|
||||||
if ( allocated (variable) ) deallocate (variable)
|
|
||||||
allocate (variable(natoms))
|
allocate (variable(natoms))
|
||||||
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
||||||
variable = Fptr
|
variable = Fptr
|
||||||
@ -863,7 +862,6 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
else
|
else
|
||||||
call lammps_extract_variable_dpa (d_var, ptr, name)
|
call lammps_extract_variable_dpa (d_var, ptr, name)
|
||||||
end if
|
end if
|
||||||
if ( allocated (variable) ) deallocate (variable)
|
|
||||||
allocate (variable(size(d_var)))
|
allocate (variable(size(d_var)))
|
||||||
variable = real(d_var)
|
variable = real(d_var)
|
||||||
deallocate (d_var)
|
deallocate (d_var)
|
||||||
@ -871,32 +869,146 @@ contains !! Wrapper functions local to this module {{{1
|
|||||||
|
|
||||||
!-------------------------------------------------------------------------2}}}
|
!-------------------------------------------------------------------------2}}}
|
||||||
|
|
||||||
subroutine lammps_get_coords (ptr, coords)
|
subroutine lammps_gather_atoms_ia (ptr, name, count, data)
|
||||||
type (C_ptr) :: ptr
|
type (C_ptr), intent(in) :: ptr
|
||||||
double precision, dimension(:), allocatable :: coords
|
character (len=*), intent(in) :: name
|
||||||
real (C_double), dimension(:), allocatable, target :: C_coords
|
integer, intent(in) :: count
|
||||||
integer :: natoms
|
integer, dimension(:), allocatable, intent(out) :: data
|
||||||
|
type (C_ptr) :: Cdata
|
||||||
|
integer (C_int), dimension(:), pointer :: Fdata
|
||||||
|
integer (C_int) :: natoms
|
||||||
|
character (kind=C_char), dimension(len_trim(name)) :: Cname
|
||||||
|
integer (C_int), parameter :: Ctype = 0
|
||||||
|
integer (C_int) :: Ccount
|
||||||
natoms = lammps_get_natoms (ptr)
|
natoms = lammps_get_natoms (ptr)
|
||||||
if ( allocated(coords) ) deallocate (coords)
|
Cname = string2Cstring (name)
|
||||||
allocate (coords(3*natoms))
|
if ( count /= 1 .and. count /= 3 ) then
|
||||||
allocate (C_coords(3*natoms))
|
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
||||||
call lammps_actual_get_coords (ptr, C_loc(C_coords))
|
& count to be either 1 or 3')
|
||||||
coords = C_coords
|
else
|
||||||
deallocate (C_coords)
|
Ccount = count
|
||||||
end subroutine lammps_get_coords
|
end if
|
||||||
|
allocate ( Fdata(count*natoms) )
|
||||||
|
allocate ( data(count*natoms) )
|
||||||
|
Cdata = C_loc (Fdata(1))
|
||||||
|
call lammps_actual_gather_atoms (ptr, Cname, Ctype, Ccount, Cdata)
|
||||||
|
data = Fdata
|
||||||
|
deallocate (Fdata)
|
||||||
|
end subroutine lammps_gather_atoms_ia
|
||||||
|
subroutine lammps_gather_atoms_dpa (ptr, name, count, data)
|
||||||
|
type (C_ptr), intent(in) :: ptr
|
||||||
|
character (len=*), intent(in) :: name
|
||||||
|
integer, intent(in) :: count
|
||||||
|
double precision, dimension(:), allocatable, intent(out) :: data
|
||||||
|
type (C_ptr) :: Cdata
|
||||||
|
real (C_double), dimension(:), pointer :: Fdata
|
||||||
|
integer (C_int) :: natoms
|
||||||
|
character (kind=C_char), dimension(len_trim(name)) :: Cname
|
||||||
|
integer (C_int), parameter :: Ctype = 1
|
||||||
|
integer (C_int) :: Ccount
|
||||||
|
natoms = lammps_get_natoms (ptr)
|
||||||
|
Cname = string2Cstring (name)
|
||||||
|
if ( count /= 1 .and. count /= 3 ) then
|
||||||
|
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
||||||
|
& count to be either 1 or 3')
|
||||||
|
else
|
||||||
|
Ccount = count
|
||||||
|
end if
|
||||||
|
allocate ( Fdata(count*natoms) )
|
||||||
|
allocate ( data(count*natoms) )
|
||||||
|
Cdata = C_loc (Fdata(1))
|
||||||
|
call lammps_actual_gather_atoms (ptr, Cname, Ctype, Ccount, Cdata)
|
||||||
|
data = Fdata(:)
|
||||||
|
deallocate (Fdata)
|
||||||
|
end subroutine lammps_gather_atoms_dpa
|
||||||
|
subroutine lammps_gather_atoms_ra (ptr, name, count, data)
|
||||||
|
type (C_ptr), intent(in) :: ptr
|
||||||
|
character (len=*), intent(in) :: name
|
||||||
|
integer, intent(in) :: count
|
||||||
|
real, dimension(:), allocatable, intent(out) :: data
|
||||||
|
double precision, dimension(:), allocatable :: d_data
|
||||||
|
call lammps_gather_atoms_dpa (ptr, name, count, d_data)
|
||||||
|
allocate (data(size(d_data)))
|
||||||
|
data = d_data
|
||||||
|
deallocate (d_data)
|
||||||
|
end subroutine lammps_gather_atoms_ra
|
||||||
|
|
||||||
!-----------------------------------------------------------------------------
|
!-----------------------------------------------------------------------------
|
||||||
|
|
||||||
subroutine lammps_put_coords (ptr, coords)
|
subroutine lammps_scatter_atoms_ia (ptr, name, data)
|
||||||
type (C_ptr) :: ptr
|
type (C_ptr), intent(in) :: ptr
|
||||||
double precision, dimension(:) :: coords
|
character (len=*), intent(in) :: name
|
||||||
real (C_double), dimension(size(coords)) :: C_coords
|
integer, dimension(:), intent(in) :: data
|
||||||
C_coords = coords
|
integer (kind=C_int) :: natoms, Ccount
|
||||||
call lammps_actual_put_coords (ptr, C_coords)
|
integer (kind=C_int), parameter :: Ctype = 0
|
||||||
end subroutine lammps_put_coords
|
character (kind=C_char), dimension(len_trim(name)) :: Cname
|
||||||
|
integer, dimension(size(data)), target :: Fdata
|
||||||
|
type (C_ptr) :: Cdata
|
||||||
|
natoms = lammps_get_natoms (ptr)
|
||||||
|
Cname = string2Cstring (name)
|
||||||
|
Ccount = size(data) / natoms
|
||||||
|
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
||||||
|
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
||||||
|
& count to be either 1 or 3')
|
||||||
|
Fdata = data
|
||||||
|
Cdata = C_loc (Fdata(1))
|
||||||
|
call lammps_actual_scatter_atoms (ptr, Cname, Ctype, Ccount, Cdata)
|
||||||
|
end subroutine lammps_scatter_atoms_ia
|
||||||
|
subroutine lammps_scatter_atoms_dpa (ptr, name, data)
|
||||||
|
type (C_ptr), intent(in) :: ptr
|
||||||
|
character (len=*), intent(in) :: name
|
||||||
|
double precision, dimension(:), intent(in) :: data
|
||||||
|
integer (kind=C_int) :: natoms, Ccount
|
||||||
|
integer (kind=C_int), parameter :: Ctype = 0
|
||||||
|
character (kind=C_char), dimension(len_trim(name)) :: Cname
|
||||||
|
double precision, dimension(size(data)), target :: Fdata
|
||||||
|
type (C_ptr) :: Cdata
|
||||||
|
natoms = lammps_get_natoms (ptr)
|
||||||
|
Cname = string2Cstring (name)
|
||||||
|
Ccount = size(data) / natoms
|
||||||
|
if ( Ccount /= 1 .and. Ccount /= 3 ) &
|
||||||
|
call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires&
|
||||||
|
& count to be either 1 or 3')
|
||||||
|
Fdata = data
|
||||||
|
Cdata = C_loc (Fdata(1))
|
||||||
|
call lammps_actual_scatter_atoms (ptr, Cname, Ctype, Ccount, Cdata)
|
||||||
|
end subroutine lammps_scatter_atoms_dpa
|
||||||
|
subroutine lammps_scatter_atoms_ra (ptr, name, data)
|
||||||
|
type (C_ptr), intent(in) :: ptr
|
||||||
|
character (len=*), intent(in) :: name
|
||||||
|
real, dimension(:), intent(out) :: data
|
||||||
|
double precision, dimension(size(data)) :: d_data
|
||||||
|
d_data = real (data, kind(d_data))
|
||||||
|
call lammps_scatter_atoms_dpa (ptr, name, d_data)
|
||||||
|
end subroutine lammps_scatter_atoms_ra
|
||||||
|
|
||||||
!-----------------------------------------------------------------------------
|
!-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
! subroutine lammps_get_coords (ptr, coords)
|
||||||
|
! type (C_ptr) :: ptr
|
||||||
|
! double precision, dimension(:), allocatable, intent(out) :: coords
|
||||||
|
! real (C_double), dimension(:), allocatable, target :: C_coords
|
||||||
|
! integer :: natoms
|
||||||
|
! natoms = lammps_get_natoms (ptr)
|
||||||
|
! allocate (coords(3*natoms))
|
||||||
|
! allocate (C_coords(3*natoms))
|
||||||
|
! call lammps_actual_get_coords (ptr, C_loc(C_coords))
|
||||||
|
! coords = C_coords
|
||||||
|
! deallocate (C_coords)
|
||||||
|
! end subroutine lammps_get_coords
|
||||||
|
!
|
||||||
|
!!-----------------------------------------------------------------------------
|
||||||
|
!
|
||||||
|
! subroutine lammps_put_coords (ptr, coords)
|
||||||
|
! type (C_ptr) :: ptr
|
||||||
|
! double precision, dimension(:) :: coords
|
||||||
|
! real (C_double), dimension(size(coords)) :: C_coords
|
||||||
|
! C_coords = coords
|
||||||
|
! call lammps_actual_put_coords (ptr, C_coords)
|
||||||
|
! end subroutine lammps_put_coords
|
||||||
|
!
|
||||||
|
!!-----------------------------------------------------------------------------
|
||||||
|
|
||||||
function lammps_extract_compute_vectorsize (ptr, id, style) &
|
function lammps_extract_compute_vectorsize (ptr, id, style) &
|
||||||
result (vectorsize)
|
result (vectorsize)
|
||||||
integer :: vectorsize
|
integer :: vectorsize
|
||||||
|
|||||||
@ -12,7 +12,7 @@ questions:
|
|||||||
Karl D. Hammond
|
Karl D. Hammond
|
||||||
University of Tennessee, Knoxville
|
University of Tennessee, Knoxville
|
||||||
karlh at ugcs.caltech.edu
|
karlh at ugcs.caltech.edu
|
||||||
karlh atutk.edu
|
karlh at utk.edu
|
||||||
|
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ compile.
|
|||||||
The following steps will work to compile this module (replace ${LAMMPS_SRC}
|
The following steps will work to compile this module (replace ${LAMMPS_SRC}
|
||||||
with the path to your LAMMPS source directory):
|
with the path to your LAMMPS source directory):
|
||||||
(1) Compile LAMMPS as a static library. Call the resulting file ${LAMMPS_LIB},
|
(1) Compile LAMMPS as a static library. Call the resulting file ${LAMMPS_LIB},
|
||||||
which will have an actual name lake liblammps_openmpi.a. If compiling
|
which will have an actual name lake liblmp_openmpi.a. If compiling
|
||||||
using the MPI stubs in ${LAMMPS_SRC}/STUBS, you will need to know where
|
using the MPI stubs in ${LAMMPS_SRC}/STUBS, you will need to know where
|
||||||
libmpi.a is as well (I'll call it ${MPI_STUBS} hereafter)
|
libmpi.a is as well (I'll call it ${MPI_STUBS} hereafter)
|
||||||
(2) Copy said library to your Fortran program's source directory or include
|
(2) Copy said library to your Fortran program's source directory or include
|
||||||
@ -61,7 +61,7 @@ with the path to your LAMMPS source directory):
|
|||||||
need to have the .mod file from part (3).
|
need to have the .mod file from part (3).
|
||||||
|
|
||||||
It is also possible to add LAMMPS.o and LAMMPS-wrapper.o into the
|
It is also possible to add LAMMPS.o and LAMMPS-wrapper.o into the
|
||||||
LAMMPS library (e.g., liblammps_openmpi.a) instead of creating a separate
|
LAMMPS library (e.g., liblmp_openmpi.a) instead of creating a separate
|
||||||
library, like so:
|
library, like so:
|
||||||
ar rs ${LAMMPS_LIB} LAMMPS.o LAMMPS-wrapper.o
|
ar rs ${LAMMPS_LIB} LAMMPS.o LAMMPS-wrapper.o
|
||||||
In this case, you can now use the Fortran wrapper functions as if they
|
In this case, you can now use the Fortran wrapper functions as if they
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
# Path to LAMMPS extraction directory
|
# Path to LAMMPS extraction directory
|
||||||
LAMMPS_ROOT = ../svn-dist
|
LAMMPS_ROOT = ../../..
|
||||||
LAMMPS_SRC = $(LAMMPS_ROOT)/src
|
LAMMPS_SRC = $(LAMMPS_ROOT)/src
|
||||||
|
|
||||||
# Remove the line below if using mpicxx/mpic++ as your C++ compiler
|
# Remove the line below if using mpicxx/mpic++ as your C++ compiler
|
||||||
|
|||||||
@ -1,35 +1,67 @@
|
|||||||
#!/usr/local/bin/python
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
# copy LAMMPS shared library src/liblammps.so and lammps.py to system dirs
|
# copy LAMMPS src/liblammps.so and lammps.py to system dirs
|
||||||
# Syntax: python install.py [libdir] [pydir]
|
|
||||||
# libdir = target dir for src/liblammps.so, default = /usr/local/lib
|
|
||||||
# pydir = target dir for lammps.py, default = Python site-packages dir
|
|
||||||
|
|
||||||
import sys,commands
|
instructions = """
|
||||||
|
Syntax: python install.py [-h] [libdir] [pydir]
|
||||||
|
libdir = target dir for src/liblammps.so, default = /usr/local/lib
|
||||||
|
pydir = target dir for lammps.py, default = Python site-packages dir
|
||||||
|
"""
|
||||||
|
|
||||||
if len(sys.argv) > 3:
|
import sys,os,commands
|
||||||
print "Syntax: python install.py [libdir] [pydir]"
|
|
||||||
|
if (len(sys.argv) > 1 and sys.argv[1] == "-h") or len(sys.argv) > 3:
|
||||||
|
print instructions
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if len(sys.argv) >= 2: libdir = sys.argv[1]
|
if len(sys.argv) >= 2: libdir = sys.argv[1]
|
||||||
else: libdir = "/usr/local/lib"
|
else: libdir = "/usr/local/lib"
|
||||||
|
|
||||||
if len(sys.argv) == 3: pydir = sys.argv[2]
|
if len(sys.argv) == 3: pydir = sys.argv[2]
|
||||||
|
else: pydir = ""
|
||||||
|
|
||||||
|
# copy C lib to libdir if it exists
|
||||||
|
# warn if not in LD_LIBRARY_PATH or LD_LIBRARY_PATH is undefined
|
||||||
|
|
||||||
|
if not os.path.isdir(libdir):
|
||||||
|
print "ERROR: libdir %s does not exist" % libdir
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if "LD_LIBRARY_PATH" not in os.environ:
|
||||||
|
print "WARNING: LD_LIBRARY_PATH undefined, cannot check libdir %s" % libdir
|
||||||
else:
|
else:
|
||||||
paths = sys.path
|
libpaths = os.environ['LD_LIBRARY_PATH'].split(':')
|
||||||
for i,path in enumerate(paths):
|
if libdir not in libpaths:
|
||||||
index = path.rfind("site-packages")
|
print "WARNING: libdir %s not in LD_LIBRARY_PATH" % libdir
|
||||||
if index < 0: continue
|
|
||||||
if index == len(path) - len("site-packages"): break
|
|
||||||
pydir = paths[i]
|
|
||||||
|
|
||||||
str = "cp ../src/liblammps.so %s" % libdir
|
str = "cp ../src/liblammps.so %s" % libdir
|
||||||
print str
|
print str
|
||||||
outstr = commands.getoutput(str)
|
outstr = commands.getoutput(str)
|
||||||
if len(outstr.strip()): print outstr
|
if len(outstr.strip()): print outstr
|
||||||
|
|
||||||
str = "cp ../python/lammps.py %s" % pydir
|
# copy lammps.py to pydir if it exists
|
||||||
print str
|
# if pydir not specified, install in site-packages via distutils setup()
|
||||||
outstr = commands.getoutput(str)
|
|
||||||
if len(outstr.strip()): print outstr
|
|
||||||
|
|
||||||
|
if pydir:
|
||||||
|
if not os.path.isdir(pydir):
|
||||||
|
print "ERROR: pydir %s does not exist" % pydir
|
||||||
|
sys.exit()
|
||||||
|
str = "cp ../python/lammps.py %s" % pydir
|
||||||
|
print str
|
||||||
|
outstr = commands.getoutput(str)
|
||||||
|
if len(outstr.strip()): print outstr
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
print "installing lammps.py in Python site-packages dir"
|
||||||
|
|
||||||
|
os.chdir('../python') # in case invoked via make in src dir
|
||||||
|
|
||||||
|
from distutils.core import setup
|
||||||
|
sys.argv = ["setup.py","install"] # as if had run "python setup.py install"
|
||||||
|
setup(name = "lammps",
|
||||||
|
version = "15Aug12",
|
||||||
|
author = "Steve Plimpton",
|
||||||
|
author_email = "sjplimp@sandia.gov",
|
||||||
|
url = "http://lammps.sandia.gov",
|
||||||
|
description = "LAMMPS molecular dynamics library",
|
||||||
|
py_modules = ["lammps"])
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
# Python wrapper on LAMMPS library via ctypes
|
# Python wrapper on LAMMPS library via ctypes
|
||||||
|
|
||||||
import types
|
import sys,traceback,types
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
@ -27,6 +27,8 @@ class lammps:
|
|||||||
if not name: self.lib = CDLL("liblammps.so")
|
if not name: self.lib = CDLL("liblammps.so")
|
||||||
else: self.lib = CDLL("liblammps_%s.so" % name)
|
else: self.lib = CDLL("liblammps_%s.so" % name)
|
||||||
except:
|
except:
|
||||||
|
type,value,tb = sys.exc_info()
|
||||||
|
traceback.print_exception(type,value,tb)
|
||||||
raise OSError,"Could not load LAMMPS dynamic library"
|
raise OSError,"Could not load LAMMPS dynamic library"
|
||||||
|
|
||||||
# create an instance of LAMMPS
|
# create an instance of LAMMPS
|
||||||
|
|||||||
@ -39,6 +39,8 @@ class FFT3d : protected Pointers {
|
|||||||
|
|
||||||
E: Could not create 3d FFT plan
|
E: Could not create 3d FFT plan
|
||||||
|
|
||||||
The FFT setup in pppm failed.
|
The FFT setup for the PPPM solver failed, typically due
|
||||||
|
to lack of memory. This is an unusual error. Check the
|
||||||
|
size of the FFT grid you are requesting.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -100,7 +100,6 @@ PPPM::PPPM(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
|
|||||||
// see JCP 109, pg 7698 for derivation of coefficients
|
// see JCP 109, pg 7698 for derivation of coefficients
|
||||||
// higher order coefficients may be computed if needed
|
// higher order coefficients may be computed if needed
|
||||||
|
|
||||||
memory->destroy(acons);
|
|
||||||
memory->create(acons,8,7,"pppm:acons");
|
memory->create(acons,8,7,"pppm:acons");
|
||||||
acons[1][0] = 2.0 / 3.0;
|
acons[1][0] = 2.0 / 3.0;
|
||||||
acons[2][0] = 1.0 / 50.0;
|
acons[2][0] = 1.0 / 50.0;
|
||||||
|
|||||||
@ -85,9 +85,6 @@ $(EXE): $(OBJ)
|
|||||||
lib: $(OBJ)
|
lib: $(OBJ)
|
||||||
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
||||||
|
|
||||||
#shlib: $(OBJ)
|
|
||||||
# $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
|
||||||
|
|
||||||
shlib: $(OBJ)
|
shlib: $(OBJ)
|
||||||
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
|
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
|
||||||
$(OBJ) $(EXTRA_LIB) $(LIB)
|
$(OBJ) $(EXTRA_LIB) $(LIB)
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
# Make.sh = update Makefile.lib or Makefile.list or style_*.h files
|
# Make.sh = update Makefile.lib, Makefile.shlib, Makefile.list
|
||||||
|
# or style_*.h files
|
||||||
# Syntax: sh Make.sh style
|
# Syntax: sh Make.sh style
|
||||||
# sh Make.sh Makefile.lib
|
# sh Make.sh Makefile.lib
|
||||||
|
# sh Make.sh Makefile.shlib
|
||||||
# sh Make.sh Makefile.list
|
# sh Make.sh Makefile.list
|
||||||
|
|
||||||
# function to create one style_*.h file
|
# function to create one style_*.h file
|
||||||
|
|||||||
@ -130,7 +130,7 @@ makelist:
|
|||||||
@$(SHELL) Make.sh style
|
@$(SHELL) Make.sh style
|
||||||
@$(SHELL) Make.sh Makefile.list
|
@$(SHELL) Make.sh Makefile.list
|
||||||
|
|
||||||
# install LAMMPS shared lib and Python wrapper in Python
|
# install LAMMPS shared lib and Python wrapper for Python usage
|
||||||
|
|
||||||
install-python:
|
install-python:
|
||||||
@python ../python/install.py
|
@python ../python/install.py
|
||||||
|
|||||||
@ -21,9 +21,6 @@ help:
|
|||||||
@files="`ls MAKE/Makefile.*`"; \
|
@files="`ls MAKE/Makefile.*`"; \
|
||||||
for file in $$files; do head -1 $$file; done
|
for file in $$files; do head -1 $$file; done
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf Obj_*
|
|
||||||
|
|
||||||
.DEFAULT:
|
.DEFAULT:
|
||||||
@test -f MAKE/Makefile.$@
|
@test -f MAKE/Makefile.$@
|
||||||
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi
|
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi
|
||||||
|
|||||||
@ -21,9 +21,6 @@ help:
|
|||||||
@files="`ls MAKE/Makefile.*`"; \
|
@files="`ls MAKE/Makefile.*`"; \
|
||||||
for file in $$files; do head -1 $$file; done
|
for file in $$files; do head -1 $$file; done
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf Obj_*
|
|
||||||
|
|
||||||
.DEFAULT:
|
.DEFAULT:
|
||||||
@test -f MAKE/Makefile.$@
|
@test -f MAKE/Makefile.$@
|
||||||
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi
|
@if [ ! -d Obj_$@ ]; then mkdir Obj_$@; fi
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -410,6 +410,8 @@ void Cuda::setDomainParams()
|
|||||||
cu_domain->boxlo_lamda[i] = domain->boxlo_lamda[i];
|
cu_domain->boxlo_lamda[i] = domain->boxlo_lamda[i];
|
||||||
cu_domain->boxhi_lamda[i] = domain->boxhi_lamda[i];
|
cu_domain->boxhi_lamda[i] = domain->boxhi_lamda[i];
|
||||||
cu_domain->prd_lamda[i] = domain->prd_lamda[i];
|
cu_domain->prd_lamda[i] = domain->prd_lamda[i];
|
||||||
|
cu_domain->sublo[i] = domain->sublo_lamda[i];
|
||||||
|
cu_domain->subhi[i] = domain->subhi_lamda[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
cu_domain->xy = domain->xy;
|
cu_domain->xy = domain->xy;
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#ifdef PAIR_CLASS
|
#ifdef PAIR_CLASS
|
||||||
|
|
||||||
PairStyle(lj/cut/omp,PairLJExpandOMP)
|
PairStyle(lj/expand/omp,PairLJExpandOMP)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,9 @@
|
|||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "compute.h"
|
#include "compute.h"
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
|
#include "comm.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
@ -383,8 +385,13 @@ void lammps_gather_atoms(void *ptr, char *name,
|
|||||||
|
|
||||||
// error if tags are not defined or not consecutive
|
// error if tags are not defined or not consecutive
|
||||||
|
|
||||||
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) return;
|
int flag = 0;
|
||||||
if (lmp->atom->natoms > MAXSMALLINT) return;
|
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) flag = 1;
|
||||||
|
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
||||||
|
if (flag && lmp->comm->me == 0) {
|
||||||
|
lmp->error->warning(FLERR,"Library error in lammps_gather_atoms");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||||
|
|
||||||
@ -464,10 +471,16 @@ void lammps_scatter_atoms(void *ptr, char *name,
|
|||||||
{
|
{
|
||||||
LAMMPS *lmp = (LAMMPS *) ptr;
|
LAMMPS *lmp = (LAMMPS *) ptr;
|
||||||
|
|
||||||
// error if tags are not defined or not consecutive
|
// error if tags are not defined or not consecutive or no atom map
|
||||||
|
|
||||||
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) return;
|
int flag = 0;
|
||||||
if (lmp->atom->natoms > MAXSMALLINT) return;
|
if (lmp->atom->tag_enable == 0 || lmp->atom->tag_consecutive() == 0) flag = 1;
|
||||||
|
if (lmp->atom->natoms > MAXSMALLINT) flag = 1;
|
||||||
|
if (lmp->atom->map_style == 0) flag = 1;
|
||||||
|
if (flag && lmp->comm->me == 0) {
|
||||||
|
lmp->error->warning(FLERR,"Library error in lammps_scatter_atoms");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int natoms = static_cast<int> (lmp->atom->natoms);
|
int natoms = static_cast<int> (lmp->atom->natoms);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user