diff --git a/doc/src/Fortran.rst b/doc/src/Fortran.rst index a62378819f..e7b44c4686 100644 --- a/doc/src/Fortran.rst +++ b/doc/src/Fortran.rst @@ -1108,7 +1108,7 @@ Procedures Bound to the lammps Derived Type of atoms, see :f:func:`gather_atoms_subset`. The *data* array will be ordered in groups of *count* values, sorted by atom - ID (e.g., if *name* is *x* and *count* = 3, then *data* = x[1][1], x[2][1], + ID (e.g., if *name* is *x* and *count* = 3, then *data* = x[1][1], x[2][1], x[3][1], x[1][2], x[2][2], x[3][2], x[1][3], :math:`\dots`); *data* must be ``ALLOCATABLE`` and will be allocated to length (*count* :math:`\times` *natoms*), as queried by diff --git a/src/library.cpp b/src/library.cpp index fe16d1e518..bfa0fc803a 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -2235,7 +2235,7 @@ a similar array but have non-consecutive atom IDs, see of atoms, see :cpp:func:`lammps_gather_atoms_subset`. The *data* array will be ordered in groups of *count* values, sorted by atom ID -(e.g., if *name* is *x* and *count* = 3, then *data* = x[0][0], x[0][1], +(e.g., if *name* is *x* and *count* = 3, then *data* = x[0][0], x[0][1], x[0][2], x[1][0], x[1][1], x[1][2], x[2][0], :math:`\dots`); *data* must be pre-allocated by the caller to length (*count* :math:`\times` *natoms*), as queried by :cpp:func:`lammps_get_natoms`, @@ -2383,7 +2383,7 @@ This subroutine gathers data for all atoms and stores them in a one-dimensional array allocated by the user. The data will be a concatenation of chunks from each processor's owned atoms, in whatever order the atoms are in on each processor. This process has no requirement that the atom IDs be -consecutive. If you need the ID of each atom, you can do another +consecutive. If you need the ID of each atom, you can do another :cpp:func:`lammps_gather_atoms_concat` call with *name* set to ``id``. If you have consecutive IDs and want the data to be in order, use :cpp:func:`lammps_gather_atoms`; for a similar array but for a subset diff --git a/unittest/fortran/test_fortran_extract_fix.f90 b/unittest/fortran/test_fortran_extract_fix.f90 index 85b4cb5f4f..7d5e18016b 100644 --- a/unittest/fortran/test_fortran_extract_fix.f90 +++ b/unittest/fortran/test_fortran_extract_fix.f90 @@ -1,27 +1,7 @@ -MODULE keepfix - USE liblammps - TYPE(LAMMPS) :: lmp - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: demo_input = & - [ CHARACTER(LEN=40) :: & - 'region box block 0 $x 0 3 0 4', & - 'create_box 1 box', & - 'create_atoms 1 single 1.0 1.0 ${zpos}' ] - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: cont_input = & - [ CHARACTER(LEN=40) :: & - 'create_atoms 1 single &', & - ' 0.2 0.1 0.1', & - 'create_atoms 1 single 0.5 0.5 0.5' ] - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: pair_input = & - [ CHARACTER(LEN=40) :: & - 'pair_style lj/cut 2.5', & - 'pair_coeff 1 1 1.0 1.0', & - 'mass 1 2.0' ] -END MODULE keepfix - FUNCTION f_lammps_with_args() BIND(C) USE ISO_C_BINDING, ONLY: C_ptr USE liblammps - USE keepfix, ONLY: lmp + USE keepstuff, ONLY: lmp IMPLICIT NONE TYPE(C_ptr) :: f_lammps_with_args CHARACTER(len=12), DIMENSION(12), PARAMETER :: args = & @@ -35,7 +15,7 @@ END FUNCTION f_lammps_with_args SUBROUTINE f_lammps_close() BIND(C) USE ISO_C_BINDING, ONLY: c_null_ptr USE liblammps - USE keepfix, ONLY: lmp + USE keepstuff, ONLY: lmp IMPLICIT NONE CALL lmp%close() @@ -44,11 +24,12 @@ END SUBROUTINE f_lammps_close SUBROUTINE f_lammps_setup_extract_fix () BIND(C) USE LIBLAMMPS - USE keepfix, ONLY : lmp, demo_input, cont_input, pair_input + USE keepstuff, ONLY : lmp, big_input, cont_input, pair_input, more_input IMPLICIT NONE - CALL lmp%commands_list(demo_input) + CALL lmp%commands_list(big_input) CALL lmp%commands_list(cont_input) + CALL lmp%commands_list(more_input) CALL lmp%commands_list(pair_input) CALL lmp%command("fix state all store/state 0 z") ! per-atom vector CALL lmp%command("fix move all move linear 0 0 0") ! for per-atom array @@ -62,7 +43,7 @@ END SUBROUTINE f_lammps_setup_extract_fix FUNCTION f_lammps_extract_fix_global_scalar () BIND(C) RESULT(scalar) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double USE LIBLAMMPS - USE keepfix, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE REAL(C_double) :: scalar @@ -72,7 +53,7 @@ END FUNCTION f_lammps_extract_fix_global_scalar FUNCTION f_lammps_extract_fix_global_vector (i) BIND(C) RESULT(element) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepfix, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(C_int), INTENT(IN), VALUE :: i REAL(C_double) :: element @@ -83,7 +64,7 @@ END FUNCTION f_lammps_extract_fix_global_vector FUNCTION f_lammps_extract_fix_global_array (i,j) BIND(C) RESULT(element) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepfix, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(C_int), INTENT(IN), VALUE :: i, j REAL(C_double) :: element @@ -94,7 +75,7 @@ END FUNCTION f_lammps_extract_fix_global_array FUNCTION f_lammps_extract_fix_peratom_vector (i) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepfix, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(C_int), INTENT(IN), VALUE :: i REAL(C_double) :: f_lammps_extract_fix_peratom_vector @@ -107,7 +88,7 @@ END FUNCTION f_lammps_extract_fix_peratom_vector FUNCTION f_lammps_extract_fix_peratom_array (i,j) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepfix, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(C_int), INTENT(IN), VALUE :: i, j REAL(C_double) :: f_lammps_extract_fix_peratom_array diff --git a/unittest/fortran/test_fortran_extract_variable.f90 b/unittest/fortran/test_fortran_extract_variable.f90 index 267b5e1139..0b16e61894 100644 --- a/unittest/fortran/test_fortran_extract_variable.f90 +++ b/unittest/fortran/test_fortran_extract_variable.f90 @@ -1,26 +1,11 @@ MODULE keepvar USE liblammps IMPLICIT NONE - TYPE(LAMMPS) :: lmp - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: demo_input = & - [ CHARACTER(LEN=40) :: & - 'region box block 0 $x 0 3 0 4', & - 'create_box 1 box', & - 'create_atoms 1 single 1.0 1.0 ${zpos}' ] - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: cont_input = & - [ CHARACTER(LEN=40) :: & - 'create_atoms 1 single &', & - ' 0.2 0.1 0.1', & - 'create_atoms 1 single 0.5 0.5 0.5' ] - CHARACTER(LEN=40), DIMENSION(3), PARAMETER :: pair_input = & - [ CHARACTER(LEN=40) :: & - 'pair_style lj/cut 2.5', & - 'pair_coeff 1 1 1.0 1.0', & - 'mass 1 2.0' ] CONTAINS FUNCTION absolute_path(filename) + USE keepstuff, ONLY : lmp CHARACTER(LEN=:), ALLOCATABLE :: absolute_path CHARACTER(LEN=*), INTENT(IN) :: filename CHARACTER(LEN=256) :: test_input_directory @@ -60,7 +45,7 @@ END MODULE keepvar FUNCTION f_lammps_with_C_args(argc, argv) BIND(C) USE ISO_C_BINDING, ONLY: c_ptr, c_char, c_int, c_size_t, C_F_POINTER USE liblammps - USE keepvar, ONLY: lmp + USE keepstuff, ONLY: lmp IMPLICIT NONE INTEGER(c_int), INTENT(IN), VALUE :: argc TYPE(c_ptr), VALUE :: argv @@ -97,7 +82,7 @@ END FUNCTION f_lammps_with_C_args SUBROUTINE f_lammps_close() BIND(C) USE ISO_C_BINDING, ONLY: c_null_ptr USE liblammps - USE keepvar, ONLY: lmp + USE keepstuff, ONLY: lmp IMPLICIT NONE CALL lmp%close() @@ -106,7 +91,8 @@ END SUBROUTINE f_lammps_close SUBROUTINE f_lammps_setup_extract_variable () BIND(C) USE LIBLAMMPS - USE keepvar, ONLY : lmp, demo_input, cont_input, pair_input, absolute_path + USE keepstuff, ONLY : lmp, big_input, cont_input, more_input, pair_input + USE keepvar, ONLY : absolute_path IMPLICIT NONE ! Had to do this one as one string because lammps_commands_list and @@ -118,8 +104,9 @@ SUBROUTINE f_lammps_setup_extract_variable () BIND(C) // NEW_LINE(' ') // '"""' CALL lmp%command('atom_modify map array') - CALL lmp%commands_list(demo_input) + CALL lmp%commands_list(big_input) CALL lmp%commands_list(cont_input) + CALL lmp%commands_list(more_input) CALL lmp%commands_list(pair_input) CALL lmp%command('variable idx index "hello" "goodbye"') CALL lmp%command('variable lp loop 10') @@ -153,7 +140,7 @@ END SUBROUTINE f_lammps_setup_extract_variable FUNCTION f_lammps_extract_variable_index_1 () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int) :: f_lammps_extract_variable_index_1 CHARACTER(LEN=80) :: str @@ -169,7 +156,7 @@ END FUNCTION f_lammps_extract_variable_index_1 FUNCTION f_lammps_extract_variable_index_2 () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int) :: f_lammps_extract_variable_index_2 CHARACTER(LEN=80) :: str @@ -185,7 +172,7 @@ END FUNCTION f_lammps_extract_variable_index_2 FUNCTION f_lammps_extract_variable_loop () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int, C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int) :: f_lammps_extract_variable_loop CHARACTER(LEN=80) :: loop @@ -197,7 +184,8 @@ END FUNCTION f_lammps_extract_variable_loop FUNCTION f_lammps_extract_variable_loop_pad () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_loop_pad CHARACTER(LEN=20) :: loop @@ -209,8 +197,8 @@ END FUNCTION f_lammps_extract_variable_loop_pad FUNCTION f_lammps_extract_variable_world () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string - + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_world CHARACTER(LEN=20) :: world @@ -222,8 +210,8 @@ END FUNCTION f_lammps_extract_variable_world FUNCTION f_lammps_extract_variable_universe () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string - + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_universe CHARACTER(LEN=20) :: universe @@ -235,7 +223,7 @@ END FUNCTION f_lammps_extract_variable_universe FUNCTION f_lammps_extract_variable_uloop () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int) :: f_lammps_extract_variable_uloop CHARACTER(LEN=80) :: uloop @@ -247,7 +235,8 @@ END FUNCTION f_lammps_extract_variable_uloop FUNCTION f_lammps_extract_variable_string () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_string CHARACTER(LEN=40) :: string @@ -259,7 +248,8 @@ END FUNCTION f_lammps_extract_variable_string FUNCTION f_lammps_extract_variable_format () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_format CHARACTER(LEN=20) :: form @@ -271,7 +261,8 @@ END FUNCTION f_lammps_extract_variable_format FUNCTION f_lammps_extract_variable_format_pad () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_format_pad CHARACTER(LEN=20) :: form @@ -283,7 +274,8 @@ END FUNCTION f_lammps_extract_variable_format_pad FUNCTION f_lammps_extract_variable_getenv () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_getenv CHARACTER(LEN=40) :: string @@ -295,7 +287,8 @@ END FUNCTION f_lammps_extract_variable_getenv FUNCTION f_lammps_extract_variable_file () BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_ptr USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE TYPE(c_ptr) :: f_lammps_extract_variable_file CHARACTER(LEN=40) :: string @@ -307,7 +300,7 @@ END FUNCTION f_lammps_extract_variable_file FUNCTION f_lammps_extract_variable_atomfile(i) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int, C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int), INTENT(IN), VALUE :: i REAL(c_double) :: f_lammps_extract_variable_atomfile @@ -320,7 +313,7 @@ END FUNCTION f_lammps_extract_variable_atomfile FUNCTION f_lammps_extract_variable_python(i) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_int, C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int), INTENT(IN), VALUE :: i REAL(c_double) :: f_lammps_extract_variable_python @@ -331,7 +324,7 @@ END FUNCTION f_lammps_extract_variable_python FUNCTION f_lammps_extract_variable_timer() BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE REAL(c_double) :: f_lammps_extract_variable_timer @@ -341,7 +334,7 @@ END FUNCTION f_lammps_extract_variable_timer FUNCTION f_lammps_extract_variable_internal() BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE REAL(c_double) :: f_lammps_extract_variable_internal @@ -351,7 +344,7 @@ END FUNCTION f_lammps_extract_variable_internal FUNCTION f_lammps_extract_variable_equal() BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE REAL(c_double) :: f_lammps_extract_variable_equal @@ -361,7 +354,7 @@ END FUNCTION f_lammps_extract_variable_equal FUNCTION f_lammps_extract_variable_atom(i) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int), INTENT(IN), VALUE :: i REAL(c_double) :: f_lammps_extract_variable_atom @@ -374,7 +367,7 @@ END FUNCTION f_lammps_extract_variable_atom FUNCTION f_lammps_extract_variable_vector(i) BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp + USE keepstuff, ONLY : lmp IMPLICIT NONE INTEGER(c_int), INTENT(IN), VALUE :: i REAL(c_double) :: f_lammps_extract_variable_vector @@ -387,7 +380,8 @@ END FUNCTION f_lammps_extract_variable_vector SUBROUTINE f_lammps_set_variable_string() BIND(C) USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_double, C_int USE LIBLAMMPS - USE keepvar, ONLY : lmp, f2c_string + USE keepstuff, ONLY : lmp + USE keepvar, ONLY : f2c_string IMPLICIT NONE CHARACTER(LEN=40) :: string