Update TNG build system
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Mon, 23 Jun 2014 10:07:23 +0000 (12:07 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sat, 28 Jun 2014 14:55:08 +0000 (16:55 +0200)
GROMACS can now find and use a copy of TNG installed on the system.
The default is still to compile the version shipped with GROMACS.
That compilation is now handled using the BuildTNG.cmake script, so
there is no duplication between the GROMACS and TNG CMake code that
builds TNG, and the result is fully portable with all supported
environments and CMake versions.

Moved TNG handling into src/gromacs/CMakeLists.txt where it is
actually used.

Bumped the version of the TNG library to 1.6. Corresponds to commit
ba9aea42b01 in the TNG repository.

Renamed md5 things with GROMACS prefixes, so that there is no internal
name clash with the md5 things in TNG, and no client of libgromacs can
get unexpected behaviour.

Updated GMX_USE_TNG=off to work, and silenced unused-parameter
warnings associated with that setting.

Refs #1453 (partial fix)
Fixes #1520

Change-Id: I7ac9b578e45b8e75c67c9df9440eed968a3a9371

35 files changed:
CMakeLists.txt
src/external/tng_io/BuildTNG.cmake [new file with mode: 0644]
src/external/tng_io/CMakeLists.txt
src/external/tng_io/Doxyfile.in
src/external/tng_io/include/tng/md5.h [moved from src/external/tng_io/include/md5.h with 100% similarity]
src/external/tng_io/include/tng/tng_io.h [moved from src/external/tng_io/include/tng_io.h with 98% similarity]
src/external/tng_io/include/tng/tng_io.hpp [moved from src/external/tng_io/include/tng_io.hpp with 100% similarity]
src/external/tng_io/include/tng/tng_io_fwd.h [moved from src/external/tng_io/include/tng_io_fwd.h with 100% similarity]
src/external/tng_io/include/tng/version.h.in [new file with mode: 0644]
src/external/tng_io/include/version.h.in [deleted file]
src/external/tng_io/src/CMakeLists.txt
src/external/tng_io/src/compression/CMakeLists.txt [deleted file]
src/external/tng_io/src/lib/CMakeLists.txt [deleted file]
src/external/tng_io/src/lib/md5.c
src/external/tng_io/src/lib/tng_io-config.cmake.in [new file with mode: 0644]
src/external/tng_io/src/lib/tng_io-configVersion.cmake.in [new file with mode: 0644]
src/external/tng_io/src/lib/tng_io.c
src/external/tng_io/src/tests/compression/CMakeLists.txt
src/external/tng_io/src/tests/compression/testsuite.c
src/external/tng_io/src/tests/md_openmp.c
src/external/tng_io/src/tests/md_openmp_util.c
src/external/tng_io/src/tests/tng_io_read_pos.c
src/external/tng_io/src/tests/tng_io_read_pos_util.c
src/external/tng_io/src/tests/tng_io_testing.c
src/external/tng_io/src/tests/tng_parallel_read.c
src/gromacs/CMakeLists.txt
src/gromacs/fileio/CMakeLists.txt
src/gromacs/fileio/gmxfio.c
src/gromacs/fileio/md5.c
src/gromacs/fileio/md5.h
src/gromacs/fileio/tngio.cpp
src/gromacs/fileio/tngio.h
src/gromacs/fileio/tngio_for_tools.cpp
src/gromacs/fileio/tngio_for_tools.h
tests/CppCheck.cmake

index ba6b3115054b053860b77d5e8747777477f89aeb..15c9cff038ba199db077eab43cc1878825d1b090 100644 (file)
@@ -848,26 +848,6 @@ else()
     endif()
 endif()
 
-if(GMX_USE_TNG)
-    find_package(ZLIB QUIET)
-    include(gmxTestZLib)
-    gmx_test_zlib(HAVE_ZLIB)
-    set(TNG_BUILD_WITH_ZLIB ${HAVE_ZLIB} CACHE BOOL  "Build TNG with zlib compression")
-    set(TNG_BUILD_FORTRAN OFF CACHE BOOL "Build Fortran compatible TNG library and examples for testing")
-    set(TNG_BUILD_EXAMPLES OFF CACHE BOOL "Build examples showing usage of the TNG API")
-    set(TNG_BUILD_COMPRESSION_TESTS OFF CACHE BOOL "Build tests of the TNG compression library")
-    set(TNG_BUILD_DOCUMENTATION OFF CACHE BOOL "Use Doxygen to create the HTML based TNG API documentation")
-    set(TNG_BUILD_TEST OFF CACHE BOOL "Build TNG testing binary.")
-    add_subdirectory(${CMAKE_SOURCE_DIR}/src/external/tng_io)
-    set(GMX_TNG_LIBRARIES tng_io)
-endif()
-mark_as_advanced(TNG_BUILD_FORTRAN)
-mark_as_advanced(TNG_BUILD_EXAMPLES)
-mark_as_advanced(TNG_BUILD_COMPRESSION_TESTS)
-mark_as_advanced(TNG_BUILD_DOCUMENTATION)
-mark_as_advanced(TNG_BUILD_TEST)
-mark_as_advanced(TNG_EXAMPLE_FILES_DIR)
-
 if (GMX_BUILD_FOR_COVERAGE)
     # Code heavy with asserts makes conditional coverage close to useless metric,
     # as by design most of the false branches are impossible to trigger in
diff --git a/src/external/tng_io/BuildTNG.cmake b/src/external/tng_io/BuildTNG.cmake
new file mode 100644 (file)
index 0000000..f4f2caf
--- /dev/null
@@ -0,0 +1,71 @@
+set(TNG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
+file(RELATIVE_PATH TNG_ROOT_BINARY_DIR ${CMAKE_SOURCE_DIR} ${TNG_ROOT_SOURCE_DIR})
+set(TNG_ROOT_BINARY_DIR ${CMAKE_BINARY_DIR}/${TNG_ROOT_BINARY_DIR})
+
+function (TNG_GENERATE_VERSION_H)
+    set(TNG_MAJOR_VERSION "1")
+    set(TNG_MINOR_VERSION "6")
+    set(TNG_VERSION_PATCH_LEVEL "0")
+    set(TNG_IO_VERSION "${TNG_MAJOR_VERSION}.${TNG_MINOR_VERSION}.${TNG_VERSION_PATCH_LEVEL}")
+    set(TNG_API_VERSION "6")
+    configure_file(${TNG_ROOT_SOURCE_DIR}/include/tng/version.h.in
+                   ${TNG_ROOT_BINARY_DIR}/include/tng/version.h)
+
+    set(TNG_MAJOR_VERSION ${TNG_MAJOR_VERSION} PARENT_SCOPE)
+    set(TNG_IO_VERSION ${TNG_IO_VERSION} PARENT_SCOPE)
+endfunction()
+
+tng_generate_version_h()
+
+include(TestBigEndian)
+test_big_endian(TNG_INTEGER_BIG_ENDIAN)
+include(CheckIncludeFile)
+check_include_file(inttypes.h TNG_HAVE_INTTYPES_H)
+
+macro(TNG_GET_SOURCE_LIST TNG_SOURCELIST TNG_COMPILEDEFS)
+    include_directories(${TNG_ROOT_SOURCE_DIR}/include)
+    include_directories(${TNG_ROOT_BINARY_DIR}/include)
+    set(_tng_compression_sources bwlzh.c bwt.c coder.c dict.c fixpoint.c huffman.c huffmem.c lz77.c merge_sort.c mtf.c rle.c tng_compress.c vals16.c warnmalloc.c widemuldiv.c xtc2.c xtc3.c)
+    set(_tng_io_sources tng_io.c md5.c)
+    set(${TNG_SOURCELIST})
+    set(${TNG_COMPILEDEFS})
+    foreach(_file ${_tng_compression_sources})
+        list(APPEND ${TNG_SOURCELIST} ${TNG_ROOT_SOURCE_DIR}/src/compression/${_file})
+    endforeach()
+    foreach(_file ${_tng_io_sources})
+        list(APPEND ${TNG_SOURCELIST} ${TNG_ROOT_SOURCE_DIR}/src/lib/${_file})
+    endforeach()
+    if(TNG_BUILD_FORTRAN)
+      list(APPEND ${TNG_SOURCELIST} ${TNG_ROOT_SOURCE_DIR}/src/lib/tng_io_fortran.c)
+    endif()
+    if (TNG_HAVE_INTTYPES_H)
+        list(APPEND ${TNG_COMPILEDEFS} USE_STD_INTTYPES_H)
+    endif()
+endmacro()
+
+macro(TNG_SET_SOURCE_PROPERTIES)
+    set(_tng_with_zlib OFF)
+    set(_curr_var)
+    foreach (_arg ${ARGN})
+        if (_arg STREQUAL "WITH_ZLIB")
+            set(_curr_var with_zlib)
+        elseif (_curr_var)
+            set(_tng_${_curr_var} ${_arg})
+            set(_curr_var "")
+        else()
+            message(FATAL_ERROR "Invalid argument ${_arg} to TNG_SET_SOURCE_PROPERTIES")
+        endif()
+    endforeach()
+    if (_tng_with_zlib)
+        set_property(SOURCE ${TNG_ROOT_SOURCE_DIR}/src/lib/tng_io.c
+                     APPEND PROPERTY COMPILE_DEFINITIONS USE_ZLIB)
+    endif()
+    if (TNG_HAVE_INTTYPES_H)
+        set_property(SOURCE ${TNG_ROOT_SOURCE_DIR}/src/lib/tng_io.c
+                     APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
+    endif()
+    if (TNG_INTEGER_BIG_ENDIAN)
+        set_property(SOURCE ${TNG_ROOT_SOURCE_DIR}/src/lib/md5.c
+                     APPEND PROPERTY COMPILE_DEFINITIONS TNG_INTEGER_BIG_ENDIAN)
+    endif()
+endmacro()
index 871d17e26e179e966b86bac8503e0a71d9d08495..7fc6ad65034b48528ac27a83a934b7ac18d4dfce 100644 (file)
@@ -1,12 +1,7 @@
 cmake_minimum_required(VERSION 2.8.8)
 
 project(TNG_IO)
-set(PROJECT_VERSION "1.5")
-set(API_VERSION "5")
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.in
-                ${CMAKE_BINARY_DIR}/include/version.h )
-include_directories(${CMAKE_BINARY_DIR}/include)
 
 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
     set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
@@ -31,9 +26,47 @@ option(TNG_BUILD_WITH_ZLIB "Build TNG with zlib compression" ${ZLIB_FOUND})
 include(CheckIncludeFile)
 check_include_file(inttypes.h   HAVE_INTTYPES_H)
 
-add_subdirectory(src)
+include(BuildTNG.cmake)
+tng_get_source_list(TNG_SOURCES TNG_COMPILE_DEFS)
+
+tng_set_source_properties(WITH_ZLIB ${ZLIB_FOUND})
+
+if (ZLIB_FOUND)
+  list(APPEND EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
+endif()
+
+if (UNIX)
+  list(APPEND EXTRA_LIBRARIES m)
+endif()
+
+add_library(tng_io ${TNG_SOURCES})
+
+target_link_libraries(tng_io ${EXTRA_LIBRARIES})
 
-install(FILES include/tng_io.h include/tng_io_fwd.h DESTINATION include/)
+set_target_properties(tng_io PROPERTIES VERSION ${TNG_IO_VERSION} SOVERSION ${TNG_MAJOR_VERSION})
+
+# Create the tng_ioConfig.cmake and tng_ioConfigVersion.cmake files for the install tree
+set(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
+configure_file(              src/lib/tng_io-config.cmake.in
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake" @ONLY)
+configure_file(              src/lib/tng_io-configVersion.cmake.in
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake" @ONLY)
+
+# Use GNUInstallDirst to set paths on multiarch systems
+include(GNUInstallDirs)
+
+# Install the tng_ioConfig.cmake and tng_ioConfigVersion.cmake
+install(FILES
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake"
+  "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake"
+  DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tng_io")
+
+install(TARGETS tng_io
+        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+install(FILES include/tng/tng_io.h include/tng/tng_io_fwd.h ${CMAKE_CURRENT_BINARY_DIR}/include/tng/version.h
+        DESTINATION include/tng)
 
 #-- Add an Option to toggle the generation of the API documentation
 option(TNG_BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
@@ -57,3 +90,5 @@ if(TNG_BUILD_DOCUMENTATION)
       DESTINATION share/tng/doc)
 endif()
 
+add_subdirectory(src)
+
index 3d6f0f7d43f48f6e3319ea7f832bb16fd62f2de8..03ba55355acc4f4809bc44dbc0363a29f978557c 100644 (file)
@@ -658,7 +658,7 @@ RECURSIVE              = NO
 # Note that relative paths are relative to the directory from which doxygen is
 # run.
 
-EXCLUDE                = @PROJECT_SOURCE_DIR@/src/lib/md5.c @PROJECT_SOURCE_DIR@/include/md5.h @PROJECT_SOURCE_DIR@/include/tng_io.hpp @PROJECT_SOURCE_DIR@/src/lib/tng_io.c
+EXCLUDE                = @PROJECT_SOURCE_DIR@/src/lib/md5.c @PROJECT_SOURCE_DIR@/include/tng/md5.h @PROJECT_SOURCE_DIR@/include/tng/tng_io.hpp @PROJECT_SOURCE_DIR@/src/lib/tng_io.c
 
 # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
 # directories that are symbolic links (a Unix file system feature) are excluded
similarity index 98%
rename from src/external/tng_io/include/tng_io.h
rename to src/external/tng_io/include/tng/tng_io.h
index 5b89cd6357255fad170d502a0d2044cdeb39fa1b..42119a5328863cd1dbfb538ef71da68fc2b49237 100644 (file)
@@ -21,9 +21,9 @@
  * Each block can contain MD5 hashes to verify data integrity and the file
  * can be signed by the user to ensure that the origin is correct.
  *
- * This is version 1.4 of the TNG API. The intention is that this version of
- * the API and ABI should be stable, but it is still possible that future
- * changes might make that impossible, in which case that will be clarified.
+ * The intention is that the API and ABI should be stable, but it is
+ * still possible that future changes might make that impossible, in which
+ * case that will be clarified.
  *
  * The API and all examples are released without any warranties. Use them at
  * your own risk.
  *
  * Revisions
  *
+ * v. 1.6 - Fourth stable release of the API.
+ *
+ *        - Removed OpenMP option when building.
+ *        - Functionality for migrating data blocks.
+ *        - Improved handling of molecules.
+ *        - Improved installation of TNG documentation.
+ *        - Enhancements to CMake usage.
+ *        - Required CMake version raised to 2.8.8.
+ *        - Bugs fixed.
+ *
  * v. 1.5 - Third stable release of the API.
  *
  *        - Fortran wrapper split into separate file
  * \code
  * #include <stdlib.h>
  * #include <stdio.h>
- * #include "tng_io.h"
+ * #include "tng/tng_io.h"
  *
  * int main(int argc, char **argv)
  * {
@@ -530,6 +540,59 @@ extern "C"
  *  @{
  */
 
+/**
+ * @brief Get the major version of the TNG library.
+ * @param tng_data is a trajectory data container, it does not have
+ * to be initialized beforehand.
+ * @param version is pointing to a value set to the major version of
+ * the library.
+ * @return TNG_SUCCESS (0) if successful.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_version_major
+                (const tng_trajectory_t tng_data,
+                 int *version);
+
+/**
+ * @brief Get the minor version of the TNG library.
+ * @param tng_data is a trajectory data container, it does not have
+ * to be initialized beforehand.
+ * @param version is pointing to a value set to the minor version of
+ * the library.
+ * @return TNG_SUCCESS (0) if successful.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_version_minor
+                (const tng_trajectory_t tng_data,
+                 int *version);
+
+/**
+ * @brief Get the patch level of the TNG library.
+ * @param tng_data is a trajectory data container, it does not have
+ * to be initialized beforehand.
+ * @param patch_level is the string to fill with the full version,
+ * memory must be allocated before.
+ * @return TNG_SUCCESS (0) if successful.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_version_patchlevel
+                (const tng_trajectory_t tng_data,
+                 int *patch_level);
+
+/**
+ * @brief Get the full version string of the TNG library.
+ * @param tng_data is a trajectory data container, it does not have
+ * to be initialized beforehand.
+ * @param version is pointing to a value set to the major version of
+ * the library.
+ * @param max_len maximum char length of the string, i.e. how much memory has
+ * been reserved for version. This includes \0 terminating character.
+ * @pre \code version != 0 \endcode The pointer to the name string
+ * must not be a NULL pointer.
+ * @return TNG_SUCCESS (0) if successful.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_version
+                (const tng_trajectory_t tng_data,
+                 char *version,
+                 const int max_len);
+
 /**
  * @brief Setup a trajectory data container.
  * @param tng_data_p a pointer to memory to initialise as a trajectory.
@@ -4677,7 +4740,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
                 (tng_trajectory_t tng_data,
                  const int64_t block_id,
                  int64_t *codec_id,
-                 float *factor);
+                 double  *factor);
 
 /** @brief High-level function for determining the next frame with data and what
  * data blocks have data for that frame. The search can be limited to certain
diff --git a/src/external/tng_io/include/tng/version.h.in b/src/external/tng_io/include/tng/version.h.in
new file mode 100644 (file)
index 0000000..662e68f
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef VERSION_CONFIG_H
+#define VERSION_CONFIG_H
+
+/* define the API version (integer) */
+#define TNG_API_VERSION @TNG_API_VERSION@
+
+/* define the major and minor versions
+   of the library */
+#define TNG_VERSION_MAJOR @TNG_MAJOR_VERSION@
+#define TNG_VERSION_MINOR @TNG_MINOR_VERSION@
+/* define the patchlevel of the library */
+#define TNG_VERSION_PATCHLEVEL @TNG_VERSION_PATCH_LEVEL@
+/* define the full version of the library (string) */
+#define TNG_VERSION "@TNG_IO_VERSION@"
+
+#endif
diff --git a/src/external/tng_io/include/version.h.in b/src/external/tng_io/include/version.h.in
deleted file mode 100644 (file)
index 840e454..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef VERSION_CONFIG_H
-#define VERSION_CONFIG_H
-
-/* define the API version */
-#define TNG_API_VERSION @API_VERSION@
-
-#endif
index d5f2bc0a20caf81b486b687fb2f1deb3bc263889..88c05163602afabc81c663eb0fd0b3db882b2a3b 100644 (file)
@@ -1,3 +1 @@
-add_subdirectory(compression)
-add_subdirectory(lib)
 add_subdirectory(tests)
diff --git a/src/external/tng_io/src/compression/CMakeLists.txt b/src/external/tng_io/src/compression/CMakeLists.txt
deleted file mode 100644 (file)
index 8bb0220..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-set(source_files bwlzh.c bwt.c coder.c dict.c fixpoint.c huffman.c huffmem.c lz77.c merge_sort.c mtf.c rle.c tng_compress.c vals16.c warnmalloc.c widemuldiv.c xtc2.c xtc3.c)
-
-add_library(tng_compress ${source_files})
-
-# Append the required library dependencies
-if(UNIX)
-  target_link_libraries(tng_compress m)
-endif()
-
-# Use GNUInstallDirst to set paths on multiarch systems
-include(GNUInstallDirs)
-
-install(TARGETS tng_compress
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/src/external/tng_io/src/lib/CMakeLists.txt b/src/external/tng_io/src/lib/CMakeLists.txt
deleted file mode 100644 (file)
index 838f827..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-set(source_files tng_io.c md5.c)
-if(TNG_BUILD_FORTRAN)
-  list(APPEND source_files tng_io_fortran.c)
-endif()
-
-add_library(tng_io ${source_files})
-
-# Now add source-file compilation properties to the source-file
-# targets
-
-if(HAVE_INTTYPES_H)
-  set_property(SOURCE tng_io.c APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
-endif()
-if(TNG_BUILD_WITH_ZLIB)
-  set_property(SOURCE tng_io.c APPEND PROPERTY COMPILE_DEFINITIONS USE_ZLIB)
-endif()
-
-# This test is for md5. The TNG library itself determines the actual byte order -
-# not just if it is small or big endian.
-include(TestBigEndian)
-test_big_endian(TNG_INTEGER_BIG_ENDIAN)
-if(TNG_INTEGER_BIG_ENDIAN)
-  set_property(SOURCE md5.c APPEND PROPERTY COMPILE_DEFINITIONS TNG_INTEGER_BIG_ENDIAN)
-endif()
-
-# Append the required library dependencies
-target_link_libraries(tng_io tng_compress)
-if(TNG_BUILD_WITH_ZLIB)
-  target_link_libraries(tng_io ${ZLIB_LIBRARIES})
-endif()
-
-# Use GNUInstallDirst to set paths on multiarch systems
-include(GNUInstallDirs)
-
-install(TARGETS tng_io
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
index ea8bb37b5e0ed7d2c8f15e7c6bdab910eeb455de..f6a2391635587c1178dd676ebf6103f2af8df416 100644 (file)
@@ -75,7 +75,7 @@
   1999-05-03 lpd Original version.
  */
 
-#include "../../include/md5.h"
+#include "tng/md5.h"
 #include <string.h>
 
 #undef BYTE_ORDER      /* 1 = big-endian, -1 = little-endian, 0 = unknown */
diff --git a/src/external/tng_io/src/lib/tng_io-config.cmake.in b/src/external/tng_io/src/lib/tng_io-config.cmake.in
new file mode 100644 (file)
index 0000000..06c0470
--- /dev/null
@@ -0,0 +1,13 @@
+# - Config file for the TNG_IO package
+# It defines the following variables
+#  TNG_IO_INCLUDE_DIRS - include directories for TNG_IO
+#  TNG_IO_LIBRARIES    - libraries to link against
+#  TNG_IO_DEFINITIONS - definitions used when compiling
+
+# Compute paths
+get_filename_component(TNG_IO_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(TNG_IO_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
+set(TNG_IO_DEFINITIONS "@TNG_COMPILE_DEFS@")
+
+set(TNG_IO_LIBRARIES tng_io)
+
diff --git a/src/external/tng_io/src/lib/tng_io-configVersion.cmake.in b/src/external/tng_io/src/lib/tng_io-configVersion.cmake.in
new file mode 100644 (file)
index 0000000..8946f5e
--- /dev/null
@@ -0,0 +1,12 @@
+set(PACKAGE_VERSION "@TNG_IO_VERSION@")
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
+
index 252cbb2901d5e393393af90a6a1ede600b303f7f..792be2e92900f5d1e17a3f4167e7464e3426750e 100644 (file)
 #include <zlib.h>
 #endif
 
-#include "../../include/tng_io.h"
-#include "../../include/md5.h"
-#include "../../include/compression/tng_compress.h"
-#include "../include/version.h"
+#include "tng/tng_io.h"
+#include "tng/md5.h"
+#include "compression/tng_compress.h"
+#include "tng/version.h"
 
 
 struct tng_bond {
@@ -7852,6 +7852,52 @@ static tng_function_status tng_atom_destroy(tng_atom_t atom)
     return(TNG_SUCCESS);
 }
 
+tng_function_status DECLSPECDLLEXPORT tng_version_major
+                (const tng_trajectory_t tng_data,
+                 int *version)
+{
+    (void)tng_data;
+
+    *version = TNG_VERSION_MAJOR;
+
+    return(TNG_SUCCESS);
+}
+
+tng_function_status DECLSPECDLLEXPORT tng_version_minor
+                (const tng_trajectory_t tng_data,
+                 int *version)
+{
+    (void)tng_data;
+
+    *version = TNG_VERSION_MINOR;
+
+    return(TNG_SUCCESS);
+}
+
+tng_function_status DECLSPECDLLEXPORT tng_version_patchlevel
+                (const tng_trajectory_t tng_data,
+                 int *patch_level)
+{
+    (void)tng_data;
+
+    *patch_level = TNG_VERSION_PATCHLEVEL;
+
+    return(TNG_SUCCESS);
+}
+
+tng_function_status DECLSPECDLLEXPORT tng_version
+                (const tng_trajectory_t tng_data,
+                 char *version,
+                 const int max_len)
+{
+    (void)tng_data;
+    TNG_ASSERT(version, "TNG library: version must not be a NULL pointer");
+
+    TNG_SNPRINTF(version, max_len, "%s", TNG_VERSION);
+
+    return(TNG_SUCCESS);
+}
+
 tng_function_status DECLSPECDLLEXPORT tng_molecule_add
                 (tng_trajectory_t tng_data,
                  const char *name,
@@ -18889,7 +18935,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
                 (tng_trajectory_t tng_data,
                  const int64_t block_id,
                  int64_t *codec_id,
-                 float *factor)
+                 double *factor)
 {
     tng_trajectory_frame_set_t frame_set;
     tng_particle_data_t p_data = 0;
@@ -18986,12 +19032,12 @@ tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get
     if(block_type == TNG_PARTICLE_BLOCK_DATA)
     {
         *codec_id = p_data->codec_id;
-        *factor   = (float)p_data->compression_multiplier;
+        *factor   = p_data->compression_multiplier;
     }
     else if(block_type == TNG_NON_PARTICLE_BLOCK_DATA)
     {
         *codec_id = np_data->codec_id;
-        *factor   = (float)np_data->compression_multiplier;
+        *factor   = np_data->compression_multiplier;
     }
     return(TNG_SUCCESS);
 }
index 075b06b747b5d463b704a0623faf5e872225909f..d29791b65d6233af67deb8d4952b5cedce32625d 100644 (file)
@@ -4,8 +4,6 @@ add_definitions(-DTNG_COMPRESS_FILES_DIR="${CMAKE_BINARY_DIR}/test_tng_compress_
 
 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test_tng_compress_files)
 
-include_directories(${CMAKE_BINARY_DIR}/include/)
-
 set(number 0)
 set(numtests 78)
 
@@ -14,7 +12,7 @@ while( number LESS ${numtests})
 math( EXPR number "${number} + 1" )
 
 add_executable(test_tng_compress_gen${number} testsuite.c)
-target_link_libraries(test_tng_compress_gen${number} tng_compress)
+target_link_libraries(test_tng_compress_gen${number} tng_io)
 if(UNIX)
 target_link_libraries(test_tng_compress_gen${number} m)
 endif()
@@ -25,7 +23,7 @@ add_dependencies(test_tng_compress_gen${number} test${number}.h)
 set_property(TARGET test_tng_compress_gen${number} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/compression_tests)
 
 add_executable(test_tng_compress_read${number} testsuite.c)
-target_link_libraries(test_tng_compress_read${number} tng_compress)
+target_link_libraries(test_tng_compress_read${number} tng_io)
 if(UNIX)
 target_link_libraries(test_tng_compress_read${number} m)
 endif()
index 2cfe05e97f9c48f8ee74d21d5ec3b7c9ae69fe68..e266c110b8b43995e56ef63ab34f165dfe163eff 100644 (file)
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
-#include "../../../include/compression/tng_compress.h"
+#include "compression/tng_compress.h"
 #include TESTPARAM
 
 #ifdef TEST_FLOAT
index fd9f4b0e770a7cb07c7699f8e2d3222f01284b96..aac8b3b7bd2d73b481cd42257767f4dfbc01aa25 100644 (file)
@@ -1,11 +1,11 @@
 #ifdef TNG_BUILD_OPENMP_EXAMPLES
 
-# include <stdlib.h>
-# include <stdio.h>
-# include <time.h>
-# include <math.h>
-# include <omp.h>
-#include "../../include/tng_io.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <math.h>
+#include <omp.h>
+#include "tng/tng_io.h"
 
 int main ();
 void compute ( int np, int nd, double pos[], double vel[],
index 8c332f32eed114d8be0eb671ff44826090a3536c..9fe6c91b60ce6b11ebcabdd69a1544bc600b5171 100644 (file)
@@ -1,11 +1,11 @@
 #ifdef TNG_BUILD_OPENMP_EXAMPLES
 
-# include <stdlib.h>
-# include <stdio.h>
-# include <time.h>
-# include <math.h>
-# include <omp.h>
-#include "../../include/tng_io.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <math.h>
+#include <omp.h>
+#include "tng/tng_io.h"
 
 int main ();
 void compute ( int np, int nd, float pos[], float vel[],
index 2a0bb0974176cfe2333907cf709d6c1fe461c928..b29cec7cd11352883d7dfd5987701594e18da0de 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include "../../include/tng_io.h"
+#include "tng/tng_io.h"
 
 int main(int argc, char **argv)
 {
index 1667bae2d8e3501bf99d6272ffdf86d7158495d1..b237dad03ddc52a226c04c9182760ae5fdf93a90 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include "../../include/tng_io.h"
+#include "tng/tng_io.h"
 
 int main(int argc, char **argv)
 {
index dd13d925d3dd3bfb39d9276519694bed4932559f..e1e2726db15c1de35876cc251d37ccc33660c9eb 100644 (file)
@@ -15,7 +15,8 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include "../../include/tng_io.h"
+#include "tng/tng_io.h"
+#include "tng/version.h"
 
 static tng_function_status tng_test_setup_molecules(tng_trajectory_t traj)
 {
@@ -595,6 +596,17 @@ int main()
     tng_trajectory_t traj;
     tng_function_status stat;
     char time_str[TNG_MAX_DATE_STR_LEN];
+    char version_str[TNG_MAX_STR_LEN];
+
+    tng_version(traj, version_str, TNG_MAX_STR_LEN);
+    if(strncmp(TNG_VERSION, version_str, TNG_MAX_STR_LEN) == 0)
+    {
+        printf("Test version control: \t\t\t\tSucceeded.\n");
+    }
+    else
+    {
+        printf("Test version control: \t\t\t\tFailed.\n");
+    }
 
     if(tng_trajectory_init(&traj) != TNG_SUCCESS)
     {
index e2e23c6b4f709bd2b0c461386c758f3c3de38cb7..44e8f796b712762586fbea1376b6764cdabdacf6 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include "../../include/tng_io.h"
+#include "tng/tng_io.h"
 
 
 /* N.B. this code is for testing parallel reading of trajectory frame sets. The
index efbebe7607c8ecee7145fe0c4e0b29bf1ad085f3..2045cebcc6f06c8be921c8d9589e6701d6e6f004 100644 (file)
@@ -45,6 +45,39 @@ function (gmx_install_headers DESTINATION)
     endif()
 endfunction ()
 
+if(GMX_USE_TNG)
+    option(GMX_EXTERNAL_TNG "Use external TNG instead of compiling the version shipped with GROMACS."
+           OFF)
+    # Detect TNG if GMX_EXTERNAL_TNG is explicitly ON
+    if(GMX_EXTERNAL_TNG)
+        find_package(TNG_IO 1.6.0)
+        if(NOT TNG_IO_FOUND)
+            message(FATAL_ERROR
+                "TNG >= 1.6.0 not found. "
+                "You can set GMX_EXTERNAL_TNG=OFF to compile TNG.")
+        endif()
+        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})
+        tng_set_source_properties(WITH_ZLIB ${HAVE_ZLIB})
+
+        if (HAVE_ZLIB)
+            list(APPEND GMX_EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
+        endif()
+    endif()
+else()
+    # We still need to get tng/tng_io_fwd.h from somewhere!
+    include_directories(${CMAKE_SOURCE_DIR}/src/external/tng_io/include)
+endif()
+
 add_subdirectory(gmxlib)
 add_subdirectory(mdlib)
 add_subdirectory(gmxpreprocess)
@@ -157,7 +190,7 @@ target_link_libraries(libgromacs
                       ${EXTRAE_LIBRARIES}
                       ${GMX_GPU_LIBRARIES}
                       ${GMX_EXTRA_LIBRARIES}
-                      ${GMX_TNG_LIBRARIES}
+                      ${TNG_IO_LIBRARIES}
                       ${FFT_LIBRARIES} ${LINEAR_ALGEBRA_LIBRARIES}
                       ${XML_LIBRARIES}
                       ${THREAD_LIB} ${GMX_SHARED_LINKER_FLAGS})
index 18078dee8149bf6f8e5f3ee7d912ef2c39c04f73..7d3d02c5f75d4a0dbf3dd8ec0e9b75aaf906e002 100644 (file)
@@ -61,13 +61,11 @@ set(FILEIO_PUBLIC_HEADERS
     )
 gmx_install_headers(fileio ${FILEIO_PUBLIC_HEADERS})
 
-# These files include tng_io.h from the TNG library. That header needs to know
-# whether inttypes.h exists or not.
-include(CheckIncludeFiles)
-check_include_file(inttypes.h   HAVE_INTTYPES_H)
-if(HAVE_INTTYPES_H)
-  set_property(SOURCE tngio.cpp APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
-  set_property(SOURCE tngio_for_tools.cpp APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
+if (GMX_USE_TNG AND TNG_IO_DEFINITIONS)
+    set_property(SOURCE tngio.cpp
+                 APPEND PROPERTY COMPILE_DEFINITIONS ${TNG_IO_DEFINITIONS})
+    set_property(SOURCE tngio_for_tools.cpp
+                 APPEND PROPERTY COMPILE_DEFINITIONS ${TNG_IO_DEFINITIONS})
 endif()
 
 if (BUILD_TESTING)
index ab627936dc5dea208bea37df04a73c6cadbfb808..d9909d56ac46f5a2dedbfc8570d379445eeeb50d 100644 (file)
@@ -751,9 +751,9 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset,
 
     if (!ret)
     {
-        md5_init(&state);
-        md5_append(&state, buf, read_len);
-        md5_finish(&state, digest);
+        gmx_md5_init(&state);
+        gmx_md5_append(&state, buf, read_len);
+        gmx_md5_finish(&state, digest);
         ret = read_len;
     }
     sfree(buf);
index ca27dbb75ae43d3f85bdfcadd5b77bb58af20300..8154a6e81153e79c4d6dc5d71ecca6847cbc41f1 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/* This software has been altered by GROMACS for its use, including
+ * the use of GMX_INTEGER_BIG_ENDIAN, and the renaming of the
+ * functions md5_init, md5_append and md5_finish to have a gmx_ prefix
+ * (to avoid name clashes). */
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -359,7 +363,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
 }
 
 void
-md5_init(md5_state_t *pms)
+gmx_md5_init(md5_state_t *pms)
 {
     pms->count[0] = pms->count[1] = 0;
     pms->abcd[0]  = 0x67452301;
@@ -369,7 +373,7 @@ md5_init(md5_state_t *pms)
 }
 
 void
-md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+gmx_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
 {
     const md5_byte_t *p = data;
     int left            = nbytes;
@@ -418,7 +422,7 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
 }
 
 void
-md5_finish(md5_state_t *pms, md5_byte_t digest[16])
+gmx_md5_finish(md5_state_t *pms, md5_byte_t digest[16])
 {
     static const md5_byte_t pad[64] = {
         0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -435,9 +439,9 @@ md5_finish(md5_state_t *pms, md5_byte_t digest[16])
         data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
     }
     /* Pad to 56 bytes mod 64. */
-    md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+    gmx_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
     /* Append the length. */
-    md5_append(pms, data, 8);
+    gmx_md5_append(pms, data, 8);
     for (i = 0; i < 16; ++i)
     {
         digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
index 5e0d6223e50c3dcd707a8cdc6d10d1f0ff310f2d..ae49d2774856debfbd3957a12cbf4c42e2339200 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
+/* This software has been altered by GROMACS for its use, including
+ * the renaming of the functions md5_init, md5_append and md5_finish
+ * to have a gmx_ prefix, and the #include guard md5_INCLUDED to have
+ * a GMX_ prefix (both to avoid name clashes). */
 /*
    Copyright (C) 1999, 2000, 2002 Aladdin Enterprises.  All rights reserved.
 
@@ -80,8 +84,8 @@
    1999-05-03 lpd Original version.
  */
 
-#ifndef md5_INCLUDED
-#  define md5_INCLUDED
+#ifndef GMX_md5_INCLUDED
+#  define GMX_md5_INCLUDED
 
 /*
  * This package supports both compile-time and run-time determination of CPU
@@ -109,16 +113,16 @@ extern "C"
 #endif
 
 /* Initialize the algorithm. */
-void md5_init(md5_state_t *pms);
+void gmx_md5_init(md5_state_t *pms);
 
 /* Append a string to the message. */
-void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
+void gmx_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
 
 /* Finish the message and return the digest. */
-void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
+void gmx_md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
 
 #ifdef __cplusplus
 }  /* end extern "C" */
 #endif
 
-#endif /* md5_INCLUDED */
+#endif
index da7a7f12fb5aa19587b7235b8accfd0b3eda6fcb..6cef6532d09aa4e7da8992ec10d81ed584cd2d31 100644 (file)
@@ -43,7 +43,7 @@
 #endif
 
 #ifdef GMX_USE_TNG
-#include "../../external/tng_io/include/tng_io.h"
+#include "tng/tng_io.h"
 #endif
 
 #include "gromacs/legacyheaders/copyrite.h"
index e899a23373de1e49f85301120d087e60f1b3a962..1f439c537aba1467d33471c63d22032fd114265f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -37,7 +37,7 @@
 #define GMX_FILEIO_TNGIO_H
 
 #include "gromacs/legacyheaders/typedefs.h"
-#include "../../external/tng_io/include/tng_io_fwd.h"
+#include "tng/tng_io_fwd.h"
 
 #ifdef __cplusplus
 extern "C" {
index 3d7954d1365c6806f0eb337751d8eb532d5cf5a1..1c579a6f81744798b72b727f3771e90fc305a132 100644 (file)
@@ -44,7 +44,7 @@
 #include "trx.h"
 
 #ifdef GMX_USE_TNG
-#include "../../external/tng_io/include/tng_io.h"
+#include "tng/tng_io.h"
 #endif
 
 #include "gromacs/legacyheaders/types/atoms.h"
@@ -171,6 +171,9 @@ void gmx_prepare_tng_writing(const char              *filename,
     GMX_UNUSED_VALUE(input);
     GMX_UNUSED_VALUE(output);
     GMX_UNUSED_VALUE(nAtoms);
+    GMX_UNUSED_VALUE(mtop);
+    GMX_UNUSED_VALUE(index);
+    GMX_UNUSED_VALUE(indexGroupName);
 #endif
 }
 
@@ -201,6 +204,7 @@ void gmx_write_tng_from_trxframe(tng_trajectory_t        output,
 #else
     GMX_UNUSED_VALUE(output);
     GMX_UNUSED_VALUE(frame);
+    GMX_UNUSED_VALUE(natoms);
 #endif
 }
 
@@ -427,7 +431,7 @@ gmx_bool gmx_read_next_tng_frame(tng_trajectory_t            input,
     void                   *values        = NULL;
     double                  frameTime     = -1.0;
     int                     size, blockDependency;
-    float                   prec;
+    double                  prec;
     const int               defaultNumIds = 5;
     static gmx_int64_t      fallbackRequestedIds[defaultNumIds] =
     {
@@ -617,6 +621,7 @@ gmx_bool gmx_read_next_tng_frame(tng_trajectory_t            input,
     GMX_UNUSED_VALUE(input);
     GMX_UNUSED_VALUE(fr);
     GMX_UNUSED_VALUE(requestedIds);
+    GMX_UNUSED_VALUE(numRequestedIds);
     return FALSE;
 #endif
 }
@@ -778,7 +783,7 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t     input,
     gmx_int64_t         codecId;
     int                 blockDependency;
     void               *data = 0;
-    float               localPrec;
+    double              localPrec;
 
     stat = tng_data_block_name_get(input, blockId, name, maxLen);
     if (stat != TNG_SUCCESS)
index ed9cc84a67c19c87dcb8758db423658a0e5abe97..f0a31eb250354fce3f5faf692e88e1cdb598760f 100644 (file)
@@ -37,7 +37,7 @@
 #define GMX_FILEIO_TNGIO_FOR_TOOLS_H
 
 #include "gromacs/legacyheaders/typedefs.h"
-#include "../../external/tng_io/include/tng_io_fwd.h"
+#include "tng/tng_io_fwd.h"
 
 #ifdef __cplusplus
 extern "C" {
index 1d7ac5c8e846a9fdd1c1db4278eaeed4d75c67df..9d4a3d52eea87c8c01698bb68ecab161639120be 100644 (file)
@@ -71,6 +71,7 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         --enable=style -DLINUX
         -I src/gromacs/legacyheaders -I src
         -I src/external/thread_mpi/include
+        -I src/external/tng_io/include
         -I ${CMAKE_BINARY_DIR}/src -I ${CMAKE_BINARY_DIR}/src/gromacs/utility
         --quiet
         ${_outputopt})