Merge branch 'lammps:develop' into mliap-bug-3204
This commit is contained in:
@ -135,13 +135,11 @@ set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions")
|
||||
# ugly hacks for MSVC which by default always reports an old C++ standard in the __cplusplus macro
|
||||
# and prints lots of pointless warnings about "unsafe" functions
|
||||
if(MSVC)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Intel"))
|
||||
add_compile_options(/Zc:__cplusplus)
|
||||
add_compile_options(/wd4244)
|
||||
add_compile_options(/wd4267)
|
||||
if(LAMMPS_EXCEPTIONS)
|
||||
add_compile_options(/EHsc)
|
||||
endif()
|
||||
add_compile_options(/EHsc)
|
||||
endif()
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
@ -208,7 +208,7 @@ Argument processing
|
||||
Convenience functions
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. doxygenfunction:: logmesg(LAMMPS *lmp, const S &format, Args&&... args)
|
||||
.. doxygenfunction:: logmesg(LAMMPS *lmp, const std::string &format, Args&&... args)
|
||||
:project: progguide
|
||||
|
||||
.. doxygenfunction:: logmesg(LAMMPS *lmp, const std::string &mesg)
|
||||
|
||||
@ -38,11 +38,11 @@ found together with equivalent examples in C and C++ in the
|
||||
|
||||
.. note::
|
||||
|
||||
A contributed (and complete!) Fortran interface that more
|
||||
closely resembles the C-library interface is available
|
||||
in the ``examples/COUPLE/fortran2`` folder. Please see the
|
||||
``README`` file in that folder for more information about it
|
||||
and how to contact its author and maintainer.
|
||||
A contributed (and more complete!) Fortran interface that more
|
||||
closely resembles the C-library interface is available in the
|
||||
``examples/COUPLE/fortran2`` folder. Please see the ``README`` file
|
||||
in that folder for more information about it and how to contact its
|
||||
author and maintainer.
|
||||
|
||||
----------
|
||||
|
||||
@ -65,8 +65,9 @@ the optional logical argument set to ``.true.``. Here is a simple example:
|
||||
|
||||
PROGRAM testlib
|
||||
USE LIBLAMMPS ! include the LAMMPS library interface
|
||||
IMPLICIT NONE
|
||||
TYPE(lammps) :: lmp ! derived type to hold LAMMPS instance
|
||||
CHARACTER(len=*), DIMENSION(*), PARAMETER :: args = &
|
||||
CHARACTER(len=*), PARAMETER :: args(3) = &
|
||||
[ CHARACTER(len=12) :: 'liblammps', '-log', 'none' ]
|
||||
|
||||
! create a LAMMPS instance (and initialize MPI)
|
||||
@ -78,6 +79,41 @@ the optional logical argument set to ``.true.``. Here is a simple example:
|
||||
|
||||
END PROGRAM testlib
|
||||
|
||||
It is also possible to pass command line flags from Fortran to C/C++ and
|
||||
thus make the resulting executable behave similar to the standalone
|
||||
executable (it will ignore the `-in/-i` flag, though). This allows to
|
||||
use the command line to configure accelerator and suffix settings,
|
||||
configure screen and logfile output, or to set index style variables
|
||||
from the command line and more. Here is a correspondingly adapted
|
||||
version of the previous example:
|
||||
|
||||
.. code-block:: fortran
|
||||
|
||||
PROGRAM testlib2
|
||||
USE LIBLAMMPS ! include the LAMMPS library interface
|
||||
IMPLICIT NONE
|
||||
TYPE(lammps) :: lmp ! derived type to hold LAMMPS instance
|
||||
CHARACTER(len=128), ALLOCATABLE :: command_args(:)
|
||||
INTEGER :: i, argc
|
||||
|
||||
! copy command line flags to `command_args()`
|
||||
argc = COMMAND_ARGUMENT_COUNT()
|
||||
ALLOCATE(command_args(0:argc))
|
||||
DO i=0, argc
|
||||
CALL GET_COMMAND_ARGUMENT(i, command_args(i))
|
||||
END DO
|
||||
|
||||
! create a LAMMPS instance (and initialize MPI)
|
||||
lmp = lammps(command_args)
|
||||
! get and print numerical version code
|
||||
PRINT*, 'Program name: ', command_args(0)
|
||||
PRINT*, 'LAMMPS Version: ', lmp%version()
|
||||
! delete LAMMPS instance (and shuts down MPI)
|
||||
CALL lmp%close(.TRUE.)
|
||||
DEALLOCATE(command_args)
|
||||
|
||||
END PROGRAM testlib2
|
||||
|
||||
--------------------
|
||||
|
||||
Executing LAMMPS commands
|
||||
@ -102,7 +138,7 @@ Below is a small demonstration of the uses of the different functions:
|
||||
USE LIBLAMMPS
|
||||
TYPE(lammps) :: lmp
|
||||
CHARACTER(len=512) :: cmds
|
||||
CHARACTER(len=40),ALLOCATABLE :: cmdlist(:)
|
||||
CHARACTER(len=40), ALLOCATABLE :: cmdlist(:)
|
||||
CHARACTER(len=10) :: trimmed
|
||||
INTEGER :: i
|
||||
|
||||
@ -111,10 +147,10 @@ Below is a small demonstration of the uses of the different functions:
|
||||
CALL lmp%command('variable zpos index 1.0')
|
||||
! define 10 groups of 10 atoms each
|
||||
ALLOCATE(cmdlist(10))
|
||||
DO i=1,10
|
||||
DO i=1, 10
|
||||
WRITE(trimmed,'(I10)') 10*i
|
||||
WRITE(cmdlist(i),'(A,I1,A,I10,A,A)') &
|
||||
'group g',i-1,' id ',10*(i-1)+1,':',ADJUSTL(trimmed)
|
||||
'group g', i-1, ' id ', 10*(i-1)+1, ':', ADJUSTL(trimmed)
|
||||
END DO
|
||||
CALL lmp%commands_list(cmdlist)
|
||||
! run multiple commands from multi-line string
|
||||
@ -123,7 +159,7 @@ Below is a small demonstration of the uses of the different functions:
|
||||
'create_box 1 box' // NEW_LINE('A') // &
|
||||
'create_atoms 1 single 1.0 1.0 ${zpos}'
|
||||
CALL lmp%commands_string(cmds)
|
||||
CALL lmp%close()
|
||||
CALL lmp%close(.TRUE.)
|
||||
|
||||
END PROGRAM testcmd
|
||||
|
||||
@ -137,9 +173,9 @@ of the contents of the ``LIBLAMMPS`` Fortran interface to LAMMPS.
|
||||
|
||||
.. f:type:: lammps
|
||||
|
||||
Derived type that is the general class of the Fortran interface.
|
||||
It holds a reference to the :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>` class instance
|
||||
that any of the included calls are forwarded to.
|
||||
Derived type that is the general class of the Fortran interface. It
|
||||
holds a reference to the :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>`
|
||||
class instance that any of the included calls are forwarded to.
|
||||
|
||||
:f c_ptr handle: reference to the LAMMPS class
|
||||
:f close: :f:func:`close`
|
||||
@ -202,7 +238,7 @@ of the contents of the ``LIBLAMMPS`` Fortran interface to LAMMPS.
|
||||
This method will call :cpp:func:`lammps_commands_list` to have LAMMPS
|
||||
execute a list of input lines.
|
||||
|
||||
:p character(len=*) cmd(*): list of LAMMPS input lines
|
||||
:p character(len=*) cmd(:): list of LAMMPS input lines
|
||||
|
||||
.. f:subroutine:: commands_string(str)
|
||||
|
||||
@ -210,4 +246,3 @@ of the contents of the ``LIBLAMMPS`` Fortran interface to LAMMPS.
|
||||
execute a block of commands from a string.
|
||||
|
||||
:p character(len=*) str: LAMMPS input in string
|
||||
|
||||
|
||||
@ -49,12 +49,12 @@ descriptions of all commands included in the LAMMPS code.
|
||||
|
||||
----------
|
||||
|
||||
.. _user_documentation:
|
||||
|
||||
************
|
||||
User Guide
|
||||
************
|
||||
|
||||
.. _user_documentation:
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:numbered: 3
|
||||
@ -75,11 +75,12 @@ User Guide
|
||||
Errors
|
||||
|
||||
|
||||
.. _programmer_documentation:
|
||||
|
||||
******************
|
||||
Programmer Guide
|
||||
******************
|
||||
|
||||
.. _programmer_documentation:
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:numbered: 3
|
||||
|
||||
@ -158,7 +158,7 @@ AMOEBA package
|
||||
**Contents:**
|
||||
|
||||
Implementation of the AMOEBA and HIPPO polarized force fields
|
||||
orginally developed by Jay Ponder's group at the U Washington at St
|
||||
originally developed by Jay Ponder's group at the U Washington at St
|
||||
Louis. The LAMMPS implementation is based on Fortran 90 code
|
||||
provided by the Ponder group in their
|
||||
`Tinker MD software <https://dasher.wustl.edu/tinker/>`_.
|
||||
|
||||
@ -66,7 +66,7 @@ Syntax
|
||||
bound(group,dir,region), gyration(group,region), ke(group,reigon),
|
||||
angmom(group,dim,region), torque(group,dim,region),
|
||||
inertia(group,dimdim,region), omega(group,dim,region)
|
||||
special functions = sum(x), min(x), max(x), ave(x), trap(x), slope(x), gmask(x), rmask(x), grmask(x,y), next(x), is_file(name), extract_setting(name)
|
||||
special functions = sum(x), min(x), max(x), ave(x), trap(x), slope(x), gmask(x), rmask(x), grmask(x,y), next(x), is_file(name), is_os(name), extract_setting(name)
|
||||
feature functions = is_active(category,feature), is_available(category,feature), is_defined(category,id)
|
||||
atom value = id[i], mass[i], type[i], mol[i], x[i], y[i], z[i], vx[i], vy[i], vz[i], fx[i], fy[i], fz[i], q[i]
|
||||
atom vector = id, mass, type, mol, x, y, z, vx, vy, vz, fx, fy, fz, q
|
||||
@ -939,6 +939,20 @@ The is_file(name) function is a test whether *name* is a (readable) file
|
||||
and returns 1 in this case, otherwise it returns 0. For that *name*
|
||||
is taken as a literal string and must not have any blanks in it.
|
||||
|
||||
The is_os(name) function is a test whether *name* is part of the OS
|
||||
information that LAMMPS collects and provides in the
|
||||
:cpp:func:`platform::os_info() <LAMMPS_NS::platform::os_info>` function.
|
||||
The argument *name* is interpreted as a regular expression as documented
|
||||
for the :cpp:func:`utils::strmatch() <LAMMPS_NS::utils::strmatch>`
|
||||
function. This allows to adapt LAMMPS inputs to the OS it runs on:
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
if $(is_os(^Windows)) then &
|
||||
"shell copy ${input_dir}\some_file.txt ." &
|
||||
else &
|
||||
"shell cp ${input_dir}/some_file.txt ."
|
||||
|
||||
The extract_setting(name) function enables access to basic settings for
|
||||
the LAMMPS executable and the running simulation via calling the
|
||||
:cpp:func:`lammps_extract_setting` library function. For example, the
|
||||
@ -1002,7 +1016,7 @@ step
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
timestep $(2.0*(1.0+2.0*is_active(pair,respa))
|
||||
timestep $(2.0*(1.0+2.0*is_active(pair,respa)))
|
||||
if $(is_active(pair,respa)) then "run_style respa 4 3 2 2 improper 1 inner 2 5.5 7.0 outer 3 kspace 4" else "run_style respa 3 3 2 improper 1 pair 2 kspace 3"
|
||||
|
||||
The *is_available(category,name)* function allows to query whether
|
||||
|
||||
@ -39,6 +39,18 @@ hr {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#userdoc.toctree-wrapper.compound p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#progdoc.toctree-wrapper.compound p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#reference.toctree-wrapper.compound p {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ui.tabular.menu .item {
|
||||
padding-right: 1em;
|
||||
padding-left: 1em;
|
||||
|
||||
@ -54,20 +54,18 @@ MODULE LIBLAMMPS
|
||||
|
||||
! interface definitions for calling functions in library.cpp
|
||||
INTERFACE
|
||||
FUNCTION lammps_open(argc,argv,comm) &
|
||||
BIND(C, name='lammps_open_fortran')
|
||||
FUNCTION lammps_open(argc, argv, comm) BIND(C, name='lammps_open_fortran')
|
||||
IMPORT :: c_ptr, c_int
|
||||
INTEGER(c_int), VALUE, INTENT(in) :: argc, comm
|
||||
TYPE(c_ptr), DIMENSION(*), INTENT(in) :: argv
|
||||
TYPE(c_ptr) :: lammps_open
|
||||
END FUNCTION lammps_open
|
||||
|
||||
FUNCTION lammps_open_no_mpi(argc,argv,handle) &
|
||||
BIND(C, name='lammps_open_no_mpi')
|
||||
FUNCTION lammps_open_no_mpi(argc, argv, handle) BIND(C, name='lammps_open_no_mpi')
|
||||
IMPORT :: c_ptr, c_int
|
||||
INTEGER(c_int), VALUE, INTENT(in) :: argc
|
||||
TYPE(c_ptr), DIMENSION(*), INTENT(in) :: argv
|
||||
TYPE(c_ptr), INTENT(out) :: handle
|
||||
TYPE(c_ptr), VALUE, INTENT(in) :: handle
|
||||
TYPE(c_ptr) :: lammps_open_no_mpi
|
||||
END FUNCTION lammps_open_no_mpi
|
||||
|
||||
@ -85,28 +83,26 @@ MODULE LIBLAMMPS
|
||||
SUBROUTINE lammps_kokkos_finalize() BIND(C, name='lammps_kokkos_finalize')
|
||||
END SUBROUTINE lammps_kokkos_finalize
|
||||
|
||||
SUBROUTINE lammps_file(handle,filename) BIND(C, name='lammps_file')
|
||||
SUBROUTINE lammps_file(handle, filename) BIND(C, name='lammps_file')
|
||||
IMPORT :: c_ptr
|
||||
TYPE(c_ptr), VALUE :: handle
|
||||
TYPE(c_ptr), VALUE :: filename
|
||||
END SUBROUTINE lammps_file
|
||||
|
||||
SUBROUTINE lammps_command(handle,cmd) BIND(C, name='lammps_command')
|
||||
SUBROUTINE lammps_command(handle, cmd) BIND(C, name='lammps_command')
|
||||
IMPORT :: c_ptr
|
||||
TYPE(c_ptr), VALUE :: handle
|
||||
TYPE(c_ptr), VALUE :: cmd
|
||||
END SUBROUTINE lammps_command
|
||||
|
||||
SUBROUTINE lammps_commands_list(handle,ncmd,cmds) &
|
||||
BIND(C, name='lammps_commands_list')
|
||||
SUBROUTINE lammps_commands_list(handle, ncmd, cmds) BIND(C, name='lammps_commands_list')
|
||||
IMPORT :: c_ptr, c_int
|
||||
TYPE(c_ptr), VALUE :: handle
|
||||
INTEGER(c_int), VALUE, INTENT(in) :: ncmd
|
||||
TYPE(c_ptr), DIMENSION(*), INTENT(in) :: cmds
|
||||
END SUBROUTINE lammps_commands_list
|
||||
|
||||
SUBROUTINE lammps_commands_string(handle,str) &
|
||||
BIND(C, name='lammps_commands_string')
|
||||
SUBROUTINE lammps_commands_string(handle, str) BIND(C, name='lammps_commands_string')
|
||||
IMPORT :: c_ptr
|
||||
TYPE(c_ptr), VALUE :: handle
|
||||
TYPE(c_ptr), VALUE :: str
|
||||
@ -137,24 +133,22 @@ MODULE LIBLAMMPS
|
||||
END INTERFACE
|
||||
|
||||
CONTAINS
|
||||
|
||||
! Fortran wrappers and helper functions.
|
||||
|
||||
! Constructor for the LAMMPS class.
|
||||
! Combined wrapper around lammps_open_fortran() and lammps_open_no_mpi()
|
||||
TYPE(lammps) FUNCTION lmp_open(args,comm)
|
||||
TYPE(lammps) FUNCTION lmp_open(args, comm)
|
||||
IMPLICIT NONE
|
||||
INTEGER,INTENT(in), OPTIONAL :: comm
|
||||
INTEGER, INTENT(in), OPTIONAL :: comm
|
||||
CHARACTER(len=*), INTENT(in), OPTIONAL :: args(:)
|
||||
TYPE(c_ptr), ALLOCATABLE :: argv(:)
|
||||
TYPE(c_ptr) :: dummy=c_null_ptr
|
||||
INTEGER :: i,argc
|
||||
INTEGER(c_int) :: i, c_comm, argc
|
||||
|
||||
IF (PRESENT(args)) THEN
|
||||
! convert argument list to c style
|
||||
! convert fortran argument list to c style
|
||||
argc = SIZE(args)
|
||||
ALLOCATE(argv(argc))
|
||||
DO i=1,argc
|
||||
DO i=1, argc
|
||||
argv(i) = f2c_string(args(i))
|
||||
END DO
|
||||
ELSE
|
||||
@ -164,23 +158,24 @@ CONTAINS
|
||||
ENDIF
|
||||
|
||||
IF (PRESENT(comm)) THEN
|
||||
lmp_open%handle = lammps_open(argc,argv,comm)
|
||||
c_comm = comm
|
||||
lmp_open%handle = lammps_open(argc, argv, c_comm)
|
||||
ELSE
|
||||
lmp_open%handle = lammps_open_no_mpi(argc,argv,dummy)
|
||||
lmp_open%handle = lammps_open_no_mpi(argc, argv, c_null_ptr)
|
||||
END IF
|
||||
|
||||
! Clean up allocated memory
|
||||
DO i=1,argc
|
||||
DO i=1, argc
|
||||
CALL lammps_free(argv(i))
|
||||
END DO
|
||||
DEALLOCATE(argv)
|
||||
END FUNCTION lmp_open
|
||||
|
||||
! Combined Fortran wrapper around lammps_close() and lammps_mpi_finalize()
|
||||
SUBROUTINE lmp_close(self,finalize)
|
||||
SUBROUTINE lmp_close(self, finalize)
|
||||
IMPLICIT NONE
|
||||
CLASS(lammps) :: self
|
||||
LOGICAL,INTENT(in),OPTIONAL :: finalize
|
||||
LOGICAL, INTENT(in), OPTIONAL :: finalize
|
||||
|
||||
CALL lammps_close(self%handle)
|
||||
|
||||
@ -206,68 +201,69 @@ CONTAINS
|
||||
lmp_get_natoms = lammps_get_natoms(self%handle)
|
||||
END FUNCTION lmp_get_natoms
|
||||
|
||||
SUBROUTINE lmp_file(self,filename)
|
||||
SUBROUTINE lmp_file(self, filename)
|
||||
IMPLICIT NONE
|
||||
CLASS(lammps) :: self
|
||||
CHARACTER(len=*) :: filename
|
||||
TYPE(c_ptr) :: str
|
||||
|
||||
str = f2c_string(filename)
|
||||
CALL lammps_file(self%handle,str)
|
||||
CALL lammps_file(self%handle, str)
|
||||
CALL lammps_free(str)
|
||||
END SUBROUTINE lmp_file
|
||||
|
||||
! equivalent function to lammps_command()
|
||||
SUBROUTINE lmp_command(self,cmd)
|
||||
SUBROUTINE lmp_command(self, cmd)
|
||||
IMPLICIT NONE
|
||||
CLASS(lammps) :: self
|
||||
CHARACTER(len=*) :: cmd
|
||||
TYPE(c_ptr) :: str
|
||||
|
||||
str = f2c_string(cmd)
|
||||
CALL lammps_command(self%handle,str)
|
||||
CALL lammps_command(self%handle, str)
|
||||
CALL lammps_free(str)
|
||||
END SUBROUTINE lmp_command
|
||||
|
||||
! equivalent function to lammps_commands_list()
|
||||
SUBROUTINE lmp_commands_list(self,cmds)
|
||||
SUBROUTINE lmp_commands_list(self, cmds)
|
||||
IMPLICIT NONE
|
||||
CLASS(lammps) :: self
|
||||
CHARACTER(len=*), INTENT(in), OPTIONAL :: cmds(:)
|
||||
TYPE(c_ptr), ALLOCATABLE :: cmdv(:)
|
||||
INTEGER :: i,ncmd
|
||||
INTEGER :: i, ncmd
|
||||
|
||||
! convert command list to c style
|
||||
ncmd = SIZE(cmds)
|
||||
ALLOCATE(cmdv(ncmd))
|
||||
DO i=1,ncmd
|
||||
DO i=1, ncmd
|
||||
cmdv(i) = f2c_string(cmds(i))
|
||||
END DO
|
||||
|
||||
CALL lammps_commands_list(self%handle,ncmd,cmdv)
|
||||
CALL lammps_commands_list(self%handle, ncmd, cmdv)
|
||||
|
||||
! Clean up allocated memory
|
||||
DO i=1,ncmd
|
||||
DO i=1, ncmd
|
||||
CALL lammps_free(cmdv(i))
|
||||
END DO
|
||||
DEALLOCATE(cmdv)
|
||||
END SUBROUTINE lmp_commands_list
|
||||
|
||||
! equivalent function to lammps_commands_string()
|
||||
SUBROUTINE lmp_commands_string(self,str)
|
||||
SUBROUTINE lmp_commands_string(self, str)
|
||||
IMPLICIT NONE
|
||||
CLASS(lammps) :: self
|
||||
CHARACTER(len=*) :: str
|
||||
TYPE(c_ptr) :: tmp
|
||||
|
||||
tmp = f2c_string(str)
|
||||
CALL lammps_commands_string(self%handle,tmp)
|
||||
CALL lammps_commands_string(self%handle, tmp)
|
||||
CALL lammps_free(tmp)
|
||||
END SUBROUTINE lmp_commands_string
|
||||
|
||||
! ----------------------------------------------------------------------
|
||||
! local helper functions
|
||||
! copy fortran string to zero terminated c string
|
||||
! ----------------------------------------------------------------------
|
||||
FUNCTION f2c_string(f_string) RESULT(ptr)
|
||||
CHARACTER (len=*), INTENT(in) :: f_string
|
||||
CHARACTER (len=1, kind=c_char), POINTER :: c_string(:)
|
||||
@ -276,8 +272,8 @@ CONTAINS
|
||||
|
||||
n = LEN_TRIM(f_string)
|
||||
ptr = lammps_malloc(n+1)
|
||||
CALL C_F_POINTER(ptr,c_string,[1])
|
||||
DO i=1,n
|
||||
CALL C_F_POINTER(ptr, c_string, [1])
|
||||
DO i=1, n
|
||||
c_string(i) = f_string(i:i)
|
||||
END DO
|
||||
c_string(n+1) = c_null_char
|
||||
|
||||
@ -54,8 +54,6 @@ class FixStorePeratom : public Fix {
|
||||
int n2, n3; // size of 3d dims of per-atom data struct
|
||||
int nvalues; // number of per-atom values
|
||||
int nbytes; // number of per-atom bytes
|
||||
|
||||
double *rbuf; // restart buffer for GLOBAL vec/array/tensor
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -234,7 +234,7 @@ fails a null pointer is returned.
|
||||
|
||||
void *lammps_open_no_mpi(int argc, char **argv, void **ptr)
|
||||
{
|
||||
return lammps_open(argc,argv,MPI_COMM_WORLD,ptr);
|
||||
return lammps_open(argc, argv, MPI_COMM_WORLD, ptr);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -1354,7 +1354,7 @@ void Neighbor::morph_granular()
|
||||
|
||||
void Neighbor::morph_halffull()
|
||||
{
|
||||
int i,j,jj,jmin;
|
||||
int i,j,jj;
|
||||
NeighRequest *irq,*jrq;
|
||||
double icut,jcut;
|
||||
|
||||
@ -1438,7 +1438,7 @@ void Neighbor::morph_halffull()
|
||||
|
||||
void Neighbor::morph_copy_trim()
|
||||
{
|
||||
int i,j,jj,jmin,inewton,jnewton;
|
||||
int i,j,jj,inewton,jnewton;
|
||||
NeighRequest *irq,*jrq;
|
||||
double icut,jcut;
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ void NPairTrim::build(NeighList *list)
|
||||
|
||||
double cutsq_custom = cutoff_custom * cutoff_custom;
|
||||
|
||||
int i,j,ii,jj,n,jnum,joriginal;
|
||||
int ii,jj,n,jnum,joriginal;
|
||||
int *neighptr,*jlist;
|
||||
double xtmp,ytmp,ztmp;
|
||||
double delx,dely,delz,rsq;
|
||||
@ -71,7 +71,7 @@ void NPairTrim::build(NeighList *list)
|
||||
|
||||
for (jj = 0; jj < jnum; jj++) {
|
||||
joriginal = jlist[jj];
|
||||
j = joriginal & NEIGHMASK;
|
||||
const int j = joriginal & NEIGHMASK;
|
||||
|
||||
delx = xtmp - x[j][0];
|
||||
dely = ytmp - x[j][1];
|
||||
|
||||
@ -3942,7 +3942,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
|
||||
strcmp(word,"trap") != 0 && strcmp(word,"slope") != 0 && strcmp(word,"gmask") != 0 && strcmp(word,"rmask") != 0 &&
|
||||
strcmp(word,"grmask") != 0 && strcmp(word,"next") != 0 && strcmp(word,"is_active") != 0 &&
|
||||
strcmp(word,"is_defined") != 0 && strcmp(word,"is_available") != 0 && strcmp(word,"is_file") != 0 &&
|
||||
strcmp(word,"extract_setting") != 0)
|
||||
strcmp(word,"is_os") != 0 && strcmp(word,"extract_setting") != 0)
|
||||
return 0;
|
||||
|
||||
// parse contents for comma-separated args
|
||||
@ -4340,6 +4340,19 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t
|
||||
treestack[ntreestack++] = newtree;
|
||||
} else argstack[nargstack++] = value;
|
||||
|
||||
} else if (strcmp(word,"is_os") == 0) {
|
||||
if (narg != 1) print_var_error(FLERR,"Invalid is_os() function in variable formula",ivar);
|
||||
value = utils::strmatch(platform::os_info(), args[0]) ? 1.0 : 0.0;
|
||||
|
||||
// save value in tree or on argstack
|
||||
|
||||
if (tree) {
|
||||
auto newtree = new Tree();
|
||||
newtree->type = VALUE;
|
||||
newtree->value = value;
|
||||
treestack[ntreestack++] = newtree;
|
||||
} else argstack[nargstack++] = value;
|
||||
|
||||
} else if (strcmp(word,"extract_setting") == 0) {
|
||||
if (narg != 1) print_var_error(FLERR,"Invalid extract_setting() function in variable formula",ivar);
|
||||
|
||||
|
||||
@ -144,12 +144,14 @@ TEST_F(VariableTest, CreateDelete)
|
||||
command("variable ten3 uloop 4 pad");
|
||||
command("variable dummy index 0");
|
||||
command("variable file equal is_file(MYFILE)");
|
||||
command("variable iswin equal is_os(^Windows)");
|
||||
command("variable islin equal is_os(^Linux)");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(variable->nvar, 18);
|
||||
ASSERT_EQ(variable->nvar, 20);
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("variable dummy delete");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(variable->nvar, 17);
|
||||
ASSERT_EQ(variable->nvar, 19);
|
||||
ASSERT_THAT(variable->retrieve("three"), StrEq("three"));
|
||||
variable->set_string("three", "four");
|
||||
ASSERT_THAT(variable->retrieve("three"), StrEq("four"));
|
||||
@ -168,6 +170,17 @@ TEST_F(VariableTest, CreateDelete)
|
||||
platform::unlink("MYFILE");
|
||||
ASSERT_THAT(variable->retrieve("file"), StrEq("0"));
|
||||
|
||||
#if defined(_WIN32)
|
||||
ASSERT_THAT(variable->retrieve("iswin"), StrEq("1"));
|
||||
ASSERT_THAT(variable->retrieve("islin"), StrEq("0"));
|
||||
#elif defined(__linux__)
|
||||
ASSERT_THAT(variable->retrieve("iswin"), StrEq("0"));
|
||||
ASSERT_THAT(variable->retrieve("islin"), StrEq("1"));
|
||||
#else
|
||||
ASSERT_THAT(variable->retrieve("iswin"), StrEq("0"));
|
||||
ASSERT_THAT(variable->retrieve("islin"), StrEq("0"));
|
||||
#endif
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("variable seven delete");
|
||||
command("variable seven getenv TEST_VARIABLE");
|
||||
|
||||
@ -36,7 +36,11 @@ if(Python_EXECUTABLE)
|
||||
COMMENT "Check completeness of force style tests")
|
||||
endif()
|
||||
|
||||
set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
string(REPLACE "/" "\\\\" TEST_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
else()
|
||||
set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||
endif()
|
||||
add_library(style_tests STATIC yaml_writer.cpp error_stats.cpp test_config_reader.cpp test_main.cpp)
|
||||
if(YAML_FOUND)
|
||||
target_compile_definitions(style_tests PRIVATE TEST_INPUT_FOLDER=${TEST_INPUT_FOLDER})
|
||||
|
||||
@ -10,7 +10,7 @@ pre_commands: ! |
|
||||
variable units index real
|
||||
variable newton_pair delete
|
||||
variable newton_pair index on
|
||||
shell cp ${input_dir}/table_CG_CG_CG.txt .
|
||||
if $(is_os(^Windows)) then "shell copy ${input_dir}\table_CG_CG_CG.txt ." else "shell cp ${input_dir}/table_CG_CG_CG.txt ."
|
||||
post_commands: ! ""
|
||||
input_file: in.metal
|
||||
pair_style: hybrid/overlay table linear 1200 sw/angle/table
|
||||
|
||||
@ -10,8 +10,8 @@ pre_commands: ! |
|
||||
variable units index real
|
||||
variable newton_pair delete
|
||||
variable newton_pair index on
|
||||
shell cp ${input_dir}/1-1-1.table .
|
||||
shell cp ${input_dir}/1-1-2.table .
|
||||
if $(is_os(^Windows)) then "shell copy ${input_dir}\1-1-1.table ." else "shell cp ${input_dir}/1-1-1.table ."
|
||||
if $(is_os(^Windows)) then "shell copy ${input_dir}\1-1-2.table ." else "shell cp ${input_dir}/1-1-2.table ."
|
||||
post_commands: ! ""
|
||||
input_file: in.metal
|
||||
pair_style: hybrid/overlay table linear 1200 threebody/table
|
||||
|
||||
@ -17,7 +17,7 @@ if(CMAKE_Fortran_COMPILER)
|
||||
get_filename_component(LAMMPS_FORTRAN_MODULE ${LAMMPS_SOURCE_DIR}/../fortran/lammps.f90 ABSOLUTE)
|
||||
if(BUILD_MPI)
|
||||
find_package(MPI REQUIRED)
|
||||
if((NOT MPI_Fortran) OR (NOT MPI_Fortran_HAVE_F77_HEADER) OR (NOT MPI_Fortran_HAVE_F90_MODULE))
|
||||
if((NOT MPI_Fortran_FOUND) OR (NOT MPI_Fortran_HAVE_F77_HEADER))
|
||||
message(STATUS "Skipping Tests for the LAMMPS Fortran Module: no MPI support for Fortran")
|
||||
return()
|
||||
endif()
|
||||
@ -29,7 +29,8 @@ if(CMAKE_Fortran_COMPILER)
|
||||
add_library(flammps STATIC ${LAMMPS_FORTRAN_MODULE})
|
||||
|
||||
add_executable(test_fortran_create wrap_create.cpp test_fortran_create.f90)
|
||||
target_link_libraries(test_fortran_create PRIVATE flammps lammps MPI::MPI_Fortran GTest::GTestMain)
|
||||
target_link_libraries(test_fortran_create PRIVATE lammps MPI::MPI_Fortran GTest::GTestMain)
|
||||
target_include_directories(test_fortran_create PRIVATE "${LAMMPS_SOURCE_DIR}/../fortran")
|
||||
add_test(NAME FortranOpen COMMAND test_fortran_create)
|
||||
|
||||
add_executable(test_fortran_commands wrap_commands.cpp test_fortran_commands.f90)
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
include 'lammps.f90'
|
||||
|
||||
MODULE keepcreate
|
||||
USE liblammps
|
||||
TYPE(LAMMPS) :: lmp
|
||||
@ -75,10 +77,11 @@ SUBROUTINE f_lammps_close() BIND(C, name="f_lammps_close")
|
||||
END SUBROUTINE f_lammps_close
|
||||
|
||||
FUNCTION f_lammps_get_comm() BIND(C, name="f_lammps_get_comm")
|
||||
USE ISO_C_BINDING, ONLY: c_int
|
||||
USE liblammps
|
||||
USE keepcreate, ONLY: mycomm
|
||||
IMPLICIT NONE
|
||||
INTEGER :: f_lammps_get_comm
|
||||
INTEGER(c_int) :: f_lammps_get_comm
|
||||
|
||||
f_lammps_get_comm = mycomm
|
||||
END FUNCTION f_lammps_get_comm
|
||||
|
||||
Reference in New Issue
Block a user