Merge release-5-0 into master
authorRoland Schulz <roland@utk.edu>
Wed, 3 Sep 2014 17:47:25 +0000 (13:47 -0400)
committerRoland Schulz <roland@utk.edu>
Wed, 3 Sep 2014 22:10:20 +0000 (18:10 -0400)
Conflicts:
cmake/gmxDetectSimd.cmake
cmake/gmxSetBuildInformation.cmake
share/template/cmake/FindGROMACS.cmakein
change superseded in master
src/gromacs/fileio/mdoutf.h
src/gromacs/gmxlib/network.c
src/gromacs/gmxlib/oenv.cpp
src/gromacs/legacyheaders/types/simple.h
change applied to
src/gromacs/utility/real.h

Change-Id: Ib076dc9894f0d590a243a7504c3db7daf2f72beb

49 files changed:
CMakeLists.txt
cmake/Platform/BlueGeneQ-base.cmake
cmake/Platform/BlueGeneQ-static-XL-C.cmake
cmake/Platform/BlueGeneQ-static-XL-CXX.cmake
cmake/Platform/BlueGeneQ-static-bgclang-cxx.cmake [new file with mode: 0644]
cmake/gmxCFlags.cmake
cmake/gmxDetectSimd.cmake
cmake/gmxManageBlueGene.cmake
cmake/gmxSetBuildInformation.cmake
docs/install-guide/install-guide.md
share/template/README
src/config.h.cmakein
src/external/tng_io/src/lib/tng_io.c
src/gromacs/CMakeLists.txt
src/gromacs/commandline/tests/CMakeLists.txt
src/gromacs/fileio/mdoutf.c
src/gromacs/fileio/mdoutf.h
src/gromacs/fileio/tngio.cpp
src/gromacs/fileio/tngio_for_tools.cpp
src/gromacs/fileio/trajectory_writing.c
src/gromacs/fileio/trajectory_writing.h
src/gromacs/gmxana/gmx_bar.c
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/legacytests/gmx_traj_tests.cpp
src/gromacs/gmxlib/copyrite.cpp
src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/kernelutil_x86_avx_128_fma_double.h
src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/kernelutil_x86_avx_128_fma_single.h
src/gromacs/gmxlib/oenv.cpp
src/gromacs/gmxpreprocess/calc_verletbuf.c
src/gromacs/legacyheaders/sim_util.h
src/gromacs/legacyheaders/vsite.h
src/gromacs/mdlib/domdec.c
src/gromacs/mdlib/minimize.c
src/gromacs/mdlib/pme.c
src/gromacs/mdlib/sim_util.c
src/gromacs/mdlib/vsite.c
src/gromacs/onlinehelp/tests/CMakeLists.txt
src/gromacs/simd/impl_intel_mic/impl_intel_mic.h
src/gromacs/simd/impl_x86_avx_128_fma/impl_x86_avx_128_fma.h
src/gromacs/simd/impl_x86_avx_256/impl_x86_avx_256.h
src/gromacs/simd/impl_x86_sse2/impl_x86_sse2.h
src/gromacs/simd/simd_math.h
src/gromacs/utility/basenetwork.cpp
src/gromacs/utility/real.h
src/gromacs/utility/smalloc.c
src/programs/mdrun/md.cpp
src/programs/mdrun/tests/rerun.cpp
src/testutils/tests/testasserts_tests.cpp

index ce27e95cc1aa3c395bf6e2a00234fc5ff225a8f1..5aafe926ada829b58ebc622faf85d92c0458ffe4 100644 (file)
@@ -520,6 +520,13 @@ if (GMX_BUILD_UNITTESTS AND NOT HAVE_LIBXML2)
         "Either set GMX_BUILD_UNITTESTS=OFF or tell CMake how to find a working version of libxml2.")
 endif()
 
+if(GMX_USE_TNG AND NOT GMX_EXTERNAL_TNG)
+    # TNG wants zlib if it is available
+    find_package(ZLIB QUIET)
+    include(gmxTestZLib)
+    gmx_test_zlib(HAVE_ZLIB)
+endif()
+
 ########################################################################
 # Our own GROMACS tests
 ########################################################################
index 5edacb98f127451687fa46cbd3d5d47237932630..1827a5e680ae7ebd2851ab69331628e52192650e 100644 (file)
@@ -172,7 +172,7 @@ macro(__BlueGeneQ_set_static_flags compiler_id lang)
   set(CMAKE_${lang}_LINK_EXECUTABLE
     "<CMAKE_${lang}_COMPILER> ${BG/Q_${lang}_DEFAULT_EXE_FLAGS}")
 
-  if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${compiler_id} STREQUAL "XL")
+  if(CMAKE_BUILD_TYPE MATCHES "Deb" AND ${compiler_id} STREQUAL "XL")
       # Work around an unknown compiler bug triggered in
       # compute_globals(). Using -O0 disables -qhot and this seems
       # to break the normal OpenMP flag -qsmp unless qualified with
index a814ac765f2beee6a80861cbeca4819810af0a44..3999635f62a71c2d933209762a6da1e79399a3c7 100644 (file)
@@ -73,17 +73,11 @@ include(BlueGeneQ-static)
 __BlueGeneQ_set_static_flags(XL C)
 __BlueGeneQ_set_static_flags(XL CXX)
 
-# This suppression stops the following information message from
-# almost every source file at -O3:
-#   1500-036: (I) The NOSTRICT option (default at OPT(3)) has the potential to alter the semantics of a program.  Please refer to documentation on the STRICT/NOSTRICT option for more information.
-set(COMPILER_SUPPRESSION "-qsuppress=1500-036")
-
 set(CMAKE_SYSTEM_NAME BlueGeneQ-static CACHE STRING "Cross-compiling for BlueGene/Q" FORCE)
 # xl.ndebug is appropriate for production calculations. For debugging,
-# use xl to add back error checks and assertions
-set(CMAKE_C_COMPILER /bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlc_r)
-set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG ${COMPILER_SUPPRESSION}" CACHE STRING "Compiler optimization flags")
-set(CMAKE_CXX_COMPILER /bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlcxx_r)
-set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${COMPILER_SUPPRESSION}" CACHE STRING "Compiler optimization flags")
+# use xl to add back error checks and assertions. Using the
+# thread-safe compiler version is required, so use (e.g.)
+# CMAKE_C_COMPILER=/bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlc_r
+# CMAKE_CXX_COMPILER=/bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlcxx_r
 
 mark_as_advanced(CMAKE_XL_CreateExportList) # No idea what spams this
index a814ac765f2beee6a80861cbeca4819810af0a44..3999635f62a71c2d933209762a6da1e79399a3c7 100644 (file)
@@ -73,17 +73,11 @@ include(BlueGeneQ-static)
 __BlueGeneQ_set_static_flags(XL C)
 __BlueGeneQ_set_static_flags(XL CXX)
 
-# This suppression stops the following information message from
-# almost every source file at -O3:
-#   1500-036: (I) The NOSTRICT option (default at OPT(3)) has the potential to alter the semantics of a program.  Please refer to documentation on the STRICT/NOSTRICT option for more information.
-set(COMPILER_SUPPRESSION "-qsuppress=1500-036")
-
 set(CMAKE_SYSTEM_NAME BlueGeneQ-static CACHE STRING "Cross-compiling for BlueGene/Q" FORCE)
 # xl.ndebug is appropriate for production calculations. For debugging,
-# use xl to add back error checks and assertions
-set(CMAKE_C_COMPILER /bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlc_r)
-set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG ${COMPILER_SUPPRESSION}" CACHE STRING "Compiler optimization flags")
-set(CMAKE_CXX_COMPILER /bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlcxx_r)
-set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${COMPILER_SUPPRESSION}" CACHE STRING "Compiler optimization flags")
+# use xl to add back error checks and assertions. Using the
+# thread-safe compiler version is required, so use (e.g.)
+# CMAKE_C_COMPILER=/bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlc_r
+# CMAKE_CXX_COMPILER=/bgsys/drivers/ppcfloor/comm/xl.ndebug/bin/mpixlcxx_r
 
 mark_as_advanced(CMAKE_XL_CreateExportList) # No idea what spams this
diff --git a/cmake/Platform/BlueGeneQ-static-bgclang-cxx.cmake b/cmake/Platform/BlueGeneQ-static-bgclang-cxx.cmake
new file mode 100644 (file)
index 0000000..410c224
--- /dev/null
@@ -0,0 +1,79 @@
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 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.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+#
+#=============================================================================
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
+# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov>
+# Copyright 2012 Julien Bigot <julien.bigot@cea.fr>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#=============================================================================
+
+include(BlueGeneQ-static)
+__BlueGeneQ_set_static_flags(bgclang C)
+__BlueGeneQ_set_static_flags(bgclang CXX)
+
+set(CMAKE_SYSTEM_NAME BlueGeneQ-static CACHE STRING "Cross-compiling for BlueGene/Q" FORCE)
+
+# Use (e.g.) bgclang and bgclang++ as base compilers inside mpicc and
+# mpicxx
index 4521a8aa0281f0908d27833d2b02d5e920a31baa..799bea1c7bc8f5438ea74a2f857dcd8b57ec61d2 100644 (file)
@@ -198,12 +198,18 @@ MACRO(gmx_c_flags)
     endif()
 
     # xlc
+    # The suppressions below stop information messages about -O3
+    # causing non-strict IEEE compliance that changes the semantics of
+    # the program (duh; 1500-036), warnings about correct PBC-related use of
+    # maximum array indices of DIM-sized C arrays (1500-010).
     if (CMAKE_C_COMPILER_ID MATCHES "XL")
         GMX_TEST_CFLAG(CFLAGS_OPT "-qarch=auto -qtune=auto" GMXC_CFLAGS)
         GMX_TEST_CFLAG(CFLAGS_LANG "-qlanglvl=extc99" GMXC_CFLAGS)
+        GMX_TEST_CFLAG(CFLAGS_LANG "-qsuppress=1500-036 -qsuppress=1500-010" GMXC_CFLAGS)
     endif()
     if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
         GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-qarch=auto -qtune=auto" GMXC_CXXFLAGS)
+        GMX_TEST_CXXFLAG(CFLAGS_LANG "-qsuppress=1500-036 -qsuppress=1500-010" GMXC_CXXFLAGS)
     endif()
 
     # msvc
index 4edfe14dd3b93977c2e9078820e4e587af9c98db..a8ac28260544cf0ddaa490571bee82a348bce7d2 100644 (file)
@@ -62,7 +62,7 @@ function(gmx_suggest_x86_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_CPUID_STANDALONE")
+    set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUID_STANDALONE")
     if(GMX_TARGET_X86)
         set(_compile_definitions "${_compile_definitions} -DGMX_TARGET_X86")
     endif()
@@ -84,10 +84,10 @@ function(gmx_suggest_x86_simd _suggested_simd)
         set(OUTPUT_TMP "None")
     endif(NOT GMX_CPUID_COMPILED)
 
-    string(STRIP "@OUTPUT_TMP@" OUTPUT_SIMD)
+    string(STRIP "${OUTPUT_TMP}" OUTPUT_SIMD)
 
-    set(${_suggested_simd} "@OUTPUT_SIMD@" PARENT_SCOPE)
-    message(STATUS "Detected best SIMD instructions for this CPU - @OUTPUT_SIMD@")
+    set(${_suggested_simd} "${OUTPUT_SIMD}" PARENT_SCOPE)
+    message(STATUS "Detected best SIMD instructions for this CPU - ${OUTPUT_SIMD}")
 endfunction()
 
 function(gmx_detect_simd _suggested_simd)
index ab4130ee2f9a5cffaae193347d6f10fc4866e27d..300519789b685aa9ada7237ec8f347e52eb95f99 100644 (file)
@@ -51,7 +51,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "BlueGene.*static")
     set(BUILD_SHARED_LIBS OFF CACHE BOOL "Static BlueGene build toolchain selected, so shared libraries are disabled" FORCE)
 endif()
 
-set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene" FORCE)
+set(GMX_SOFTWARE_INVSQRT OFF CACHE BOOL "Do not use software reciprocal square root on BlueGene")
 set(GMX_X11 OFF CACHE BOOL "X11 not compatible with BlueGene, disabled!" FORCE)
 set(GMX_GPU OFF CACHE BOOL "Cannot do GPU acceleration on BlueGene" FORCE)
 
index 04a03bfb0b874f7ce490512f53e873df1aae8805..7565410844fef9f73ab6f3b5e52f50cbea2fe026 100644 (file)
@@ -69,21 +69,21 @@ macro(gmx_set_build_information)
         execute_process( COMMAND date     OUTPUT_VARIABLE TMP_TIME    OUTPUT_STRIP_TRAILING_WHITESPACE)
         execute_process( COMMAND whoami   OUTPUT_VARIABLE TMP_USER       OUTPUT_STRIP_TRAILING_WHITESPACE)
         execute_process( COMMAND hostname OUTPUT_VARIABLE TMP_HOSTNAME   OUTPUT_STRIP_TRAILING_WHITESPACE)
-        set(BUILD_USER    "@TMP_USER@\@@TMP_HOSTNAME@ [CMAKE]" CACHE INTERNAL "Build user")
-        set(BUILD_TIME    "@TMP_TIME@" CACHE INTERNAL "Build date & time")
+        set(BUILD_USER    "${TMP_USER}\@${TMP_HOSTNAME} [CMAKE]" CACHE INTERNAL "Build user")
+        set(BUILD_TIME    "${TMP_TIME}" CACHE INTERNAL "Build date & time")
         execute_process( COMMAND uname -srm OUTPUT_VARIABLE TMP_HOST OUTPUT_STRIP_TRAILING_WHITESPACE)
-        set(BUILD_HOST    "@TMP_HOST@" CACHE INTERNAL "Build host & architecture")
+        set(BUILD_HOST    "${TMP_HOST}" CACHE INTERNAL "Build host & architecture")
         message(STATUS "Setting build user & time - OK")
     else()
-        set(BUILD_USER    "Anonymous@unknown [CMAKE]" CACHE INTERNAL "Build user")
+        set(BUILD_USER    "Anonymous\@unknown [CMAKE]" CACHE INTERNAL "Build user")
         set(BUILD_TIME    "Unknown date" CACHE INTERNAL "Build date & time")
-        set(BUILD_HOST    "@CMAKE_HOST_SYSTEM@ @CMAKE_HOST_SYSTEM_PROCESSOR@" CACHE INTERNAL "Build host & architecture")
+        set(BUILD_HOST    "${CMAKE_HOST_SYSTEM} ${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE INTERNAL "Build host & architecture")
         message(STATUS "Setting build user & time - not on Unix, using anonymous")
     endif()
 
     if(NOT CMAKE_CROSSCOMPILING)
         # Get CPU information, e.g. for deciding what SIMD support exists
-        set(_compile_definitions "@GCC_INLINE_ASM_DEFINE@ -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUID_STANDALONE")
+        set(_compile_definitions "${GCC_INLINE_ASM_DEFINE} -I${CMAKE_SOURCE_DIR}/src -DGMX_CPUID_STANDALONE")
         if(GMX_TARGET_X86)
             set(_compile_definitions "${_compile_definitions} -DGMX_TARGET_X86")
         endif()
@@ -119,40 +119,40 @@ macro(gmx_set_build_information)
             RUN_OUTPUT_VARIABLE OUTPUT_CPU_FEATURES ARGS "-features")
         unset(_compile_definitions)
 
-        string(STRIP "@OUTPUT_CPU_VENDOR@" OUTPUT_CPU_VENDOR)
-        string(STRIP "@OUTPUT_CPU_BRAND@" OUTPUT_CPU_BRAND)
-        string(STRIP "@OUTPUT_CPU_FAMILY@" OUTPUT_CPU_FAMILY)
-        string(STRIP "@OUTPUT_CPU_MODEL@" OUTPUT_CPU_MODEL)
-        string(STRIP "@OUTPUT_CPU_STEPPING@" OUTPUT_CPU_STEPPING)
-        string(STRIP "@OUTPUT_CPU_FEATURES@" OUTPUT_CPU_FEATURES)
+        string(STRIP "${OUTPUT_CPU_VENDOR}" OUTPUT_CPU_VENDOR)
+        string(STRIP "${OUTPUT_CPU_BRAND}" OUTPUT_CPU_BRAND)
+        string(STRIP "${OUTPUT_CPU_FAMILY}" OUTPUT_CPU_FAMILY)
+        string(STRIP "${OUTPUT_CPU_MODEL}" OUTPUT_CPU_MODEL)
+        string(STRIP "${OUTPUT_CPU_STEPPING}" OUTPUT_CPU_STEPPING)
+        string(STRIP "${OUTPUT_CPU_FEATURES}" OUTPUT_CPU_FEATURES)
 
         if(GMX_CPUID_RUN_VENDOR EQUAL 0)
-            set(BUILD_CPU_VENDOR   "@OUTPUT_CPU_VENDOR@"   CACHE INTERNAL "Build CPU vendor")
+            set(BUILD_CPU_VENDOR   "${OUTPUT_CPU_VENDOR}"   CACHE INTERNAL "Build CPU vendor")
         else()
             set(BUILD_CPU_VENDOR   "Unknown, detect failed" CACHE INTERNAL "Build CPU vendor")
         endif()
         if(GMX_CPUID_RUN_BRAND EQUAL 0)
-            set(BUILD_CPU_BRAND    "@OUTPUT_CPU_BRAND@"    CACHE INTERNAL "Build CPU brand")
+            set(BUILD_CPU_BRAND    "${OUTPUT_CPU_BRAND}"    CACHE INTERNAL "Build CPU brand")
         else()
             set(BUILD_CPU_BRAND    "Unknown, detect failed" CACHE INTERNAL "Build CPU brand")
         endif()
         if(GMX_CPUID_RUN_FAMILY EQUAL 0)
-            set(BUILD_CPU_FAMILY   "@OUTPUT_CPU_FAMILY@"   CACHE INTERNAL "Build CPU family")
+            set(BUILD_CPU_FAMILY   "${OUTPUT_CPU_FAMILY}"   CACHE INTERNAL "Build CPU family")
         else()
             set(BUILD_CPU_FAMILY   "0"                     CACHE INTERNAL "Build CPU family")
         endif()
         if(GMX_CPUID_RUN_MODEL EQUAL 0)
-            set(BUILD_CPU_MODEL    "@OUTPUT_CPU_MODEL@"    CACHE INTERNAL "Build CPU model")
+            set(BUILD_CPU_MODEL    "${OUTPUT_CPU_MODEL}"    CACHE INTERNAL "Build CPU model")
         else()
             set(BUILD_CPU_MODEL    "0"                     CACHE INTERNAL "Build CPU model")
         endif()
         if(GMX_CPUID_RUN_STEPPING EQUAL 0)
-            set(BUILD_CPU_STEPPING "@OUTPUT_CPU_STEPPING@" CACHE INTERNAL "Build CPU stepping")
+            set(BUILD_CPU_STEPPING "${OUTPUT_CPU_STEPPING}" CACHE INTERNAL "Build CPU stepping")
         else()
             set(BUILD_CPU_STEPPING "0"                     CACHE INTERNAL "Build CPU stepping")
         endif()
             if(GMX_CPUID_RUN_FEATURES EQUAL 0)
-            set(BUILD_CPU_FEATURES "@OUTPUT_CPU_FEATURES@" CACHE INTERNAL "Build CPU features")
+            set(BUILD_CPU_FEATURES "${OUTPUT_CPU_FEATURES}" CACHE INTERNAL "Build CPU features")
         else()
             set(BUILD_CPU_FEATURES ""                      CACHE INTERNAL "Build CPU features")
         endif()
index 1a973dad5d785a91848d4640d864add005c8a475..d34a3b5d67c9c3280651c36cf34454b7a942ed53 100644 (file)
@@ -916,18 +916,22 @@ accuracy and costs twice as much time moving memory around.
 You need to arrange for FFTW to be installed correctly, following the
 above instructions.
 
-`mpicc` is used for compiling and linking. This can make it awkward to
+MPI wrapper compilers should be used for compiling and linking. Both
+xlc and bgclang are supported back ends - either might prove to be
+faster in practice. The MPI wrapper compilers can make it awkward to
 attempt to use IBM's optimized BLAS/LAPACK called ESSL (see the
-section on
-[linear algebra libraries](#linear-algebra-libraries)). Since mdrun is
-the only part of GROMACS that should normally run on the compute
-nodes, and there is nearly no need for linear algebra support for
-mdrun, it is recommended to use the GROMACS built-in linear algebra
-routines - it is rare for this to run slowly.
+section on [linear algebra
+libraries](#linear-algebra-libraries)). Since mdrun is the only part
+of GROMACS that should normally run on the compute nodes, and there is
+nearly no need for linear algebra support for mdrun, it is recommended
+to use the GROMACS built-in linear algebra routines - this is never
+a problem for normal simulations.
 
 The recommended configuration is to use
 
-    cmake .. -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-XL-CXX \
+    cmake .. -DCMAKE_C_COMPILER=mpicc \
+             -DCMAKE_CXX_COMPILER=mpicxx \
+             -DCMAKE_TOOLCHAIN_FILE=Platform/BlueGeneQ-static-XL-CXX \
              -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix \
              -DGMX_MPI=ON \
              -DGMX_BUILD_MDRUN_ONLY=ON
@@ -935,7 +939,9 @@ The recommended configuration is to use
     make install
 
 which will build a statically-linked MPI-enabled mdrun for the compute
-nodes. Otherwise, GROMACS default configuration behaviour applies.
+nodes. Or use the Platform/BlueGeneQ-static-bgclang-cxx
+toolchain file if compiling with bgclang. Otherwise, GROMACS default configuration
+behaviour applies.
 
 It is possible to configure and make the remaining GROMACS tools with
 the compute-node toolchain, but as none of those tools are MPI-aware
index 535db079bcb0640ff7f2bf1c33088482e98dd063..dc25c57bfa4a3e06a5f6bb8aea734625a53fb58d 100644 (file)
@@ -6,12 +6,35 @@ The CMakelist.txt can be used together with cmake to
 build the template program:
 $ source /path/to/GMXRC
 $ cmake /path/to/template
+Alternatively, setting CMAKE_PREFIX_PATH will direct cmake
+to find a particular GROMACS installation.
 
-The Makefile.pkg can be used if cmake is unavailble. It
+The Makefile.pkg can be used if cmake is unavailable. It
 makes use of pkg-config only to build the template program:
 $ source /path/to/GMXRC
 $ make -f Makefile.pkg
 
+You will need to make sure that you use a sufficiently similar C++
+compiler and C++ Standard Library as the one that was used for
+compiling GROMACS, preferably the same one. If you used any system
+libraries (e.g. Boost, FFTW, BLAS, LAPACK) when installing GROMACS,
+then you will need make them available to the template build system
+also. The easiest way to do this is to have pkg-config installed on
+your system, and to source GMXRC from the GROMACS installation before
+you attempt to configure the template. A subset of Boost is supposed
+to be installed with GROMACS, but currently the automatic machinery
+does not detect that installation, so you may need to install Boost
+(headers only) in order to use the GROMACS template program.
+
+If the compiler used for GROMACS was capable of some C++11 features
+then, by default, those will be required for compiling the
+template. To make that work, you can either configure GROMACS with
+$ cmake -DGMX_CXX11=off
+or configure the template with the appropriate
+$ cmake -DCMAKE_CXX_FLAGS="-flag-for-your-compiler"
+You can find out the necessary flags from your compiler's documentation,
+or by inspecting the src/buildinfo.h file in the GROMACS build tree.
+
 ----------------------------------------------------------
 
 If you are reading this in the distribution directory,
index f7304583407f95e5a19a0867f2b09566749072fa..32e4cf00417eed7dd4d539d55b3e1013cfd9d812 100644 (file)
 /* Define if we have pipes */
 #cmakedefine HAVE_PIPES
 
+/* Define if we have zlib */
+#cmakedefine HAVE_ZLIB
+
 /*! \endcond */
index 001521b6c0efe32888d3dae45c12a5555b254489..c388f789bfcbae367f3e583bde0c91098c41631f 100644 (file)
@@ -9,6 +9,14 @@
  * modify it under the terms of the Revised BSD License.
  */
 
+#define _FILE_OFFSET_BITS 64
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#define _LARGEFILE_SOURCE
+/* Define for large files, on AIX-style hosts. */
+#define _LARGE_FILES
+
+#include "tng/tng_io.h"
+
 #ifdef USE_STD_INTTYPES_H
 #include <inttypes.h>
 #endif
 #include <zlib.h>
 #endif
 
-#include "tng/tng_io.h"
 #include "tng/md5.h"
 #include "compression/tng_compress.h"
 #include "tng/version.h"
 
+#ifdef _MSC_VER
+#define fseeko _fseeki64
+#define ftello _ftelli64
+#endif
 
 struct tng_bond {
     /** One of the atoms of the bond */
@@ -260,7 +271,7 @@ struct tng_trajectory {
     /** A handle to the input file */
     FILE *input_file;
     /** The length of the input file */
-    long input_file_len;
+    int64_t input_file_len;
     /** The path of the output trajectory file */
     char *output_file_path;
     /** A handle to the output file */
@@ -345,9 +356,9 @@ struct tng_trajectory {
     /** The currently active frame set */
     struct tng_trajectory_frame_set current_trajectory_frame_set;
     /** The pos in the src file of the current frame set */
-    long current_trajectory_frame_set_input_file_pos;
+    int64_t current_trajectory_frame_set_input_file_pos;
     /** The pos in the dest file of the current frame set */
-    long current_trajectory_frame_set_output_file_pos;
+    int64_t current_trajectory_frame_set_output_file_pos;
     /** The number of frame sets in the trajectory N.B. Not saved in file and
      *  cannot be trusted to be up-to-date */
     int64_t n_trajectory_frame_sets;
@@ -801,7 +812,8 @@ static tng_function_status tng_block_destroy(struct tng_gen_block **block_p)
 static tng_function_status tng_block_header_read
                 (tng_trajectory_t tng_data, tng_gen_block_t block)
 {
-    int len, offset = 0;
+    int len;
+    int64_t offset = 0;
 
     TNG_ASSERT(block != 0, "TNG library: Trying to read to uninitialized block (NULL pointer).");
 
@@ -826,7 +838,7 @@ static tng_function_status tng_block_header_read
     }
 
     /* If this was the size of the general info block check the endianness */
-    if(ftell(tng_data->input_file) < 9)
+    if(ftello(tng_data->input_file) < 9)
     {
         /* File is little endian */
         if ( *((const char*)&block->header_contents_size) != 0x00 &&
@@ -893,8 +905,8 @@ static tng_function_status tng_block_header_read
     }
 
     /* Move the reading position to the beginning of the header. */
-    fseek(tng_data->input_file, -(long)sizeof(block->header_contents_size),
-          SEEK_CUR);
+    fseeko(tng_data->input_file, -(int64_t)sizeof(block->header_contents_size),
+           SEEK_CUR);
 
     /* If there is already memory allocated for the contents free it (we do not
      * know if the size is correct). */
@@ -1061,7 +1073,7 @@ static tng_function_status tng_md5_hash_update(tng_trajectory_t tng_data,
         return(TNG_CRITICAL);
     }
 
-    fseek(tng_data->output_file, (long)contents_start_pos, SEEK_SET);
+    fseeko(tng_data->output_file, contents_start_pos, SEEK_SET);
     if(fread(block->block_contents, block->block_contents_size, 1,
             tng_data->output_file) == 0)
     {
@@ -1071,7 +1083,7 @@ static tng_function_status tng_md5_hash_update(tng_trajectory_t tng_data,
 
     tng_block_md5_hash_generate(block);
 
-    fseek(tng_data->output_file, (long)header_start_pos + 3 * sizeof(int64_t),
+    fseeko(tng_data->output_file, header_start_pos + 3 * sizeof(int64_t),
           SEEK_SET);
     fwrite(block->md5_hash, TNG_MD5_HASH_LEN, 1, tng_data->output_file);
 
@@ -1104,8 +1116,8 @@ static tng_function_status tng_header_pointers_update
 
     tng_block_init(&block);
 
-    output_file_pos = ftell(tng_data->output_file);
-    fseek(tng_data->output_file, 0, SEEK_SET);
+    output_file_pos = ftello(tng_data->output_file);
+    fseeko(tng_data->output_file, 0, SEEK_SET);
 
     if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
     {
@@ -1116,9 +1128,9 @@ static tng_function_status tng_header_pointers_update
         return(TNG_CRITICAL);
     }
 
-    contents_start_pos = ftell(tng_data->output_file);
+    contents_start_pos = ftello(tng_data->output_file);
 
-    fseek(tng_data->output_file, (long)block->block_contents_size - 5 *
+    fseeko(tng_data->output_file, block->block_contents_size - 5 *
           sizeof(int64_t), SEEK_CUR);
 
     tng_data->input_file = temp;
@@ -1169,7 +1181,7 @@ static tng_function_status tng_header_pointers_update
 
     tng_block_destroy(&block);
 
-    fseek(tng_data->output_file, (long)output_file_pos, SEEK_SET);
+    fseeko(tng_data->output_file, output_file_pos, SEEK_SET);
 
     return(TNG_SUCCESS);
 }
@@ -1199,7 +1211,7 @@ static tng_function_status tng_frame_set_pointers_update
     }
 
     tng_block_init(&block);
-    output_file_pos = ftell(tng_data->output_file);
+    output_file_pos = ftello(tng_data->output_file);
 
     tng_data->input_file = tng_data->output_file;
 
@@ -1210,7 +1222,7 @@ static tng_function_status tng_frame_set_pointers_update
     /* Update next frame set */
     if(frame_set->next_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file, (long)frame_set->next_frame_set_file_pos,
+        fseeko(tng_data->output_file, frame_set->next_frame_set_file_pos,
               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
@@ -1222,9 +1234,9 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (5 *
+        fseeko(tng_data->output_file, block->block_contents_size - (5 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
@@ -1250,12 +1262,12 @@ static tng_function_status tng_frame_set_pointers_update
             tng_md5_hash_update(tng_data, block, frame_set->next_frame_set_file_pos,
                                 contents_start_pos);
         }
-        fseek(tng_data->output_file, (long)output_file_pos, SEEK_SET);
+        fseeko(tng_data->output_file, output_file_pos, SEEK_SET);
     }
     /* Update previous frame set */
     if(frame_set->prev_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file, (long)frame_set->prev_frame_set_file_pos,
+        fseeko(tng_data->output_file, frame_set->prev_frame_set_file_pos,
               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
@@ -1267,9 +1279,9 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (6 *
+        fseeko(tng_data->output_file, block->block_contents_size - (6 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
@@ -1295,15 +1307,15 @@ static tng_function_status tng_frame_set_pointers_update
             tng_md5_hash_update(tng_data, block, frame_set->prev_frame_set_file_pos,
                                 contents_start_pos);
         }
-        fseek(tng_data->output_file, (long)output_file_pos, SEEK_SET);
+        fseeko(tng_data->output_file, output_file_pos, SEEK_SET);
     }
 
     /* Update the frame set one medium stride step after */
     if(frame_set->medium_stride_next_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file,
-              (long)frame_set->medium_stride_next_frame_set_file_pos,
-              SEEK_SET);
+        fseeko(tng_data->output_file,
+               frame_set->medium_stride_next_frame_set_file_pos,
+               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
         {
@@ -1314,9 +1326,9 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (3 *
+        fseeko(tng_data->output_file, block->block_contents_size - (3 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
@@ -1347,9 +1359,9 @@ static tng_function_status tng_frame_set_pointers_update
     /* Update the frame set one medium stride step before */
     if(frame_set->medium_stride_prev_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file,
-              (long)frame_set->medium_stride_prev_frame_set_file_pos,
-              SEEK_SET);
+        fseeko(tng_data->output_file,
+               frame_set->medium_stride_prev_frame_set_file_pos,
+               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
         {
@@ -1360,9 +1372,9 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (4 *
+        fseeko(tng_data->output_file, block->block_contents_size - (4 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
@@ -1394,9 +1406,9 @@ static tng_function_status tng_frame_set_pointers_update
     /* Update the frame set one long stride step after */
     if(frame_set->long_stride_next_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file,
-              (long)frame_set->long_stride_next_frame_set_file_pos,
-              SEEK_SET);
+        fseeko(tng_data->output_file,
+               frame_set->long_stride_next_frame_set_file_pos,
+               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
         {
@@ -1407,10 +1419,10 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (1 *
-            sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
+        fseeko(tng_data->output_file, block->block_contents_size - (1 *
+               sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
         {
@@ -1440,9 +1452,9 @@ static tng_function_status tng_frame_set_pointers_update
     /* Update the frame set one long stride step before */
     if(frame_set->long_stride_prev_frame_set_file_pos > 0)
     {
-        fseek(tng_data->output_file,
-              (long)frame_set->long_stride_prev_frame_set_file_pos,
-              SEEK_SET);
+        fseeko(tng_data->output_file,
+               frame_set->long_stride_prev_frame_set_file_pos,
+               SEEK_SET);
 
         if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
         {
@@ -1453,9 +1465,9 @@ static tng_function_status tng_frame_set_pointers_update
             return(TNG_CRITICAL);
         }
 
-        contents_start_pos = ftell(tng_data->output_file);
+        contents_start_pos = ftello(tng_data->output_file);
 
-        fseek(tng_data->output_file, (long)block->block_contents_size - (2 *
+        fseeko(tng_data->output_file, block->block_contents_size - (2 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
         if(tng_data->input_endianness_swap_func_64)
@@ -1484,7 +1496,7 @@ static tng_function_status tng_frame_set_pointers_update
         }
     }
 
-    fseek(tng_data->output_file, (long)output_file_pos, SEEK_SET);
+    fseeko(tng_data->output_file, output_file_pos, SEEK_SET);
 
     tng_data->input_file = temp;
 
@@ -1502,7 +1514,7 @@ static tng_function_status tng_reread_frame_set_at_file_pos
 
     tng_block_init(&block);
 
-    fseek(tng_data->input_file, pos, SEEK_SET);
+    fseeko(tng_data->input_file, pos, SEEK_SET);
     if(pos > 0)
     {
         stat = tng_block_header_read(tng_data, block);
@@ -1537,7 +1549,7 @@ static tng_function_status tng_file_pos_of_subsequent_trajectory_block_get
     tng_trajectory_frame_set_t frame_set =
     &tng_data->current_trajectory_frame_set;
 
-    orig_pos = ftell(tng_data->input_file);
+    orig_pos = ftello(tng_data->input_file);
     curr_frame_set_pos = tng_data->current_trajectory_frame_set_input_file_pos;
 
     *pos = tng_data->first_trajectory_frame_set_input_file_pos;
@@ -1547,7 +1559,7 @@ static tng_function_status tng_file_pos_of_subsequent_trajectory_block_get
         return(TNG_SUCCESS);
     }
 
-    fseek(tng_data->input_file, *pos, SEEK_SET);
+    fseeko(tng_data->input_file, *pos, SEEK_SET);
 
     tng_block_init(&block);
     /* Read block headers first to see that a frame set block is found. */
@@ -1570,7 +1582,7 @@ static tng_function_status tng_file_pos_of_subsequent_trajectory_block_get
     /* Read all frame set blocks (not the blocks between them) */
     while(frame_set->next_frame_set_file_pos > 0)
     {
-        fseek(tng_data->input_file, frame_set->next_frame_set_file_pos, SEEK_SET);
+        fseeko(tng_data->input_file, frame_set->next_frame_set_file_pos, SEEK_SET);
         stat = tng_block_header_read(tng_data, block);
         if(stat == TNG_CRITICAL)
         {
@@ -1601,7 +1613,7 @@ static tng_function_status tng_file_pos_of_subsequent_trajectory_block_get
     /* Re-read the frame set that used to be the current one */
     tng_reread_frame_set_at_file_pos(tng_data, curr_frame_set_pos);
 
-    fseek(tng_data->input_file, orig_pos, SEEK_SET);
+    fseeko(tng_data->input_file, orig_pos, SEEK_SET);
 
     tng_block_destroy(&block);
 
@@ -1624,7 +1636,7 @@ static tng_function_status tng_frame_set_complete_migrate
         return(TNG_CRITICAL);
     }
 
-    fseek(tng_data->input_file, block_start_pos, SEEK_SET);
+    fseeko(tng_data->input_file, block_start_pos, SEEK_SET);
 
     contents = malloc(block_len);
     if(!contents)
@@ -1641,7 +1653,7 @@ static tng_function_status tng_frame_set_complete_migrate
         free(contents);
         return(TNG_CRITICAL);
     }
-    fseek(tng_data->output_file, new_pos, SEEK_SET);
+    fseeko(tng_data->output_file, new_pos, SEEK_SET);
 
     if(fwrite(contents, block_len, 1, tng_data->output_file) != 1)
     {
@@ -1676,7 +1688,7 @@ static tng_function_status tng_frame_set_complete_migrate
     {
         contents[i] = '\0';
     }
-    fseek(tng_data->output_file, block_start_pos, SEEK_SET);
+    fseeko(tng_data->output_file, block_start_pos, SEEK_SET);
 
     /* FIXME: casting block_len to size_t is dangerous */
     fwrite(contents, 1, block_len, tng_data->output_file);
@@ -1694,12 +1706,12 @@ static tng_function_status tng_length_of_current_frame_set_contents_get
     tng_gen_block_t block;
     tng_function_status stat;
 
-    orig_pos = ftell(tng_data->input_file);
+    orig_pos = ftello(tng_data->input_file);
     curr_frame_set_pos = pos = tng_data->current_trajectory_frame_set_input_file_pos;
 
     *len = 0;
 
-    fseek(tng_data->input_file, curr_frame_set_pos, SEEK_SET);
+    fseeko(tng_data->input_file, curr_frame_set_pos, SEEK_SET);
 
     tng_block_init(&block);
     /* Read block headers first to see that a frame set block is found. */
@@ -1715,7 +1727,7 @@ static tng_function_status tng_length_of_current_frame_set_contents_get
     /* Read the headers of all blocks in the frame set (not the actual contents of them) */
     while(stat == TNG_SUCCESS)
     {
-        fseek(tng_data->input_file, block->block_contents_size, SEEK_CUR);
+        fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
         *len += block->header_contents_size + block->block_contents_size;
         pos += block->header_contents_size + block->block_contents_size;
         if(pos >= tng_data->input_file_len)
@@ -1732,7 +1744,7 @@ static tng_function_status tng_length_of_current_frame_set_contents_get
     /* Re-read the frame set that used to be the current one */
     tng_reread_frame_set_at_file_pos(tng_data, curr_frame_set_pos);
 
-    fseek(tng_data->input_file, orig_pos, SEEK_SET);
+    fseeko(tng_data->input_file, orig_pos, SEEK_SET);
 
     tng_block_destroy(&block);
 
@@ -1783,12 +1795,12 @@ static tng_function_status tng_migrate_data_in_file
         return(TNG_SUCCESS);
     }
 
-    orig_file_pos = ftell(tng_data->input_file);
+    orig_file_pos = ftello(tng_data->input_file);
     tng_block_init(&block);
 
     while(empty_space < offset)
     {
-        fseek(tng_data->input_file, traj_start_pos, SEEK_SET);
+        fseeko(tng_data->input_file, traj_start_pos, SEEK_SET);
         stat = tng_block_header_read(tng_data, block);
         if(stat == TNG_CRITICAL)
         {
@@ -1822,7 +1834,7 @@ static tng_function_status tng_migrate_data_in_file
 
         empty_space += frame_set_length;
     }
-    fseek(tng_data->input_file, orig_file_pos, SEEK_SET);
+    fseeko(tng_data->input_file, orig_file_pos, SEEK_SET);
     tng_block_destroy(&block);
 
     return(TNG_SUCCESS);
@@ -2410,7 +2422,7 @@ static tng_function_status tng_general_info_block_read
     if(tng_data->input_endianness_swap_func_64)
     {
         if(tng_data->input_endianness_swap_func_64(tng_data,
-                                                 &tng_data->long_stride_length)
+                                                   &tng_data->long_stride_length)
             != TNG_SUCCESS)
         {
             fprintf(stderr, "TNG library: Cannot swap byte order. %s: %d\n",
@@ -2462,7 +2474,7 @@ static tng_function_status tng_general_info_block_write
         return(TNG_CRITICAL);
     }
 
-    fseek(tng_data->output_file, 0, SEEK_SET);
+    fseeko(tng_data->output_file, 0, SEEK_SET);
 
     tng_block_init(&block);
 
@@ -3870,9 +3882,8 @@ static tng_function_status tng_frame_set_block_read
                  tng_gen_block_t block,
                  const char hash_mode)
 {
-    long file_pos;
     int offset = 0;
-    int64_t i, prev_n_particles;
+    int64_t file_pos, i, prev_n_particles;
     tng_bool same_hash;
     tng_trajectory_frame_set_t frame_set =
     &tng_data->current_trajectory_frame_set;
@@ -3907,15 +3918,15 @@ static tng_function_status tng_frame_set_block_read
     /* FIXME: Does not check if the size of the contents matches the expected
      * size or if the contents can be read. */
 
-    file_pos = (int64_t)ftell(tng_data->input_file) -
-               (long)(block->block_contents_size + block->header_contents_size);
+    file_pos = (int64_t)ftello(tng_data->input_file) -
+               (block->block_contents_size + block->header_contents_size);
 
     if(hash_mode == TNG_USE_HASH)
     {
         tng_md5_hash_match_verify(block, &same_hash);
         if(same_hash != TNG_TRUE)
         {
-            fprintf(stderr, "TNG library: Frame set block contents corrupt. File pos %ld Hashes do not match. "
+            fprintf(stderr, "TNG library: Frame set block contents corrupt. File pos %"PRId64" Hashes do not match. "
                 "%s: %d\n",
                 file_pos, __FILE__, __LINE__);
     /*         return(TNG_FAILURE); */
@@ -4763,8 +4774,7 @@ static tng_function_status tng_compress(tng_trajectory_t tng_data,
     int new_len;
     int *alt_algo = 0;
     char *dest, *temp, *temp_data_contents;
-    int64_t algo_find_n_frames, compressed_len;
-    unsigned long offset;
+    int64_t algo_find_n_frames, compressed_len, offset;
     float f_precision;
     double d_precision;
 
@@ -4907,7 +4917,7 @@ static tng_function_status tng_compress(tng_trajectory_t tng_data,
         if(n_frames == 1 && tng_data->frame_set_n_frames > 1)
         {
             nalgo = tng_compress_nalgo();
-            alt_algo=malloc(nalgo * sizeof *tng_data->compress_algo_pos);
+            alt_algo=malloc(nalgo * sizeof *tng_data->compress_algo_vel);
             if(type == TNG_FLOAT_DATA)
             {
                 dest = tng_compress_vel_float_find_algo((float *)temp_data_contents, (int)n_particles,
@@ -5044,12 +5054,13 @@ static tng_function_status tng_uncompress(tng_trajectory_t tng_data,
                                           tng_gen_block_t block,
                                           const char type,
                                           void *start_pos,
-                                          const unsigned long uncompressed_len)
+                                          const int64_t uncompressed_len)
 {
     char *temp, *temp_data_contents;
+    int64_t compressed_len;
     double *d_dest = 0;
     float *f_dest = 0;
-    unsigned long offset;
+    int64_t offset;
     int result;
     (void)tng_data;
 
@@ -5068,22 +5079,23 @@ static tng_function_status tng_uncompress(tng_trajectory_t tng_data,
         return(TNG_FAILURE);
     }
 
-    temp_data_contents = malloc(uncompressed_len);
+    compressed_len = block->block_contents_size - (int64_t)((char *)start_pos - (char *)block->block_contents);
+    temp_data_contents = malloc(compressed_len);
     if(!temp_data_contents)
     {
-        fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
                 uncompressed_len, __FILE__, __LINE__);
         return(TNG_CRITICAL);
     }
 
-    memcpy(temp_data_contents, (char *)start_pos, uncompressed_len);
+    memcpy(temp_data_contents, (char *)start_pos, compressed_len);
 
     if(type == TNG_FLOAT_DATA)
     {
         f_dest = malloc(uncompressed_len);
         if(!f_dest)
         {
-            fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+            fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
                 uncompressed_len, __FILE__, __LINE__);
             free(temp_data_contents);
             return(TNG_CRITICAL);
@@ -5095,7 +5107,7 @@ static tng_function_status tng_uncompress(tng_trajectory_t tng_data,
         d_dest = malloc(uncompressed_len);
         if(!d_dest)
         {
-            fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n",
+            fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
                 uncompressed_len, __FILE__, __LINE__);
             free(temp_data_contents);
             return(TNG_CRITICAL);
@@ -5662,7 +5674,7 @@ static tng_function_status tng_particle_data_read
 {
     int64_t i, j, k, tot_n_particles, n_frames_div;
     int size, len;
-    unsigned long data_size;
+    int64_t data_size;
     char ***first_dim_values, **second_dim_values;
     tng_particle_data_t data;
     tng_trajectory_frame_set_t frame_set =
@@ -5671,6 +5683,16 @@ static tng_function_status tng_particle_data_read
 
     TNG_ASSERT(offset != 0, "TNG library: offset must not be a NULL pointer.");
 
+    /* This must be caught early to avoid creating a data block if not necessary. */
+#ifndef USE_ZLIB
+    if(codec_id == TNG_GZIP_COMPRESSION)
+    {
+        fprintf(stderr, "TNG library: Cannot uncompress data block. %s: %d\n", __FILE__,
+                __LINE__);
+        return(TNG_FAILURE);
+    }
+#endif
+
     switch(datatype)
     {
     case TNG_CHAR_DATA:
@@ -6594,7 +6616,7 @@ static tng_function_status tng_data_read(tng_trajectory_t tng_data,
     int64_t i, j, n_frames_div;
     int size, len;
 #ifdef USE_ZLIB
-    unsigned long data_size;
+    int64_t data_size;
 #endif
     tng_non_particle_data_t data;
     tng_trajectory_frame_set_t frame_set =
@@ -6605,6 +6627,16 @@ static tng_function_status tng_data_read(tng_trajectory_t tng_data,
 
 /*     fprintf(stderr, "TNG library: %s\n", block->name);*/
 
+    /* This must be caught early to avoid creating a data block if not necessary. */
+#ifndef USE_ZLIB
+    if(codec_id == TNG_GZIP_COMPRESSION)
+    {
+        fprintf(stderr, "TNG library: Cannot uncompress data block. %s: %d\n", __FILE__,
+                __LINE__);
+        return(TNG_FAILURE);
+    }
+#endif
+
     switch(datatype)
     {
     case TNG_CHAR_DATA:
@@ -7550,13 +7582,13 @@ static tng_function_status tng_data_block_contents_read
 //     }
 //
 //     tng_block_init(&block);
-// //     output_file_pos = ftell(tng_data->output_file);
+// //     output_file_pos = ftello(tng_data->output_file);
 //
 //     tng_data->input_file = tng_data->output_file;
 //
 //     pos = tng_data->current_trajectory_frame_set_output_file_pos;
 //
-//     fseek(tng_data->output_file, pos, SEEK_SET);
+//     fseeko(tng_data->output_file, pos, SEEK_SET);
 //     if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
 //     {
 //         fprintf(stderr, "TNG library: Cannot read frame set header. %s: %d\n",
@@ -7566,12 +7598,12 @@ static tng_function_status tng_data_block_contents_read
 //         return(TNG_CRITICAL);
 //     }
 //
-//     contents_start_pos = ftell(tng_data->output_file);
+//     contents_start_pos = ftello(tng_data->output_file);
 //
-//     fseek(tng_data->output_file, 0, SEEK_END);
-//     output_file_len = ftell(tng_data->output_file);
+//     fseeko(tng_data->output_file, 0, SEEK_END);
+//     output_file_len = ftello(tng_data->output_file);
 //     pos = contents_start_pos + block->block_contents_size;
-//     fseek(tng_data->output_file, pos,
+//     fseeko(tng_data->output_file, pos,
 //           SEEK_SET);
 //
 //     while(pos < output_file_len)
@@ -7585,7 +7617,7 @@ static tng_function_status tng_data_block_contents_read
 //             return(TNG_CRITICAL);
 //         }
 //         pos += block->header_contents_size + block->block_contents_size;
-//         fseek(tng_data->output_file, pos, SEEK_SET);
+//         fseeko(tng_data->output_file, pos, SEEK_SET);
 //     }
 //
 //     return(TNG_SUCCESS);
@@ -7623,13 +7655,13 @@ static tng_function_status tng_frame_set_finalize
     }
 
     tng_block_init(&block);
-/*     output_file_pos = ftell(tng_data->output_file); */
+/*     output_file_pos = ftello(tng_data->output_file); */
 
     tng_data->input_file = tng_data->output_file;
 
     pos = tng_data->current_trajectory_frame_set_output_file_pos;
 
-    fseek(tng_data->output_file, (long)pos, SEEK_SET);
+    fseeko(tng_data->output_file, pos, SEEK_SET);
 
     if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
     {
@@ -7640,9 +7672,9 @@ static tng_function_status tng_frame_set_finalize
         return(TNG_CRITICAL);
     }
 
-    contents_start_pos = ftell(tng_data->output_file);
+    contents_start_pos = ftello(tng_data->output_file);
 
-    fseek(tng_data->output_file, sizeof(frame_set->first_frame), SEEK_CUR);
+    fseeko(tng_data->output_file, sizeof(frame_set->first_frame), SEEK_CUR);
     if(fwrite(&frame_set->n_written_frames, sizeof(frame_set->n_frames),
               1, tng_data->output_file) != 1)
     {
@@ -7658,10 +7690,10 @@ static tng_function_status tng_frame_set_finalize
                             pos + block->header_contents_size);
     }
 
-    fseek(tng_data->output_file, 0, SEEK_END);
-    output_file_len = ftell(tng_data->output_file);
+    fseeko(tng_data->output_file, 0, SEEK_END);
+    output_file_len = ftello(tng_data->output_file);
     pos = contents_start_pos + block->block_contents_size;
-    fseek(tng_data->output_file, (long)pos, SEEK_SET);
+    fseeko(tng_data->output_file, pos, SEEK_SET);
 
     while(pos < output_file_len)
     {
@@ -7680,7 +7712,7 @@ static tng_function_status tng_frame_set_finalize
                                 pos + block->header_contents_size);
         }
         pos += block->header_contents_size + block->block_contents_size;
-        fseek(tng_data->output_file, (long)pos, SEEK_SET);
+        fseeko(tng_data->output_file, pos, SEEK_SET);
     }
 
     tng_data->input_file = temp;
@@ -8355,21 +8387,24 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(tng_trajectory_t
             }
         }
         molecule_temp->n_bonds = molecule->n_bonds;
-        bond_temp = realloc(molecule_temp->bonds, sizeof(struct tng_bond) *
-                            molecule->n_bonds);
-        if(!bond_temp)
-        {
-            fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
-                   sizeof(struct tng_bond) * molecule->n_bonds,
-                   __FILE__, __LINE__);
-            free(molecule_temp->bonds);
-            molecule_temp->n_bonds = 0;
-            return(TNG_CRITICAL);
-        }
-        molecule_temp->bonds = bond_temp;
-        for(j = 0; j < molecule->n_bonds; j++)
+        if(molecule->n_bonds > 0)
         {
-            molecule_temp->bonds[j] = molecule->bonds[j];
+            bond_temp = realloc(molecule_temp->bonds, sizeof(struct tng_bond) *
+                                molecule->n_bonds);
+            if(!bond_temp)
+            {
+                fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n",
+                       sizeof(struct tng_bond) * molecule->n_bonds,
+                       __FILE__, __LINE__);
+                free(molecule_temp->bonds);
+                molecule_temp->n_bonds = 0;
+                return(TNG_CRITICAL);
+            }
+            molecule_temp->bonds = bond_temp;
+            for(j = 0; j < molecule->n_bonds; j++)
+            {
+                molecule_temp->bonds[j] = molecule->bonds[j];
+            }
         }
         stat = tng_molecule_cnt_set(tng_data_dest, molecule_temp,
                                     tng_data_src->molecule_cnt_list[i]);
@@ -10623,7 +10658,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set
 
     /* Tne endianness cannot be changed if the data has already been written
      * to the output file. */
-    if(ftell(tng_data->output_file) > 0)
+    if(ftello(tng_data->output_file) > 0)
     {
         return(TNG_FAILURE);
     }
@@ -11247,14 +11282,13 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
 {
     tng_gen_block_t block;
     tng_function_status stat;
-    long file_pos;
-    int64_t last_file_pos, first_frame, n_frames;
+    int64_t file_pos, last_file_pos, first_frame, n_frames;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
     TNG_ASSERT(tng_data->input_file, "TNG library: An input file must be open to find the next frame set");
     TNG_ASSERT(n, "TNG library: n must not be a NULL pointer");
 
-    file_pos = ftell(tng_data->input_file);
+    file_pos = ftello(tng_data->input_file);
     last_file_pos = tng_data->last_trajectory_frame_set_input_file_pos;
 
     if(last_file_pos <= 0)
@@ -11263,9 +11297,9 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
     }
 
     tng_block_init(&block);
-    fseek(tng_data->input_file,
-          (long)last_file_pos,
-          SEEK_SET);
+    fseeko(tng_data->input_file,
+           last_file_pos,
+           SEEK_SET);
     /* Read block headers first to see that a frame set block is found. */
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11289,7 +11323,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frames_get
                __FILE__, __LINE__);
         return(TNG_CRITICAL);
     }
-    fseek(tng_data->input_file, file_pos, SEEK_SET);
+    fseeko(tng_data->input_file, file_pos, SEEK_SET);
 
     *n = first_frame + n_frames;
 
@@ -11552,7 +11586,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                  int64_t *n)
 {
     int64_t long_stride_length, medium_stride_length;
-    long file_pos, orig_frame_set_file_pos;
+    int64_t file_pos, orig_frame_set_file_pos;
     tng_trajectory_frame_set_t frame_set;
     struct tng_trajectory_frame_set orig_frame_set;
     tng_gen_block_t block;
@@ -11567,7 +11601,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
     frame_set = &tng_data->current_trajectory_frame_set;
 
     orig_frame_set_file_pos = tng_data->current_trajectory_frame_set_input_file_pos;
-    file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
+    file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
 
     if(file_pos < 0)
     {
@@ -11576,7 +11610,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
     }
 
     tng_block_init(&block);
-    fseek(tng_data->input_file,
+    fseeko(tng_data->input_file,
           file_pos,
           SEEK_SET);
     tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
@@ -11584,7 +11618,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos,
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n", file_pos,
                 __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(TNG_CRITICAL);
@@ -11604,18 +11638,18 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
 
     /* Take long steps forward until a long step forward would be too long or
      * the last frame set is found */
-    file_pos = (long)frame_set->long_stride_next_frame_set_file_pos;
+    file_pos = frame_set->long_stride_next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             cnt += long_stride_length;
-            fseek(tng_data->input_file, file_pos, SEEK_SET);
+            fseeko(tng_data->input_file, file_pos, SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -11628,25 +11662,25 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = (long)frame_set->long_stride_next_frame_set_file_pos;
+        file_pos = frame_set->long_stride_next_frame_set_file_pos;
     }
 
     /* Take medium steps forward until a medium step forward would be too long
      * or the last frame set is found */
-    file_pos = (long)frame_set->medium_stride_next_frame_set_file_pos;
+    file_pos = frame_set->medium_stride_next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             cnt += medium_stride_length;
-            fseek(tng_data->input_file,
+            fseeko(tng_data->input_file,
                   file_pos,
                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -11659,24 +11693,24 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = (long)frame_set->medium_stride_next_frame_set_file_pos;
+        file_pos = frame_set->medium_stride_next_frame_set_file_pos;
     }
 
     /* Take one step forward until the last frame set is found */
-    file_pos = (long)frame_set->next_frame_set_file_pos;
+    file_pos = frame_set->next_frame_set_file_pos;
     while(file_pos > 0)
     {
         if(file_pos > 0)
         {
             ++cnt;
-            fseek(tng_data->input_file,
+            fseeko(tng_data->input_file,
                   file_pos,
                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                        file_pos, __FILE__, __LINE__);
                 tng_block_destroy(&block);
                 return(TNG_CRITICAL);
@@ -11689,7 +11723,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
                 return(TNG_CRITICAL);
             }
         }
-        file_pos = (long)frame_set->next_frame_set_file_pos;
+        file_pos = frame_set->next_frame_set_file_pos;
     }
 
     tng_block_destroy(&block);
@@ -11702,9 +11736,9 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get
     frame_set->mappings = 0;
     frame_set->n_mapping_blocks = 0;
 
-    fseek(tng_data->input_file,
-          (long)tng_data->first_trajectory_frame_set_input_file_pos,
-          SEEK_SET);
+    fseeko(tng_data->input_file,
+           tng_data->first_trajectory_frame_set_input_file_pos,
+           SEEK_SET);
 
     tng_data->current_trajectory_frame_set_input_file_pos = orig_frame_set_file_pos;
 
@@ -11771,10 +11805,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
     }
 
     tng_block_init(&block);
-    fseek(tng_data->input_file,
-          (long)file_pos,
-          SEEK_SET);
-    tng_data->current_trajectory_frame_set_input_file_pos = (long)file_pos;
+    fseeko(tng_data->input_file,
+           file_pos,
+           SEEK_SET);
+    tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
     /* Read block headers first to see what block is found. */
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11808,7 +11842,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             curr_nr += long_stride_length;
-            fseek(tng_data->input_file, (long)file_pos, SEEK_SET);
+            fseeko(tng_data->input_file, file_pos, SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11841,9 +11875,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             curr_nr += medium_stride_length;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11876,9 +11910,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             ++curr_nr;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11911,9 +11945,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             curr_nr -= long_stride_length;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11946,9 +11980,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             curr_nr -= medium_stride_length;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -11980,9 +12014,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             --curr_nr;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12015,9 +12049,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find
         if(file_pos > 0)
         {
             ++curr_nr;
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12067,10 +12101,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
     if(tng_data->current_trajectory_frame_set_input_file_pos < 0)
     {
         file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
-        fseek(tng_data->input_file,
-                (long)file_pos,
-                SEEK_SET);
-        tng_data->current_trajectory_frame_set_input_file_pos = (long)file_pos;
+        fseeko(tng_data->input_file,
+               file_pos,
+               SEEK_SET);
+        tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
         /* Read block headers first to see what block is found. */
         stat = tng_block_header_read(tng_data, block);
         if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12150,10 +12184,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
 
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
-            tng_data->current_trajectory_frame_set_input_file_pos = (long)file_pos;
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
+            tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12192,7 +12226,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->long_stride_next_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file, (long)file_pos, SEEK_SET);
+            fseeko(tng_data->input_file, file_pos, SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12227,9 +12261,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->medium_stride_next_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12262,9 +12296,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->next_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12299,9 +12333,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->long_stride_prev_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12336,9 +12370,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->medium_stride_prev_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12371,9 +12405,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->prev_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12407,9 +12441,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find
         file_pos = frame_set->next_frame_set_file_pos;
         if(file_pos > 0)
         {
-            fseek(tng_data->input_file,
-                  (long)file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   file_pos,
+                   SEEK_SET);
             /* Read block headers first to see what block is found. */
             stat = tng_block_header_read(tng_data, block);
             if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
@@ -12576,14 +12610,14 @@ static tng_function_status tng_file_headers_len_get
 
     *len = 0;
 
-    orig_pos = ftell(tng_data->input_file);
+    orig_pos = ftello(tng_data->input_file);
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
     }
-    fseek(tng_data->input_file, 0, SEEK_SET);
+    fseeko(tng_data->input_file, 0, SEEK_SET);
 
     tng_block_init(&block);
     /* Read through the headers of non-trajectory blocks (they come before the
@@ -12594,10 +12628,10 @@ static tng_function_status tng_file_headers_len_get
            block->id != TNG_TRAJECTORY_FRAME_SET)
     {
         *len += block->header_contents_size + block->block_contents_size;
-        fseek(tng_data->input_file, block->block_contents_size, SEEK_CUR);
+        fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
     }
 
-    fseek(tng_data->input_file, orig_pos, SEEK_SET);
+    fseeko(tng_data->input_file, orig_pos, SEEK_SET);
 
     tng_block_destroy(&block);
 
@@ -12622,10 +12656,10 @@ tng_function_status DECLSPECDLLEXPORT tng_file_headers_read
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
     }
-    fseek(tng_data->input_file, 0, SEEK_SET);
+    fseeko(tng_data->input_file, 0, SEEK_SET);
 
     tng_block_init(&block);
     /* Non trajectory blocks (they come before the trajectory
@@ -12636,13 +12670,13 @@ tng_function_status DECLSPECDLLEXPORT tng_file_headers_read
            block->id != TNG_TRAJECTORY_FRAME_SET)
     {
         tng_block_read_next(tng_data, block, hash_mode);
-        prev_pos = ftell(tng_data->input_file);
+        prev_pos = ftello(tng_data->input_file);
     }
 
     /* Go back if a trajectory block was encountered */
     if(block->id == TNG_TRAJECTORY_FRAME_SET)
     {
-        fseek(tng_data->input_file, prev_pos, SEEK_SET);
+        fseeko(tng_data->input_file, prev_pos, SEEK_SET);
     }
 
     tng_block_destroy(&block);
@@ -12796,7 +12830,7 @@ tng_function_status DECLSPECDLLEXPORT tng_block_read_next(tng_trajectory_t tng_d
         else
         {
             /* Skip to the next block */
-            fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+            fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
             return(TNG_FAILURE);
         }
     }
@@ -12806,7 +12840,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
                 (tng_trajectory_t tng_data,
                  const char hash_mode)
 {
-    long file_pos;
+    int64_t file_pos;
     tng_gen_block_t block;
     tng_function_status stat;
 
@@ -12817,15 +12851,15 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
         return(TNG_CRITICAL);
     }
 
-    file_pos = ftell(tng_data->input_file);
+    file_pos = ftello(tng_data->input_file);
 
     tng_block_init(&block);
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
-        fseek(tng_data->input_file, file_pos, SEEK_SET);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
+        fseeko(tng_data->input_file, file_pos, SEEK_SET);
     }
 
     /* Read block headers first to see what block is found. */
@@ -12833,7 +12867,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET ||
        block->id == -1)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                file_pos, __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(TNG_CRITICAL);
@@ -12845,7 +12879,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
                            hash_mode) == TNG_SUCCESS)
     {
         tng_data->n_trajectory_frame_sets++;
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -12857,7 +12891,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
                                        hash_mode);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -12866,7 +12900,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
         }
         if(stat == TNG_CRITICAL)
         {
-            fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+            fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                    file_pos, __FILE__, __LINE__);
             tng_block_destroy(&block);
             return(stat);
@@ -12874,7 +12908,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read
 
         if(block->id == TNG_TRAJECTORY_FRAME_SET)
         {
-            fseek(tng_data->input_file, file_pos, SEEK_SET);
+            fseeko(tng_data->input_file, file_pos, SEEK_SET);
         }
     }
 
@@ -12889,7 +12923,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
                  const char hash_mode,
                  const int64_t block_id)
 {
-    long file_pos;
+    int64_t file_pos;
     tng_gen_block_t block;
     tng_function_status stat;
     int found_flag = 1;
@@ -12901,19 +12935,19 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
         return(TNG_CRITICAL);
     }
 
-    file_pos = (long)tng_data->current_trajectory_frame_set_input_file_pos;
+    file_pos = tng_data->current_trajectory_frame_set_input_file_pos;
 
     if(file_pos < 0)
     {
         /* No current frame set. This means that the first frame set must be
          * read */
         found_flag = 0;
-        file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
+        file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
     }
 
     if(file_pos > 0)
     {
-        fseek(tng_data->input_file,
+        fseeko(tng_data->input_file,
               file_pos,
               SEEK_SET);
     }
@@ -12926,16 +12960,16 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
-        fseek(tng_data->input_file, file_pos, SEEK_SET);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
+        fseeko(tng_data->input_file, file_pos, SEEK_SET);
     }
 
     /* Read block headers first to see what block is found. */
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                file_pos, __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(TNG_CRITICAL);
@@ -12943,7 +12977,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
     /* If the current frame set had already been read skip its block contents */
     if(found_flag)
     {
-        fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+        fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
     }
     /* Otherwiese read the frame set block */
     else
@@ -12957,7 +12991,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
             return(stat);
         }
     }
-    file_pos = ftell(tng_data->input_file);
+    file_pos = ftello(tng_data->input_file);
 
     found_flag = 0;
 
@@ -12975,7 +13009,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
                                        hash_mode);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 found_flag = 1;
                 if(file_pos < tng_data->input_file_len)
                 {
@@ -12985,8 +13019,8 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
         }
         else
         {
-            file_pos += (long)(block->block_contents_size + block->header_contents_size);
-            fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+            file_pos += (block->block_contents_size + block->header_contents_size);
+            fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
             if(file_pos < tng_data->input_file_len)
             {
                 stat = tng_block_header_read(tng_data, block);
@@ -12995,7 +13029,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
     }
     if(stat == TNG_CRITICAL)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                 file_pos, __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(stat);
@@ -13003,7 +13037,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_current_only_data_from_
 
     if(block->id == TNG_TRAJECTORY_FRAME_SET)
     {
-        fseek(tng_data->input_file, file_pos, SEEK_SET);
+        fseeko(tng_data->input_file, file_pos, SEEK_SET);
     }
 
     tng_block_destroy(&block);
@@ -13022,7 +13056,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next
                 (tng_trajectory_t tng_data,
                  const char hash_mode)
 {
-    long file_pos;
+    int64_t file_pos;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
 
@@ -13031,16 +13065,16 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next
         return(TNG_CRITICAL);
     }
 
-    file_pos = (long)tng_data->current_trajectory_frame_set.next_frame_set_file_pos;
+    file_pos = tng_data->current_trajectory_frame_set.next_frame_set_file_pos;
 
     if(file_pos < 0 && tng_data->current_trajectory_frame_set_input_file_pos <= 0)
     {
-        file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
+        file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
     }
 
     if(file_pos > 0)
     {
-        fseek(tng_data->input_file,
+        fseeko(tng_data->input_file,
               file_pos,
               SEEK_SET);
     }
@@ -13057,7 +13091,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_only_data_from_blo
                  const char hash_mode,
                  const int64_t block_id)
 {
-    long file_pos;
+    int64_t file_pos;
     tng_gen_block_t block;
     tng_function_status stat;
 
@@ -13068,16 +13102,16 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_only_data_from_blo
         return(TNG_CRITICAL);
     }
 
-    file_pos = (long)tng_data->current_trajectory_frame_set.next_frame_set_file_pos;
+    file_pos = tng_data->current_trajectory_frame_set.next_frame_set_file_pos;
 
     if(file_pos < 0 && tng_data->current_trajectory_frame_set_input_file_pos <= 0)
     {
-        file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
+        file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
     }
 
     if(file_pos > 0)
     {
-        fseek(tng_data->input_file,
+        fseeko(tng_data->input_file,
               file_pos,
               SEEK_SET);
     }
@@ -13090,16 +13124,16 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_only_data_from_blo
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
-        fseek(tng_data->input_file, file_pos, SEEK_SET);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
+        fseeko(tng_data->input_file, file_pos, SEEK_SET);
     }
 
     /* Read block headers first to see what block is found. */
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                file_pos, __FILE__, __LINE__);
         tng_block_destroy(&block);
         return(TNG_CRITICAL);
@@ -13136,7 +13170,7 @@ tng_function_status tng_frame_set_write(tng_trajectory_t tng_data,
     }
 
     tng_data->current_trajectory_frame_set_output_file_pos =
-    ftell(tng_data->output_file);
+    ftello(tng_data->output_file);
     tng_data->last_trajectory_frame_set_output_file_pos =
     tng_data->current_trajectory_frame_set_output_file_pos;
 
@@ -13247,7 +13281,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
 
     frame_set = &tng_data->current_trajectory_frame_set;
 
-    curr_pos = ftell(tng_data->output_file);
+    curr_pos = ftello(tng_data->output_file);
 
     if(curr_pos <= 10)
     {
@@ -13265,7 +13299,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
     }
 
     tng_data->current_trajectory_frame_set_output_file_pos =
-    ftell(tng_data->output_file);
+    ftello(tng_data->output_file);
 
     tng_data->n_trajectory_frame_sets++;
 
@@ -13285,10 +13319,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
             tng_block_init(&block);
             tng_data->input_file = tng_data->output_file;
 
-            curr_pos = ftell(tng_data->output_file);
-            fseek(tng_data->output_file,
-                  (long)frame_set->medium_stride_prev_frame_set_file_pos,
-                  SEEK_SET);
+            curr_pos = ftello(tng_data->output_file);
+            fseeko(tng_data->output_file,
+                   frame_set->medium_stride_prev_frame_set_file_pos,
+                   SEEK_SET);
 
             if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
             {
@@ -13301,7 +13335,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
 
             /* Read the next frame set from the previous frame set and one
              * medium stride step back */
-            fseek(tng_data->output_file, (long)block->block_contents_size - (6 *
+            fseeko(tng_data->output_file, block->block_contents_size - (6 *
             sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
             if(fread(&frame_set->medium_stride_prev_frame_set_file_pos,
                sizeof(frame_set->medium_stride_prev_frame_set_file_pos),
@@ -13342,9 +13376,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
                     tng_block_init(&block);
                     tng_data->input_file = tng_data->output_file;
 
-                    fseek(tng_data->output_file,
-                          (long)frame_set->long_stride_prev_frame_set_file_pos,
-                          SEEK_SET);
+                    fseeko(tng_data->output_file,
+                           frame_set->long_stride_prev_frame_set_file_pos,
+                           SEEK_SET);
 
                     if(tng_block_header_read(tng_data, block) != TNG_SUCCESS)
                     {
@@ -13357,7 +13391,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
 
                     /* Read the next frame set from the previous frame set and one
                     * long stride step back */
-                    fseek(tng_data->output_file, (long)block->block_contents_size - (6 *
+                    fseeko(tng_data->output_file, block->block_contents_size - (6 *
                           sizeof(int64_t) + 2 * sizeof(double)), SEEK_CUR);
 
                     tng_block_destroy(&block);
@@ -13386,7 +13420,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_new
             }
 
             tng_data->input_file = temp;
-            fseek(tng_data->output_file, (long)curr_pos, SEEK_SET);
+            fseeko(tng_data->output_file, curr_pos, SEEK_SET);
         }
     }
 
@@ -13456,7 +13490,7 @@ tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
                 (const tng_trajectory_t tng_data,
                  int64_t *frame)
 {
-    long file_pos, next_frame_set_file_pos;
+    int64_t file_pos, next_frame_set_file_pos;
     tng_gen_block_t block;
     tng_function_status stat;
 
@@ -13466,16 +13500,16 @@ tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
     TNG_ASSERT(tng_data->input_file, "TNG library: An input file must be open to find the next frame set");
     TNG_ASSERT(frame, "TNG library: frame must not be a NULL pointer");
 
-    file_pos = ftell(tng_data->input_file);
+    file_pos = ftello(tng_data->input_file);
 
     if(tng_data->current_trajectory_frame_set_input_file_pos <= 0)
     {
-        next_frame_set_file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos;
+        next_frame_set_file_pos = tng_data->first_trajectory_frame_set_input_file_pos;
     }
     else
     {
         frame_set = &tng_data->current_trajectory_frame_set;
-        next_frame_set_file_pos = (long)frame_set->next_frame_set_file_pos;
+        next_frame_set_file_pos = frame_set->next_frame_set_file_pos;
     }
 
     if(next_frame_set_file_pos <= 0)
@@ -13483,13 +13517,13 @@ tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
         return(TNG_FAILURE);
     }
 
-    fseek(tng_data->input_file, (long)next_frame_set_file_pos, SEEK_SET);
+    fseeko(tng_data->input_file, next_frame_set_file_pos, SEEK_SET);
     /* Read block headers first to see that a frame set block is found. */
     tng_block_init(&block);
     stat = tng_block_header_read(tng_data, block);
     if(stat == TNG_CRITICAL || block->id != TNG_TRAJECTORY_FRAME_SET)
     {
-        fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+        fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                file_pos, __FILE__, __LINE__);
         return(TNG_CRITICAL);
     }
@@ -13505,7 +13539,7 @@ tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get
                __FILE__, __LINE__);
         return(TNG_CRITICAL);
     }
-    fseek(tng_data->input_file, file_pos, SEEK_SET);
+    fseeko(tng_data->input_file, file_pos, SEEK_SET);
 
     return(TNG_SUCCESS);
 }
@@ -14085,8 +14119,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
     int64_t header_pos, file_pos;
     int64_t output_file_len, n_values_per_frame, size, contents_size;
     int64_t header_size, temp_first, temp_last;
-    int64_t i, last_frame;
-    long temp_current;
+    int64_t i, last_frame, temp_current;
     tng_gen_block_t block;
     tng_trajectory_frame_set_t frame_set;
     FILE *temp = tng_data->input_file;
@@ -14141,10 +14174,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
             tng_frame_set_new(tng_data,
                               last_frame+1,
                               tng_data->frame_set_n_frames);
-            file_pos = ftell(tng_data->output_file);
-            fseek(tng_data->output_file, 0, SEEK_END);
-            output_file_len = ftell(tng_data->output_file);
-            fseek(tng_data->output_file, (long)file_pos, SEEK_SET);
+            file_pos = ftello(tng_data->output_file);
+            fseeko(tng_data->output_file, 0, SEEK_END);
+            output_file_len = ftello(tng_data->output_file);
+            fseeko(tng_data->output_file, file_pos, SEEK_SET);
 
             /* Read mapping blocks from the last frame set */
             tng_block_init(&block);
@@ -14162,10 +14195,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
                 }
                 else
                 {
-                    fseek(tng_data->output_file, (long)block->block_contents_size,
-                        SEEK_CUR);
+                    fseeko(tng_data->output_file, block->block_contents_size,
+                           SEEK_CUR);
                 }
-                file_pos = ftell(tng_data->output_file);
+                file_pos = ftello(tng_data->output_file);
                 if(file_pos < output_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -14194,9 +14227,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
 
     file_pos = tng_data->current_trajectory_frame_set_output_file_pos;
 
-    fseek(tng_data->output_file, 0, SEEK_END);
-    output_file_len = ftell(tng_data->output_file);
-    fseek(tng_data->output_file, (long)file_pos, SEEK_SET);
+    fseeko(tng_data->output_file, 0, SEEK_END);
+    output_file_len = ftello(tng_data->output_file);
+    fseeko(tng_data->output_file, file_pos, SEEK_SET);
 
     /* Read past the frame set block first */
     stat = tng_block_header_read(tng_data, block);
@@ -14212,8 +14245,8 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
         tng_data->current_trajectory_frame_set_input_file_pos = temp_current;
         return(stat);
     }
-    fseek(tng_data->output_file, (long)block->block_contents_size,
-            SEEK_CUR);
+    fseeko(tng_data->output_file, block->block_contents_size,
+           SEEK_CUR);
 
     /* Read all block headers until next frame set block or
      * until the wanted block id is found */
@@ -14224,8 +14257,8 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
             block->id != TNG_TRAJECTORY_FRAME_SET &&
             block->id != -1)
     {
-        fseek(tng_data->output_file, (long)block->block_contents_size, SEEK_CUR);
-        file_pos = ftell(tng_data->output_file);
+        fseeko(tng_data->output_file, block->block_contents_size, SEEK_CUR);
+        file_pos = ftello(tng_data->output_file);
         if(file_pos < output_file_len)
         {
             stat = tng_block_header_read(tng_data, block);
@@ -14246,7 +14279,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
     contents_size = block->block_contents_size;
     header_size = block->header_contents_size;
 
-    header_pos = ftell(tng_data->output_file) - header_size;
+    header_pos = ftello(tng_data->output_file) - header_size;
     frame_set = &tng_data->current_trajectory_frame_set;
 
     if(fread(&datatype, sizeof(datatype), 1, tng_data->input_file) == 0)
@@ -14428,7 +14461,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_data_write
         return(TNG_FAILURE);
     }
 
-    fseek(tng_data->output_file, (long)file_pos, SEEK_CUR);
+    fseeko(tng_data->output_file, file_pos, SEEK_CUR);
 
     /* If the endianness is not big endian the data needs to be swapped */
     if((data.datatype == TNG_INT_DATA ||
@@ -14511,8 +14544,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
     int64_t output_file_len, n_values_per_frame, size, contents_size;
     int64_t header_size, temp_first, temp_last;
     int64_t mapping_block_end_pos, num_first_particle, block_n_particles;
-    int64_t i, last_frame;
-    long temp_current;
+    int64_t i, last_frame, temp_current;
     tng_gen_block_t block;
     tng_trajectory_frame_set_t frame_set;
     FILE *temp = tng_data->input_file;
@@ -14571,10 +14603,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
                               last_frame+1,
                               tng_data->frame_set_n_frames);
 
-            file_pos = ftell(tng_data->output_file);
-            fseek(tng_data->output_file, 0, SEEK_END);
-            output_file_len = ftell(tng_data->output_file);
-            fseek(tng_data->output_file, (long)file_pos, SEEK_SET);
+            file_pos = ftello(tng_data->output_file);
+            fseeko(tng_data->output_file, 0, SEEK_END);
+            output_file_len = ftello(tng_data->output_file);
+            fseeko(tng_data->output_file, file_pos, SEEK_SET);
 
             /* Read mapping blocks from the last frame set */
             tng_block_init(&block);
@@ -14592,10 +14624,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
                 }
                 else
                 {
-                    fseek(tng_data->output_file, (long)block->block_contents_size,
+                    fseeko(tng_data->output_file, block->block_contents_size,
                         SEEK_CUR);
                 }
-                file_pos = ftell(tng_data->output_file);
+                file_pos = ftello(tng_data->output_file);
                 if(file_pos < output_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -14625,9 +14657,9 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
 
     file_pos = tng_data->current_trajectory_frame_set_output_file_pos;
 
-    fseek(tng_data->output_file, 0, SEEK_END);
-    output_file_len = ftell(tng_data->output_file);
-    fseek(tng_data->output_file, (long)file_pos, SEEK_SET);
+    fseeko(tng_data->output_file, 0, SEEK_END);
+    output_file_len = ftello(tng_data->output_file);
+    fseeko(tng_data->output_file, file_pos, SEEK_SET);
 
     /* Read past the frame set block first */
     stat = tng_block_header_read(tng_data, block);
@@ -14643,7 +14675,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
         tng_data->current_trajectory_frame_set_input_file_pos = temp_current;
         return(stat);
     }
-    fseek(tng_data->output_file, (long)block->block_contents_size,
+    fseeko(tng_data->output_file, block->block_contents_size,
             SEEK_CUR);
 
     if(tng_data->var_num_atoms_flag)
@@ -14671,10 +14703,10 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
             }
             else
             {
-                fseek(tng_data->output_file, (long)block->block_contents_size,
+                fseeko(tng_data->output_file, block->block_contents_size,
                       SEEK_CUR);
             }
-            file_pos = ftell(tng_data->output_file);
+            file_pos = ftello(tng_data->output_file);
             if(block->id == TNG_PARTICLE_MAPPING)
             {
                 mapping = &frame_set->mappings[frame_set->n_mapping_blocks - 1];
@@ -14714,7 +14746,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
             tng_data->current_trajectory_frame_set_input_file_pos = temp_current;
             return(TNG_FAILURE);
         }
-        fseek(tng_data->output_file, (long)mapping_block_end_pos, SEEK_SET);
+        fseeko(tng_data->output_file, mapping_block_end_pos, SEEK_SET);
     }
 
     /* Read all block headers until next frame set block or
@@ -14727,8 +14759,8 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
             block->id != TNG_TRAJECTORY_FRAME_SET &&
             block->id != -1)
     {
-        fseek(tng_data->output_file, (long)block->block_contents_size, SEEK_CUR);
-        file_pos = ftell(tng_data->output_file);
+        fseeko(tng_data->output_file, block->block_contents_size, SEEK_CUR);
+        file_pos = ftello(tng_data->output_file);
         if(file_pos < output_file_len)
         {
             stat = tng_block_header_read(tng_data, block);
@@ -14750,7 +14782,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
     contents_size = block->block_contents_size;
     header_size = block->header_contents_size;
 
-    header_pos = ftell(tng_data->output_file) - header_size;
+    header_pos = ftello(tng_data->output_file) - header_size;
     frame_set = &tng_data->current_trajectory_frame_set;
 
     if(fread(&datatype, sizeof(datatype), 1, tng_data->input_file) == 0)
@@ -14974,7 +15006,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write
         return(TNG_FAILURE);
     }
 
-    fseek(tng_data->output_file, (long)file_pos, SEEK_CUR);
+    fseeko(tng_data->output_file, file_pos, SEEK_CUR);
 
     /* If the endianness is not big endian the data needs to be swapped */
     if((data.datatype == TNG_INT_DATA ||
@@ -15282,7 +15314,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_get
     if(tng_data_find(tng_data, block_id, &data) != TNG_SUCCESS)
     {
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -15295,7 +15327,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_get
                                     TNG_USE_HASH);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -15423,7 +15455,7 @@ tng_function_status tng_data_vector_get(tng_trajectory_t tng_data,
     if(tng_data_find(tng_data, block_id, &data) != TNG_SUCCESS)
     {
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -15436,7 +15468,7 @@ tng_function_status tng_data_vector_get(tng_trajectory_t tng_data,
                                     TNG_USE_HASH);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -15552,7 +15584,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_interval_get
        frame_set->n_data_blocks <= 0)
     {
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -15564,7 +15596,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_interval_get
                                     hash_mode);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -15759,9 +15791,9 @@ tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
         tng_block_init(&block);
         if(stat != TNG_SUCCESS)
         {
-            fseek(tng_data->input_file,
-                  (long)tng_data->current_trajectory_frame_set_input_file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   tng_data->current_trajectory_frame_set_input_file_pos,
+                   SEEK_SET);
             stat = tng_block_header_read(tng_data, block);
             if(stat != TNG_SUCCESS)
             {
@@ -15770,9 +15802,9 @@ tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
                 return(stat);
             }
 
-            fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+            fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
         }
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -15786,7 +15818,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
                                         hash_mode);
                 if(stat != TNG_CRITICAL)
                 {
-                    file_pos = ftell(tng_data->input_file);
+                    file_pos = ftello(tng_data->input_file);
                     if(file_pos < tng_data->input_file_len)
                     {
                         stat = tng_block_header_read(tng_data, block);
@@ -15796,7 +15828,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_vector_interval_get
             else
             {
                 file_pos += block->block_contents_size + block->header_contents_size;
-                fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+                fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -15996,7 +16028,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_get
         }
 
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -16009,7 +16041,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_get
                                     TNG_USE_HASH);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -16192,7 +16224,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_get
     if(tng_particle_data_find(tng_data, block_id, &data) != TNG_SUCCESS)
     {
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -16205,7 +16237,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_get
                                     TNG_USE_HASH);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -16363,7 +16395,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get
        frame_set->n_particle_data_blocks <= 0)
     {
         tng_block_init(&block);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read all blocks until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -16375,7 +16407,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get
                                     hash_mode);
             if(stat != TNG_CRITICAL)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -16607,9 +16639,9 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
         tng_block_init(&block);
         if(stat != TNG_SUCCESS)
         {
-            fseek(tng_data->input_file,
-                  (long)tng_data->current_trajectory_frame_set_input_file_pos,
-                  SEEK_SET);
+            fseeko(tng_data->input_file,
+                   tng_data->current_trajectory_frame_set_input_file_pos,
+                   SEEK_SET);
             stat = tng_block_header_read(tng_data, block);
             if(stat != TNG_SUCCESS)
             {
@@ -16618,9 +16650,9 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
                 return(stat);
             }
 
-            fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+            fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
         }
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         /* Read until next frame set block */
         stat = tng_block_header_read(tng_data, block);
         while(file_pos < tng_data->input_file_len &&
@@ -16634,7 +16666,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
                                         hash_mode);
                 if(stat != TNG_CRITICAL)
                 {
-                    file_pos = ftell(tng_data->input_file);
+                    file_pos = ftello(tng_data->input_file);
                     if(file_pos < tng_data->input_file_len)
                     {
                         stat = tng_block_header_read(tng_data, block);
@@ -16644,7 +16676,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
             else
             {
                 file_pos += block->block_contents_size + block->header_contents_size;
-                fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+                fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
                 if(file_pos < tng_data->input_file_len)
                 {
                     stat = tng_block_header_read(tng_data, block);
@@ -16811,7 +16843,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
     tng_function_status stat;
     tng_non_particle_data_t np_data;
     tng_particle_data_t p_data;
-    long orig_file_pos, file_pos;
+    int64_t orig_file_pos, file_pos;
     int is_particle_data;
 
     if(tng_data->current_trajectory_frame_set_input_file_pos <= 0)
@@ -16838,11 +16870,11 @@ tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
             /* If no specific frame was required read until this data block is found */
             if(frame < 0)
             {
-                file_pos = ftell(tng_data->input_file);
+                file_pos = ftello(tng_data->input_file);
                 while(stat != TNG_SUCCESS && file_pos < tng_data->input_file_len)
                 {
                     stat = tng_frame_set_read_next_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
-                    file_pos = ftell(tng_data->input_file);
+                    file_pos = ftello(tng_data->input_file);
                 }
             }
             if(stat != TNG_SUCCESS)
@@ -16961,9 +16993,9 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open
             fclose((*tng_data_p)->output_file);
         }
         (*tng_data_p)->output_file = (*tng_data_p)->input_file;
-        fseek((*tng_data_p)->input_file,
-                (long)(*tng_data_p)->last_trajectory_frame_set_input_file_pos,
-                SEEK_SET);
+        fseeko((*tng_data_p)->input_file,
+               (*tng_data_p)->last_trajectory_frame_set_input_file_pos,
+               SEEK_SET);
 
         stat = tng_frame_set_read(*tng_data_p, TNG_USE_HASH);
         if(stat != TNG_SUCCESS)
@@ -16991,7 +17023,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_open
         }
         tng_output_append_file_set(*tng_data_p, filename);
 
-        fseek((*tng_data_p)->output_file, 0, SEEK_END);
+        fseeko((*tng_data_p)->output_file, 0, SEEK_END);
     }
 
     return(TNG_SUCCESS);
@@ -17339,9 +17371,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_particle_data_next_frame_read
     tng_particle_data_t data = 0;
     tng_function_status stat;
     int size;
-    int64_t i, data_size, n_particles;
+    int64_t i, data_size, n_particles, file_pos;
     void *temp;
-    long file_pos;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
     TNG_ASSERT(values, "TNG library: The pointer to the values array must not be a NULL pointer");
@@ -17355,11 +17386,11 @@ tng_function_status DECLSPECDLLEXPORT tng_util_particle_data_next_frame_read
     if(stat != TNG_SUCCESS)
     {
         stat = tng_frame_set_read_current_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         while(stat != TNG_SUCCESS && file_pos < tng_data->input_file_len)
         {
             stat = tng_frame_set_read_next_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
-            file_pos = ftell(tng_data->input_file);
+            file_pos = ftello(tng_data->input_file);
         }
         if(stat != TNG_SUCCESS)
         {
@@ -17373,9 +17404,9 @@ tng_function_status DECLSPECDLLEXPORT tng_util_particle_data_next_frame_read
     }
     if(data->last_retrieved_frame < 0)
     {
-        fseek(tng_data->input_file,
-              (long)tng_data->first_trajectory_frame_set_input_file_pos,
-              SEEK_SET);
+        fseeko(tng_data->input_file,
+               tng_data->first_trajectory_frame_set_input_file_pos,
+               SEEK_SET);
         stat = tng_frame_set_read(tng_data, TNG_USE_HASH);
         if(stat != TNG_SUCCESS)
         {
@@ -17503,9 +17534,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
     tng_non_particle_data_t data = 0;
     tng_function_status stat;
     int size;
-    int64_t i, data_size;
+    int64_t i, data_size, file_pos;
     void *temp;
-    long file_pos;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
     TNG_ASSERT(values, "TNG library: The pointer to the values array must not be a NULL pointer");
@@ -17519,11 +17549,11 @@ tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
     if(stat != TNG_SUCCESS)
     {
         stat = tng_frame_set_read_current_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         while(stat != TNG_SUCCESS && file_pos < tng_data->input_file_len)
         {
             stat = tng_frame_set_read_next_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
-            file_pos = ftell(tng_data->input_file);
+            file_pos = ftello(tng_data->input_file);
         }
         if(stat != TNG_SUCCESS)
         {
@@ -17537,9 +17567,9 @@ tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
     }
     if(data->last_retrieved_frame < 0)
     {
-        fseek(tng_data->input_file,
-                (long)tng_data->first_trajectory_frame_set_input_file_pos,
-                SEEK_SET);
+        fseeko(tng_data->input_file,
+               tng_data->first_trajectory_frame_set_input_file_pos,
+               SEEK_SET);
         stat = tng_frame_set_read(tng_data, TNG_USE_HASH);
         if(stat != TNG_SUCCESS)
         {
@@ -19110,9 +19140,8 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
     tng_gen_block_t block;
     int64_t i, j, block_id, *temp;
     int64_t data_frame, frame_diff, min_diff;
-    int64_t size, frame_set_file_pos;
+    int64_t size, frame_set_file_pos, file_pos;
     int found, read_all = 0;
-    long file_pos;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
     TNG_ASSERT(next_frame, "TNG library: The pointer to the next frame must not be NULL.");
@@ -19163,7 +19192,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
     /* Check for data blocks only if they have not already been found. */
     if(frame_set->n_particle_data_blocks <= 0 && frame_set->n_data_blocks <= 0)
     {
-        file_pos = ftell(tng_data->input_file);
+        file_pos = ftello(tng_data->input_file);
         if(file_pos < tng_data->input_file_len)
         {
             tng_block_init(&block);
@@ -19177,7 +19206,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
                                         TNG_USE_HASH);
                 if(stat != TNG_CRITICAL)
                 {
-                    file_pos = ftell(tng_data->input_file);
+                    file_pos = ftello(tng_data->input_file);
                     if(file_pos < tng_data->input_file_len)
                     {
                         stat = tng_block_header_read(tng_data, block);
@@ -19187,7 +19216,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_next_frame_present_dat
             tng_block_destroy(&block);
             if(stat == TNG_CRITICAL)
             {
-                fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n",
+                fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n",
                         file_pos, __FILE__, __LINE__);
                 return(stat);
             }
@@ -19395,7 +19424,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_all_data_block_types_g
                  char **compressions)
 {
     tng_gen_block_t block;
-    long orig_file_pos, file_pos;
+    int64_t orig_file_pos, file_pos;
 
     TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup.");
     TNG_ASSERT(n_data_blocks, "TNG library: The pointer to n_data_blocks must not be NULL.");
@@ -19403,15 +19432,15 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_all_data_block_types_g
     TNG_ASSERT(data_block_names, "TNG library: The pointer to the list of data block names must not be NULL.");
     TNG_ASSERT(stride_lengths, "TNG library: The pointer to the list of stride lengths must not be NULL.");
 
-    orig_file_pos = ftell(tng_data->input_file);
+    orig_file_pos = ftello(tng_data->input_file);
 
     if(!tng_data->input_file_len)
     {
-        fseek(tng_data->input_file, 0, SEEK_END);
-        tng_data->input_file_len = ftell(tng_data->input_file);
+        fseeko(tng_data->input_file, 0, SEEK_END);
+        tng_data->input_file_len = ftello(tng_data->input_file);
     }
 
-    fseek(tng_data->input_file, 0, SEEK_SET);
+    fseeko(tng_data->input_file, 0, SEEK_SET);
     file_pos = 0;
 
     *n_data_blocks = 0;
@@ -19425,11 +19454,11 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_all_data_block_types_g
         {
 
         }
-        file_pos += (long)(block->block_contents_size + block->header_contents_size);
-        fseek(tng_data->input_file, (long)block->block_contents_size, SEEK_CUR);
+        file_pos += (block->block_contents_size + block->header_contents_size);
+        fseeko(tng_data->input_file, block->block_contents_size, SEEK_CUR);
     }
 
-    fseek(tng_data->input_file, orig_file_pos, SEEK_SET);
+    fseeko(tng_data->input_file, orig_file_pos, SEEK_SET);
 
     return(TNG_SUCCESS);
 }
index e9de38158b74379428f01b60aa057ce6652555c2..8be67f17ba7fc4dcbb35ccaf87821c26a562eaaa 100644 (file)
@@ -59,11 +59,6 @@ if(GMX_USE_TNG)
         include_directories(${TNG_IO_INCLUDE_DIRS})
     endif()
     if(NOT GMX_EXTERNAL_TNG)
-        # TNG wants zlib if it is available
-        find_package(ZLIB QUIET)
-        include(gmxTestZLib)
-        gmx_test_zlib(HAVE_ZLIB)
-
         include(${CMAKE_SOURCE_DIR}/src/external/tng_io/BuildTNG.cmake)
         tng_get_source_list(TNG_SOURCES TNG_IO_DEFINITIONS)
         list(APPEND LIBGROMACS_SOURCES ${TNG_SOURCES})
index 62e09d9c01921206222d427041d0cbe18136cd08..e9718d6b6b1ede8ae1a00995d30af529a6325b54 100644 (file)
@@ -58,3 +58,10 @@ gmx_add_unit_test(CommandLineUnitTests commandline-test
                   cmdlineprogramcontext.cpp
                   pargs.cpp
                   $<TARGET_OBJECTS:onlinehelp-test-shared>)
+
+if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+    # This suppression stops a very verbose cascade of messages about the
+    # mocks, which is probably a compiler issue.
+    #   1540-2924 (W) Cannot pass an argument of non-POD class type "const gmx::CommandLineHelpContext" through ellipsis.
+    set_property(SOURCE cmdlinemodulemanager.cpp PROPERTY COMPILE_FLAGS "-qsuppress=1540-2924")
+endif()
index da67416fb8cff3fb84018827b35db4612fac55ec..4532b7d65b1ee1b9a9290fc8efece4a83328c680 100644 (file)
@@ -51,6 +51,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
+#include "gromacs/timing/wallcycle.h"
 
 struct gmx_mdoutf {
     t_fileio         *fp_trn;
@@ -70,13 +71,14 @@ struct gmx_mdoutf {
     int               natoms_global;
     int               natoms_x_compressed;
     gmx_groups_t     *groups; /* for compressed position writing */
+    gmx_wallcycle_t   wcycle;
 };
 
 
 gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
                          int mdrun_flags, const t_commrec *cr,
                          const t_inputrec *ir, gmx_mtop_t *top_global,
-                         const output_env_t oenv)
+                         const output_env_t oenv, gmx_wallcycle_t wcycle)
 {
     gmx_mdoutf_t  of;
     char          filemode[3];
@@ -98,6 +100,7 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
     of->elamstats               = ir->expandedvals->elamstats;
     of->simulation_part         = ir->simulation_part;
     of->x_compression_precision = ir->x_compression_precision;
+    of->wcycle                  = wcycle;
 
     if (MASTER(cr))
     {
@@ -234,6 +237,11 @@ FILE *mdoutf_get_fp_dhdl(gmx_mdoutf_t of)
     return of->fp_dhdl;
 }
 
+gmx_wallcycle_t mdoutf_get_wcycle(gmx_mdoutf_t of)
+{
+    return of->wcycle;
+}
+
 void mdoutf_write_to_trajectory_files(FILE *fplog, t_commrec *cr,
                                       gmx_mdoutf_t of,
                                       int mdof_flags,
@@ -375,6 +383,17 @@ void mdoutf_write_to_trajectory_files(FILE *fplog, t_commrec *cr,
     }
 }
 
+void mdoutf_tng_close(gmx_mdoutf_t of)
+{
+    if (of->tng || of->tng_low_prec)
+    {
+        wallcycle_start(of->wcycle, ewcTRAJ);
+        gmx_tng_close(&of->tng);
+        gmx_tng_close(&of->tng_low_prec);
+        wallcycle_stop(of->wcycle, ewcTRAJ);
+    }
+}
+
 void done_mdoutf(gmx_mdoutf_t of)
 {
     if (of->fp_ene != NULL)
@@ -397,6 +416,7 @@ void done_mdoutf(gmx_mdoutf_t of)
     {
         gmx_fio_fclose(of->fp_field);
     }
+
     gmx_tng_close(&of->tng);
     gmx_tng_close(&of->tng_low_prec);
 
index 645ecab6f09d966be56dec3062283410aee2a7ab..7c9f2a3309188c12cbf4f7fd1b7f725b25c6355a 100644 (file)
@@ -43,6 +43,7 @@
 #include "../legacyheaders/network.h"
 
 #include "../math/vectypes.h"
+#include "../timing/wallcycle.h"
 #include "../utility/basedefinitions.h"
 #include "filenm.h"
 #include "enxio.h"
@@ -67,7 +68,8 @@ gmx_mdoutf_t init_mdoutf(FILE              *fplog,
                          const t_commrec   *cr,
                          const t_inputrec  *ir,
                          struct gmx_mtop_t *mtop,
-                         const output_env_t oenv);
+                         const output_env_t oenv,
+                         gmx_wallcycle_t    wcycle);
 
 /*! \brief Getter for file pointer */
 FILE *mdoutf_get_fp_field(gmx_mdoutf_t of);
@@ -78,6 +80,16 @@ ener_file_t mdoutf_get_fp_ene(gmx_mdoutf_t of);
 /*! \brief Getter for file pointer */
 FILE *mdoutf_get_fp_dhdl(gmx_mdoutf_t of);
 
+/*! \brief Getter for wallcycle timer */
+gmx_wallcycle_t mdoutf_get_wcycle(gmx_mdoutf_t of);
+
+/*! \brief Close TNG files if they are open.
+ *
+ * This also measures the time it takes to close the TNG
+ * files.
+ */
+void mdoutf_tng_close(gmx_mdoutf_t of);
+
 /*! \brief Close all open output files and free the of pointer */
 void done_mdoutf(gmx_mdoutf_t of);
 
index 31447ee6d395433836a97be0379f80998d581975..20932d54c37627bcd7e91c4f145d2701f3058619 100644 (file)
@@ -152,10 +152,12 @@ void gmx_tng_open(const char       *filename,
 
 #ifdef HAVE_UNISTD_H
         char username[256];
-        getlogin_r(username, 256);
-        if (mode == 'w')
+        if (!getlogin_r(username, 256))
         {
-            tng_first_user_name_set(*tng, username);
+            if (mode == 'w')
+            {
+                tng_first_user_name_set(*tng, username);
+            }
         }
 /* TODO: This should be implemented when the above fixme is done (adding data to
  * the header). */
index 89f9d6703c9c52b21b7cd4883e0f6058457b5659..f15d15dafc6cf36050015bd53c392cfdc93e66ac 100644 (file)
@@ -76,6 +76,18 @@ void gmx_prepare_tng_writing(const char              *filename,
         "FORCES", "LAMBDAS"
     };
 
+    typedef tng_function_status (*set_writing_interval_func_pointer)(tng_trajectory_t,
+                                                                     const gmx_int64_t,
+                                                                     const gmx_int64_t,
+                                                                     const gmx_int64_t,
+                                                                     const char*,
+                                                                     const char,
+                                                                     const char);
+#ifdef GMX_DOUBLE
+    set_writing_interval_func_pointer set_writing_interval = tng_util_generic_write_interval_double_set;
+#else
+    set_writing_interval_func_pointer set_writing_interval = tng_util_generic_write_interval_set;
+#endif
 
     gmx_tng_open(filename, mode, output);
 
@@ -113,24 +125,24 @@ void gmx_prepare_tng_writing(const char              *filename,
                 {
                     case TNG_TRAJ_POSITIONS:
                     case TNG_TRAJ_VELOCITIES:
-                        tng_util_generic_write_interval_set(*output, interval, 3, fallbackIds[i],
-                                                            fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
-                                                            compression_type);
+                        set_writing_interval(*output, interval, 3, fallbackIds[i],
+                                             fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
+                                             compression_type);
                         break;
                     case TNG_TRAJ_FORCES:
-                        tng_util_generic_write_interval_set(*output, interval, 3, fallbackIds[i],
-                                                            fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
-                                                            TNG_GZIP_COMPRESSION);
+                        set_writing_interval(*output, interval, 3, fallbackIds[i],
+                                             fallbackNames[i], TNG_PARTICLE_BLOCK_DATA,
+                                             TNG_GZIP_COMPRESSION);
                         break;
                     case TNG_TRAJ_BOX_SHAPE:
-                        tng_util_generic_write_interval_set(*output, interval, 9, fallbackIds[i],
-                                                            fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
-                                                            TNG_GZIP_COMPRESSION);
+                        set_writing_interval(*output, interval, 9, fallbackIds[i],
+                                             fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
+                                             TNG_GZIP_COMPRESSION);
                         break;
                     case TNG_GMX_LAMBDA:
-                        tng_util_generic_write_interval_set(*output, interval, 1, fallbackIds[i],
-                                                            fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
-                                                            TNG_GZIP_COMPRESSION);
+                        set_writing_interval(*output, interval, 1, fallbackIds[i],
+                                             fallbackNames[i], TNG_NON_PARTICLE_BLOCK_DATA,
+                                             TNG_GZIP_COMPRESSION);
                     default:
                         continue;
                 }
index ba842ce3f674db19920668e7e0a12f4eea97a42e..2780a76ad853599c485c694e7480b3485c8a3be9 100644 (file)
@@ -66,7 +66,6 @@ do_md_trajectory_writing(FILE           *fplog,
                          gmx_ekindata_t *ekind,
                          rvec           *f,
                          rvec           *f_global,
-                         gmx_wallcycle_t wcycle,
                          int            *nchkpt,
                          gmx_bool        bCPT,
                          gmx_bool        bRerunMD,
@@ -126,7 +125,7 @@ do_md_trajectory_writing(FILE           *fplog,
 
     if (mdof_flags != 0)
     {
-        wallcycle_start(wcycle, ewcTRAJ);
+        wallcycle_start(mdoutf_get_wcycle(outf), ewcTRAJ);
         if (bCPT)
         {
             if (MASTER(cr))
@@ -170,6 +169,6 @@ do_md_trajectory_writing(FILE           *fplog,
                                 ir->ePBC, state->box);
             debug_gmx();
         }
-        wallcycle_stop(wcycle, ewcTRAJ);
+        wallcycle_stop(mdoutf_get_wcycle(outf), ewcTRAJ);
     }
 }
index a5250d2afdd68d5d2a5b1cb0335f612001b06a1a..e604eb58b22b89ff2dd74edfe40e41c7978ee932 100644 (file)
@@ -73,7 +73,6 @@ do_md_trajectory_writing(FILE           *fplog,
                          gmx_ekindata_t *ekind,
                          rvec           *f,
                          rvec           *f_global,
-                         gmx_wallcycle_t wcycle,
                          int            *nchkpt,
                          gmx_bool        bCPT,
                          gmx_bool        bRerunMD,
index 7d603873a2b620f838de0480bc04dc72b993f37a..496d379b82af48562ed59dc8691d171fb26bb92e 100644 (file)
@@ -1132,6 +1132,31 @@ void sim_data_histogram(sim_data_t *sd, const char *filename,
     xvgrclose(fp);
 }
 
+static int
+snprint_lambda_vec(char *str, int sz, const char *label, lambda_vec_t *lambda)
+{
+    int n = 0;
+
+    n += snprintf(str+n, sz-n, "lambda vector [%s]: ", label);
+    if (lambda->index >= 0)
+    {
+        n += snprintf(str+n, sz-n, " init-lambda-state=%d", lambda->index);
+    }
+    if (lambda->dhdl >= 0)
+    {
+        n += snprintf(str+n, sz-n, " dhdl index=%d", lambda->dhdl);
+    }
+    else
+    {
+        int i;
+        for (i = 0; i < lambda->lc->N; i++)
+        {
+            n += snprintf(str+n, sz-n, " (%s) l=%g", lambda->lc->names[i], lambda->val[i]);
+        }
+    }
+    return n;
+}
+
 /* create a collection (array) of barres_t object given a ordered linked list
    of barlamda_t sample collections */
 static barres_t *barres_list_create(sim_data_t *sd, int *nres,
@@ -1187,17 +1212,27 @@ static barres_t *barres_list_create(sim_data_t *sd, int *nres,
         }
         else if (!scprev && !sc)
         {
-            gmx_fatal(FARGS, "There is no path from lambda=%f -> %f that is covered by foreign lambdas:\ncannot proceed with BAR.\nUse thermodynamic integration of dH/dl by calculating the averages of dH/dl\nwith g_analyze and integrating them.\nAlternatively, use the -extp option if (and only if) the Hamiltonian\ndepends linearly on lambda, which is NOT normally the case.\n", bl->prev->lambda, bl->lambda);
+            char descX[STRLEN], descY[STRLEN];
+            snprint_lambda_vec(descX, STRLEN, "X", bl->prev->lambda);
+            snprint_lambda_vec(descY, STRLEN, "Y", bl->lambda);
+
+            gmx_fatal(FARGS, "There is no path between the states X & Y below that is covered by foreign lambdas:\ncannot proceed with BAR.\nUse thermodynamic integration of dH/dl by calculating the averages of dH/dl\nwith g_analyze and integrating them.\nAlternatively, use the -extp option if (and only if) the Hamiltonian\ndepends linearly on lambda, which is NOT normally the case.\n\n%s\n%s\n", descX, descY);
         }
 
         /* normal delta H */
         if (!scprev)
         {
-            gmx_fatal(FARGS, "Could not find a set for foreign lambda = %f\nin the files for lambda = %f", bl->lambda, bl->prev->lambda);
+            char descX[STRLEN], descY[STRLEN];
+            snprint_lambda_vec(descX, STRLEN, "X", bl->lambda);
+            snprint_lambda_vec(descY, STRLEN, "Y", bl->prev->lambda);
+            gmx_fatal(FARGS, "Could not find a set for foreign lambda (state X below)\nin the files for main lambda (state Y below)\n\n%s\n%s\n", descX, descY);
         }
         if (!sc)
         {
-            gmx_fatal(FARGS, "Could not find a set for foreign lambda = %f\nin the files for lambda = %f", bl->prev->lambda, bl->lambda);
+            char descX[STRLEN], descY[STRLEN];
+            snprint_lambda_vec(descX, STRLEN, "X", bl->prev->lambda);
+            snprint_lambda_vec(descY, STRLEN, "Y", bl->lambda);
+            gmx_fatal(FARGS, "Could not find a set for foreign lambda (state X below)\nin the files for main lambda (state Y below)\n\n%s\n%s\n", descX, descY);
         }
         br->a = scprev;
         br->b = sc;
index 12e4fcfca5e165dbd9036b2bc737967b5eb96898..59411cd54980dca7aed26f1851b1400f6c0bc588 100644 (file)
@@ -117,7 +117,7 @@ int gmx_covar(int argc, char *argv[])
         { "-pbc",  FALSE,  etBOOL, {&bPBC},
           "Apply corrections for periodic boundary conditions" }
     };
-    FILE           *out;
+    FILE           *out = NULL; /* initialization makes all compilers happy */
     t_trxstatus    *status;
     t_trxstatus    *trjout;
     t_topology      top;
@@ -546,18 +546,7 @@ int gmx_covar(int argc, char *argv[])
         fprintf(stderr, "\nWARNING: eigenvalue sum deviates from the trace of the covariance matrix\n");
     }
 
-    fprintf(stderr, "\nWriting eigenvalues to %s\n", eigvalfile);
-
-    sprintf(str, "(%snm\\S2\\N)", bM ? "u " : "");
-    out = xvgropen(eigvalfile,
-                   "Eigenvalues of the covariance matrix",
-                   "Eigenvector index", str, oenv);
-    for (i = 0; (i < end); i++)
-    {
-        fprintf (out, "%10d %g\n", (int)i+1, eigenvalues[ndim-1-i]);
-    }
-    gmx_ffclose(out);
-
+    /* Set 'end', the maximum eigenvector and -value index used for output */
     if (end == -1)
     {
         if (nframes-1 < ndim)
@@ -572,6 +561,19 @@ int gmx_covar(int argc, char *argv[])
             end = ndim;
         }
     }
+
+    fprintf(stderr, "\nWriting eigenvalues to %s\n", eigvalfile);
+
+    sprintf(str, "(%snm\\S2\\N)", bM ? "u " : "");
+    out = xvgropen(eigvalfile,
+                   "Eigenvalues of the covariance matrix",
+                   "Eigenvector index", str, oenv);
+    for (i = 0; (i < end); i++)
+    {
+        fprintf (out, "%10d %g\n", (int)i+1, eigenvalues[ndim-1-i]);
+    }
+    gmx_ffclose(out);
+
     if (bFit)
     {
         /* misuse lambda: 0/1 mass weighted analysis no/yes */
index 1c8f173a0ff3e6cfce4d5b9d08ac78ba18f4d034..eea360649502ea108c938eb85dc1fb79f5ec6828 100644 (file)
 //! longest file names allowed in input files
 #define WHAM_MAXFILELEN 2048
 
+/*! \brief
+ * x-axis legend for output files
+ */
+static const char *xlabel = "\\xx\\f{} (nm)";
+
 /*! \brief
  * enum for energy units
  */
@@ -1209,7 +1214,7 @@ void calc_cumulatives(t_UmbrellaWindow *window, int nWindows,
         snew(fn, strlen(fnhist)+10);
         snew(buf, strlen(fnhist)+10);
         sprintf(fn, "%s_cumul.xvg", strncpy(buf, fnhist, strlen(fnhist)-4));
-        fp = xvgropen(fn, "CDFs of umbrella windows", "z", "CDF", opt->oenv);
+        fp = xvgropen(fn, "CDFs of umbrella windows", xlabel, "CDF", opt->oenv);
     }
 
     nbin = opt->bins;
@@ -1459,7 +1464,7 @@ void print_histograms(const char *fnhist, t_UmbrellaWindow * window, int nWindow
         strcpy(title, "Umbrella histograms");
     }
 
-    fp   = xvgropen(fn, title, "z", "count", opt->oenv);
+    fp   = xvgropen(fn, title, xlabel, "count", opt->oenv);
     bins = opt->bins;
 
     /* Write histograms */
@@ -1632,7 +1637,7 @@ void do_bootstrapping(const char *fnres, const char* fnprof, const char *fnhist,
     }
 
     /* do bootstrapping */
-    fp = xvgropen(fnprof, "Boot strap profiles", "z", ylabel, opt->oenv);
+    fp = xvgropen(fnprof, "Boot strap profiles", xlabel, ylabel, opt->oenv);
     for (ib = 0; ib < opt->nBootStrap; ib++)
     {
         printf("  *******************************************\n"
@@ -1723,7 +1728,7 @@ void do_bootstrapping(const char *fnres, const char* fnprof, const char *fnhist,
     gmx_ffclose(fp);
 
     /* write average and stddev */
-    fp = xvgropen(fnres, "Average and stddev from bootstrapping", "z", ylabel, opt->oenv);
+    fp = xvgropen(fnres, "Average and stddev from bootstrapping", xlabel, ylabel, opt->oenv);
     if (output_env_get_print_xvgr_codes(opt->oenv))
     {
         fprintf(fp, "@TYPE xydy\n");
@@ -2715,7 +2720,7 @@ void calcIntegratedAutocorrelationTimes(t_UmbrellaWindow *window, int nwins,
     }
 
     /* plot IACT along reaction coordinate */
-    fp = xvgropen(fn, "Integrated autocorrelation times", "z", "IACT [ps]", opt->oenv);
+    fp = xvgropen(fn, "Integrated autocorrelation times", xlabel, "IACT [ps]", opt->oenv);
     if (output_env_get_print_xvgr_codes(opt->oenv))
     {
         fprintf(fp, "@    s0 symbol 1\n@    s0 symbol size 0.5\n@    s0 line linestyle 0\n");
@@ -2955,7 +2960,7 @@ void guessPotByIntegration(t_UmbrellaWindow *window, int nWindows, t_UmbrellaOpt
                     nHist++;
                     fAv += window[i].forceAv[ig];
                 }
-                /* at the same time, rememer closest histogram */
+                /* at the same time, remember closest histogram */
                 if (dist < distmin)
                 {
                     winmin   = i;
@@ -2991,7 +2996,7 @@ void guessPotByIntegration(t_UmbrellaWindow *window, int nWindows, t_UmbrellaOpt
     }
     if (opt->verbose)
     {
-        fp = xvgropen("pmfintegrated.xvg", "PMF from force integration", "z", "PMF [kJ/mol]", opt->oenv);
+        fp = xvgropen("pmfintegrated.xvg", "PMF from force integration", xlabel, "PMF (kJ/mol)", opt->oenv);
         for (j = 0; j < opt->bins; ++j)
         {
             fprintf(fp, "%g  %g\n", (j+0.5)*dz+opt->min, pot[j]);
@@ -3502,7 +3507,7 @@ int gmx_wham(int argc, char *argv[])
 
     /* write histograms */
     histout = xvgropen(opt2fn("-hist", NFILE, fnm), "Umbrella histograms",
-                       "z", "count", opt.oenv);
+                       xlabel, "count", opt.oenv);
     for (l = 0; l < opt.bins; ++l)
     {
         fprintf(histout, "%e\t", (double)(l+0.5)/opt.bins*(opt.max-opt.min)+opt.min);
@@ -3611,7 +3616,7 @@ int gmx_wham(int argc, char *argv[])
     }
 
     /* write profile or density of states */
-    profout = xvgropen(opt2fn("-o", NFILE, fnm), title, "z", ylabel, opt.oenv);
+    profout = xvgropen(opt2fn("-o", NFILE, fnm), title, xlabel, ylabel, opt.oenv);
     for (i = 0; i < opt.bins; ++i)
     {
         fprintf(profout, "%e\t%e\n", (double)(i+0.5)/opt.bins*(opt.max-opt.min)+opt.min, profile[i]);
index 5bde38bf21c298a2bf1e76d4dfa9171422566620..7c96a96f3cbc83fee8cdd2f1e0dc1f6f0c1951c2 100644 (file)
@@ -46,6 +46,8 @@
 #include "testutils/cmdlinetest.h"
 #include "gromacs/utility/arrayref.h"
 
+#include "config.h"
+
 namespace
 {
 
index c4e5e9ae1cc0ac7fe10cc3ede1dc4ecb60b37e64..e2a2da88cbc7e755adc9facf74e8541a3045896d 100644 (file)
@@ -618,12 +618,16 @@ const char *GromacsVersion()
 
 const char *ShortProgram(void)
 {
+    const char *programName = NULL;
+
     try
     {
         // TODO: Use the display name once it doesn't break anything.
-        return gmx::getProgramContext().programName();
+        programName = gmx::getProgramContext().programName();
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+
+    return programName;
 }
 
 const char *Program(void)
index bc4b3a6e78dc0da93d43348925527e013853cd73..f2b4a4e0fdb988b415ebe7416885ebc5008dfdf5 100644 (file)
@@ -634,7 +634,6 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_
     _mm_storeu_pd(ptrB+8, t11);
     _mm_storeu_pd(ptrB+10, t12);
 }
-#endif
 
 
 static gmx_inline void gmx_simdcall
@@ -724,7 +723,6 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1,
     _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));
     _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));
 }
-#endif
 
 
 static gmx_inline void gmx_simdcall
index 9af5bb410a96b90af5e454907d9937d46d2e130b..319ad63efa49a51665eaa0aaf9037bd2dd918fbe 100644 (file)
@@ -625,7 +625,6 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
     _mm_store_ss(fshiftptr+2, t5);
     _mm_storeh_pi((__m64 *)(fshiftptr), t5);
 }
-#endif
 
 
 static gmx_inline void gmx_simdcall
index 3241c0bfc63da12c88edf6b045972e886f5d1188..d7fcc05037414e3762aaf20921bcf46151ce319d 100644 (file)
@@ -197,11 +197,15 @@ xvg_format_t output_env_get_xvg_format(const output_env_t oenv)
 
 const char *output_env_get_program_display_name(const output_env_t oenv)
 {
+    const char *displayName = NULL;
+
     try
     {
-        return oenv->programContext.displayName();
+        displayName = oenv->programContext.displayName();
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+
+    return displayName;
 }
 
 const gmx::ProgramContextInterface &
index 6074ed84dbbe415c5b2b251c5d486809332aea9e..29cd01d86a3cb40c139746c3f6899c079d4023dc 100644 (file)
@@ -268,6 +268,8 @@ static void get_vsite_masses(const gmx_moltype_t  *moltype,
                             inv_mass += coeff*coeff/m_aj;
                         }
                         vsite_m[a1] = 1/inv_mass;
+                        /* Correct for loop increment of i */
+                        i += j - 1 - NRAL(ft);
                         break;
                     default:
                         /* Use the mass of the lightest constructing atom.
index 70acb1910bbd778a7b6b2ed36079206b61bb442b..b7f94dea7fd5af1d40ded346bd7c75288d89eb1e 100644 (file)
@@ -136,7 +136,8 @@ void init_md(FILE *fplog,
              gmx_mdoutf_t *outf, t_mdebin **mdebin,
              tensor force_vir, tensor shake_vir,
              rvec mu_tot,
-             gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags);
+             gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags,
+             gmx_wallcycle_t wcycle);
 /* Routine in sim_util.c */
 
 gmx_bool use_GPU(const struct nonbonded_verlet_t *nbv);
index df2954ff6f2e7369d1c0c41486a3ecc44ffed156..79b6a839d662c65d9bcd6bd7fffedf98d62a2525 100644 (file)
@@ -115,6 +115,7 @@ gmx_vsite_t *init_vsite(gmx_mtop_t *mtop, t_commrec *cr,
  */
 
 void split_vsites_over_threads(const t_ilist   *ilist,
+                               const t_iparams *ip,
                                const t_mdatoms *mdatoms,
                                gmx_bool         bLimitRange,
                                gmx_vsite_t     *vsite);
index c871588c016642038331d61808e18bb9185c4e3a..05ecc86c0c3e526e441e96e8c5c1805001839607 100644 (file)
@@ -9753,7 +9753,8 @@ void dd_partition_system(FILE                *fplog,
     if (vsite != NULL)
     {
         /* Now we have updated mdatoms, we can do the last vsite bookkeeping */
-        split_vsites_over_threads(top_local->idef.il, mdatoms, FALSE, vsite);
+        split_vsites_over_threads(top_local->idef.il, top_local->idef.iparams,
+                                  mdatoms, FALSE, vsite);
     }
 
     if (shellfc)
index 83533b671f1ff14cca139a87a54f0a0f92b3f784..baba60f8c389adcd27218999faa438d0295844e6 100644 (file)
@@ -312,7 +312,8 @@ void init_em(FILE *fplog, const char *title,
              gmx_vsite_t *vsite, gmx_constr_t constr,
              int nfile, const t_filenm fnm[],
              gmx_mdoutf_t *outf, t_mdebin **mdebin,
-             int imdport, unsigned long gmx_unused Flags)
+             int imdport, unsigned long gmx_unused Flags,
+             gmx_wallcycle_t wcycle)
 {
     int  i;
     real dvdl_constr;
@@ -429,7 +430,7 @@ void init_em(FILE *fplog, const char *title,
         *gstat = global_stat_init(ir);
     }
 
-    *outf = init_mdoutf(fplog, nfile, fnm, 0, cr, ir, top_global, NULL);
+    *outf = init_mdoutf(fplog, nfile, fnm, 0, cr, ir, top_global, NULL, wcycle);
 
     snew(*enerd, 1);
     init_enerdata(top_global->groups.grps[egcENER].nr, ir->fepvals->n_lambda,
@@ -998,7 +999,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
     init_em(fplog, CG, cr, inputrec,
             state_global, top_global, s_min, &top, &f, &f_global,
             nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
-            nfile, fnm, &outf, &mdebin, imdport, Flags);
+            nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
 
     /* Print to log file */
     print_em_start(fplog, cr, walltime_accounting, wcycle, CG);
@@ -1670,7 +1671,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
     init_em(fplog, LBFGS, cr, inputrec,
             state, top_global, &ems, &top, &f, &f_global,
             nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
-            nfile, fnm, &outf, &mdebin, imdport, Flags);
+            nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
     /* Do_lbfgs is not completely updated like do_steep and do_cg,
      * so we free some memory again.
      */
@@ -2414,7 +2415,7 @@ double do_steep(FILE *fplog, t_commrec *cr,
     init_em(fplog, SD, cr, inputrec,
             state_global, top_global, s_try, &top, &f, &f_global,
             nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
-            nfile, fnm, &outf, &mdebin, imdport, Flags);
+            nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
 
     /* Print to log file  */
     print_em_start(fplog, cr, walltime_accounting, wcycle, SD);
@@ -2666,7 +2667,7 @@ double do_nm(FILE *fplog, t_commrec *cr,
             state_global, top_global, state_work, &top,
             &f, &f_global,
             nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
-            nfile, fnm, &outf, NULL, imdport, Flags);
+            nfile, fnm, &outf, NULL, imdport, Flags, wcycle);
 
     natoms = top_global->natoms;
     snew(fneg, natoms);
index 81821d97085682626dd545b3dc63a6eed9b53854..284480184ee23bb6751068cefea47cda31f4db0a 100644 (file)
@@ -3133,8 +3133,9 @@ init_overlap_comm(pme_overlap_t *  ol,
     {
         /* s2g0 the local interpolation grid start.
          * s2g1 the local interpolation grid end.
-         * Because grid overlap communication only goes forward,
-         * the grid the slabs for fft's should be rounded down.
+         * Since in calc_pidx we divide particles, and not grid lines,
+         * spatially uniform along dimension x or y, we need to round
+         * s2g0 down and s2g1 up.
          */
         ol->s2g0[i] = ( i   *ndata + 0       )/nnodes;
         ol->s2g1[i] = ((i+1)*ndata + nnodes-1)/nnodes + norder - 1;
@@ -3836,7 +3837,7 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
     int  fft_my, fft_mz;
     int  buf_my = -1;
     int  nsx, nsy, nsz;
-    ivec ne;
+    ivec localcopy_end;
     int  offx, offy, offz, x, y, z, i0, i0t;
     int  sx, sy, sz, fx, fy, fz, tx1, ty1, tz1, ox, oy, oz;
     gmx_bool bClearBufX, bClearBufY, bClearBufXY, bClearBuf;
@@ -3872,8 +3873,14 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
 
     for (d = 0; d < DIM; d++)
     {
-        ne[d] = min(pmegrid->offset[d]+pmegrid->n[d]-(pmegrid->order-1),
-                    local_fft_ndata[d]);
+        /* Determine up to where our thread needs to copy from the
+         * thread-local charge spreading grid to the rank-local FFT grid.
+         * This is up to our spreading grid end minus order-1 and
+         * not beyond the local FFT grid.
+         */
+        localcopy_end[d] =
+            min(pmegrid->offset[d]+pmegrid->n[d]-(pmegrid->order-1),
+                local_fft_ndata[d]);
     }
 
     offx = pmegrid->offset[XX];
@@ -3905,7 +3912,16 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
         pmegrid_g = &pmegrids->grid_th[fx*pmegrids->nc[YY]*pmegrids->nc[ZZ]];
         ox       += pmegrid_g->offset[XX];
         /* Determine the end of our part of the source grid */
-        tx1 = min(ox + pmegrid_g->n[XX], ne[XX]);
+        if (!bCommX)
+        {
+            /* Use our thread local source grid and target grid part */
+            tx1 = min(ox + pmegrid_g->n[XX], localcopy_end[XX]);
+        }
+        else
+        {
+            /* Use our thread local source grid and the spreading range */
+            tx1 = min(ox + pmegrid_g->n[XX], pme->pme_order);
+        }
 
         for (sy = 0; sy >= -pmegrids->nthread_comm[YY]; sy--)
         {
@@ -3921,7 +3937,16 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
             pmegrid_g = &pmegrids->grid_th[fy*pmegrids->nc[ZZ]];
             oy       += pmegrid_g->offset[YY];
             /* Determine the end of our part of the source grid */
-            ty1 = min(oy + pmegrid_g->n[YY], ne[YY]);
+            if (!bCommY)
+            {
+                /* Use our thread local source grid and target grid part */
+                ty1 = min(oy + pmegrid_g->n[YY], localcopy_end[YY]);
+            }
+            else
+            {
+                /* Use our thread local source grid and the spreading range */
+                ty1 = min(oy + pmegrid_g->n[YY], pme->pme_order);
+            }
 
             for (sz = 0; sz >= -pmegrids->nthread_comm[ZZ]; sz--)
             {
@@ -3934,7 +3959,7 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
                 }
                 pmegrid_g = &pmegrids->grid_th[fz];
                 oz       += pmegrid_g->offset[ZZ];
-                tz1       = min(oz + pmegrid_g->n[ZZ], ne[ZZ]);
+                tz1       = min(oz + pmegrid_g->n[ZZ], localcopy_end[ZZ]);
 
                 if (sx == 0 && sy == 0 && sz == 0)
                 {
@@ -3990,8 +4015,13 @@ reduce_threadgrid_overlap(gmx_pme_t pme,
                     if (bCommY)
                     {
                         commbuf = commbuf_y;
-                        /* The y-size of the communication buffer is order-1 */
-                        buf_my  = pmegrid->order - 1;
+                        /* The y-size of the communication buffer is set by
+                         * the overlap of the grid part of our local slab
+                         * with the part starting at the next slab.
+                         */
+                        buf_my  =
+                            pme->overlap[1].s2g1[pme->nodeid_minor] -
+                            pme->overlap[1].s2g0[pme->nodeid_minor+1];
                         if (bCommX)
                         {
                             /* We index commbuf modulo the local grid size */
@@ -4104,6 +4134,12 @@ static void sum_fftgrid_dd(gmx_pme_t pme, real *fftgrid, int grid_index)
             sendptr = overlap->sendbuf + send_index0*local_fft_ndata[ZZ];
             recvptr = overlap->recvbuf;
 
+            if (debug != NULL)
+            {
+                fprintf(debug, "PME fftgrid comm y %2d x %2d x %2d\n",
+                        local_fft_ndata[XX], send_nindex, local_fft_ndata[ZZ]);
+            }
+
 #ifdef GMX_MPI
             MPI_Sendrecv(sendptr, send_size_y*datasize, GMX_MPI_REAL,
                          send_id, ipulse,
@@ -4170,7 +4206,7 @@ static void sum_fftgrid_dd(gmx_pme_t pme, real *fftgrid, int grid_index)
 
         if (debug != NULL)
         {
-            fprintf(debug, "PME fftgrid comm %2d x %2d x %2d\n",
+            fprintf(debug, "PME fftgrid comm %2d x %2d x %2d\n",
                     send_nindex, local_fft_ndata[YY], local_fft_ndata[ZZ]);
         }
 
index 07f89c5114b987e435cd72fd15c1d5f28b3c122d..f71408148cd10583600324b841a378614a7f9998 100644 (file)
@@ -2812,7 +2812,8 @@ void init_md(FILE *fplog,
              int nfile, const t_filenm fnm[],
              gmx_mdoutf_t *outf, t_mdebin **mdebin,
              tensor force_vir, tensor shake_vir, rvec mu_tot,
-             gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags)
+             gmx_bool *bSimAnn, t_vcm **vcm, unsigned long Flags,
+             gmx_wallcycle_t wcycle)
 {
     int  i, j, n;
     real tmpt, mod;
@@ -2868,7 +2869,7 @@ void init_md(FILE *fplog,
 
     if (nfile != -1)
     {
-        *outf = init_mdoutf(fplog, nfile, fnm, Flags, cr, ir, mtop, oenv);
+        *outf = init_mdoutf(fplog, nfile, fnm, Flags, cr, ir, mtop, oenv, wcycle);
 
         *mdebin = init_mdebin((Flags & MD_APPENDFILES) ? NULL : mdoutf_get_fp_ene(*outf),
                               mtop, ir, mdoutf_get_fp_dhdl(*outf));
index 861c9ef299196acd1f7d208508f81162cad9117c..a2aa461351c1a1999e7b83aa4448c495670de006 100644 (file)
@@ -1843,6 +1843,7 @@ static void prepare_vsite_thread(const t_ilist      *ilist,
 }
 
 void split_vsites_over_threads(const t_ilist   *ilist,
+                               const t_iparams *ip,
                                const t_mdatoms *mdatoms,
                                gmx_bool         bLimitRange,
                                gmx_vsite_t     *vsite)
@@ -1881,16 +1882,38 @@ void split_vsites_over_threads(const t_ilist   *ilist,
         vsite_atom_range = -1;
         for (ftype = 0; ftype < F_NRE; ftype++)
         {
-            if ((interaction_function[ftype].flags & IF_VSITE) &&
-                ftype != F_VSITEN)
+            if (interaction_function[ftype].flags & IF_VSITE)
             {
-                nral1 = 1 + NRAL(ftype);
-                iat   = ilist[ftype].iatoms;
-                for (i = 0; i < ilist[ftype].nr; i += nral1)
+                if (ftype != F_VSITEN)
                 {
-                    for (j = i+1; j < i+nral1; j++)
+                    nral1 = 1 + NRAL(ftype);
+                    iat   = ilist[ftype].iatoms;
+                    for (i = 0; i < ilist[ftype].nr; i += nral1)
                     {
-                        vsite_atom_range = max(vsite_atom_range, iat[j]);
+                        for (j = i + 1; j < i + nral1; j++)
+                        {
+                            vsite_atom_range = max(vsite_atom_range, iat[j]);
+                        }
+                    }
+                }
+                else
+                {
+                    int vs_ind_end;
+
+                    iat = ilist[ftype].iatoms;
+
+                    i = 0;
+                    while (i < ilist[ftype].nr)
+                    {
+                        /* The 3 below is from 1+NRAL(ftype)=3 */
+                        vs_ind_end = i + ip[iat[i]].vsiten.n*3;
+
+                        vsite_atom_range = max(vsite_atom_range, iat[i+1]);
+                        while (i < vs_ind_end)
+                        {
+                            vsite_atom_range = max(vsite_atom_range, iat[i+2]);
+                            i               += 3;
+                        }
                     }
                 }
             }
@@ -1938,8 +1961,7 @@ void split_vsites_over_threads(const t_ilist   *ilist,
 
     for (ftype = 0; ftype < F_NRE; ftype++)
     {
-        if ((interaction_function[ftype].flags & IF_VSITE) &&
-            ftype != F_VSITEN)
+        if (interaction_function[ftype].flags & IF_VSITE)
         {
             nral1 = 1 + NRAL(ftype);
             inc   = nral1;
@@ -1953,7 +1975,7 @@ void split_vsites_over_threads(const t_ilist   *ilist,
                  */
                 if (ftype != F_VSITEN)
                 {
-                    for (j = i+2; j < i+nral1; j++)
+                    for (j = i + 2; j < i + nral1; j++)
                     {
                         if (th_ind[iat[j]] != th)
                         {
@@ -1966,8 +1988,9 @@ void split_vsites_over_threads(const t_ilist   *ilist,
                 }
                 else
                 {
-                    inc = iat[i];
-                    for (j = i+2; j < i+inc; j += 3)
+                    /* The 3 below is from 1+NRAL(ftype)=3 */
+                    inc = ip[iat[i]].vsiten.n*3;
+                    for (j = i + 2; j < i + inc; j += 3)
                     {
                         if (th_ind[iat[j]] != th)
                         {
@@ -1977,7 +2000,7 @@ void split_vsites_over_threads(const t_ilist   *ilist,
                 }
                 /* Copy this vsite to the thread data struct of thread th */
                 il_th = &vsite->tdata[th].ilist[ftype];
-                for (j = i; j < i+inc; j++)
+                for (j = i; j < i + inc; j++)
                 {
                     il_th->iatoms[il_th->nr++] = iat[j];
                 }
@@ -2034,6 +2057,7 @@ void set_vsite_top(gmx_vsite_t *vsite, gmx_localtop_t *top, t_mdatoms *md,
             gmx_fatal(FARGS, "The combination of threading, virtual sites and charge groups is not implemented");
         }
 
-        split_vsites_over_threads(top->idef.il, md, !DOMAINDECOMP(cr), vsite);
+        split_vsites_over_threads(top->idef.il, top->idef.iparams,
+                                  md, !DOMAINDECOMP(cr), vsite);
     }
 }
index 01dd85eff81efb4e84a1abb9ef2aa31da8c5ddb2..1e47c92f7b594acfba944f0fb27d7800927d42a8 100644 (file)
 gmx_add_unit_test_object_library(onlinehelp-test-shared
                                  mock_helptopic.cpp)
 
+if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+    # This suppression stops a very verbose cascade of messages about the
+    # mocks, which is probably a compiler issue.
+    #   1540-2924 (W) Cannot pass an argument of non-POD class type "const gmx::HelpWriterContext" through ellipsis.
+    set_property(SOURCE mock_helptopic.cpp PROPERTY COMPILE_FLAGS "-qsuppress=1540-2924")
+endif()
+
 gmx_add_unit_test(OnlineHelpUnitTests onlinehelp-test
                   helpformat.cpp
                   helpmanager.cpp
index 8c62c3a43b8e070a9d81f68376ce218a1ee52f44..e3d49126f0ebf5132ad8744c2e2caa198f591f18 100644 (file)
@@ -98,7 +98,7 @@
 #define gmx_simd_xor_f(a, b)        _mm512_castsi512_ps(_mm512_xor_epi32(_mm512_castps_si512(a), _mm512_castps_si512(b)))
 #define gmx_simd_rsqrt_f           _mm512_rsqrt23_ps
 #define gmx_simd_rcp_f             _mm512_rcp23_ps
-#define gmx_simd_fabs_f(x)         gmx_simd_andnot_f(_mm512_set1_ps(-0.0), x)
+#define gmx_simd_fabs_f(x)         gmx_simd_andnot_f(_mm512_set1_ps(GMX_FLOAT_NEGZERO), x)
 #define gmx_simd_fneg_f(x)         _mm512_addn_ps(x, _mm512_setzero_ps())
 #define gmx_simd_max_f             _mm512_gmax_ps
 #define gmx_simd_min_f             _mm512_gmin_ps
 #define gmx_simd_xor_d(a, b)       _mm512_castsi512_pd(_mm512_xor_epi32(_mm512_castpd_si512(a), _mm512_castpd_si512(b)))
 #define gmx_simd_rsqrt_d(x)        _mm512_cvtpslo_pd(_mm512_rsqrt23_ps(_mm512_cvtpd_pslo(x)))
 #define gmx_simd_rcp_d(x)          _mm512_cvtpslo_pd(_mm512_rcp23_ps(_mm512_cvtpd_pslo(x)))
-#define gmx_simd_fabs_d(x)         gmx_simd_andnot_d(_mm512_set1_pd(-0.0), x)
+#define gmx_simd_fabs_d(x)         gmx_simd_andnot_d(_mm512_set1_pd(GMX_DOUBLE_NEGZERO), x)
 #define gmx_simd_fneg_d(x)         _mm512_addn_pd(x, _mm512_setzero_pd())
 #define gmx_simd_max_d             _mm512_gmax_pd
 #define gmx_simd_min_d             _mm512_gmin_pd
 #define gmx_simd4_or_f(a, b)        _mm512_castsi512_ps(_mm512_mask_or_epi32(_mm512_undefined_epi32(), gmx_simd4_mask, _mm512_castps_si512(a), _mm512_castps_si512(b)))
 #define gmx_simd4_xor_f(a, b)       _mm512_castsi512_ps(_mm512_mask_xor_epi32(_mm512_undefined_epi32(), gmx_simd4_mask, _mm512_castps_si512(a), _mm512_castps_si512(b)))
 #define gmx_simd4_rsqrt_f(a)        _mm512_mask_rsqrt23_ps(_mm512_undefined_ps(), gmx_simd4_mask, a)
-#define gmx_simd4_fabs_f(x)         gmx_simd4_andnot_f(_mm512_set1_ps(-0.0), x)
+#define gmx_simd4_fabs_f(x)         gmx_simd4_andnot_f(_mm512_set1_ps(GMX_FLOAT_NEGZERO), x)
 #define gmx_simd4_fneg_f(x)         _mm512_mask_addn_ps(_mm512_undefined_ps(), gmx_simd4_mask, x, _mm512_setzero_ps())
 #define gmx_simd4_max_f(a, b)       _mm512_mask_gmax_ps(_mm512_undefined_ps(), gmx_simd4_mask, a, b)
 #define gmx_simd4_min_f(a, b)       _mm512_mask_gmin_ps(_mm512_undefined_ps(), gmx_simd4_mask, a, b)
 #define gmx_simd4_or_d(a, b)        _mm512_castsi512_pd(_mm512_mask_or_epi32(_mm512_undefined_epi32(), mask_loh, _mm512_castpd_si512(a), _mm512_castpd_si512(b)))
 #define gmx_simd4_xor_d(a, b)       _mm512_castsi512_pd(_mm512_mask_xor_epi32(_mm512_undefined_epi32(), mask_loh, _mm512_castpd_si512(a), _mm512_castpd_si512(b)))
 #define gmx_simd4_rsqrt_d(a)        _mm512_mask_cvtpslo_pd(_mm512_undefined_pd(), gmx_simd4_mask, _mm512_mask_rsqrt23_ps(_mm512_undefined_ps(), gmx_simd4_mask, _mm512_mask_cvtpd_pslo(_mm512_undefined_ps(), gmx_simd4_mask, x)))
-#define gmx_simd4_fabs_d(x)         gmx_simd4_andnot_d(_mm512_set1_pd(-0.0), x)
+#define gmx_simd4_fabs_d(x)         gmx_simd4_andnot_d(_mm512_set1_pd(GMX_DOUBLE_NEGZERO), x)
 #define gmx_simd4_fneg_d(x)         _mm512_mask_addn_pd(_mm512_undefined_pd(), gmx_simd4_mask, x, _mm512_setzero_pd())
 #define gmx_simd4_max_d(a, b)       _mm512_mask_gmax_pd(_mm512_undefined_pd(), gmx_simd4_mask, a, b)
 #define gmx_simd4_min_d(a, b)       _mm512_mask_gmin_pd(_mm512_undefined_pd(), gmx_simd4_mask, a, b)
index 823bfe81b996ef2aaefbfce38b1791c5b8ed6785..5b3096bee322f5fe367c39da2165a030ea6b1db7 100644 (file)
 #define gmx_simd4_or_d                   _mm256_or_pd
 #define gmx_simd4_xor_d                  _mm256_xor_pd
 #define gmx_simd4_rsqrt_d(x)             _mm256_cvtps_pd(_mm_rsqrt_ps(_mm256_cvtpd_ps(x)))
-#define gmx_simd4_fabs_d(x)              _mm256_andnot_pd(_mm256_set1_pd(-0.0), x)
-#define gmx_simd4_fneg_d(x)              _mm256_xor_pd(x, _mm256_set1_pd(-0.0))
+#define gmx_simd4_fabs_d(x)              _mm256_andnot_pd(_mm256_set1_pd(GMX_DOUBLE_NEGZERO), x)
+#define gmx_simd4_fneg_d(x)              _mm256_xor_pd(x, _mm256_set1_pd(GMX_DOUBLE_NEGZERO))
 #define gmx_simd4_max_d                  _mm256_max_pd
 #define gmx_simd4_min_d                  _mm256_min_pd
 #define gmx_simd4_round_d(x)             _mm256_round_pd(x, _MM_FROUND_NINT)
index d787708b4c0f6e44cd68ed55b727f8190774a02b..cff1a7e2cbd00bb782aadfba2b862214706a98d1 100644 (file)
 #define gmx_simd_xor_f             _mm256_xor_ps
 #define gmx_simd_rsqrt_f           _mm256_rsqrt_ps
 #define gmx_simd_rcp_f             _mm256_rcp_ps
-#define gmx_simd_fabs_f(x)         _mm256_andnot_ps(_mm256_set1_ps(-0.0), x)
-#define gmx_simd_fneg_f(x)         _mm256_xor_ps(x, _mm256_set1_ps(-0.0))
+#define gmx_simd_fabs_f(x)         _mm256_andnot_ps(_mm256_set1_ps(GMX_FLOAT_NEGZERO), x)
+#define gmx_simd_fneg_f(x)         _mm256_xor_ps(x, _mm256_set1_ps(GMX_FLOAT_NEGZERO))
 #define gmx_simd_max_f             _mm256_max_ps
 #define gmx_simd_min_f             _mm256_min_ps
 #define gmx_simd_round_f(x)        _mm256_round_ps(x, _MM_FROUND_NINT)
index 5d6b195965b25441f3bc1ca030dbfe6d51dd4b98..7aab27ae21c5faad2de33dde08b39594b00498e8 100644 (file)
@@ -99,8 +99,8 @@
 #define gmx_simd_xor_f            _mm_xor_ps
 #define gmx_simd_rsqrt_f          _mm_rsqrt_ps
 #define gmx_simd_rcp_f            _mm_rcp_ps
-#define gmx_simd_fabs_f(x)        _mm_andnot_ps(_mm_set1_ps(-0.0), x)
-#define gmx_simd_fneg_f(x)        _mm_xor_ps(x, _mm_set1_ps(-0.0))
+#define gmx_simd_fabs_f(x)        _mm_andnot_ps(_mm_set1_ps(GMX_FLOAT_NEGZERO), x)
+#define gmx_simd_fneg_f(x)        _mm_xor_ps(x, _mm_set1_ps(GMX_FLOAT_NEGZERO))
 #define gmx_simd_max_f            _mm_max_ps
 #define gmx_simd_min_f            _mm_min_ps
 #define gmx_simd_round_f(x)       _mm_cvtepi32_ps(_mm_cvtps_epi32(x))
 #define gmx_simd_rsqrt_d(x)        _mm_cvtps_pd(_mm_rsqrt_ps(_mm_cvtpd_ps(x)))
 /* Don't use FMA for sqrt N-R iterations - this saves 1 instruction without FMA hardware */
 #define gmx_simd_rcp_d(x)          _mm_cvtps_pd(_mm_rcp_ps(_mm_cvtpd_ps(x)))
-#define gmx_simd_fabs_d(x)         _mm_andnot_pd(_mm_set1_pd(-0.0), x)
-#define gmx_simd_fneg_d(x)         _mm_xor_pd(x, _mm_set1_pd(-0.0))
+#define gmx_simd_fabs_d(x)         _mm_andnot_pd(_mm_set1_pd(GMX_DOUBLE_NEGZERO), x)
+#define gmx_simd_fneg_d(x)         _mm_xor_pd(x, _mm_set1_pd(GMX_DOUBLE_NEGZERO))
 #define gmx_simd_max_d             _mm_max_pd
 #define gmx_simd_min_d             _mm_min_pd
 #define gmx_simd_round_d(x)        _mm_cvtepi32_pd(_mm_cvtpd_epi32(x))
index 1f6dc08361ade3a6ee3c77a1cba1c839b10c9a2a..68ab6774ef0031b3f4b71ca5cceb21663245c59f 100644 (file)
@@ -124,7 +124,7 @@ static gmx_inline gmx_simd_float_t gmx_simdcall
 gmx_simd_xor_sign_f(gmx_simd_float_t a, gmx_simd_float_t b)
 {
 #ifdef GMX_SIMD_HAVE_LOGICAL
-    return gmx_simd_xor_f(a, gmx_simd_and_f(gmx_simd_set1_f(-0.0), b));
+    return gmx_simd_xor_f(a, gmx_simd_and_f(gmx_simd_set1_f(GMX_FLOAT_NEGZERO), b));
 #else
     return gmx_simd_blendv_f(a, gmx_simd_fneg_f(a), gmx_simd_cmplt_f(b, gmx_simd_setzero_f()));
 #endif
@@ -729,8 +729,8 @@ gmx_simd_sincos_f(gmx_simd_float_t x, gmx_simd_float_t *sinval, gmx_simd_float_t
     y       = gmx_simd_round_f(z);
 
     mask    = gmx_simd_cvt_fib2fb(gmx_simd_cmpeq_fi(gmx_simd_and_fi(iy, ione), gmx_simd_setzero_fi()));
-    ssign   = gmx_simd_blendzero_f(gmx_simd_set1_f(-0.0f), gmx_simd_cvt_fib2fb(gmx_simd_cmpeq_fi(gmx_simd_and_fi(iy, itwo), itwo)));
-    csign   = gmx_simd_blendzero_f(gmx_simd_set1_f(-0.0f), gmx_simd_cvt_fib2fb(gmx_simd_cmpeq_fi(gmx_simd_and_fi(gmx_simd_add_fi(iy, ione), itwo), itwo)));
+    ssign   = gmx_simd_blendzero_f(gmx_simd_set1_f(GMX_FLOAT_NEGZERO), gmx_simd_cvt_fib2fb(gmx_simd_cmpeq_fi(gmx_simd_and_fi(iy, itwo), itwo)));
+    csign   = gmx_simd_blendzero_f(gmx_simd_set1_f(GMX_FLOAT_NEGZERO), gmx_simd_cvt_fib2fb(gmx_simd_cmpeq_fi(gmx_simd_and_fi(gmx_simd_add_fi(iy, ione), itwo), itwo)));
 #else
     const gmx_simd_float_t  quarter         = gmx_simd_set1_f(0.25f);
     const gmx_simd_float_t  minusquarter    = gmx_simd_set1_f(-0.25f);
@@ -766,8 +766,8 @@ gmx_simd_sincos_f(gmx_simd_float_t x, gmx_simd_float_t *sinval, gmx_simd_float_t
      * active or inactive - you will get errors if only one is used.
      */
 #    ifdef GMX_SIMD_HAVE_LOGICAL
-    ssign   = gmx_simd_and_f(ssign, gmx_simd_set1_f(-0.0f));
-    csign   = gmx_simd_andnot_f(q, gmx_simd_set1_f(-0.0f));
+    ssign   = gmx_simd_and_f(ssign, gmx_simd_set1_f(GMX_FLOAT_NEGZERO));
+    csign   = gmx_simd_andnot_f(q, gmx_simd_set1_f(GMX_FLOAT_NEGZERO));
     ssign   = gmx_simd_xor_f(ssign, csign);
 #    else
     csign   = gmx_simd_xor_sign_f(gmx_simd_set1_f(-1.0f), q);
@@ -884,7 +884,7 @@ gmx_simd_tan_f(gmx_simd_float_t x)
     x       = gmx_simd_fnmadd_f(y, argred1, x);
     x       = gmx_simd_fnmadd_f(y, argred2, x);
     x       = gmx_simd_fnmadd_f(y, argred3, x);
-    x       = gmx_simd_xor_f(gmx_simd_blendzero_f(gmx_simd_set1_f(-0.0f), mask), x);
+    x       = gmx_simd_xor_f(gmx_simd_blendzero_f(gmx_simd_set1_f(GMX_FLOAT_NEGZERO), mask), x);
 #else
     const gmx_simd_float_t  quarter         = gmx_simd_set1_f(0.25f);
     const gmx_simd_float_t  half            = gmx_simd_set1_f(0.5f);
@@ -1338,7 +1338,7 @@ static gmx_inline gmx_simd_double_t gmx_simdcall
 gmx_simd_xor_sign_d(gmx_simd_double_t a, gmx_simd_double_t b)
 {
 #ifdef GMX_SIMD_HAVE_LOGICAL
-    return gmx_simd_xor_d(a, gmx_simd_and_d(gmx_simd_set1_d(-0.0), b));
+    return gmx_simd_xor_d(a, gmx_simd_and_d(gmx_simd_set1_d(GMX_DOUBLE_NEGZERO), b));
 #else
     return gmx_simd_blendv_d(a, gmx_simd_fneg_d(a), gmx_simd_cmplt_d(b, gmx_simd_setzero_d()));
 #endif
@@ -2025,8 +2025,8 @@ gmx_simd_sincos_d(gmx_simd_double_t x, gmx_simd_double_t *sinval, gmx_simd_doubl
     y       = gmx_simd_round_d(z);
 
     mask    = gmx_simd_cvt_dib2db(gmx_simd_cmpeq_di(gmx_simd_and_di(iy, ione), gmx_simd_setzero_di()));
-    ssign   = gmx_simd_blendzero_d(gmx_simd_set1_d(-0.0), gmx_simd_cvt_dib2db(gmx_simd_cmpeq_di(gmx_simd_and_di(iy, itwo), itwo)));
-    csign   = gmx_simd_blendzero_d(gmx_simd_set1_d(-0.0), gmx_simd_cvt_dib2db(gmx_simd_cmpeq_di(gmx_simd_and_di(gmx_simd_add_di(iy, ione), itwo), itwo)));
+    ssign   = gmx_simd_blendzero_d(gmx_simd_set1_d(GMX_DOUBLE_NEGZERO), gmx_simd_cvt_dib2db(gmx_simd_cmpeq_di(gmx_simd_and_di(iy, itwo), itwo)));
+    csign   = gmx_simd_blendzero_d(gmx_simd_set1_d(GMX_DOUBLE_NEGZERO), gmx_simd_cvt_dib2db(gmx_simd_cmpeq_di(gmx_simd_and_di(gmx_simd_add_di(iy, ione), itwo), itwo)));
 #else
     const gmx_simd_double_t  quarter         = gmx_simd_set1_d(0.25);
     const gmx_simd_double_t  minusquarter    = gmx_simd_set1_d(-0.25);
@@ -2062,8 +2062,8 @@ gmx_simd_sincos_d(gmx_simd_double_t x, gmx_simd_double_t *sinval, gmx_simd_doubl
      * active or inactive - you will get errors if only one is used.
      */
 #    ifdef GMX_SIMD_HAVE_LOGICAL
-    ssign   = gmx_simd_and_d(ssign, gmx_simd_set1_d(-0.0));
-    csign   = gmx_simd_andnot_d(q, gmx_simd_set1_d(-0.0));
+    ssign   = gmx_simd_and_d(ssign, gmx_simd_set1_d(GMX_DOUBLE_NEGZERO));
+    csign   = gmx_simd_andnot_d(q, gmx_simd_set1_d(GMX_DOUBLE_NEGZERO));
     ssign   = gmx_simd_xor_d(ssign, csign);
 #    else
     csign   = gmx_simd_xor_sign_d(gmx_simd_set1_d(-1.0), q);
@@ -2179,7 +2179,7 @@ gmx_simd_tan_d(gmx_simd_double_t x)
     x       = gmx_simd_fnmadd_d(y, argred1, x);
     x       = gmx_simd_fnmadd_d(y, argred2, x);
     x       = gmx_simd_fnmadd_d(y, argred3, x);
-    x       = gmx_simd_xor_d(gmx_simd_blendzero_d(gmx_simd_set1_d(-0.0), mask), x);
+    x       = gmx_simd_xor_d(gmx_simd_blendzero_d(gmx_simd_set1_d(GMX_DOUBLE_NEGZERO), mask), x);
 #else
     const gmx_simd_double_t  quarter         = gmx_simd_set1_d(0.25);
     const gmx_simd_double_t  half            = gmx_simd_set1_d(0.5);
index b1747df93b544d4d293bd884d7c14e7ea60c8112..8c7bffbf542b77c827a515ccba1a9522cce6d95e 100644 (file)
@@ -157,6 +157,15 @@ static int mpi_hostname_hash(void)
 }
 
 #if defined GMX_LIB_MPI && defined GMX_TARGET_BGQ
+#ifdef __clang__
+/* IBM's declaration of this function in
+ * /bgsys/drivers/V1R2M2/ppc64/spi/include/kernel/process.h
+ * erroneously fails to specify __INLINE__, despite
+ * /bgsys/drivers/V1R2M2/ppc64/spi/include/kernel/cnk/process_impl.h
+ * specifiying __INLINE__, so bgclang thinks they are different enough
+ * to complain about. */
+static uint64_t Kernel_GetJobID();
+#endif
 #include <spi/include/kernel/location.h>
 
 static int bgq_nodenum(void)
index a8fb5a52deec970017af31f1f15437b9bc0fccb8..e8a3ae18e7702dc765c24ddc2564438e8a875b67 100644 (file)
 /*! \brief Minimum single precision value */
 #define GMX_FLOAT_MIN    1.175494351E-38F
 
+#ifdef __PGI
+/* The portland group x86 C/C++ compilers do not treat negative zero initializers
+ * correctly, but "optimizes" them to positive zero, so we implement it explicitly.
+ * These constructs are optimized to simple loads at compile time. If you want to
+ * use them on other compilers those have to support gcc preprocessor extensions.
+ * Note: These initializers might be sensitive to the endianness (which can
+ * be different for byte and word order), so check that it works for your platform
+ * and add a separate section if necessary before adding to the ifdef above.
+ */
+#    define GMX_DOUBLE_NEGZERO  ({ const union { int  di[2]; double d; } _gmx_dzero = {0, -2147483648}; _gmx_dzero.d; })
+#    define GMX_FLOAT_NEGZERO   ({ const union { int  fi; float f; } _gmx_fzero = {-2147483648}; _gmx_fzero.f; })
+#else
+/*! \brief Negative zero in double */
+#    define GMX_DOUBLE_NEGZERO  (-0.0)
+
+/*! \brief Negative zero in float */
+#    define GMX_FLOAT_NEGZERO   (-0.0f)
+#endif
 
 /*! \typedef real
  * \brief Precision-dependent \Gromacs floating-point type.
@@ -81,6 +99,9 @@
 /*! \def GMX_REAL_MAX
  * \brief Largest finite value for `real`.
  */
+/*! \def GMX_REAL_NEGZERO
+ * \brief Negative zero for `real`.
+ */
 /*! \def gmx_real_fullprecision_pfmt
  * \brief Format string for full `real` precision.
  */
@@ -91,10 +112,11 @@ typedef double      real;
 #define HAVE_REAL
 #endif
 
-#define GMX_MPI_REAL    MPI_DOUBLE
-#define GMX_REAL_EPS    GMX_DOUBLE_EPS
-#define GMX_REAL_MIN    GMX_DOUBLE_MIN
-#define GMX_REAL_MAX    GMX_DOUBLE_MAX
+#define GMX_MPI_REAL      MPI_DOUBLE
+#define GMX_REAL_EPS      GMX_DOUBLE_EPS
+#define GMX_REAL_MIN      GMX_DOUBLE_MIN
+#define GMX_REAL_MAX      GMX_DOUBLE_MAX
+#define GMX_REAL_NEGZERO  GMX_DOUBLE_NEGZERO
 #define gmx_real_fullprecision_pfmt "%21.14e"
 
 #else /* GMX_DOUBLE */
@@ -104,10 +126,11 @@ typedef float           real;
 #define HAVE_REAL
 #endif
 
-#define GMX_MPI_REAL    MPI_FLOAT
-#define GMX_REAL_EPS    GMX_FLOAT_EPS
-#define GMX_REAL_MIN    GMX_FLOAT_MIN
-#define GMX_REAL_MAX    GMX_FLOAT_MAX
+#define GMX_MPI_REAL      MPI_FLOAT
+#define GMX_REAL_EPS      GMX_FLOAT_EPS
+#define GMX_REAL_MIN      GMX_FLOAT_MIN
+#define GMX_REAL_MAX      GMX_FLOAT_MAX
+#define GMX_REAL_NEGZERO  GMX_FLOAT_NEGZERO
 #define gmx_real_fullprecision_pfmt "%14.7e"
 
 #endif /* GMX_DOUBLE */
index 3580a0e0a0c9c8460d7e8f8a4553cbe5830dbd82..6b45a99a82be08246483cfa8eb7035a6d6cfbf4a 100644 (file)
@@ -53,6 +53,7 @@
 
 #include "gromacs/utility/fatalerror.h"
 #ifdef PRINT_ALLOC_KB
+#include "gromacs/utility/basenetwork.h"
 #include "gromacs/utility/gmxmpi.h"
 #endif
 
@@ -151,12 +152,9 @@ void *save_calloc(const char *name, const char *file, int line,
     else
     {
 #ifdef PRINT_ALLOC_KB
-        int rank = 0;
         if (nelem*elsize >= PRINT_ALLOC_KB*1024)
         {
-#ifdef GMX_MPI
-            MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-#endif
+            int rank = gmx_node_rank();
             printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n",
                    nelem*elsize/1048576.0, name, file, line, rank);
         }
@@ -205,12 +203,9 @@ void *save_realloc(const char *name, const char *file, int line, void *ptr,
     else
     {
 #ifdef PRINT_ALLOC_KB
-        int rank = 0;
         if (size >= PRINT_ALLOC_KB*1024)
         {
-#ifdef GMX_MPI
-            MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-#endif
+            int rank = gmx_node_rank();
             printf("Reallocating %.1f MB for %s (called from file %s, line %d on %d)\n",
                    size/1048576.0, name, file, line, rank);
         }
@@ -288,8 +283,9 @@ void *save_malloc_aligned(const char *name, const char *file, int line,
 #ifdef PRINT_ALLOC_KB
         if (nelem*elsize >= PRINT_ALLOC_KB*1024)
         {
-            printf("Allocating %.1f MB for %s\n",
-                   nelem*elsize/(PRINT_ALLOC_KB*1024.0), name);
+            int rank = gmx_node_rank();
+            printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n",
+                   nelem*elsize/1048576.0, name, file, line, rank);
         }
 #endif
 
index 259484cc18018aca3a2c67394350281c6a0391ed..db1a5affaa364a60fd2902a26809e8de916bf6d8 100644 (file)
@@ -291,7 +291,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
             &(state_global->fep_state), lam0,
             nrnb, top_global, &upd,
             nfile, fnm, &outf, &mdebin,
-            force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, Flags);
+            force_vir, shake_vir, mu_tot, &bSimAnn, &vcm, Flags, wcycle);
 
     clear_mat(total_vir);
     clear_mat(pres);
@@ -1308,7 +1308,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         do_md_trajectory_writing(fplog, cr, nfile, fnm, step, step_rel, t,
                                  ir, state, state_global, top_global, fr,
                                  outf, mdebin, ekind, f, f_global,
-                                 wcycle, &nchkpt,
+                                 &nchkpt,
                                  bCPT, bRerunMD, bLastStep, (Flags & MD_CONFOUT),
                                  bSumEkinhOld);
         /* Check if IMD step and do IMD communication, if bIMD is TRUE. */
@@ -1941,6 +1941,10 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     /* End of main MD loop */
     debug_gmx();
 
+    /* Closing TNG files can include compressing data. Therefore it is good to do that
+     * before stopping the time measurements. */
+    mdoutf_tng_close(outf);
+
     /* Stop measuring walltime */
     walltime_accounting_end(walltime_accounting);
 
index eac4fc8e59866117041a46f1323d1784f720255f..54b4e5951e3605cc809e40534b6611e0b6e58dd7 100644 (file)
@@ -47,6 +47,8 @@
 #include "gromacs/options/filenameoption.h"
 #include "testutils/cmdlinetest.h"
 
+#include "config.h"
+
 namespace
 {
 
@@ -77,7 +79,7 @@ TEST_P(MdrunRerun, WithDifferentInputFormats)
  * version. */
 const char *trajectoryFileNames[] = {
     "../../../gromacs/gmxana/legacytests/spc2-traj.trr",
-#ifdef GMX_USE_TNG
+#if defined GMX_USE_TNG && defined HAVE_ZLIB
     "../../../gromacs/gmxana/legacytests/spc2-traj.tng",
 #endif
     "../../../gromacs/gmxana/legacytests/spc2-traj.xtc",
index 258052d50bf52f4f536ed275313a0782438cf86e..ed0542adfa575326f001943bb1ea032a7d71d701 100644 (file)
@@ -77,7 +77,7 @@ TEST(FloatingPointDifferenceTest, HandlesEqualValues)
 
 TEST(FloatingPointDifferenceTest, HandlesZerosOfDifferentSign)
 {
-    FloatingPointDifference diff(0.0, -0.0);
+    FloatingPointDifference diff(0.0, GMX_DOUBLE_NEGZERO);
     EXPECT_FALSE(diff.isNaN());
     EXPECT_EQ(0.0, diff.asAbsolute());
     EXPECT_EQ(0U,  diff.asUlps());
@@ -93,7 +93,7 @@ TEST(FloatingPointDifferenceTest, HandlesSignComparisonWithZero)
         EXPECT_TRUE(diff.signsDiffer());
     }
     {
-        FloatingPointDifference diff(-0.0, -1.2);
+        FloatingPointDifference diff(GMX_DOUBLE_NEGZERO, -1.2);
         EXPECT_FALSE(diff.isNaN());
         EXPECT_DOUBLE_EQ(1.2, diff.asAbsolute());
         EXPECT_FALSE(diff.signsDiffer());
@@ -122,7 +122,7 @@ TEST(FloatingPointDifferenceTest, HandlesUlpDifferences)
 
 TEST(FloatingPointDifferenceTest, HandlesUlpDifferenceAcrossZero)
 {
-    const double            first  = addUlps(-0.0, 2);
+    const double            first  = addUlps(GMX_DOUBLE_NEGZERO, 2);
     const double            second = addUlps( 0.0, 2);
     FloatingPointDifference diff(first, second);
     EXPECT_FALSE(diff.isNaN());