Merge branch release-2016
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 7 Dec 2016 04:16:48 +0000 (15:16 +1100)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 7 Dec 2016 04:17:43 +0000 (15:17 +1100)
Ignored fix to zlib management for GMX_EXTERNAL_TNG=on because that
was already a feature of the refactoring of TNG management in master
branch.

Change-Id: I8bc7ce196fb0d64685c6957b5055d73ff093d864

13 files changed:
cmake/gmxDetectSimd.cmake
cmake/gmxSetBuildInformation.cmake
src/gromacs/fileio/tngio_for_tools.cpp
src/gromacs/gmxana/gmx_trjconv.cpp
src/gromacs/gmxana/gmx_vanhove.cpp
src/gromacs/hardware/tests/cpuinfo.cpp
src/gromacs/selection/compiler.cpp
src/gromacs/selection/selhelp.cpp
src/gromacs/selection/sm_simple.cpp
src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionVariableInModifier.xml [new file with mode: 0644]
src/gromacs/selection/tests/selectioncollection.cpp
src/gromacs/tools/dump.cpp
src/programs/mdrun/membed.cpp

index 2d70f20e4da1ef4b4d849b5e6bb63f801234cb9d..fdf64df5f8744edc6c216eea359ae7873dc4b0a7 100644 (file)
@@ -72,10 +72,12 @@ function(gmx_suggest_simd _suggested_simd)
     message(STATUS "Detecting best SIMD instructions for this CPU")
 
     # Get CPU SIMD properties information
-    set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS}")
     if(GMX_TARGET_X86)
-        set(_compile_definitions "${_compile_definitions} -DGMX_TARGET_X86")
+        set(GMX_TARGET_X86_VALUE 1)
+    else()
+        set(GMX_TARGET_X86_VALUE 0)
     endif()
+    set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE}")
 
     # Prepare a default suggestion
     set(OUTPUT_SIMD "None")
index f064ba419f8d6d537aee25a2d935769ee6c9ecc0..52b60c3ea0a8a65558c1c5149f8d0aa5c781b51b 100644 (file)
@@ -95,10 +95,12 @@ macro(gmx_set_build_information)
 
     if(NOT CMAKE_CROSSCOMPILING)
         # Get CPU information, e.g. for deciding what SIMD support probably exists
-        set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS}")
         if(GMX_TARGET_X86)
-            set(_compile_definitions "${_compile_definitions} -DGMX_TARGET_X86")
+            set(GMX_TARGET_X86_VALUE 1)
+        else()
+            set(GMX_TARGET_X86_VALUE 0)
         endif()
+        set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUINFO_STANDALONE ${GMX_STDLIB_CXX_FLAGS} -DGMX_TARGET_X86=${GMX_TARGET_X86_VALUE}")
 
         set(GMX_BUILDINFORMATION_BINARY "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/GmxBuildInformation${CMAKE_EXECUTABLE_SUFFIX}")
         set(LINK_LIBRARIES "${GMX_STDLIB_LIBRARIES}")
index e351aed6131a9523b5291726645dfd4701fae79e..51839aa06dd61261d84e1b48a2eccd1d8df7d856 100644 (file)
@@ -616,7 +616,7 @@ gmx_bool gmx_read_next_tng_frame(tng_trajectory_t            input,
          * be reallocated if it is not NULL. */
     }
 
-    fr->step  = static_cast<int>(frameNumber);
+    fr->step  = frameNumber;
     fr->bStep = TRUE;
     // Convert the time to ps
     fr->time  = frameTime / PICO;
@@ -840,7 +840,7 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t     input,
     {
         gmx_file("Cannot read next frame of TNG file");
     }
-    snew(*values, sizeof(real) * *nValuesPerFrame * *nAtoms);
+    srenew(*values, sizeof(real) * *nValuesPerFrame * *nAtoms);
     convert_array_to_real_array(data,
                                 *values,
                                 getDistanceScaleFactor(input),
index a28040b72f782cae6057b239e927bb99fadc441d..cf975601f976e91a632a23dfce5570a09025cef1 100644 (file)
@@ -861,7 +861,7 @@ int gmx_trjconv(int argc, char *argv[])
     FILE             *out    = NULL;
     t_trxstatus      *trxout = NULL;
     t_trxstatus      *trxin;
-    int               ftp, ftpin = 0, file_nr;
+    int               file_nr;
     t_trxframe        fr, frout;
     int               flags;
     rvec             *xmem  = NULL, *vmem = NULL, *fmem = NULL;
@@ -1015,13 +1015,13 @@ int gmx_trjconv(int argc, char *argv[])
 
         /* Determine output type */
         out_file = opt2fn("-o", NFILE, fnm);
-        ftp      = fn2ftp(out_file);
+        int ftp  = fn2ftp(out_file);
         fprintf(stderr, "Will write %s: %s\n", ftp2ext(ftp), ftp2desc(ftp));
         bNeedPrec = (ftp == efXTC || ftp == efGRO);
+        int ftpin = fn2ftp(in_file);
         if (bVels)
         {
             /* check if velocities are possible in input and output files */
-            ftpin = fn2ftp(in_file);
             bVels = (ftp == efTRR || ftp == efGRO ||
                      ftp == efG96 || ftp == efTNG)
                 && (ftpin == efTRR || ftpin == efGRO ||
index db3da07cff5eeb9089dbcedaf2d5d5407d39e1ce..0c660cc4b359639c1366d26a0101d917b5321634 100644 (file)
@@ -229,7 +229,7 @@ int gmx_vanhove(int argc, char *argv[])
 
     dt = (time[nfr-1] - time[0])/(nfr - 1);
     /* Some ugly rounding to get nice nice times in the output */
-    dt = static_cast<int>((10000.0*dt + 0.5)/10000.0);
+    dt = std::round(10000.0*dt)/10000.0;
 
     invbin = 1.0/rbin;
 
index f7bc5d32ca5668cdfe852201625a5d36a3939a08..e90d83606b15f82942bd05afc23002bf63256b3c 100644 (file)
@@ -68,7 +68,7 @@ TEST(CpuInfoTest, SupportLevel)
     EXPECT_GT(c.supportLevel(), gmx::CpuInfo::SupportLevel::None)
     << "No CPU information at all could be detected. " << commonMsg << std::endl;
 
-#ifdef GMX_TARGET_X86
+#if GMX_TARGET_X86
     EXPECT_GE(c.supportLevel(), gmx::CpuInfo::SupportLevel::Features)
     << "No CPU features could be detected. " << commonMsg << std::endl;
 #endif
index 217a4b71b52fbc566dbdc091adc0eb80839eaa74..a35ac378a01d52dfc82ff246087b6ac29bf9b53e 100644 (file)
@@ -2281,6 +2281,7 @@ analyze_static(gmx_sel_evaluate_t                *data,
                 if (sel->v.type == POS_VALUE)
                 {
                     alloc_selection_pos_data(sel);
+                    gmx_ana_pos_copy(sel->v.u.p, sel->child->v.u.p, true);
                 }
                 else
                 {
index 57887d8865258536b4144855192fa660c0835d45..14220e28c291cb9f7315516628a9656b6ce78397 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -163,6 +163,23 @@ const char *const CmdLineHelpText::text[] = {
     "  positions used in selecting atoms by coordinates.",
     "",
     "See the \"positions\" subtopic for more information on these options.",
+    "",
+    "Tools that take selections apply them to a structure/topology and/or",
+    "a trajectory file. If the tool takes both (typically as [TT]-s[tt]",
+    "for structure/topology and [TT]-f[tt] for trajectory), then the",
+    "trajectory file is only used for coordinate information, and all other",
+    "information, such as atom names and residue information, is read from",
+    "the structure/topology file. If the tool only takes a structure file,",
+    "or if only that input parameter is provided, then also the coordinates",
+    "are taken from that file.",
+    "For example, to select atoms from a [TT].pdb[tt]/[TT].gro[tt] file in",
+    "a tool that provides both options, pass it as [TT]-s[tt] (only).",
+    "There is no warning if the trajectory file specifies, e.g., different",
+    "atom names than the structure file. Only the number of atoms is checked.",
+    "Many selection-enabled tools also provide an [TT]-fgroup[tt] option",
+    "to specify the atom indices that are present in the trajectory for cases",
+    "where the trajectory only has a subset of atoms from the",
+    "topology/structure file."
 };
 
 struct EvaluationHelpText
index 4af50ee16347c9c3f1f3bde89f02d89b9c784ac7..60910d1cbe43b604284636459c9c68f22b22d41b 100644 (file)
@@ -205,6 +205,28 @@ static const char *const help_atomname[] = {
     "keywords."
 };
 
+//! Help title for residue index selection keywords.
+static const char        helptitle_resindex[] = "Selecting atoms by residue number";
+//! Help text for residue index selection keywords.
+static const char *const help_resindex[] = {
+    "::",
+    "",
+    "  resnr",
+    "  resid",
+    "  resindex",
+    "  residue",
+    "",
+    "[TT]resnr[tt] selects atoms using the residue numbering in the input",
+    "file. [TT]resid[tt] is synonym for this keyword for VMD compatibility.",
+    "",
+    "[TT]resindex N[tt] selects the [TT]N[tt]th residue starting from the",
+    "beginning of the input file. This is useful for uniquely identifying",
+    "residues if there are duplicate numbers in the input file (e.g., in",
+    "multiple chains).",
+    "[TT]residue[tt] is a synonym for [TT]resindex[tt]. This allows",
+    "[TT]same residue as[tt] to work as expected."
+};
+
 /** Selection method data for \p all selection keyword. */
 gmx_ana_selmethod_t sm_all = {
     "all", GROUP_VALUE, 0,
@@ -259,6 +281,7 @@ gmx_ana_selmethod_t sm_resnr = {
     NULL,
     &evaluate_resnr,
     NULL,
+    {NULL, helptitle_resindex, asize(help_resindex), help_resindex}
 };
 
 /** Selection method data for \p resindex selection keyword. */
@@ -273,6 +296,7 @@ gmx_ana_selmethod_t sm_resindex = {
     NULL,
     &evaluate_resindex,
     NULL,
+    {NULL, helptitle_resindex, asize(help_resindex), help_resindex}
 };
 
 /** Selection method data for \p molindex selection keyword. */
diff --git a/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionVariableInModifier.xml b/src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesPositionVariableInModifier.xml
new file mode 100644 (file)
index 0000000..6381ff5
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <ParsedSelections Name="Parsed">
+    <ParsedVariable Name="Variable1">
+      <String Name="Input">foo = cog of resnr 1</String>
+    </ParsedVariable>
+    <ParsedSelection Name="Selection1">
+      <String Name="Input">cog of resnr 2 plus foo</String>
+      <String Name="Text">cog of resnr 2 plus foo</String>
+      <Bool Name="Dynamic">false</Bool>
+    </ParsedSelection>
+    <ParsedSelection Name="Selection2">
+      <String Name="Input">cog of resnr 3 plus foo</String>
+      <String Name="Text">cog of resnr 3 plus foo</String>
+      <Bool Name="Dynamic">false</Bool>
+    </ParsedSelection>
+  </ParsedSelections>
+  <CompiledSelections Name="Compiled">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">6</Int>
+        <Int>3</Int>
+        <Int>4</Int>
+        <Int>5</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+      </Sequence>
+    </Selection>
+    <Selection Name="Selection2">
+      <Sequence Name="Atoms">
+        <Int Name="Length">6</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+      </Sequence>
+    </Selection>
+  </CompiledSelections>
+  <EvaluatedSelections Name="Frame1">
+    <Selection Name="Selection1">
+      <Sequence Name="Atoms">
+        <Int Name="Length">6</Int>
+        <Int>3</Int>
+        <Int>4</Int>
+        <Int>5</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+      </Sequence>
+      <Sequence Name="Positions">
+        <Int Name="Length">2</Int>
+        <Position>
+          <Vector Name="Coordinates">
+            <Real Name="X">1.6666666666666665</Real>
+            <Real Name="Y">2.333333333333333</Real>
+            <Real Name="Z">0</Real>
+          </Vector>
+        </Position>
+        <Position>
+          <Vector Name="Coordinates">
+            <Real Name="X">1</Real>
+            <Real Name="Y">2</Real>
+            <Real Name="Z">0</Real>
+          </Vector>
+        </Position>
+      </Sequence>
+    </Selection>
+    <Selection Name="Selection2">
+      <Sequence Name="Atoms">
+        <Int Name="Length">6</Int>
+        <Int>6</Int>
+        <Int>7</Int>
+        <Int>8</Int>
+        <Int>0</Int>
+        <Int>1</Int>
+        <Int>2</Int>
+      </Sequence>
+      <Sequence Name="Positions">
+        <Int Name="Length">2</Int>
+        <Position>
+          <Vector Name="Coordinates">
+            <Real Name="X">2.333333333333333</Real>
+            <Real Name="Y">2.6666666666666665</Real>
+            <Real Name="Z">0</Real>
+          </Vector>
+        </Position>
+        <Position>
+          <Vector Name="Coordinates">
+            <Real Name="X">1</Real>
+            <Real Name="Y">2</Real>
+            <Real Name="Z">0</Real>
+          </Vector>
+        </Position>
+      </Sequence>
+    </Selection>
+  </EvaluatedSelections>
+</ReferenceData>
index 2d89ecc2d1ac6be70b559d390358f0f167aa58e8..c8c3a75c4a63151845f1ba538f8bc78e86e75bad 100644 (file)
@@ -1532,6 +1532,18 @@ TEST_F(SelectionCollectionDataTest, HandlesPositionVariables)
 }
 
 
+TEST_F(SelectionCollectionDataTest, HandlesPositionVariableInModifier)
+{
+    static const char * const selections[] = {
+        "foo = cog of resnr 1",
+        "cog of resnr 2 plus foo",
+        "cog of resnr 3 plus foo"
+    };
+    setFlags(TestFlags() | efTestEvaluation | efTestPositionCoordinates);
+    runTest("simple.gro", selections);
+}
+
+
 TEST_F(SelectionCollectionDataTest, HandlesConstantPositionInVariable)
 {
     static const char * const selections[] = {
index 1e9da4acfd4cc87d299cd1c7adf3efb7b3692b3d..17196243034a9236066579cf80beb25999c4a83a 100644 (file)
@@ -353,6 +353,7 @@ static void list_tng(const char gmx_unused *fn)
     gmx_int64_t          nframe = 0;
     gmx_int64_t          i, *block_ids = NULL, step, ndatablocks;
     gmx_bool             bOK;
+    real                *values = NULL;
 
     gmx_tng_open(fn, 'r', &tng);
     gmx_print_tng_molecule_system(tng, stdout);
@@ -367,7 +368,7 @@ static void list_tng(const char gmx_unused *fn)
         for (i = 0; i < ndatablocks; i++)
         {
             double               frame_time;
-            real                 prec, *values = NULL;
+            real                 prec;
             gmx_int64_t          n_values_per_frame, n_atoms;
             char                 block_name[STRLEN];
 
@@ -401,7 +402,7 @@ static void list_tng(const char gmx_unused *fn)
     {
         sfree(block_ids);
     }
-
+    sfree(values);
     gmx_tng_close(&tng);
 #endif
 }
index c57dc73c3234dcc05ec1900d4d604081c50381bc..ce15054cf88be6b169668a73a088d8b695b5f74d 100644 (file)
@@ -1116,7 +1116,7 @@ gmx_membed_t *init_membed(FILE *fplog, int nfile, const t_filenm fnm[], gmx_mtop
         if (xy_fac < min_xy_init)
         {
             warn++;
-            fprintf(stderr, "\nWarning %d:\nThe initial size of %s is probably too smal.\n\n", warn, ins);
+            fprintf(stderr, "\nWarning %d:\nThe initial size of %s is probably too small.\n\n", warn, ins);
         }
 
         if (it_xy < min_it_xy)