Merge release-4-6 into release-5-0
authorRoland Schulz <roland@utk.edu>
Fri, 27 Jun 2014 23:22:28 +0000 (19:22 -0400)
committerRoland Schulz <roland@utk.edu>
Fri, 27 Jun 2014 23:22:28 +0000 (19:22 -0400)
Conflicts:
CMakeLists.txt
share/top/oplsaa.ff/watermodels.dat
src/gromacs/fileio/trxio.c
src/gromacs/gmxana/anadih.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gmx_tcaf.c
src/gromacs/gmxlib/checkpoint.c
src/gromacs/legacyheaders/tables.h
src/gromacs/mdlib/shellfc.c
src/gromacs/mdlib/tables.c
src/gromacs/pulling/pull.c
src/kernel/readpull.c -> applied to
             src/gromacs/gmxpreprocess/readpull.c
src/programs/mdrun/repl_ex.c

Change ignored because was already merged:
       src/gromacs/mdlib/sim_util.c

Deleted. No merge:
src/gmxlib/gpu_utils/dummy.cpp

Removal of INSTALL_NAME_DIR not necessary because
was already not there anymore:
src/gmxlib/CMakeLists.txt
src/tools/CMakeLists.txt
src/kernel/CMakeLists.txt
src/mdlib/CMakeLists.txt

Tools deleted - no merge:
src/tools/gmx_bond.c
src/tools/gmx_kinetics.c

Change-Id: Ibeb5a23cce94fb1765ebee271c9c92e001b83630

65 files changed:
CMakeLists.txt
cmake/gmxManageGPU.cmake
cmake/gmxManageNvccConfig.cmake
share/top/amber03.ff/tip5p.itp
share/top/amber03.ff/watermodels.dat
share/top/amber94.ff/tip5p.itp
share/top/amber94.ff/watermodels.dat
share/top/amber96.ff/tip5p.itp
share/top/amber96.ff/watermodels.dat
share/top/amber99.ff/tip5p.itp
share/top/amber99.ff/watermodels.dat
share/top/amber99sb-ildn.ff/tip5p.itp
share/top/amber99sb-ildn.ff/watermodels.dat
share/top/amber99sb.ff/tip5p.itp
share/top/amber99sb.ff/watermodels.dat
share/top/amberGS.ff/tip5p.itp
share/top/amberGS.ff/watermodels.dat
share/top/charmm27.ff/aminoacids.r2b
share/top/charmm27.ff/atomtypes.atp
share/top/charmm27.ff/ffnonbonded.itp
share/top/charmm27.ff/gb.itp
share/top/charmm27.ff/tip5p.itp
share/top/charmm27.ff/watermodels.dat
share/top/oplsaa.ff/aminoacids.rtp
share/top/oplsaa.ff/tip5p.itp
share/top/oplsaa.ff/watermodels.dat
src/gromacs/fileio/libxdrf.c
src/gromacs/fileio/trx.h
src/gromacs/fileio/trxio.c
src/gromacs/gmxana/anadih.c
src/gromacs/gmxana/gmx_anaeig.c
src/gromacs/gmxana/gmx_analyze.c
src/gromacs/gmxana/gmx_angle.c
src/gromacs/gmxana/gmx_chi.c
src/gromacs/gmxana/gmx_cluster.c
src/gromacs/gmxana/gmx_dos.c
src/gromacs/gmxana/gmx_enemat.c
src/gromacs/gmxana/gmx_energy.c
src/gromacs/gmxana/gmx_genpr.c
src/gromacs/gmxana/gmx_mdmat.c
src/gromacs/gmxana/gmx_mindist.c
src/gromacs/gmxana/gmx_polystat.c
src/gromacs/gmxana/gmx_rama.c
src/gromacs/gmxana/gmx_rms.c
src/gromacs/gmxana/gmx_tcaf.c
src/gromacs/gmxana/gmx_vanhove.c
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxlib/bondfree.c
src/gromacs/gmxlib/checkpoint.c
src/gromacs/gmxpreprocess/grompp.c
src/gromacs/gmxpreprocess/readpull.c
src/gromacs/gmxpreprocess/toppush.c
src/gromacs/legacyheaders/oenv.h
src/gromacs/legacyheaders/shellfc.h
src/gromacs/legacyheaders/tables.h
src/gromacs/mdlib/pme.c
src/gromacs/mdlib/shellfc.c
src/gromacs/mdlib/tables.c
src/gromacs/mdlib/update.c
src/gromacs/mdlib/wall.c
src/gromacs/pulling/pull.c
src/gromacs/tools/compare.c
src/programs/mdrun/md.c
src/programs/mdrun/mdrun.cpp
src/programs/mdrun/repl_ex.c

index 3d3c3f6791d8b02f54d611db0f1a1ea49e81d243..ba6b3115054b053860b77d5e8747777477f89aeb 100644 (file)
@@ -802,16 +802,22 @@ set(GMXLIB_FALLBACK   ${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/top)
 # Binary and library suffix options
 include(gmxManageSuffixes)
 
-##################################################################
+################################################################
 # Shared library settings
-##################################################################
-if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+################################################################
+if((NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR ((CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0) AND (CMAKE_VERSION VERSION_GREATER 2.8.11)))
     if(GMX_LIB_INSTALL_DIR STREQUAL "lib")
         set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
     endif()
-    set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${GMX_LIB_INSTALL_DIR}")
+    if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+        set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${GMX_LIB_INSTALL_DIR}")
+    else()
+        set(CMAKE_INSTALL_RPATH "@executable_path/../${GMX_LIB_INSTALL_DIR}")
+    endif()
     set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+    set(CMAKE_MACOSX_RPATH 1)
 else()
+    # We are on Darwin/OSX, and cmake cannot handle proper RPATHs
     if(CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0) #rpath supported for >10.4
         set(CMAKE_INSTALL_NAME_DIR "@rpath")
         set(GMX_EXE_LINKER_FLAGS ${GMX_EXE_LINKER_FLAGS} "-Wl,-rpath,@executable_path/../${GMX_LIB_INSTALL_DIR}")
index 569f028de41446f8ae36712c71a51b9494ca9b08..b7761de7f5ad1dd9523fe0a4d4170808ebf5e16b 100644 (file)
@@ -70,6 +70,22 @@ if(GMX_GPU OR GMX_GPU_AUTO)
     else()
         find_package(CUDA 4.0 ${FIND_CUDA_QUIETLY})
     endif()
+    # Cmake 2.8.12 (and CMake 3.0) introduced a new bug where the cuda
+    # library dir is added twice as an rpath on APPLE, which in turn causes
+    # the install_name_tool to wreck the binaries when it tries to remove this
+    # path. Since this is set inside the cuda module, we remove the extra rpath
+    # added in the library string - an rpath is not a library anyway, and at
+    # least for Gromacs this works on all CMake versions. This should be
+    # reasonably future-proof, since newer versions of CMake appear to handle
+    # the rpath automatically based on the provided library path, meaning
+    # the explicit rpath specification is no longer needed.
+    if(APPLE AND (CMAKE_VERSION VERSION_GREATER 2.8.11))
+        foreach(elem ${CUDA_LIBRARIES})
+            if(elem MATCHES "-Wl,.*")
+                list(REMOVE_ITEM CUDA_LIBRARIES ${elem})
+            endif()
+        endforeach(elem)
+    endif()
 endif()
 
 # Depending on the current vale of GMX_GPU and GMX_GPU_AUTO:
index a0b3028c925502fce18ce309b603aee4e9564cbc..e0a7728221a600049d7990b5f1f8b892ddf952de 100644 (file)
@@ -125,6 +125,12 @@ if (NOT DEFINED CUDA_NVCC_FLAGS_SET)
         mark_as_advanced(CUDA_HOST_COMPILER CUDA_HOST_COMPILER_OPTIONS)
     endif()
 
+    if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "GNU")
+        # Some versions of gcc-4.8 and gcc-4.9 produce errors (in particular on OS X)
+        # if we do not use -D__STRICT_ANSI__. It is harmless, so we might as well add it for all versions.
+        set(CUDA_HOST_COMPILER_OPTIONS "${CUDA_HOST_COMPILER_OPTIONS}-D__STRICT_ANSI__;")
+    endif()
+
     # on Linux we need to add -fPIC when building shared gmx libs
     # Note: will add -fPIC for any compiler that supports it as it shouldn't hurt
     if(BUILD_SHARED_LIBS)
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 66f8fabc0b116a10ed35a2b5ba60fd2b3a68836d..fa5b9442f647acf64c00e4bdcfdbe5a8062f0920 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald, recommended 
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index c3120b0ed1e9345c044dc59215e7e5b55876c178..007b57acda9154e630a58e5e43178ddf7fee7b40 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 420808db5e5779b24161f08d306c6dda18d5ec8e..7e4956a7e9a47dd4fafbf390fb65446eade24058 100644 (file)
@@ -1,5 +1,6 @@
 tip3p    TIP3P     TIP 3-point, recommended
 tip4p    TIP4P     TIP 4-point
 tip4pew  TIP4P-Ew  TIP 4-point optimized with Ewald
+tip5p    TIP5P     TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc      SPC       simple point charge
 spce     SPC/E     extended simple point charge
index 41bcbab9f1415cf2f0c653c0537854c0583ba5ec..f3e88d2682c818df69b4ac6b31ebda897c917855 100644 (file)
@@ -1,6 +1,7 @@
 ; rtp residue to rtp building block table
 ;GMX   Force-field
 HISD   HSD
+HIS1   HSD
 HISE   HSE
 HISH   HSP
 LYSN   LSN
index 1af5eac52716fa7f424b78480cbcb7a8dda0b09b..b4d7135fcdb678707a8d1a16f08632b45b06385b 100644 (file)
@@ -129,6 +129,7 @@ MNH3        0.0000 ; vsite (rigid tetrahedrical NH3 group)
 MNH2   0.0000 ; vsite
 MCH3   0.0000 ; vsite (rigid CH3 group connected to carbons)
 MCH3S  0.0000 ; vsite (rigid CH3 group connected to S)
+MW      0.0    ; Dummy mass in rigid tyrosine rings
 ; DNA and RNA section
 P       30.974 ;        Phosphorus  ### For DNA
 P2     30.974000 ;     pyrophosphate phosphorus (see toppar_all27_na_nad_ppi.str)  ### For DNA 
index 48ab6326d3ed9e3e99289422fa4f8e207fb30c18..82daff23322a6de758854c30aafb31d7b536a25e 100644 (file)
@@ -156,6 +156,7 @@ MNH3        0       0.000000        0.00    A       0.0     0.0
 MNH2   0       0.000000        0.00    A       0.0     0.0
 MCH3   0       0.000000        0.00    A       0.0     0.0
 MCH3S  0       0.000000        0.00    A       0.0     0.0
+MW      0       0.000000        0.00    A       0.0     0.0
 ; Ions and noble gases (useful for tutorials)
 Cu2+   29      63.54600        2.00    A       2.08470e-01     4.76976e+00
 Ar     18      39.94800        0.00    A       3.41000e-01     2.74580e-02
index bdd87ef10b710f6200255c012a3fb1a71d178e24..33d51c6d94169909a129d9ca24a2323e58b47285 100644 (file)
@@ -45,3 +45,4 @@
  MNH2          0       0       0       0        0    ; dummy mass
  MCH3          0       0       0       0        0    ; dummy mass
  MCH3S         0       0       0       0        0    ; dummy mass
+ MW             0       0       0       0        0
index d5e92ffd61480223335e135ff9129a0fc3bbf33d..d13477c90f5eeac1c0efa5061a58f832d2827c48 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname      nrexcl
 SOL            2
index 72f00cd5db86072aef34ef3cf47f5cbfba2fe856..5446473cdee132eadedde36c29193336919ab077 100644 (file)
@@ -1,5 +1,6 @@
 tip3p   TIP3P   TIP 3-point, recommended
 tip4p   TIP4P   TIP 4-point
 tips3p  TIPS3P  CHARMM TIP 3-point with LJ on H's (note: twice as slow in GROMACS)
+tip5p   TIP5P   TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 spc     SPC     simple point charge
 spce    SPC/E   extended simple point charge
index 597e3eb9a4afae11ceaeed611f5ee0b58316468f..abadb0b3865a2f54bf233617378c95f92d1245fe 100644 (file)
    HB1    opls_140    0.060     2
    HB2    opls_140    0.060     2
     CG    opls_267    0.520     3
-   OD1    opls_269   -0.530     3
-   OD2    opls_268   -0.440     4
+   OD1    opls_269   -0.440     3
+   OD2    opls_268   -0.530     4
    HD2    opls_270    0.450     4
      C    opls_235    0.500     5
      O    opls_236   -0.500     5
index 02b8c67fa5f17e883d3443b9d537492796a153c5..22418b5f6239700d09341a9e36c86493c1569aad 100644 (file)
@@ -1,3 +1,8 @@
+; original reference: [M. W. Mahoney and W. L. Jorgensen, J. Chem. Phys. 112 , 2000]
+;
+; Note that there are various issues with tip5p and the different forcefields.
+; Discussion is here: http://redmine.gromacs.org/issues/1348
+
 [ moleculetype ]
 ; molname       nrexcl
 SOL             2
@@ -10,10 +15,25 @@ SOL             2
 4       opls_120     1       SOL             LP1             1      -0.241
 5       opls_120     1       SOL             LP2             1      -0.241
 
+#ifndef FLEXIBLE
+
 [ settles ]
 ; i     funct   doh     dhh
 1       1       0.09572 0.15139
 
+#else
+
+[ bonds ]
+; i     j       funct   length  force.c.
+1       2       1       0.09572 502416.0 0.09572        502416.0
+1       3       1       0.09572 502416.0 0.09572        502416.0
+
+[ angles ]
+; i     j       k       funct   angle   force.c.
+2       1       3       1       104.52  628.02  104.52  628.02
+
+#endif
+
 [ virtual_sites3 ]
 ; The position of the virtual site is computed as follows:
 ;
index 44f5e9270a7602129556ac13a010a99016551c58..420bb9225a6f49715a12eb298cc276eb6244b75e 100644 (file)
@@ -1,6 +1,6 @@
 tip4p   TIP4P  TIP 4-point, recommended
 tip3p   TIP3P  TIP 3-point
-tip5p   TIP5P  TIP 5-point
+tip5p   TIP5P  TIP 5-point (see http://redmine.gromacs.org/issues/1348 for issues)
 tip5pe  TIP5P  TIP 5-point improved for Ewald sums
 spc     SPC    simple point charge
 spce    SPC/E  extended simple point charge
index 14c750190067f0181998b79d4d972f06d210c32a..d83d7e6bd191e45f007e10cf8460ca4a90c0e5c6 100644 (file)
@@ -1443,7 +1443,7 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms, gmx_bool bSeek
 
     if (bSeekForwardOnly)
     {
-        low = gmx_ftell(fp);
+        low = gmx_ftell(fp)-header_size;
     }
     if (gmx_fseek(fp, 0, SEEK_END))
     {
index 3a0727b18a9db569ae3ff0d85bb4b88e3518c895..b0f5096f78abe4b6c13a7f6eb3b959befa3c3114 100644 (file)
@@ -2,8 +2,8 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
@@ -59,6 +59,7 @@ typedef struct trxframe
     int      natoms;           /* number of atoms (atoms, x, v, f) */
     real     t0;               /* time of the first frame, needed  *
                                 * for skipping frames with -dt     */
+    real     tf;               /* internal frame time - DO NOT CHANGE */
     real     tpf;              /* time of the previous frame, not  */
                                /* the read, but real file frames   */
     real     tppf;             /* time of two frames ago           */
index 25d3dd1fa4f57088401873eb716e39251bf9f23b..2c9eb34e53000fa5875a6d23d43192125d4e8d5c 100644 (file)
@@ -282,6 +282,7 @@ void clear_trxframe(t_trxframe *fr, gmx_bool bFirst)
         fr->bDouble   = FALSE;
         fr->natoms    = -1;
         fr->t0        = 0;
+        fr->tf        = 0;
         fr->tpf       = 0;
         fr->tppf      = 0;
         fr->title     = NULL;
@@ -795,13 +796,13 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
     int      ftp;
 
     bRet = FALSE;
-    pt   = fr->time;
+    pt   = fr->tf;
 
     do
     {
         clear_trxframe(fr, FALSE);
         fr->tppf = fr->tpf;
-        fr->tpf  = fr->time;
+        fr->tpf  = fr->tf;
 
         if (status->tng)
         {
@@ -834,7 +835,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
                 /* DvdS 2005-05-31: this has been fixed along with the increased
                  * accuracy of the control over -b and -e options.
                  */
-                if (bTimeSet(TBEGIN) && (fr->time < rTimeValue(TBEGIN)))
+                if (bTimeSet(TBEGIN) && (fr->tf < rTimeValue(TBEGIN)))
                 {
                     if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE))
                     {
@@ -875,6 +876,7 @@ gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxfram
                           gmx_fio_getname(status->fio));
 #endif
         }
+        fr->tf = fr->time;
 
         if (bRet)
         {
@@ -1044,6 +1046,7 @@ int read_first_frame(const output_env_t oenv, t_trxstatus **status,
 #endif
             break;
     }
+    fr->tf = fr->time;
 
     /* Return FALSE if we read a frame that's past the set ending time. */
     if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0))
index a9d28823e8d8af3d6cfd1a4054d8ae3191ef7f65..de46abf7ff78fcef8c0126334f3d4796a6e842ab 100644 (file)
@@ -419,7 +419,8 @@ void mk_chi_lookup (int **lookup, int maxchi,
     int i, j, Dih, Chi;
 
     j = 0;
-    for (Dih = 0; (Dih < NONCHI+maxchi); Dih++)
+    /* NONCHI points to chi1, therefore we have to start counting there. */
+    for (Dih = NONCHI; (Dih < NONCHI+maxchi); Dih++)
     {
         for (i = 0; (i < nlist); i++)
         {
@@ -570,9 +571,12 @@ void get_chi_product_traj (real **dih, int nframes, int nlist,
                 sprintf(histitle, "cumulative rotamer distribution for %s", dlist[i].name);
                 fprintf(stderr, "  and %s  ", hisfile);
                 fp = xvgropen(hisfile, histitle, "number", "", oenv);
-                fprintf(fp, "@ xaxis tick on\n");
-                fprintf(fp, "@ xaxis tick major 1\n");
-                fprintf(fp, "@ type xy\n");
+                if (output_env_get_print_xvgr_codes(oenv))
+                {
+                    fprintf(fp, "@ xaxis tick on\n");
+                    fprintf(fp, "@ xaxis tick major 1\n");
+                    fprintf(fp, "@ type xy\n");
+                }
                 for (k = 0; (k < nbin); k++)
                 {
                     if (bNormalize)
@@ -584,7 +588,7 @@ void get_chi_product_traj (real **dih, int nframes, int nlist,
                         fprintf(fp, "%5d  %10d\n", k, chi_prhist[k]);
                     }
                 }
-                fprintf(fp, "&\n");
+                fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
                 gmx_ffclose(fp);
             }
 
index 21d4f836ceb3fa2930b5113986c01454450ffcd7..f0d58de9f9c3dd920a79749be51d0f66fc280334 100644 (file)
@@ -259,18 +259,12 @@ static void write_xvgr_graphs(const char *file, int ngraphs, int nsetspergraph,
             {
                 if (bSplit && i > 0 && fabs(x[i]) < 1e-5)
                 {
-                    if (output_env_get_print_xvgr_codes(oenv))
-                    {
-                        fprintf(out, "&\n");
-                    }
+                    fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
                 }
                 fprintf(out, "%10.4f %10.5f\n",
                         x[i]*scale_x, y ? y[g][i] : sy[g][s][i]);
             }
-            if (output_env_get_print_xvgr_codes(oenv))
-            {
-                fprintf(out, "&\n");
-            }
+            fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
     }
     gmx_ffclose(out);
@@ -472,8 +466,10 @@ static void overlap(const char *outfile, int natoms,
 
     out = xvgropen(outfile, "Subspace overlap",
                    "Eigenvectors of trajectory 2", "Overlap", oenv);
-    fprintf(out, "@ subtitle \"using %d eigenvectors of trajectory 1\"\n",
-            noutvec);
+    if (output_env_get_print_xvgr_codes(oenv))
+    {
+        fprintf(out, "@ subtitle \"using %d eigenvectors of trajectory 1\"\n", noutvec);
+    }
     overlap = 0;
     for (x = 0; x < nvec2; x++)
     {
@@ -672,7 +668,7 @@ static void project(const char *trajfile, t_topology *top, int ePBC, matrix topb
         {
             if (bSplit && i > 0 && fabs(inprod[noutvec][i]) < 1e-5)
             {
-                fprintf(xvgrout, "&\n");
+                fprintf(xvgrout, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
             fprintf(xvgrout, "%10.5f %10.5f\n", inprod[0][i], inprod[noutvec-1][i]);
         }
index 494e19e3e0dca82b5429ccf6c1e89ebdb47c75f4..480c1c67b2c164ebcab95e860b7e8afa63c5a8c2 100644 (file)
@@ -290,7 +290,7 @@ void histogram(const char *distfile, real binwidth, int n, int nset, real **val,
         }
         if (s < nset-1)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
     }
     gmx_ffclose(fp);
@@ -610,9 +610,16 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
         }
         fprintf(stdout, "Set %3d:  err.est. %g  a %g  tau1 %g  tau2 %g\n",
                 s+1, ee, a, tau1, tau2);
-        fprintf(fp, "@ legend string %d \"av %f\"\n", 2*s, av[s]);
-        fprintf(fp, "@ legend string %d \"ee %6g\"\n",
-                2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        if (output_env_get_xvg_format(oenv) == exvgXMGR)
+        {
+            fprintf(fp, "@ legend string %d \"av %f\"\n", 2*s, av[s]);
+            fprintf(fp, "@ legend string %d \"ee %6g\"\n", 2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        }
+        else if (output_env_get_xvg_format(oenv) == exvgXMGRACE)
+        {
+            fprintf(fp, "@ s%d legend \"av %f\"\n", 2*s, av[s]);
+            fprintf(fp, "@ s%d legend \"ee %6g\"\n", 2*s+1, sig[s]*anal_ee_inf(fitparm, n*dt));
+        }
         for (i = 0; i < nbs; i++)
         {
             fprintf(fp, "%g %g %g\n", tbs[i], sig[s]*sqrt(ybs[i]/(n*dt)),
@@ -668,7 +675,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
                     s+1, sig[s]*anal_ee_inf(ac_fit, n*dt),
                     ac_fit[1], ac_fit[0], ac_fit[2]);
 
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             for (i = 0; i < nbs; i++)
             {
                 fprintf(fp, "%g %g\n", tbs[i],
@@ -679,7 +686,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n,
         }
         if (s < nset-1)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
     }
     sfree(fitsig);
@@ -1352,7 +1359,7 @@ int gmx_analyze(int argc, char *argv[])
             }
             if (s < nset-1)
             {
-                fprintf(out, "&\n");
+                fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
         }
         gmx_ffclose(out);
index 65bfad1cc58973aa04ece639ec9bfd9ca565ae55..534f9153cd47d73ea42158b76963101f4c939c12 100644 (file)
@@ -443,15 +443,18 @@ int gmx_g_angle(int argc, char *argv[])
         {
             maxstat = max(maxstat, angstat[i]*norm_fac);
         }
-        fprintf(out, "@with g0\n");
-        fprintf(out, "@    world xmin -180\n");
-        fprintf(out, "@    world xmax  180\n");
-        fprintf(out, "@    world ymin 0\n");
-        fprintf(out, "@    world ymax %g\n", maxstat*1.05);
-        fprintf(out, "@    xaxis  tick major 60\n");
-        fprintf(out, "@    xaxis  tick minor 30\n");
-        fprintf(out, "@    yaxis  tick major 0.005\n");
-        fprintf(out, "@    yaxis  tick minor 0.0025\n");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(out, "@with g0\n");
+            fprintf(out, "@    world xmin -180\n");
+            fprintf(out, "@    world xmax  180\n");
+            fprintf(out, "@    world ymin 0\n");
+            fprintf(out, "@    world ymax %g\n", maxstat*1.05);
+            fprintf(out, "@    xaxis  tick major 60\n");
+            fprintf(out, "@    xaxis  tick minor 30\n");
+            fprintf(out, "@    yaxis  tick major 0.005\n");
+            fprintf(out, "@    yaxis  tick minor 0.0025\n");
+        }
     }
     for (i = first; (i <= last); i++)
     {
index 90362c04d07e4e940727ffd0d90bfa4dff2fe589..93a5e02c33184d59b039ff088948046023d320b2 100644 (file)
@@ -763,16 +763,22 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t rt,
                 strcpy(hhisfile, hisfile);
                 strcat(hhisfile, ".xvg");
                 fp = xvgropen(hhisfile, title, "Degrees", "", oenv);
-                fprintf(fp, "@ with g0\n");
+                if (output_env_get_print_xvgr_codes(oenv))
+                {
+                    fprintf(fp, "@ with g0\n");
+                }
                 xvgr_world(fp, -180, 0, 180, 0.1, oenv);
-                fprintf(fp, "# this effort to set graph size fails unless you run with -autoscale none or -autoscale y flags\n");
-                fprintf(fp, "@ xaxis tick on\n");
-                fprintf(fp, "@ xaxis tick major 90\n");
-                fprintf(fp, "@ xaxis tick minor 30\n");
-                fprintf(fp, "@ xaxis ticklabel prec 0\n");
-                fprintf(fp, "@ yaxis tick off\n");
-                fprintf(fp, "@ yaxis ticklabel off\n");
-                fprintf(fp, "@ type xy\n");
+                if (output_env_get_print_xvgr_codes(oenv))
+                {
+                    fprintf(fp, "# this effort to set graph size fails unless you run with -autoscale none or -autoscale y flags\n");
+                    fprintf(fp, "@ xaxis tick on\n");
+                    fprintf(fp, "@ xaxis tick major 90\n");
+                    fprintf(fp, "@ xaxis tick minor 30\n");
+                    fprintf(fp, "@ xaxis ticklabel prec 0\n");
+                    fprintf(fp, "@ yaxis tick off\n");
+                    fprintf(fp, "@ yaxis ticklabel off\n");
+                    fprintf(fp, "@ type xy\n");
+                }
                 if (bSSHisto)
                 {
                     for (k = 0; (k < 3); k++)
@@ -801,13 +807,13 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t rt,
                         }
                     }
                 }
-                fprintf(fp, "&\n");
+                fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
                 gmx_ffclose(fp);
                 if (bSSHisto)
                 {
                     for (k = 0; (k < 3); k++)
                     {
-                        fprintf(ssfp[k], "&\n");
+                        fprintf(ssfp[k], "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
                         gmx_ffclose(ssfp[k]);
                     }
                 }
@@ -842,30 +848,35 @@ static FILE *rama_file(const char *fn, const char *title, const char *xaxis,
     FILE *fp;
 
     fp = xvgropen(fn, title, xaxis, yaxis, oenv);
-    fprintf(fp, "@ with g0\n");
+    if (output_env_get_print_xvgr_codes(oenv))
+    {
+        fprintf(fp, "@ with g0\n");
+    }
     xvgr_world(fp, -180, -180, 180, 180, oenv);
-    fprintf(fp, "@ xaxis tick on\n");
-    fprintf(fp, "@ xaxis tick major 90\n");
-    fprintf(fp, "@ xaxis tick minor 30\n");
-    fprintf(fp, "@ xaxis ticklabel prec 0\n");
-    fprintf(fp, "@ yaxis tick on\n");
-    fprintf(fp, "@ yaxis tick major 90\n");
-    fprintf(fp, "@ yaxis tick minor 30\n");
-    fprintf(fp, "@ yaxis ticklabel prec 0\n");
-    fprintf(fp, "@    s0 type xy\n");
-    fprintf(fp, "@    s0 symbol 2\n");
-    fprintf(fp, "@    s0 symbol size 0.410000\n");
-    fprintf(fp, "@    s0 symbol fill 1\n");
-    fprintf(fp, "@    s0 symbol color 1\n");
-    fprintf(fp, "@    s0 symbol linewidth 1\n");
-    fprintf(fp, "@    s0 symbol linestyle 1\n");
-    fprintf(fp, "@    s0 symbol center false\n");
-    fprintf(fp, "@    s0 symbol char 0\n");
-    fprintf(fp, "@    s0 skip 0\n");
-    fprintf(fp, "@    s0 linestyle 0\n");
-    fprintf(fp, "@    s0 linewidth 1\n");
-    fprintf(fp, "@ type xy\n");
-
+    if (output_env_get_print_xvgr_codes(oenv))
+    {
+        fprintf(fp, "@ xaxis tick on\n");
+        fprintf(fp, "@ xaxis tick major 90\n");
+        fprintf(fp, "@ xaxis tick minor 30\n");
+        fprintf(fp, "@ xaxis ticklabel prec 0\n");
+        fprintf(fp, "@ yaxis tick on\n");
+        fprintf(fp, "@ yaxis tick major 90\n");
+        fprintf(fp, "@ yaxis tick minor 30\n");
+        fprintf(fp, "@ yaxis ticklabel prec 0\n");
+        fprintf(fp, "@    s0 type xy\n");
+        fprintf(fp, "@    s0 symbol 2\n");
+        fprintf(fp, "@    s0 symbol size 0.410000\n");
+        fprintf(fp, "@    s0 symbol fill 1\n");
+        fprintf(fp, "@    s0 symbol color 1\n");
+        fprintf(fp, "@    s0 symbol linewidth 1\n");
+        fprintf(fp, "@    s0 symbol linestyle 1\n");
+        fprintf(fp, "@    s0 symbol center false\n");
+        fprintf(fp, "@    s0 symbol char 0\n");
+        fprintf(fp, "@    s0 skip 0\n");
+        fprintf(fp, "@    s0 linestyle 0\n");
+        fprintf(fp, "@    s0 linewidth 1\n");
+        fprintf(fp, "@ type xy\n");
+    }
     return fp;
 }
 
index 1e5a9e6d5a96f092eb579d24b147657a9e2c65be..4919de60897ffb785ffe390c425f728141cf093f 100644 (file)
@@ -1097,9 +1097,12 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
     if (clustidfn)
     {
         fp = xvgropen(clustidfn, "Clusters", output_env_get_xvgr_tlabel(oenv), "Cluster #", oenv);
-        fprintf(fp, "@    s0 symbol 2\n");
-        fprintf(fp, "@    s0 symbol size 0.2\n");
-        fprintf(fp, "@    s0 linestyle 0\n");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@    s0 symbol 2\n");
+            fprintf(fp, "@    s0 symbol size 0.2\n");
+            fprintf(fp, "@    s0 linestyle 0\n");
+        }
         for (i = 0; i < nf; i++)
         {
             fprintf(fp, "%8g %8d\n", time[i], clust->cl[i]);
@@ -1109,7 +1112,10 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
     if (sizefn)
     {
         fp = xvgropen(sizefn, "Cluster Sizes", "Cluster #", "# Structures", oenv);
-        fprintf(fp, "@g%d type %s\n", 0, "bar");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@g%d type %s\n", 0, "bar");
+        }
     }
     snew(structure, nf);
     fprintf(log, "\n%3s | %3s  %4s | %6s %4s | cluster members\n",
index 8d5438c3fb980ff29c877e8611eccd45b7229467..281e500a2a25cd6ed22dd385326a7bcce8d3d1b0 100644 (file)
@@ -222,8 +222,11 @@ static void dump_fy(output_env_t oenv, real toler)
     DD = pow(10.0, 0.125);
     fp = xvgropen("fy.xvg", "Fig. 2, Lin2003a", "Delta", "y or fy", oenv);
     xvgr_legend(fp, asize(leg), leg, oenv);
-    fprintf(fp, "@    world 1e-05, 0, 1000, 1\n");
-    fprintf(fp, "@    xaxes scale Logarithmic\n");
+    if (output_env_get_print_xvgr_codes(oenv))
+    {
+        fprintf(fp, "@    world 1e-05, 0, 1000, 1\n");
+        fprintf(fp, "@    xaxes scale Logarithmic\n");
+    }
     for (Delta = 1e-5; (Delta <= 1000); Delta *= DD)
     {
         f = calc_fluidicity(Delta, toler);
index f0c7730eb74f6f1373f2cdf893977bd6676745c8..4e57212642cc76a12c9c750c5c55be20a3f5e059 100644 (file)
@@ -513,39 +513,55 @@ int gmx_enemat(int argc, char *argv[])
                        oenv);
         xvgr_legend(out, 0, NULL, oenv);
         j = 0;
-        for (m = 0; (m < egNR+egSP); m++)
+        if (output_env_get_print_xvgr_codes(oenv))
         {
-            if (egrp_use[m])
+            char str1[STRLEN], str2[STRLEN];
+            if (output_env_get_xvg_format(oenv) == exvgXMGR)
             {
-                fprintf(out, "@ legend string %d \"%s\"\n", j++, egrp_nm[m]);
+                sprintf(str1, "@ legend string ");
+                sprintf(str2, " ");
             }
-        }
-        if (bFree)
-        {
-            fprintf(out, "@ legend string %d \"%s\"\n", j++, "Free");
-        }
-        if (bFree)
-        {
-            fprintf(out, "@ legend string %d \"%s\"\n", j++, "Diff");
-        }
-        fprintf(out, "@TYPE xy\n");
-        fprintf(out, "#%3s", "grp");
-        for (m = 0; (m < egNR+egSP); m++)
-        {
-            if (egrp_use[m])
+            else
             {
-                fprintf(out, " %9s", egrp_nm[m]);
+                sprintf(str1, "@ s");
+                sprintf(str2, " legend ");
             }
+
+            for (m = 0; (m < egNR+egSP); m++)
+            {
+                if (egrp_use[m])
+                {
+                    fprintf(out, "%s%d%s \"%s\"\n", str1, j++, str2, egrp_nm[m]);
+                }
+            }
+            if (bFree)
+            {
+                fprintf(out, "%s%d%s \"%s\"\n", str1, j++, str2, "Free");
+            }
+            if (bFree)
+            {
+                fprintf(out, "%s%d%s \"%s\"\n", str1, j++, str2, "Diff");
+            }
+            fprintf(out, "@TYPE xy\n");
+            fprintf(out, "#%3s", "grp");
+
+            for (m = 0; (m < egNR+egSP); m++)
+            {
+                if (egrp_use[m])
+                {
+                    fprintf(out, " %9s", egrp_nm[m]);
+                }
+            }
+            if (bFree)
+            {
+                fprintf(out, " %9s", "Free");
+            }
+            if (bFree)
+            {
+                fprintf(out, " %9s", "Diff");
+            }
+            fprintf(out, "\n");
         }
-        if (bFree)
-        {
-            fprintf(out, " %9s", "Free");
-        }
-        if (bFree)
-        {
-            fprintf(out, " %9s", "Diff");
-        }
-        fprintf(out, "\n");
         for (i = 0; (i < ngroups); i++)
         {
             fprintf(out, "%3.0f", groupnr[i]);
index 884c45d7f5331866006890c2b07577fc97d5d9d4..de70d3f40223c562be63cee6750a146fcefcebe8 100644 (file)
@@ -2253,7 +2253,7 @@ int gmx_energy(int argc, char *argv[])
                 {
                     fort = xvgropen(opt2fn("-ort", NFILE, fnm), "Calculated orientations",
                                     "Time (ps)", "", oenv);
-                    if (bOrinst)
+                    if (bOrinst && output_env_get_print_xvgr_codes(oenv))
                     {
                         fprintf(fort, "%s", orinst_sub);
                     }
@@ -2264,7 +2264,7 @@ int gmx_energy(int argc, char *argv[])
                     fodt = xvgropen(opt2fn("-odt", NFILE, fnm),
                                     "Orientation restraint deviation",
                                     "Time (ps)", "", oenv);
-                    if (bOrinst)
+                    if (bOrinst && output_env_get_print_xvgr_codes(oenv))
                     {
                         fprintf(fodt, "%s", orinst_sub);
                     }
@@ -2730,7 +2730,7 @@ int gmx_energy(int argc, char *argv[])
         out = xvgropen(opt2fn("-ora", NFILE, fnm),
                        "Average calculated orientations",
                        "Restraint label", "", oenv);
-        if (bOrinst)
+        if (bOrinst && output_env_get_print_xvgr_codes(oenv))
         {
             fprintf(out, "%s", orinst_sub);
         }
@@ -2745,7 +2745,7 @@ int gmx_energy(int argc, char *argv[])
         out = xvgropen(opt2fn("-oda", NFILE, fnm),
                        "Average restraint deviation",
                        "Restraint label", "", oenv);
-        if (bOrinst)
+        if (bOrinst && output_env_get_print_xvgr_codes(oenv))
         {
             fprintf(out, "%s", orinst_sub);
         }
@@ -2760,7 +2760,7 @@ int gmx_energy(int argc, char *argv[])
         out = xvgropen(opt2fn("-odr", NFILE, fnm),
                        "RMS orientation restraint deviations",
                        "Restraint label", "", oenv);
-        if (bOrinst)
+        if (bOrinst && output_env_get_print_xvgr_codes(oenv))
         {
             fprintf(out, "%s", orinst_sub);
         }
index 6257f6a6742d7f6b081e5dc79d56268455531a77..718846578d1ceee1ebc68405de44b837744d77f2 100644 (file)
@@ -231,7 +231,7 @@ int gmx_genpr(int argc, char *argv[])
                         hi = d+dd;
                         fprintf(out, "%5d %5d %1d %5d %10d %10g %10g %10g %10g\n",
                                 ind_grp[i]+1, ind_grp[j]+1, 1, k, 1,
-                                lo, hi, hi+1, 1.0);
+                                lo, hi, hi+disre_up2, 1.0);
                     }
                 }
             }
index 09900e1ff4e0dafcc67534f0c320cf13f5593c42..029edf26c28abb9980bf2972a55f3cf4386f370f 100644 (file)
@@ -368,20 +368,22 @@ int gmx_mdmat(int argc, char *argv[])
 
     if (bCalcN)
     {
+        char **legend;
+
+        snew(legend, 5);
+        for (i = 0; i < 5; i++)
+        {
+            snew(legend[i], STRLEN);
+        }
         tot_nmat(nres, natoms, nframes, totnmat, tot_n, mean_n);
         fp = xvgropen(ftp2fn(efXVG, NFILE, fnm),
                       "Increase in number of contacts", "Residue", "Ratio", oenv);
-        fprintf(fp, "@ legend on\n");
-        fprintf(fp, "@ legend box on\n");
-        fprintf(fp, "@ legend loctype view\n");
-        fprintf(fp, "@ legend 0.75, 0.8\n");
-        fprintf(fp, "@ legend string 0 \"Total/mean\"\n");
-        fprintf(fp, "@ legend string 1 \"Total\"\n");
-        fprintf(fp, "@ legend string 2 \"Mean\"\n");
-        fprintf(fp, "@ legend string 3 \"# atoms\"\n");
-        fprintf(fp, "@ legend string 4 \"Mean/# atoms\"\n");
-        fprintf(fp, "#%3s %8s  %3s  %8s  %3s  %8s\n",
-                "res", "ratio", "tot", "mean", "natm", "mean/atm");
+        sprintf(legend[0], "Total/mean");
+        sprintf(legend[1], "Total");
+        sprintf(legend[2], "Mean");
+        sprintf(legend[3], "# atoms");
+        sprintf(legend[4], "Mean/# atoms");
+        xvgr_legend(fp, 5, (const char**)legend, oenv);
         for (i = 0; (i < nres); i++)
         {
             if (mean_n[i] == 0)
index 311e3d687365422e2222e2d0eb08d85e9339cef3..8fbb7d3712a6b426e4743d5e5b8adebadf2677dd 100644 (file)
 #include "gromacs/fileio/trxio.h"
 #include "rmpbc.h"
 #include "gmx_ana.h"
+#include "names.h"
 
 
-static void periodic_dist(matrix box, rvec x[], int n, atom_id index[],
+static void periodic_dist(int ePBC,
+                          matrix box, rvec x[], int n, atom_id index[],
                           real *rmin, real *rmax, int *min_ind)
 {
-#define NSHIFT 26
-    int  sx, sy, sz, i, j, s;
+#define NSHIFT_MAX 26
+    int  nsz, nshift, sx, sy, sz, i, j, s;
     real sqr_box, r2min, r2max, r2;
-    rvec shift[NSHIFT], d0, d;
+    rvec shift[NSHIFT_MAX], d0, d;
 
-    sqr_box = sqr(min(norm(box[XX]), min(norm(box[YY]), norm(box[ZZ]))));
+    sqr_box = min(norm2(box[XX]), norm2(box[YY]));
+    if (ePBC == epbcXYZ)
+    {
+        sqr_box = min(sqr_box, norm2(box[ZZ]));
+        nsz     = 1;
+    }
+    else if (ePBC == epbcXY)
+    {
+        nsz = 0;
+    }
+    else
+    {
+        gmx_fatal(FARGS, "pbc = %s is not supported by g_mindist",
+                  epbc_names[ePBC]);
+        nsz = 0; /* Keep compilers quiet */
+    }
 
-    s = 0;
-    for (sz = -1; sz <= 1; sz++)
+    nshift = 0;
+    for (sz = -nsz; sz <= nsz; sz++)
     {
         for (sy = -1; sy <= 1; sy++)
         {
@@ -79,9 +96,10 @@ static void periodic_dist(matrix box, rvec x[], int n, atom_id index[],
                 {
                     for (i = 0; i < DIM; i++)
                     {
-                        shift[s][i] = sx*box[XX][i]+sy*box[YY][i]+sz*box[ZZ][i];
+                        shift[nshift][i] =
+                            sx*box[XX][i] + sy*box[YY][i] + sz*box[ZZ][i];
                     }
-                    s++;
+                    nshift++;
                 }
             }
         }
@@ -100,7 +118,7 @@ static void periodic_dist(matrix box, rvec x[], int n, atom_id index[],
             {
                 r2max = r2;
             }
-            for (s = 0; s < NSHIFT; s++)
+            for (s = 0; s < nshift; s++)
             {
                 rvec_add(d0, shift[s], d);
                 r2 = norm2(d);
@@ -162,7 +180,7 @@ static void periodic_mindist_plot(const char *trxfn, const char *outfn,
             gmx_rmpbc(gpbc, natoms, box, x);
         }
 
-        periodic_dist(box, x, n, index, &rmin, &rmax, ind_min);
+        periodic_dist(ePBC, box, x, n, index, &rmin, &rmax, ind_min);
         if (rmin < rmint)
         {
             rmint    = rmin;
@@ -172,7 +190,7 @@ static void periodic_mindist_plot(const char *trxfn, const char *outfn,
         }
         if (bSplit && !bFirst && fabs(t/output_env_get_time_factor(oenv)) < 1e-5)
         {
-            fprintf(out, "&\n");
+            fprintf(out, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
         fprintf(out, "\t%g\t%6.3f %6.3f %6.3f %6.3f %6.3f\n",
                 output_env_conv_time(oenv, t), rmin, rmax, norm(box[0]), norm(box[1]), norm(box[2]));
@@ -423,14 +441,14 @@ void dist_plot(const char *fn, const char *afile, const char *dfile,
     {
         if (bSplit && !bFirst && fabs(t/output_env_get_time_factor(oenv)) < 1e-5)
         {
-            fprintf(dist, "&\n");
+            fprintf(dist, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             if (num)
             {
-                fprintf(num, "&\n");
+                fprintf(num, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
             if (atm)
             {
-                fprintf(atm, "&\n");
+                fprintf(atm, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
         }
         fprintf(dist, "%12e", output_env_conv_time(oenv, t));
index 41d9eaf07761fa8c5b28fd20737bfab499b95bfb..ff0bfb0b32a672ef441de04647f8d6667f0c5612 100644 (file)
@@ -493,7 +493,10 @@ int gmx_polystat(int argc, char *argv[])
     /* Handle printing of internal distances. */
     if (outi)
     {
-        fprintf(outi, "@    xaxes scale Logarithmic\n");
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(outi, "@    xaxes scale Logarithmic\n");
+        }
         ymax = -1;
         ymin = 1e300;
         j    = index[molind[1]-1] - index[molind[0]]; /* Polymer length -1. */
index b544a6a897dbb0878ddcbc914edab0a3f583fabd..b9d708b837697050879725881ff0365104b4adf2 100644 (file)
@@ -102,10 +102,12 @@ int gmx_rama(int argc, char *argv[])
     xvgr_line_props(out, 0, elNone, ecFrank, oenv);
     xvgr_view(out, 0.2, 0.2, 0.8, 0.8, oenv);
     xvgr_world(out, -180, -180, 180, 180, oenv);
-    fprintf(out, "@    xaxis  tick on\n@    xaxis  tick major 60\n@    xaxis  tick minor 30\n");
-    fprintf(out, "@    yaxis  tick on\n@    yaxis  tick major 60\n@    yaxis  tick minor 30\n");
-    fprintf(out, "@ s0 symbol 2\n@ s0 symbol size 0.4\n@ s0 symbol fill 1\n");
-
+    if (output_env_get_print_xvgr_codes(oenv))
+    {
+        fprintf(out, "@    xaxis  tick on\n@    xaxis  tick major 60\n@    xaxis  tick minor 30\n");
+        fprintf(out, "@    yaxis  tick on\n@    yaxis  tick major 60\n@    yaxis  tick minor 30\n");
+        fprintf(out, "@ s0 symbol 2\n@ s0 symbol size 0.4\n@ s0 symbol fill 1\n");
+    }
     j = 0;
     do
     {
index 3962646be66226b11eadeef7d569ae65025032c9..90605021a4c891c0b2e9a1b7f4019d98edaccd80 100644 (file)
@@ -322,6 +322,8 @@ int gmx_rms(int argc, char *argv[])
     bPrev = (prev > 0);
     if (bPrev)
     {
+        fprintf(stderr, "WARNING: using option -prev with large trajectories will\n"
+                "         require a lot of memory and could lead to crashes\n");
         prev = abs(prev);
         if (freq != 1)
         {
@@ -1137,7 +1139,7 @@ int gmx_rms(int argc, char *argv[])
         if (bSplit && i > 0 &&
             fabs(time[bPrev ? freq*i : i]/output_env_get_time_factor(oenv)) < 1e-5)
         {
-            fprintf(fp, "&\n");
+            fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
         fprintf(fp, "%12.7f", time[bPrev ? freq*i : i]);
         for (j = 0; (j < nrms); j++)
@@ -1179,7 +1181,7 @@ int gmx_rms(int argc, char *argv[])
         {
             if (bSplit && i > 0 && fabs(time[i]) < 1e-5)
             {
-                fprintf(fp, "&\n");
+                fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             }
             fprintf(fp, "%12.7f", time[i]);
             for (j = 0; (j < nrms); j++)
index 15738d8c4fbce2b48742d28e6df2fcd8844ffa42..f1922f55373cb0249a5f3e95f4d8b485da36195b 100644 (file)
@@ -183,20 +183,23 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
                 tcafc[kc][i] /= tcafc[kc][0];
                 fprintf(fp_cub, "%g %g\n", i*dt, tcafc[kc][i]);
             }
-            fprintf(fp_cub, "&\n");
+            fprintf(fp_cub, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
             tcafc[kc][0] = 1.0;
         }
     }
 
     fp_vk = xvgropen(fn_vk, "Fits", "k (nm\\S-1\\N)",
                      "\\8h\\4 (10\\S-3\\N kg m\\S-1\\N s\\S-1\\N)", oenv);
-    fprintf(fp_vk, "@    s0 symbol 2\n");
-    fprintf(fp_vk, "@    s0 symbol color 1\n");
-    fprintf(fp_vk, "@    s0 linestyle 0\n");
-    if (fn_cub)
+    if (output_env_get_print_xvgr_codes(oenv))
     {
-        fprintf(fp_vk, "@    s1 symbol 3\n");
-        fprintf(fp_vk, "@    s1 symbol color 2\n");
+        fprintf(fp_vk, "@    s0 symbol 2\n");
+        fprintf(fp_vk, "@    s0 symbol color 1\n");
+        fprintf(fp_vk, "@    s0 linestyle 0\n");
+        if (fn_cub)
+        {
+            fprintf(fp_vk, "@    s1 symbol 3\n");
+            fprintf(fp_vk, "@    s1 symbol color 2\n");
+        }
     }
     fp = xvgropen(fn_tcf, "TCAF Fits", "Time (ps)", "", oenv);
     for (k = 0; k < nk; k++)
@@ -215,7 +218,7 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
         {
             fprintf(fp, "%g %g\n", i*dt, fit_function(effnVAC, fitparms, i*dt));
         }
-        fprintf(fp, "&\n");
+        fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
     }
     gmx_ffclose(fp);
     do_view(oenv, fn_tcf, "-nxy");
@@ -223,7 +226,7 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
     if (fn_cub)
     {
         fprintf(stdout, "Averaged over k-vectors:\n");
-        fprintf(fp_vk, "&\n");
+        fprintf(fp_vk, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         for (k = 0; k < nkc; k++)
         {
             tcafc[k][0]  = 1.0;
@@ -241,9 +244,9 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac,
             {
                 fprintf(fp_cub, "%g %g\n", i*dt, fit_function(effnVAC, fitparms, i*dt));
             }
-            fprintf(fp_cub, "&\n");
+            fprintf(fp_cub, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         }
-        fprintf(fp_vk, "&\n");
+        fprintf(fp_vk, "%s\n", output_env_get_print_xvgr_codes(oenv) ? "&" : "");
         gmx_ffclose(fp_cub);
         do_view(oenv, fn_cub, "-nxy");
     }
index e3f14fa84fa94deca5bf347e6039391ae87c9dc7..71c5c0ec6955223e9a7a407621273ad7300f8a29 100644 (file)
@@ -434,7 +434,10 @@ int gmx_vanhove(int argc, char *argv[])
     if (orfile)
     {
         fp = xvgropen(orfile, "Van Hove function", "r (nm)", "G (nm\\S-1\\N)", oenv);
-        fprintf(fp, "@ subtitle \"for particles in group %s\"\n", grpname);
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@ subtitle \"for particles in group %s\"\n", grpname);
+        }
         snew(legend, nr);
         for (fbin = 0; fbin < nr; fbin++)
         {
@@ -459,7 +462,10 @@ int gmx_vanhove(int argc, char *argv[])
     {
         sprintf(buf, "Probability of moving less than %g nm", rint);
         fp = xvgropen(otfile, buf, "t (ps)", "", oenv);
-        fprintf(fp, "@ subtitle \"for particles in group %s\"\n", grpname);
+        if (output_env_get_print_xvgr_codes(oenv))
+        {
+            fprintf(fp, "@ subtitle \"for particles in group %s\"\n", grpname);
+        }
         for (f = 0; f <= ftmax; f++)
         {
             fprintf(fp, "%g %g\n", f*dt, (real)pt[f]/(tcount[f]*isize));
index 6e63e7a5c0372dfb6035c40f218e61c87dbf5538..3d7bd72465fe0e150f42b1a761865b7e74c30e58 100644 (file)
@@ -1718,13 +1718,16 @@ void do_bootstrapping(const char *fnres, const char* fnprof, const char *fnhist,
             bsProfiles_av2[i] += tmp*tmp;
             fprintf(fp, "%e\t%e\n", (i+0.5)*opt->dz+opt->min, tmp);
         }
-        fprintf(fp, "&\n");
+        fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(opt->oenv) ? "&" : "");
     }
     gmx_ffclose(fp);
 
     /* write average and stddev */
     fp = xvgropen(fnres, "Average and stddev from bootstrapping", "z", ylabel, opt->oenv);
-    fprintf(fp, "@TYPE xydy\n");
+    if (output_env_get_print_xvgr_codes(opt->oenv))
+    {
+        fprintf(fp, "@TYPE xydy\n");
+    }
     for (i = 0; i < opt->bins; i++)
     {
         bsProfiles_av [i] /= opt->nBootStrap;
@@ -2685,7 +2688,7 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins,
                 {
                     fprintf(fpcorr, "%g  %g\n", k*dt, corr[k]);
                 }
-                fprintf(fpcorr, "&\n");
+                fprintf(fpcorr, "%s\n", output_env_get_print_xvgr_codes(opt->oenv) ? "&" : "");
             }
 
             /* esimate integrated correlation time, fitting is too unstable */
@@ -2713,16 +2716,19 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins,
 
     /* plot IACT along reaction coordinate */
     fp = xvgropen(fn, "Integrated autocorrelation times", "z", "IACT [ps]", opt->oenv);
-    fprintf(fp, "@    s0 symbol 1\n@    s0 symbol size 0.5\n@    s0 line linestyle 0\n");
-    fprintf(fp, "#  WIN   tau(gr1)  tau(gr2) ...\n");
-    for (i = 0; i < nwins; i++)
+    if (output_env_get_print_xvgr_codes(opt->oenv))
     {
-        fprintf(fp, "# %3d   ", i);
-        for (ig = 0; ig < window[i].nPull; ig++)
+        fprintf(fp, "@    s0 symbol 1\n@    s0 symbol size 0.5\n@    s0 line linestyle 0\n");
+        fprintf(fp, "#  WIN   tau(gr1)  tau(gr2) ...\n");
+        for (i = 0; i < nwins; i++)
         {
-            fprintf(fp, " %11g", window[i].tau[ig]);
+            fprintf(fp, "# %3d   ", i);
+            for (ig = 0; ig < window[i].nPull; ig++)
+            {
+                fprintf(fp, " %11g", window[i].tau[ig]);
+            }
+            fprintf(fp, "\n");
         }
-        fprintf(fp, "\n");
     }
     for (i = 0; i < nwins; i++)
     {
@@ -2737,8 +2743,12 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins,
                opt->sigSmoothIact);
         /* smooth IACT along reaction coordinate and overwrite g=1+2tau */
         smoothIact(window, nwins, opt);
-        fprintf(fp, "&\n@    s1 symbol 1\n@    s1 symbol size 0.5\n@    s1 line linestyle 0\n");
-        fprintf(fp, "@    s1 symbol color 2\n");
+        fprintf(fp, "%s\n", output_env_get_print_xvgr_codes(opt->oenv) ? "&" : "");
+        if (output_env_get_print_xvgr_codes(opt->oenv))
+        {
+            fprintf(fp, "@    s1 symbol 1\n@    s1 symbol size 0.5\n@    s1 line linestyle 0\n");
+            fprintf(fp, "@    s1 symbol color 2\n");
+        }
         for (i = 0; i < nwins; i++)
         {
             for (ig = 0; ig < window[i].nPull; ig++)
index 6d696e93f7ade05a3c9d51543dcef58109ea999e..c465183bb3e1789bcfde934f888512bdecbdeff1 100644 (file)
@@ -733,7 +733,8 @@ real water_pol(int nbonds,
      * a shell connected to a dummy with spring constant that differ in the
      * three spatial dimensions in the molecular frame.
      */
-    int  i, m, aO, aH1, aH2, aD, aS, type, type0;
+    int  i, m, aO, aH1, aH2, aD, aS, type, type0, ki;
+    ivec dt;
     rvec dOH1, dOH2, dHH, dOD, dDS, nW, kk, dx, kdx, proj;
 #ifdef DEBUG
     rvec df;
@@ -776,11 +777,11 @@ real water_pol(int nbonds,
             aS   = forceatoms[i+5];
 
             /* Compute vectors describing the water frame */
-            rvec_sub(x[aH1], x[aO], dOH1);
-            rvec_sub(x[aH2], x[aO], dOH2);
-            rvec_sub(x[aH2], x[aH1], dHH);
-            rvec_sub(x[aD], x[aO], dOD);
-            rvec_sub(x[aS], x[aD], dDS);
+            pbc_rvec_sub(pbc, x[aH1], x[aO], dOH1);
+            pbc_rvec_sub(pbc, x[aH2], x[aO], dOH2);
+            pbc_rvec_sub(pbc, x[aH2], x[aH1], dHH);
+            pbc_rvec_sub(pbc, x[aD], x[aO], dOD);
+            ki = pbc_rvec_sub(pbc, x[aS], x[aD], dDS);
             cprod(dOH1, dOH2, nW);
 
             /* Compute inverse length of normal vector
@@ -835,6 +836,13 @@ real water_pol(int nbonds,
             kdx[YY] = kk[YY]*dx[YY];
             kdx[ZZ] = kk[ZZ]*dx[ZZ];
             vtot   += iprod(dx, kdx);
+
+            if (g)
+            {
+                ivec_sub(SHIFT_IVEC(g, aS), SHIFT_IVEC(g, aD), dt);
+                ki = IVEC2IS(dt);
+            }
+
             for (m = 0; (m < DIM); m++)
             {
                 /* This is a tensor operation but written out for speed */
@@ -845,8 +853,10 @@ real water_pol(int nbonds,
 #ifdef DEBUG
                 df[m] = fij;
 #endif
-                f[aS][m] += fij;
-                f[aD][m] -= fij;
+                f[aS][m]           += fij;
+                f[aD][m]           -= fij;
+                fshift[ki][m]      += fij;
+                fshift[CENTRAL][m] -= fij;
             }
 #ifdef DEBUG
             if (debug)
@@ -2422,7 +2432,7 @@ real posres(int nbonds,
             vtot       += 0.5*kk*dx[m]*dx[m];
             *dvdlambda +=
                 0.5*(pr->posres.fcB[m] - pr->posres.fcA[m])*dx[m]*dx[m]
-                -fm*dpdl[m];
+                fm*dpdl[m];
 
             /* Here we correct for the pbc_dx which included rdist */
             if (bForceValid)
index 1dd000c09eb9573876d7cffe64693afd91e9864f..825a8968dad1cbb59ef6e5b94ce8b750b8019395 100644 (file)
@@ -1789,11 +1789,26 @@ static void check_match(FILE *fplog,
                         ivec dd_nc, ivec dd_nc_f)
 {
     int      npp;
-    gmx_bool mm;
-
-    mm = FALSE;
+    gmx_bool mm                 = FALSE;
+    gmx_bool patchlevel_differs = FALSE;
+    gmx_bool version_differs    = FALSE;
 
     check_string(fplog, "Version", gmx_version(), version, &mm);
+    patchlevel_differs = mm;
+
+    if (patchlevel_differs)
+    {
+        /* Gromacs should be able to continue from checkpoints between
+         * different patch level versions, but we do not guarantee
+         * compatibility between different major/minor versions - check this.
+         */
+        int   gmx_major, gmx_minor;
+        int   cpt_major, cpt_minor;
+        sscanf(gmx_version(), "VERSION %d.%d", &gmx_major, &gmx_minor);
+        sscanf(version, "VERSION %d.%d", &cpt_major, &cpt_minor);
+        version_differs = (gmx_major != cpt_major || gmx_minor != cpt_minor);
+    }
+
     check_string(fplog, "Build time", BUILD_TIME, btime, &mm);
     check_string(fplog, "Build user", BUILD_USER, buser, &mm);
     check_string(fplog, "Build host", BUILD_HOST, bhost, &mm);
@@ -1820,16 +1835,39 @@ static void check_match(FILE *fplog,
 
     if (mm)
     {
-        fprintf(stderr,
-                "Gromacs binary or parallel settings not identical to previous run.\n"
-                "Continuation is exact, but is not guaranteed to be binary identical%s.\n\n",
-                fplog ? ",\n see the log file for details" : "");
+        const char msg_version_difference[] =
+            "The current Gromacs major & minor version are not identical to those that\n"
+            "generated the checkpoint file. In principle Gromacs does not support\n"
+            "continuation from checkpoints between different versions, so we advise\n"
+            "against this. If you still want to try your luck we recommend that you use\n"
+            "the -noappend flag to keep your output files from the two versions separate.\n"
+            "This might also work around errors where the output fields in the energy\n"
+            "file have changed between the different major & minor versions.\n";
 
-        if (fplog)
+        const char msg_mismatch_notice[] =
+            "Gromacs patchlevel, binary or parallel settings differ from previous run.\n"
+            "Continuation is exact, but not guaranteed to be binary identical.\n";
+
+        const char msg_logdetails[] =
+            "See the log file for details.\n";
+
+        if (version_differs)
         {
-            fprintf(fplog,
-                    "Gromacs binary or parallel settings not identical to previous run.\n"
-                    "Continuation is exact, but is not guaranteed to be binary identical.\n\n");
+            fprintf(stderr, "%s%s\n", msg_version_difference, fplog ? msg_logdetails : "");
+
+            if (fplog)
+            {
+                fprintf(fplog, "%s\n", msg_version_difference);
+            }
+        }
+        else
+        {
+            /* Major & minor versions match at least, but something is different. */
+            fprintf(stderr, "%s%s\n", msg_mismatch_notice, fplog ? msg_logdetails : "");
+            if (fplog)
+            {
+                fprintf(fplog, "%s\n", msg_mismatch_notice);
+            }
         }
     }
 }
@@ -2596,7 +2634,7 @@ gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_p
                     }
                     fprintf(stderr, "\n");
 
-                    gmx_fatal(FARGS, "File appending requested, but only %d of the %d output files are present", nexist, nfiles);
+                    gmx_fatal(FARGS, "File appending requested, but %d of the %d output files are not present or are named differently", nfiles-nexist, nfiles);
                 }
             }
 
index 4c1e6d888b1d87f78ec401907d5bd23fb0829074..04ee47de4053d37c9ffca49f81165448a4312224 100644 (file)
@@ -86,6 +86,7 @@
 #include "calc_verletbuf.h"
 #include "tomorse.h"
 #include "gromacs/imd/imd.h"
+#include "gromacs/utility/cstringutil.h"
 
 
 static int rm_interactions(int ifunc, int nrmols, t_molinfo mols[])
@@ -369,6 +370,41 @@ static void check_vel(gmx_mtop_t *mtop, rvec v[])
     }
 }
 
+static void check_shells_inputrec(gmx_mtop_t *mtop,
+                                  t_inputrec *ir,
+                                  warninp_t   wi)
+{
+    gmx_mtop_atomloop_all_t aloop;
+    t_atom                 *atom;
+    int                     a, nshells = 0;
+    char                    warn_buf[STRLEN];
+
+    aloop = gmx_mtop_atomloop_all_init(mtop);
+    while (gmx_mtop_atomloop_all_next(aloop, &a, &atom))
+    {
+        if (atom->ptype == eptShell ||
+            atom->ptype == eptBond)
+        {
+            nshells++;
+        }
+    }
+    if (IR_TWINRANGE(*ir) && (nshells > 0))
+    {
+        snprintf(warn_buf, STRLEN,
+                 "The combination of using shells and a twin-range cut-off is not supported");
+        warning_error(wi, warn_buf);
+    }
+    if ((nshells > 0) && (ir->nstcalcenergy != 1))
+    {
+        set_warning_line(wi, "unknown", -1);
+        snprintf(warn_buf, STRLEN,
+                 "There are %d shells, changing nstcalcenergy from %d to 1",
+                 nshells, ir->nstcalcenergy);
+        ir->nstcalcenergy = 1;
+        warning(wi, warn_buf);
+    }
+}
+
 static gmx_bool nint_ftype(gmx_mtop_t *mtop, t_molinfo *mi, int ftype)
 {
     int nint, mb;
@@ -1784,6 +1820,9 @@ int gmx_grompp(int argc, char *argv[])
         check_vel(sys, state.v);
     }
 
+    /* check for shells and inpurecs */
+    check_shells_inputrec(sys, ir, wi);
+
     /* check masses */
     check_mol(sys, wi);
 
index 9f8b5769bcfec7d3f3e62898739ecb9ae64af694..aebd0d9e679e174678dc410085eb7d02f46dd270 100644 (file)
@@ -252,6 +252,11 @@ void make_pull_groups(t_pull *pull,
     {
         pgrp = &pull->group[g];
 
+        if (strcmp(pgnames[g], "") == 0)
+        {
+            gmx_fatal(FARGS, "Group pull_group%d required by grompp was undefined.", g);
+        }
+
         ig        = search_string(pgnames[g], grps->nr, gnames);
         pgrp->nat = grps->index[ig+1] - grps->index[ig];
 
index bc7f299e551dd888f80cf00673cd510384c3abbb..fd2a8a1595bbed7f9349c10757948f2d25bd5855 100644 (file)
@@ -95,7 +95,7 @@ void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype_t atyp
                     break;
 
                 case eCOMB_ARITHMETIC:
-                    /* c0 and c1 are epsilon and sigma */
+                    /* c0 and c1 are sigma and epsilon */
                     for (i = k = 0; (i < nr); i++)
                     {
                         for (j = 0; (j < nr); j++, k++)
@@ -104,14 +104,21 @@ void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype_t atyp
                             cj0                  = get_atomtype_nbparam(j, 0, atype);
                             ci1                  = get_atomtype_nbparam(i, 1, atype);
                             cj1                  = get_atomtype_nbparam(j, 1, atype);
-                            plist->param[k].c[0] = (ci0+cj0)*0.5;
+                            plist->param[k].c[0] = (fabs(ci0) + fabs(cj0))*0.5;
+                            /* Negative sigma signals that c6 should be set to zero later,
+                             * so we need to propagate that through the combination rules.
+                             */
+                            if (ci0 < 0 || cj0 < 0)
+                            {
+                                plist->param[k].c[0] *= -1;
+                            }
                             plist->param[k].c[1] = sqrt(ci1*cj1);
                         }
                     }
 
                     break;
                 case eCOMB_GEOM_SIG_EPS:
-                    /* c0 and c1 are epsilon and sigma */
+                    /* c0 and c1 are sigma and epsilon */
                     for (i = k = 0; (i < nr); i++)
                     {
                         for (j = 0; (j < nr); j++, k++)
@@ -120,7 +127,14 @@ void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype_t atyp
                             cj0                  = get_atomtype_nbparam(j, 0, atype);
                             ci1                  = get_atomtype_nbparam(i, 1, atype);
                             cj1                  = get_atomtype_nbparam(j, 1, atype);
-                            plist->param[k].c[0] = sqrt(ci0*cj0);
+                            plist->param[k].c[0] = sqrt(fabs(ci0*cj0));
+                            /* Negative sigma signals that c6 should be set to zero later,
+                             * so we need to propagate that through the combination rules.
+                             */
+                            if (ci0 < 0 || cj0 < 0)
+                            {
+                                plist->param[k].c[0] *= -1;
+                            }
                             plist->param[k].c[1] = sqrt(ci1*cj1);
                         }
                     }
index efd24f896e8cdc0f6a7ef6df7ee05ab8102b418f..c8fdf66b7a05f59ebc42b3fc3df3cf5b1c2c6f3f 100644 (file)
@@ -96,7 +96,7 @@ real output_env_get_time_factor(const output_env_t oenv);
 /* return time conversion factor from ps (i.e. 1e-3 for ps->ns) */
 
 real output_env_get_time_invfactor(const output_env_t oenv);
-/* return inverse time conversion factor from ps (i.e. 1e3 for ps->ns) */
+/* return inverse time conversion factor to ps (i.e. 1e3 for ns->ps) */
 
 real output_env_conv_time(const output_env_t oenv, real time);
 /* return converted time */
index 22cd489e4b30756fb577b5330818248f29929a92..0c1126e8e5c8bee8c8875eea3e6c9769fd6204a4 100644 (file)
@@ -46,7 +46,6 @@ extern "C" {
  * If x!=NULL, the shells are predict for the global coordinates x.
  */
 gmx_shellfc_t init_shell_flexcon(FILE *fplog,
-                                 gmx_bool bCutoffSchemeIsVerlet,
                                  gmx_mtop_t *mtop, int nflexcon,
                                  rvec *x);
 
index affbf51ac9e0b300324eebc9a01082fb11c3a269..b16abe9141e9d5427073880cdef23ae63697f26a 100644 (file)
@@ -53,7 +53,7 @@ void table_spline3_fill_ewald_lr(real                                 *table_F,
                                  real                                 *table_V,
                                  real                                 *table_FDV0,
                                  int                                   ntab,
-                                 real                                  dx,
+                                 double                                dx,
                                  real                                  beta,
                                  real_space_grid_contribution_computer v_lr);
 /* Fill tables of ntab points with spacing dr with the ewald long-range
index 90a43f97ef1232991218c5c3ede2ca9800abab33..c244e7e3a0e21bf620f7f85ba2dc6038ce723e4b 100644 (file)
@@ -3885,7 +3885,7 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
     /* Now loop over all the thread data blocks that contribute
      * to the grid region we (our thread) are operating on.
      */
-    /* Note that ffy_nx/y is equal to the number of grid points
+    /* Note that fft_nx/y is equal to the number of grid points
      * between the first point of our node grid and the one of the next node.
      */
     for (sx = 0; sx >= -pmegrids->nthread_comm[XX]; sx--)
@@ -3901,14 +3901,8 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
         }
         pmegrid_g = &pmegrids->grid_th[fx*pmegrids->nc[YY]*pmegrids->nc[ZZ]];
         ox       += pmegrid_g->offset[XX];
-        if (!bCommX)
-        {
-            tx1 = min(ox + pmegrid_g->n[XX], ne[XX]);
-        }
-        else
-        {
-            tx1 = min(ox + pmegrid_g->n[XX], pme->pme_order);
-        }
+        /* Determine the end of our part of the source grid */
+        tx1 = min(ox + pmegrid_g->n[XX], ne[XX]);
 
         for (sy = 0; sy >= -pmegrids->nthread_comm[YY]; sy--)
         {
@@ -3923,14 +3917,8 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
             }
             pmegrid_g = &pmegrids->grid_th[fy*pmegrids->nc[ZZ]];
             oy       += pmegrid_g->offset[YY];
-            if (!bCommY)
-            {
-                ty1 = min(oy + pmegrid_g->n[YY], ne[YY]);
-            }
-            else
-            {
-                ty1 = min(oy + pmegrid_g->n[YY], pme->pme_order);
-            }
+            /* Determine the end of our part of the source grid */
+            ty1 = min(oy + pmegrid_g->n[YY], ne[YY]);
 
             for (sz = 0; sz >= -pmegrids->nthread_comm[ZZ]; sz--)
             {
index 531b88b61673dc519f888287f881b43600db2a5b..7c1f8679f44741ccb1d2d16ad8c5842106623e89 100644 (file)
@@ -230,7 +230,6 @@ static void predict_shells(FILE *fplog, rvec x[], rvec v[], real dt,
 }
 
 gmx_shellfc_t init_shell_flexcon(FILE *fplog,
-                                 gmx_bool bCutoffSchemeIsVerlet,
                                  gmx_mtop_t *mtop, int nflexcon,
                                  rvec *x)
 {
@@ -284,11 +283,6 @@ gmx_shellfc_t init_shell_flexcon(FILE *fplog,
         return NULL;
     }
 
-    if (bCutoffSchemeIsVerlet)
-    {
-        gmx_fatal(FARGS, "The shell code does not work with the Verlet cut-off scheme.\n");
-    }
-
     snew(shfc, 1);
     shfc->nflexcon = nflexcon;
 
@@ -532,6 +526,12 @@ gmx_shellfc_t init_shell_flexcon(FILE *fplog,
             {
                 fprintf(fplog, "\nNOTE: there all shells that are connected to particles outside thier own charge group, will not predict shells positions during the run\n\n");
             }
+            /* Prediction improves performance, so we should implement either:
+             * 1. communication for the atoms needed for prediction
+             * 2. prediction using the velocities of shells; currently the
+             *    shell velocities are zeroed, it's a bit tricky to keep
+             *    track of the shell displacements and thus the velocity.
+             */
             shfc->bPredict = FALSE;
         }
     }
@@ -992,26 +992,31 @@ int relax_shell_flexcon(FILE *fplog, t_commrec *cr, gmx_bool bVerbose,
         force[i] = shfc->f[i];
     }
 
-    /* When we had particle decomposition, this code only worked with
-     * PD when all particles involved with each shell were in the same
-     * charge group. Not sure if this is still relevant. */
     if (bDoNS && inputrec->ePBC != epbcNONE && !DOMAINDECOMP(cr))
     {
         /* This is the only time where the coordinates are used
          * before do_force is called, which normally puts all
          * charge groups in the box.
          */
-        cg0 = 0;
-        cg1 = top->cgs.nr;
-        put_charge_groups_in_box(fplog, cg0, cg1, fr->ePBC, state->box,
-                                 &(top->cgs), state->x, fr->cg_cm);
+        if (inputrec->cutoff_scheme == ecutsVERLET)
+        {
+            put_atoms_in_box_omp(fr->ePBC, state->box, md->homenr, state->x);
+        }
+        else
+        {
+            cg0 = 0;
+            cg1 = top->cgs.nr;
+            put_charge_groups_in_box(fplog, cg0, cg1, fr->ePBC, state->box,
+                                     &(top->cgs), state->x, fr->cg_cm);
+        }
+
         if (graph)
         {
             mk_mshift(fplog, graph, fr->ePBC, state->box, state->x);
         }
     }
 
-    /* After this all coordinate arrays will contain whole molecules */
+    /* After this all coordinate arrays will contain whole charge groups */
     if (graph)
     {
         shift_self(graph, state->box, state->x);
index 404516c4674eb205ae11425bddb2938921799571..feb36f60f4aa88027a332b5218133d1337e64cf2 100644 (file)
@@ -166,7 +166,7 @@ void table_spline3_fill_ewald_lr(real                                 *table_f,
                                  real                                 *table_v,
                                  real                                 *table_fdv0,
                                  int                                   ntab,
-                                 real                                  dx,
+                                 double                                dx,
                                  real                                  beta,
                                  real_space_grid_contribution_computer v_lr)
 {
index 3d6d040bd4c9dcdf68eb6e53deca46e1b7e1d61b..7f5d4c8594cd4a71d17517e6f4258698a8007a6c 100644 (file)
@@ -1063,7 +1063,12 @@ static void calc_ke_part_visc(matrix box, rvec x[], rvec v[],
         }
         if (md->nPerturbed && md->bPerturbed[n])
         {
-            dekindl += 0.5*(md->massB[n] - md->massA[n])*iprod(v_corrt, v_corrt);
+            /* The minus sign here might be confusing.
+             * The kinetic contribution from dH/dl doesn't come from
+             * d m(l)/2 v^2 / dl, but rather from d p^2/2m(l) / dl,
+             * where p are the momenta. The difference is only a minus sign.
+             */
+            dekindl -= 0.5*(md->massB[n] - md->massA[n])*iprod(v_corrt, v_corrt);
         }
     }
     ekind->dekindl = dekindl;
index 85a74eb4aef035394a95ba6b97b3be308294bca1..6de4e9e4478e65991a0d5b327c0bde341234699e 100644 (file)
@@ -161,7 +161,7 @@ real do_walls(t_inputrec *ir, t_forcerec *fr, matrix box, t_mdatoms *md,
             }
             else
             {
-                lamfac = 0;
+                lamfac = lambda;
                 type   = md->typeB;
             }
         }
index a4500a4d4e24a749eb2ae0e9a0509245787190b5..64bdbfd3a5b3c96264a23a1a43b3b17a9cfb220b 100644 (file)
@@ -629,6 +629,7 @@ static void do_constraint(t_pull *pull, t_pbc *pbc,
         for (c = 0; c < pull->ncoord; c++)
         {
             pcrd = &pull->coord[c];
+            ref  = pcrd->init + pcrd->rate*t;
 
             low_get_pull_coord_dr(pull, pcrd, pbc, t,
                                   rnew[pcrd->group[1]],
index fd2297792588e6a62d3cc01df957219ff60752e8..cbbf9f8ee473253c8c4c12adaea955b9dcfeb0f9 100644 (file)
@@ -1070,7 +1070,14 @@ void comp_frame(FILE *fp, t_trxframe *fr1, t_trxframe *fr2,
     }
     if (cmp_bool(fp, "bF", -1, fr1->bF, fr2->bF))
     {
-        cmp_rvecs_rmstol(fp, "f", min(fr1->natoms, fr2->natoms), fr1->f, fr2->f, ftol, abstol);
+        if (bRMSD)
+        {
+            cmp_rvecs(fp, "f", min(fr1->natoms, fr2->natoms), fr1->f, fr2->f, bRMSD, ftol, abstol);
+        }
+        else
+        {
+            cmp_rvecs_rmstol(fp, "f", min(fr1->natoms, fr2->natoms), fr1->f, fr2->f, ftol, abstol);
+        }
     }
     if (cmp_bool(fp, "bBox", -1, fr1->bBox, fr2->bBox))
     {
index b7dab3cf200677fa778e29ec6b4e3906ce302b8e..5fb9b70118317957d50ee5ad803b94dd42aab242 100644 (file)
@@ -328,12 +328,19 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     debug_gmx();
 
     /* Check for polarizable models and flexible constraints */
-    shellfc = init_shell_flexcon(fplog, fr->cutoff_scheme == ecutsVERLET,
+    shellfc = init_shell_flexcon(fplog,
                                  top_global, n_flexible_constraints(constr),
                                  (ir->bContinuation ||
                                   (DOMAINDECOMP(cr) && !MASTER(cr))) ?
                                  NULL : state_global->x);
-
+    if (shellfc && ir->nstcalcenergy != 1)
+    {
+        gmx_fatal(FARGS, "You have nstcalcenergy set to a value (%d) that is different from 1.\nThis is not supported in combinations with shell particles.\nPlease make a new tpr file.", ir->nstcalcenergy);
+    }
+    if (shellfc && DOMAINDECOMP(cr))
+    {
+        gmx_fatal(FARGS, "Shell particles are not implemented with domain decomposition, use a single rank");
+    }
     if (shellfc && ir->eI == eiNM)
     {
         /* Currently shells don't work with Normal Modes */
index 41a4021775e2facce77370a5d7b5341c4ffdcfb4..cf69f96a2b53a93ae57c370eedabe0e494c42f03 100644 (file)
@@ -207,13 +207,16 @@ int gmx_mdrun(int argc, char *argv[])
         "[PAR]",
         "When PME is used with domain decomposition, separate nodes can",
         "be assigned to do only the PME mesh calculation;",
-        "this is computationally more efficient starting at about 12 nodes.",
+        "this is computationally more efficient starting at about 12 nodes",
+        "or even fewer when OpenMP parallelization is used.",
         "The number of PME nodes is set with option [TT]-npme[tt],",
         "this can not be more than half of the nodes.",
         "By default [TT]mdrun[tt] makes a guess for the number of PME",
-        "nodes when the number of nodes is larger than 11 or performance wise",
-        "not compatible with the PME grid x dimension.",
-        "But the user should optimize npme. Performance statistics on this issue",
+        "nodes when the number of nodes is larger than 16. With GPUs,",
+        "PME nodes are not selected automatically, since the optimal setup",
+        "depends very much on the details of the hardware.",
+        "In all cases you might gain performance by optimizing [TT]-npme[tt].",
+        "Performance statistics on this issue",
         "are written at the end of the log file.",
         "For good load balancing at high parallelization, the PME grid x and y",
         "dimensions should be divisible by the number of PME nodes",
index d52bf5b95f9b250afb598d4f027ca04d3d6a275b..46a9bc0113cd1cd6755cca7903cc71128c2386f4 100644 (file)
@@ -278,6 +278,16 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
             {
                 if (re->q[re->type][re->ind[j]] < re->q[re->type][re->ind[i]])
                 {
+                    /* Unordered replicas are supposed to work, but there
+                     * is still an issues somewhere.
+                     * Note that at this point still re->ind[i]=i.
+                     */
+                    gmx_fatal(FARGS, "Replicas with indices %d < %d have %ss %g > %g, please order your replicas on increasing %s",
+                              i, j,
+                              erename[re->type],
+                              re->q[re->type][i], re->q[re->type][j],
+                              erename[re->type]);
+
                     k          = re->ind[i];
                     re->ind[i] = re->ind[j];
                     re->ind[j] = k;
@@ -870,7 +880,7 @@ static real calc_delta(FILE *fplog, gmx_bool bPrint, struct gmx_repl_ex *re, int
         dpV = (beta[ap]*re->pres[ap]-beta[bp]*re->pres[bp])*(Vol[b]-Vol[a])/PRESFAC;
         if (bPrint)
         {
-            fprintf(fplog, "  dpV = %10.3e  d = %10.3e\nb", dpV, delta + dpV);
+            fprintf(fplog, "  dpV = %10.3e  d = %10.3e\n", dpV, delta + dpV);
         }
         delta += dpV;
     }
@@ -898,7 +908,7 @@ test_for_replica_exchange(FILE                 *fplog,
     gmx_rng_t rng;
 
     bMultiEx = (re->nex > 1);  /* multiple exchanges at each state */
-    fprintf(fplog, "Replica exchange at step " "%"GMX_PRId64 " time %g\n", step, time);
+    fprintf(fplog, "Replica exchange at step " "%"GMX_PRId64 " time %.5f\n", step, time);
 
     if (re->bNPT)
     {
@@ -1239,15 +1249,11 @@ compute_exchange_order(FILE     *fplog,
 }
 
 static void
-prepare_to_do_exchange(FILE      *fplog,
-                       const int *destinations,
-                       const int  replica_id,
-                       const int  nrepl,
-                       int       *maxswap,
-                       int      **order,
-                       int      **cyclic,
-                       int       *incycle,
-                       gmx_bool  *bThisReplicaExchanged)
+prepare_to_do_exchange(FILE               *fplog,
+                       struct gmx_repl_ex *re,
+                       const int           replica_id,
+                       int                *maxswap,
+                       gmx_bool           *bThisReplicaExchanged)
 {
     int i, j;
     /* Hold the cyclic decomposition of the (multiple) replica
@@ -1255,9 +1261,9 @@ prepare_to_do_exchange(FILE      *fplog,
     gmx_bool bAnyReplicaExchanged = FALSE;
     *bThisReplicaExchanged = FALSE;
 
-    for (i = 0; i < nrepl; i++)
+    for (i = 0; i < re->nrepl; i++)
     {
-        if (destinations[i] != i)
+        if (re->destinations[i] != re->ind[i])
         {
             /* only mark as exchanged if the index has been shuffled */
             bAnyReplicaExchanged = TRUE;
@@ -1267,27 +1273,27 @@ prepare_to_do_exchange(FILE      *fplog,
     if (bAnyReplicaExchanged)
     {
         /* reinitialize the placeholder arrays */
-        for (i = 0; i < nrepl; i++)
+        for (i = 0; i < re->nrepl; i++)
         {
-            for (j = 0; j < nrepl; j++)
+            for (j = 0; j < re->nrepl; j++)
             {
-                cyclic[i][j] = -1;
-                order[i][j]  = -1;
+                re->cyclic[i][j] = -1;
+                re->order[i][j]  = -1;
             }
         }
 
         /* Identify the cyclic decomposition of the permutation (very
          * fast if neighbor replica exchange). */
-        cyclic_decomposition(destinations, cyclic, incycle, nrepl, maxswap);
+        cyclic_decomposition(re->destinations, re->cyclic, re->incycle, re->nrepl, maxswap);
 
         /* Now translate the decomposition into a replica exchange
          * order at each step. */
-        compute_exchange_order(fplog, cyclic, order, nrepl, *maxswap);
+        compute_exchange_order(fplog, re->cyclic, re->order, re->nrepl, *maxswap);
 
         /* Did this replica do any exchange at any point? */
         for (j = 0; j < *maxswap; j++)
         {
-            if (replica_id != order[replica_id][j])
+            if (replica_id != re->order[replica_id][j])
             {
                 *bThisReplicaExchanged = TRUE;
                 break;
@@ -1314,8 +1320,7 @@ gmx_bool replica_exchange(FILE *fplog, const t_commrec *cr, struct gmx_repl_ex *
     {
         replica_id  = re->repl;
         test_for_replica_exchange(fplog, cr->ms, re, enerd, det(state_local->box), step, time);
-        prepare_to_do_exchange(fplog, re->destinations, replica_id, re->nrepl, &maxswap,
-                               re->order, re->cyclic, re->incycle, &bThisReplicaExchanged);
+        prepare_to_do_exchange(fplog, re, replica_id, &maxswap, &bThisReplicaExchanged);
     }
     /* Do intra-simulation broadcast so all processors belonging to
      * each simulation know whether they need to participate in