git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8767 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -767,17 +767,13 @@ contains !! Wrapper functions local to this module {{{1
|
||||
character (len=*), intent(in) :: name
|
||||
character (len=*), intent(in), optional :: group
|
||||
integer, intent(out) :: variable
|
||||
type (C_ptr) :: Cptr
|
||||
integer (C_int), pointer :: Fptr
|
||||
if ( present(group) ) then
|
||||
Cptr = lammps_extract_variable_Cptr (ptr, name, group)
|
||||
double precision :: d_var
|
||||
if ( present (group) ) then
|
||||
call lammps_extract_variable_dp (d_var, ptr, name, group)
|
||||
else
|
||||
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
||||
call lammps_extract_variable_dp (d_var, ptr, name)
|
||||
end if
|
||||
call C_F_pointer (Cptr, Fptr)
|
||||
variable = Fptr
|
||||
nullify (Fptr)
|
||||
call lammps_free (Cptr)
|
||||
variable = nint(d_var)
|
||||
end subroutine lammps_extract_variable_i
|
||||
subroutine lammps_extract_variable_dp (variable, ptr, name, group)
|
||||
type (C_ptr), intent(in) :: ptr
|
||||
@ -811,25 +807,19 @@ contains !! Wrapper functions local to this module {{{1
|
||||
end subroutine lammps_extract_variable_r
|
||||
|
||||
subroutine lammps_extract_variable_ia (variable, ptr, name, group)
|
||||
integer, dimension(:), allocatable, intent(out) :: variable
|
||||
type (C_ptr), intent(in) :: ptr
|
||||
character (len=*), intent(in) :: name
|
||||
character (len=*), intent(in), optional :: group
|
||||
type (C_ptr) :: Cptr
|
||||
integer (C_int), dimension(:), pointer :: Fptr
|
||||
integer :: natoms
|
||||
nullify (Fptr)
|
||||
if ( present(group) ) then
|
||||
Cptr = lammps_extract_variable_Cptr (ptr, name, group)
|
||||
integer, dimension(:), allocatable, intent(out) :: variable
|
||||
double precision, dimension(:), allocatable :: d_var
|
||||
if ( present (group) ) then
|
||||
call lammps_extract_variable_dpa (d_var, ptr, name, group)
|
||||
else
|
||||
Cptr = lammps_extract_variable_Cptr (ptr, name)
|
||||
call lammps_extract_variable_dpa (d_var, ptr, name)
|
||||
end if
|
||||
natoms = lammps_get_natoms (ptr)
|
||||
allocate (variable(natoms))
|
||||
call C_F_pointer (Cptr, Fptr, (/natoms/))
|
||||
variable = Fptr
|
||||
nullify (Fptr)
|
||||
call lammps_free (Cptr)
|
||||
allocate (variable(size(d_var)))
|
||||
variable = nint(d_var)
|
||||
deallocate (d_var)
|
||||
end subroutine lammps_extract_variable_ia
|
||||
subroutine lammps_extract_variable_dpa (variable, ptr, name, group)
|
||||
double precision, dimension(:), allocatable, intent(out) :: variable
|
||||
@ -877,8 +867,8 @@ contains !! Wrapper functions local to this module {{{1
|
||||
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
|
||||
character (kind=C_char), dimension(len_trim(name)+1) :: Cname
|
||||
integer (C_int), parameter :: Ctype = 0_C_int
|
||||
integer (C_int) :: Ccount
|
||||
natoms = lammps_get_natoms (ptr)
|
||||
Cname = string2Cstring (name)
|
||||
@ -903,8 +893,8 @@ contains !! Wrapper functions local to this module {{{1
|
||||
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
|
||||
character (kind=C_char), dimension(len_trim(name)+1) :: Cname
|
||||
integer (C_int), parameter :: Ctype = 1_C_int
|
||||
integer (C_int) :: Ccount
|
||||
natoms = lammps_get_natoms (ptr)
|
||||
Cname = string2Cstring (name)
|
||||
@ -940,9 +930,9 @@ contains !! Wrapper functions local to this module {{{1
|
||||
character (len=*), intent(in) :: name
|
||||
integer, 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
|
||||
integer, dimension(size(data)), target :: Fdata
|
||||
integer (kind=C_int), parameter :: Ctype = 0_C_int
|
||||
character (kind=C_char), dimension(len_trim(name)+1) :: Cname
|
||||
integer (C_int), dimension(size(data)), target :: Fdata
|
||||
type (C_ptr) :: Cdata
|
||||
natoms = lammps_get_natoms (ptr)
|
||||
Cname = string2Cstring (name)
|
||||
@ -959,9 +949,9 @@ contains !! Wrapper functions local to this module {{{1
|
||||
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
|
||||
integer (kind=C_int), parameter :: Ctype = 1_C_int
|
||||
character (kind=C_char), dimension(len_trim(name)+1) :: Cname
|
||||
real (C_double), dimension(size(data)), target :: Fdata
|
||||
type (C_ptr) :: Cdata
|
||||
natoms = lammps_get_natoms (ptr)
|
||||
Cname = string2Cstring (name)
|
||||
@ -976,7 +966,7 @@ contains !! Wrapper functions local to this module {{{1
|
||||
subroutine lammps_scatter_atoms_ra (ptr, name, data)
|
||||
type (C_ptr), intent(in) :: ptr
|
||||
character (len=*), intent(in) :: name
|
||||
real, dimension(:), intent(out) :: data
|
||||
real, dimension(:), intent(in) :: data
|
||||
double precision, dimension(size(data)) :: d_data
|
||||
d_data = real (data, kind(d_data))
|
||||
call lammps_scatter_atoms_dpa (ptr, name, d_data)
|
||||
@ -984,31 +974,6 @@ contains !! Wrapper functions local to this module {{{1
|
||||
|
||||
!-----------------------------------------------------------------------------
|
||||
|
||||
! 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) &
|
||||
result (vectorsize)
|
||||
integer :: vectorsize
|
||||
|
||||
@ -1,33 +1,36 @@
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Path to LAMMPS extraction directory
|
||||
LAMMPS_ROOT = ../../..
|
||||
LAMMPS_SRC = $(LAMMPS_ROOT)/src
|
||||
|
||||
# Remove the line below if using mpicxx/mpic++ as your C++ compiler
|
||||
MPI_STUBS = $(LAMMPS_SRC)/STUBS
|
||||
|
||||
FC = gfortran # replace with your Fortran compiler
|
||||
CXX = g++ # replace with your C++ compiler
|
||||
|
||||
# Flags for Fortran compiler, C++ compiler, and C preprocessor, respectively
|
||||
FFLAGS = -O2
|
||||
CXXFLAGS = -O2
|
||||
CPPFLAGS =
|
||||
|
||||
all : liblammps_fortran.a
|
||||
|
||||
liblammps_fortran.a : LAMMPS.o LAMMPS-wrapper.o
|
||||
$(AR) rs $@ $^
|
||||
|
||||
LAMMPS.o lammps.mod : LAMMPS.F90
|
||||
$(FC) $(CPPFLAGS) $(FFLAGS) -c $<
|
||||
|
||||
LAMMPS-wrapper.o : LAMMPS-wrapper.cpp LAMMPS-wrapper.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -I$(LAMMPS_SRC) -I$(MPI_STUBS)
|
||||
|
||||
clean :
|
||||
$(RM) *.o *.mod liblammps_fortran.a
|
||||
|
||||
dist :
|
||||
tar -czf Fortran-interface.tar.gz LAMMPS-wrapper.h LAMMPS-wrapper.cpp LAMMPS.F90 makefile README
|
||||
SHELL = /bin/sh
|
||||
|
||||
# Path to LAMMPS extraction directory
|
||||
LAMMPS_ROOT = ../../..
|
||||
LAMMPS_SRC = $(LAMMPS_ROOT)/src
|
||||
|
||||
# Uncomment the line below if using the MPI stubs library
|
||||
MPI_STUBS = #-I$(LAMMPS_SRC)/STUBS
|
||||
|
||||
FC = mpif90 # replace with your Fortran compiler
|
||||
CXX = mpicxx # replace with your C++ compiler
|
||||
|
||||
# Flags for Fortran compiler, C++ compiler, and C preprocessor, respectively
|
||||
FFLAGS = -O2 -fPIC
|
||||
CXXFLAGS = -O2 -fPIC
|
||||
CPPFLAGS =
|
||||
|
||||
all : liblammps_fortran.a liblammps_fortran.so
|
||||
|
||||
liblammps_fortran.so : LAMMPS.o LAMMPS-wrapper.o
|
||||
$(FC) $(FFLAGS) -shared -o $@ $^
|
||||
|
||||
liblammps_fortran.a : LAMMPS.o LAMMPS-wrapper.o
|
||||
$(AR) rs $@ $^
|
||||
|
||||
LAMMPS.o lammps.mod : LAMMPS.F90
|
||||
$(FC) $(CPPFLAGS) $(FFLAGS) -c $<
|
||||
|
||||
LAMMPS-wrapper.o : LAMMPS-wrapper.cpp LAMMPS-wrapper.h
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -I$(LAMMPS_SRC) $(MPI_STUBS)
|
||||
|
||||
clean :
|
||||
$(RM) *.o *.mod liblammps_fortran.a liblammps_fortran.so
|
||||
|
||||
dist :
|
||||
tar -czf Fortran-interface.tar.gz LAMMPS-wrapper.h LAMMPS-wrapper.cpp LAMMPS.F90 makefile README
|
||||
|
||||
Reference in New Issue
Block a user