diff --git a/doc/src/Fortran.rst b/doc/src/Fortran.rst index 0f292af108..4c450a0c08 100644 --- a/doc/src/Fortran.rst +++ b/doc/src/Fortran.rst @@ -1567,6 +1567,8 @@ Procedures Bound to the :f:type:`lammps` Derived Type Gather the named per-atom, per-atom fix, per-atom compute, or fix property/atom-based entities from all processes, unordered. + .. versionadded:: TBD + This subroutine gathers data for all atoms and stores them in a one-dimensional allocatable array. The data will be a concatenation of chunks from each processor's owned atoms, in whatever order @@ -1610,7 +1612,9 @@ Procedures Bound to the :f:type:`lammps` Derived Type Gather the named per-atom, per-atom fix, per-atom compute, or fix property/atom-based entities from all processes for a subset of atoms. - + + .. versionadded:: TBD + This subroutine gathers data for the requested atom IDs and stores them in a one-dimensional allocatable array. The data will be ordered by atom ID, but there is no requirement that the IDs be consecutive. If you wish to return a diff --git a/unittest/fortran/wrap_gather_scatter.cpp b/unittest/fortran/wrap_gather_scatter.cpp index 5e836c1759..3aea3b8d44 100644 --- a/unittest/fortran/wrap_gather_scatter.cpp +++ b/unittest/fortran/wrap_gather_scatter.cpp @@ -214,72 +214,77 @@ TEST_F(LAMMPS_gather_scatter, scatter_atoms_subset_mask) TEST_F(LAMMPS_gather_scatter, gather_bonds) { - f_lammps_setup_gather_bonds(); + f_lammps_setup_gather_bonds(); #ifdef LAMMPS_BIGBIG - EXPECT_EQ(f_lammps_test_gather_bonds_big(), 1); + EXPECT_EQ(f_lammps_test_gather_bonds_big(), 1); #else - EXPECT_EQ(f_lammps_test_gather_bonds_small(), 1); + EXPECT_EQ(f_lammps_test_gather_bonds_small(), 1); #endif - }; TEST_F(LAMMPS_gather_scatter, gather_compute) { #ifdef LAMMPS_BIGBIG - GTEST_SKIP() + GTEST_SKIP(); +#else + f_lammps_setup_gather_scatter(); + lammps_command(lmp, "run 0"); + int natoms = lmp->atom->natoms; + int *tag = lmp->atom->tag; + double *pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, + LMP_TYPE_VECTOR); + for (int i = 0; i < natoms; i++) + EXPECT_DOUBLE_EQ(f_lammps_gather_pe_atom(tag[i]), pe[i]); #endif - f_lammps_setup_gather_scatter(); - lammps_command(lmp, "run 0"); - int natoms = lmp->atom->natoms; - int *tag = lmp->atom->tag; - double *pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, - LMP_TYPE_VECTOR); - for (int i = 0; i < natoms; i++) - EXPECT_DOUBLE_EQ(f_lammps_gather_pe_atom(tag[i]), pe[i]); }; TEST_F(LAMMPS_gather_scatter, gather_compute_concat) { #ifdef LAMMPS_BIGBIG - GTEST_SKIP() + GTEST_SKIP(); +#else + f_lammps_setup_gather_scatter(); + lammps_command(lmp, "run 0"); + int natoms = lmp->atom->natoms; + int *tag = lmp->atom->tag; + double *pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, + LMP_TYPE_VECTOR); + for (int i = 0; i < natoms; i++) + EXPECT_DOUBLE_EQ(f_lammps_gather_pe_atom(tag[i]), pe[i]); #endif - f_lammps_setup_gather_scatter(); - lammps_command(lmp, "run 0"); - int natoms = lmp->atom->natoms; - int *tag = lmp->atom->tag; - double *pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, - LMP_TYPE_VECTOR); - for (int i = 0; i < natoms; i++) - EXPECT_DOUBLE_EQ(f_lammps_gather_pe_atom(tag[i]), pe[i]); }; TEST_F(LAMMPS_gather_scatter, gather_compute_subset) { - f_lammps_setup_gather_scatter(); - lammps_command(lmp, "run 0"); - int ids[2] = {3, 1}; - int *tag = lmp->atom->tag; - double pe[2] = {0.0, 0.0}; - int nlocal = lammps_extract_setting(lmp, "nlocal"); - double *pa_pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, - LMP_TYPE_VECTOR); +#ifdef LAMMPS_BIGBIG + GTEST_SKIP(); +#else + f_lammps_setup_gather_scatter(); + lammps_command(lmp, "run 0"); + int ids[2] = {3, 1}; + int *tag = lmp->atom->tag; + double pe[2] = {0.0, 0.0}; + int nlocal = lammps_extract_setting(lmp, "nlocal"); + double *pa_pe = (double*) lammps_extract_compute(lmp, "pe", LMP_STYLE_ATOM, + LMP_TYPE_VECTOR); - for (int i = 0; i < nlocal; i++) { - if(tag[i] == ids[0]) pe[0] = pa_pe[i]; - if(tag[i] == ids[1]) pe[1] = pa_pe[i]; - } + for (int i = 0; i < nlocal; i++) { + if(tag[i] == ids[0]) pe[0] = pa_pe[i]; + if(tag[i] == ids[1]) pe[1] = pa_pe[i]; + } - double ftn_pe[2]; - f_lammps_gather_pe_atom_subset(ids, ftn_pe); - EXPECT_DOUBLE_EQ(ftn_pe[0], pe[0]); - EXPECT_DOUBLE_EQ(ftn_pe[1], pe[1]); + double ftn_pe[2]; + f_lammps_gather_pe_atom_subset(ids, ftn_pe); + EXPECT_DOUBLE_EQ(ftn_pe[0], pe[0]); + EXPECT_DOUBLE_EQ(ftn_pe[1], pe[1]); +#endif }; TEST_F(LAMMPS_gather_scatter, scatter_compute) { #ifdef LAMMPS_BIGBIG GTEST_SKIP(); -#endif +#else f_lammps_setup_gather_scatter(); int natoms = lmp->atom->natoms; double *pe = new double[natoms]; @@ -298,13 +303,14 @@ TEST_F(LAMMPS_gather_scatter, scatter_compute) EXPECT_DOUBLE_EQ(pe[2], old_pe[0]); delete[] old_pe; delete[] pe; +#endif }; TEST_F(LAMMPS_gather_scatter, scatter_subset_compute) { #ifdef LAMMPS_BIGBIG GTEST_SKIP(); -#endif +#else f_lammps_setup_gather_scatter(); int natoms = lmp->atom->natoms; double *pe = new double[natoms]; @@ -323,4 +329,5 @@ TEST_F(LAMMPS_gather_scatter, scatter_subset_compute) EXPECT_DOUBLE_EQ(pe[2], old_pe[0]); delete[] old_pe; delete[] pe; +#endif };