From 7b8b0fc840cc4b8bcb9f730b4136b69d4dcfd5a1 Mon Sep 17 00:00:00 2001 From: Magnus Lundborg Date: Wed, 12 Feb 2014 08:59:48 +0100 Subject: [PATCH] Bumped TNG to latest version. Change-Id: Iefbb35ce46f0c545a23b8bea6b90ad5e11caeffc --- src/external/tng_io/CMakeLists.txt | 11 +- src/external/tng_io/include/tng_io.h | 71 +++++---- src/external/tng_io/include/tng_io.hpp | 2 +- src/external/tng_io/include/tng_io_fwd.h | 2 +- .../tng_io/src/compression/tng_compress.c | 9 +- src/external/tng_io/src/lib/tng_io.c | 147 +++++++++++------- src/external/tng_io/src/lib/tng_io_fortran.c | 2 +- src/external/tng_io/src/tests/CMakeLists.txt | 5 +- src/external/tng_io/src/tests/md_openmp.c | 4 - src/external/tng_io/src/tests/md_openmp.f | 2 +- .../tng_io/src/tests/md_openmp_util.c | 4 - .../tng_io/src/tests/tng_io_testing.c | 18 +-- src/gromacs/fileio/tngio_for_tools.cpp | 7 +- 13 files changed, 155 insertions(+), 129 deletions(-) diff --git a/src/external/tng_io/CMakeLists.txt b/src/external/tng_io/CMakeLists.txt index a0f917d515..52cf7aa752 100644 --- a/src/external/tng_io/CMakeLists.txt +++ b/src/external/tng_io/CMakeLists.txt @@ -18,16 +18,7 @@ option(TNG_BUILD_EXAMPLES "Build examples showing usage of the TNG API" ON) option(TNG_BUILD_TEST "Build TNG testing binary." ON) option(TNG_BUILD_COMPRESSION_TESTS "Build tests of the TNG compression library" OFF) -option(TNG_USE_OPENMP "Try to use the OpenMP library (if available)" OFF) -if(TNG_USE_OPENMP) - find_package(OpenMP) - if(OPENMP_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") - endif() -endif() - -find_package(ZLIB) +find_package(ZLIB QUIET) include(CheckIncludeFile) check_include_file(inttypes.h HAVE_INTTYPES_H) diff --git a/src/external/tng_io/include/tng_io.h b/src/external/tng_io/include/tng_io.h index a240d3277e..45cb1d8d2d 100644 --- a/src/external/tng_io/include/tng_io.h +++ b/src/external/tng_io/include/tng_io.h @@ -1,6 +1,6 @@ /* This code is part of the tng binary trajectory format. * - * VERSION 1.4 + * VERSION 1.5 * * Written by Magnus Lundborg * Copyright (c) 2012-2013, The GROMACS development team. @@ -78,6 +78,17 @@ * * Revisions * + * v. 1.5 - Third stable release of the API. + * + * - Fortran wrapper split into separate file + * - Added more block IDs. + * - Some new functions and utility functions added. + * - Improved compression precision settings. + * - Improved tests. + * - Make appending to file work better. + * - Modified CMake settings + * - Bugs fixed + * * v. 1.4 - Changed from LGPL to the Revised BSD License. * * - More flexible support for digital signatures in header. @@ -334,7 +345,7 @@ typedef unsigned __int64 uint64_t; /** The version of this TNG build */ -#define TNG_VERSION 4 /* TNG_VERSION 4 => Api version 1.4 */ +#define TNG_VERSION 5 /* TNG_VERSION 4 => Api version 1.5 */ /** Flag to indicate frame dependent data. */ #define TNG_FRAME_DEPENDENT 1 @@ -658,7 +669,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set * could not be retrieved. */ tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get - (tng_trajectory_t tng_data, tng_file_endianness *endianness); + (const tng_trajectory_t tng_data, tng_file_endianness *endianness); /** * @brief Set the endianness of the output file. @@ -1283,7 +1294,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get * @return TNG_SUCCESS (0) if successful. */ tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, tng_trajectory_frame_set_t *frame_set_p); /** @@ -1516,8 +1527,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set * has occurred or TNG_CRITICAL (2) if a major error has occured. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, int64_t *cnt); /** @@ -1601,8 +1612,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_system_copy(tng_trajectory_t * @return TNG_SUCCESS (0) if successful. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_chains_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, int64_t *n); /** @@ -1633,8 +1644,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_of_index_get * @return TNG_SUCCESS (0) if successful. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, int64_t *n); /** @@ -1650,9 +1661,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get * residue is not found. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, + const int64_t index, tng_residue_t *residue); /** @@ -1665,8 +1676,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get * @return TNG_SUCCESS (0) if successful. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, int64_t *n); /** @@ -1682,9 +1693,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get * atom is not found. */ tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, + const int64_t index, tng_atom_t *atom); /** @@ -1856,9 +1867,9 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get * residue is not found. */ tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get - (tng_trajectory_t tng_data, - tng_chain_t chain, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_chain_t chain, + const int64_t index, tng_residue_t *residue); /** @@ -1988,9 +1999,9 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get * atom is not found. */ tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get - (tng_trajectory_t tng_data, - tng_residue_t residue, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_residue_t residue, + const int64_t index, tng_atom_t *atom); /** @@ -2049,7 +2060,7 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_atom_w_id_add * @pre \code atom != 0 \endcode The atom must not be NULL. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data, +tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data, const tng_atom_t atom, tng_residue_t *residue); @@ -2600,7 +2611,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set * frame set or TNG_CRITICAL(2) if a major error has occured. */ tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t *frame); /** @@ -2725,7 +2736,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get * TNG_CRITICAL (2) if a major error has occured. */ tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t block_id, int *block_dependency); @@ -2742,7 +2753,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get * TNG_CRITICAL (2) if a major error has occured. */ tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t block_id, int64_t *n_values_per_frame); @@ -3218,7 +3229,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get * has occurred or TNG_CRITICAL (2) if a major error has occured. */ tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, const int64_t block_id, int64_t frame, int64_t *stride_length); @@ -4670,7 +4681,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get (tng_trajectory_t tng_data, const int64_t block_id, - char *codec_id, + int64_t *codec_id, float *factor); /** @brief High-level function for determining the next frame with data and what diff --git a/src/external/tng_io/include/tng_io.hpp b/src/external/tng_io/include/tng_io.hpp index 202f9dbcba..f3bc32abea 100644 --- a/src/external/tng_io/include/tng_io.hpp +++ b/src/external/tng_io/include/tng_io.hpp @@ -1,6 +1,6 @@ /* This code is part of the tng binary trajectory format. * - * VERSION 1.4 + * VERSION 1.5 * * Written by Anders Gärdenäs * Copyright (c) 2012-2013, The GROMACS development team. diff --git a/src/external/tng_io/include/tng_io_fwd.h b/src/external/tng_io/include/tng_io_fwd.h index 340c264b23..34ddd87bad 100644 --- a/src/external/tng_io/include/tng_io_fwd.h +++ b/src/external/tng_io/include/tng_io_fwd.h @@ -1,6 +1,6 @@ /* This code is part of the tng binary trajectory format. * - * VERSION 1.4 + * VERSION 1.5 * * Written by Magnus Lundborg * Copyright (c) 2012-2013, The GROMACS development team. diff --git a/src/external/tng_io/src/compression/tng_compress.c b/src/external/tng_io/src/compression/tng_compress.c index 6174e8fcda..b39d7220cb 100644 --- a/src/external/tng_io/src/compression/tng_compress.c +++ b/src/external/tng_io/src/compression/tng_compress.c @@ -423,9 +423,12 @@ static void compress_quantized_pos(int *quant, int *quant_inter, int *quant_intr if (data) bufferfix((unsigned char*)data+bufloc,(fix_t)length,4); bufloc+=4; - if (data) - memcpy(data+bufloc,datablock,length); - free(datablock); + if (datablock) + { + if (data) + memcpy(data+bufloc,datablock,length); + free(datablock); + } bufloc+=length; } *nitems=bufloc; diff --git a/src/external/tng_io/src/lib/tng_io.c b/src/external/tng_io/src/lib/tng_io.c index 4b813124dd..b51796adbc 100644 --- a/src/external/tng_io/src/lib/tng_io.c +++ b/src/external/tng_io/src/lib/tng_io.c @@ -1,6 +1,6 @@ /* This code is part of the tng binary trajectory format. * - * VERSION 1.4 + * VERSION 1.5 * * Written by Magnus Lundborg * Copyright (c) 2012-2013, The GROMACS development team. @@ -683,7 +683,7 @@ static tng_function_status tng_input_file_init(tng_trajectory_t tng_data) __FILE__, __LINE__); return(TNG_CRITICAL); } - tng_data->input_file = fopen(tng_data->input_file_path, "r"); + tng_data->input_file = fopen(tng_data->input_file_path, "rb"); if(!tng_data->input_file) { fprintf(stderr, "TNG library: Cannot open file %s. %s: %d\n", @@ -710,7 +710,7 @@ static tng_function_status tng_output_file_init(tng_trajectory_t tng_data) return(TNG_CRITICAL); } - tng_data->output_file = fopen(tng_data->output_file_path, "w+"); + tng_data->output_file = fopen(tng_data->output_file_path, "wb+"); if(!tng_data->output_file) { @@ -733,7 +733,6 @@ static tng_function_status tng_block_init(struct tng_gen_block **block_p) tng_gen_block_t block; *block_p = malloc(sizeof(struct tng_gen_block)); - if(!*block_p) { fprintf(stderr, "TNG library: Cannot allocate memory (%lu bytes). %s: %d\n", @@ -3865,7 +3864,7 @@ static tng_function_status tng_compress(tng_trajectory_t tng_data, return(TNG_FAILURE); } - f_precision = 1/tng_data->compression_precision; + f_precision = 1/(float)tng_data->compression_precision; d_precision = 1/tng_data->compression_precision; if(block->id == TNG_TRAJ_POSITIONS) @@ -4216,6 +4215,12 @@ static tng_function_status tng_gzip_compress(tng_trajectory_t tng_data, max_len = compressBound(len); dest = malloc(max_len); + if(!dest) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%ld bytes). %s: %d\n", + max_len, __FILE__, __LINE__); + return(TNG_CRITICAL); + } stat = compress(dest, &max_len, start_pos, len); if(stat != (unsigned long)Z_OK) @@ -4271,6 +4276,12 @@ static tng_function_status tng_gzip_uncompress(tng_trajectory_t tng_data, offset = (char *)start_pos - (char *)block->block_contents; dest = malloc(uncompressed_len); + if(!dest) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%lud bytes). %s: %d\n", + uncompressed_len, __FILE__, __LINE__); + return(TNG_CRITICAL); + } stat = uncompress(dest, &uncompressed_len, (Bytef *) start_pos, block->block_contents_size - offset); @@ -5448,6 +5459,11 @@ static tng_function_status tng_allocate_data_mem int64_t i, j, size, frame_alloc; (void)tng_data; + if(n_values_per_frame == 0) + { + return(TNG_FAILURE); + } + if(data->strings && data->datatype == TNG_CHAR_DATA) { for(i = data->n_frames; i--;) @@ -6242,7 +6258,6 @@ static tng_function_status tng_data_block_meta_information_read { meta_size = 3 * sizeof(char) + sizeof(double) + 6 * sizeof(int64_t); contents = malloc(meta_size); - if(!contents) { fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n", @@ -6528,6 +6543,13 @@ static tng_function_status tng_md5_hash_update(tng_trajectory_t tng_data, } block->block_contents = malloc(block->block_contents_size); + if(!block->block_contents) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%"PRId64" bytes). %s: %d\n", + block->block_contents_size, __FILE__, __LINE__); + return(TNG_CRITICAL); + } + fseek(tng_data->output_file, (long)contents_start_pos, SEEK_SET); if(fread(block->block_contents, block->block_contents_size, 1, tng_data->output_file) == 0) @@ -7047,7 +7069,7 @@ static tng_function_status tng_frame_set_finalize // } */ -tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data, +tng_function_status tng_atom_residue_get(const tng_trajectory_t tng_data, const tng_atom_t atom, tng_residue_t *residue) { @@ -7060,7 +7082,7 @@ tng_function_status tng_atom_residue_get(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_atom_name_get(tng_trajectory_t tng_data, +tng_function_status tng_atom_name_get(const tng_trajectory_t tng_data, const tng_atom_t atom, char *name, const int max_len) @@ -7114,7 +7136,7 @@ tng_function_status tng_atom_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_atom_type_get(tng_trajectory_t tng_data, +tng_function_status tng_atom_type_get(const tng_trajectory_t tng_data, const tng_atom_t atom, char *type, const int max_len) @@ -7384,7 +7406,7 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_existing_add return(TNG_SUCCESS); } -tng_function_status tng_molecule_name_get(tng_trajectory_t tng_data, +tng_function_status tng_molecule_name_get(const tng_trajectory_t tng_data, const tng_molecule_t molecule, char *name, const int max_len) @@ -7440,8 +7462,8 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set } tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, int64_t *cnt) { int64_t i, index = -1; @@ -7735,9 +7757,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_residues_get } tng_function_status DECLSPECDLLEXPORT tng_molecule_residue_of_index_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, + const int64_t index, tng_residue_t *residue) { (void) tng_data; @@ -7768,9 +7790,9 @@ tng_function_status DECLSPECDLLEXPORT tng_molecule_num_atoms_get } tng_function_status DECLSPECDLLEXPORT tng_molecule_atom_of_index_get - (tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_molecule_t molecule, + const int64_t index, tng_atom_t *atom) { (void) tng_data; @@ -8035,9 +8057,9 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_num_residues_get } tng_function_status DECLSPECDLLEXPORT tng_chain_residue_of_index_get - (tng_trajectory_t tng_data, - tng_chain_t chain, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_chain_t chain, + const int64_t index, tng_residue_t *residue) { (void) tng_data; @@ -8192,7 +8214,7 @@ tng_function_status DECLSPECDLLEXPORT tng_chain_residue_w_id_add return(stat); } -tng_function_status tng_residue_name_get(tng_trajectory_t tng_data, +tng_function_status tng_residue_name_get(const tng_trajectory_t tng_data, const tng_residue_t residue, char *name, const int max_len) @@ -8261,9 +8283,9 @@ tng_function_status DECLSPECDLLEXPORT tng_residue_num_atoms_get } tng_function_status DECLSPECDLLEXPORT tng_residue_atom_of_index_get - (tng_trajectory_t tng_data, - tng_residue_t residue, - int64_t index, + (const tng_trajectory_t tng_data, + const tng_residue_t residue, + const int64_t index, tng_atom_t *atom) { tng_chain_t chain; @@ -9590,9 +9612,23 @@ tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajector frame_set = &dest->current_trajectory_frame_set; + dest->input_file_path = malloc(strlen(src->input_file_path) + 1); + if(!dest->input_file_path) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n", + (int)strlen(src->input_file_path) + 1, __FILE__, __LINE__); + return(TNG_CRITICAL); + } strcpy(dest->input_file_path, src->input_file_path); dest->input_file = 0; dest->input_file_len = src->input_file_len; + dest->output_file_path = malloc(strlen(src->output_file_path) + 1); + if(!dest->output_file_path) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n", + (int)strlen(src->output_file_path) + 1, __FILE__, __LINE__); + return(TNG_CRITICAL); + } strcpy(dest->output_file_path, src->output_file_path); dest->output_file = 0; @@ -9818,7 +9854,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set strncpy(tng_data->output_file_path, file_name, len); - tng_data->output_file = fopen(tng_data->output_file_path, "r+"); + tng_data->output_file = fopen(tng_data->output_file_path, "rb+"); if(!tng_data->output_file) { fprintf(stderr, "TNG library: Cannot open file %s. %s: %d\n", @@ -9830,7 +9866,7 @@ tng_function_status DECLSPECDLLEXPORT tng_output_append_file_set } tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get - (tng_trajectory_t tng_data, tng_file_endianness *endianness) + (const tng_trajectory_t tng_data, tng_file_endianness *endianness) { tng_endianness_32 end_32; tng_endianness_64 end_64; @@ -10627,7 +10663,12 @@ tng_function_status DECLSPECDLLEXPORT tng_implicit_num_particles_set stat = tng_molecule_find(tng_data, "TNG_IMPLICIT_MOL", -1, &mol); if(stat == TNG_SUCCESS) { - tng_molecule_cnt_get(tng_data, mol, &n_impl); + if(tng_molecule_cnt_get(tng_data, mol, &n_impl) != TNG_SUCCESS) + { + fprintf(stderr, "TNG library: Cannot get the number of implicit molecules. %s: %d\n", + __FILE__, __LINE__); + return(TNG_FAILURE); + } diff -= n_impl * mol->n_atoms; } @@ -10838,7 +10879,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get int64_t *n) { int64_t long_stride_length, medium_stride_length; - int64_t file_pos, orig_frame_set_file_pos; + long 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; @@ -10853,18 +10894,18 @@ 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 = tng_data->first_trajectory_frame_set_input_file_pos; + file_pos = (long)tng_data->first_trajectory_frame_set_input_file_pos; tng_block_init(&block); fseek(tng_data->input_file, - (long)file_pos, + file_pos, SEEK_SET); - tng_data->current_trajectory_frame_set_input_file_pos = (long)file_pos; + 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) { - fprintf(stderr, "TNG library: Cannot read block header at pos %"PRId64". %s: %d\n", file_pos, + fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos, __FILE__, __LINE__); tng_block_destroy(&block); return(TNG_CRITICAL); @@ -10884,18 +10925,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 = frame_set->long_stride_next_frame_set_file_pos; + file_pos = (long)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, (long)file_pos, SEEK_SET); + fseek(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 %"PRId64". %s: %d\n", + fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos, __FILE__, __LINE__); tng_block_destroy(&block); return(TNG_CRITICAL); @@ -10908,25 +10949,25 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get return(TNG_CRITICAL); } } - file_pos = frame_set->long_stride_next_frame_set_file_pos; + file_pos = (long)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 = frame_set->medium_stride_next_frame_set_file_pos; + file_pos = (long)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, - (long)file_pos, + 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 %"PRId64". %s: %d\n", + fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos, __FILE__, __LINE__); tng_block_destroy(&block); return(TNG_CRITICAL); @@ -10939,24 +10980,24 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get return(TNG_CRITICAL); } } - file_pos = frame_set->medium_stride_next_frame_set_file_pos; + file_pos = (long)frame_set->medium_stride_next_frame_set_file_pos; } /* Take one step forward until the last frame set is found */ - file_pos = frame_set->next_frame_set_file_pos; + file_pos = (long)frame_set->next_frame_set_file_pos; while(file_pos > 0) { if(file_pos > 0) { ++cnt; fseek(tng_data->input_file, - (long)file_pos, + 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 %"PRId64". %s: %d\n", + fprintf(stderr, "TNG library: Cannot read block header at pos %ld. %s: %d\n", file_pos, __FILE__, __LINE__); tng_block_destroy(&block); return(TNG_CRITICAL); @@ -10969,7 +11010,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get return(TNG_CRITICAL); } } - file_pos = frame_set->next_frame_set_file_pos; + file_pos = (long)frame_set->next_frame_set_file_pos; } tng_block_destroy(&block); @@ -10988,7 +11029,7 @@ tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get } tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, tng_trajectory_frame_set_t *frame_set_p) { TNG_ASSERT(tng_data, "TNG library: Trajectory container not properly setup."); @@ -12621,7 +12662,7 @@ tng_function_status DECLSPECDLLEXPORT tng_frame_set_first_frame_time_set } tng_function_status DECLSPECDLLEXPORT tng_first_frame_nr_of_next_frame_set_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t *frame) { long file_pos, next_frame_set_file_pos; @@ -13096,7 +13137,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_name_get } tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t block_id, int *block_dependency) { @@ -13170,7 +13211,7 @@ tng_function_status DECLSPECDLLEXPORT tng_data_block_dependency_get } tng_function_status DECLSPECDLLEXPORT tng_data_block_num_values_per_frame_get - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, int64_t block_id, int64_t *n_values_per_frame) { @@ -15958,7 +15999,7 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get } tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length - (tng_trajectory_t tng_data, + (const tng_trajectory_t tng_data, const int64_t block_id, int64_t frame, int64_t *stride_length) @@ -18104,7 +18145,7 @@ tng_function_status DECLSPECDLLEXPORT tng_util_box_shape_with_time_double_write tng_function_status DECLSPECDLLEXPORT tng_util_frame_current_compression_get (tng_trajectory_t tng_data, const int64_t block_id, - char *codec_id, + int64_t *codec_id, float *factor) { tng_trajectory_frame_set_t frame_set; @@ -18202,12 +18243,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 = p_data->compression_multiplier; + *factor = (float)p_data->compression_multiplier; } else if(block_type == TNG_NON_PARTICLE_BLOCK_DATA) { *codec_id = np_data->codec_id; - *factor = np_data->compression_multiplier; + *factor = (float)np_data->compression_multiplier; } return(TNG_SUCCESS); } diff --git a/src/external/tng_io/src/lib/tng_io_fortran.c b/src/external/tng_io/src/lib/tng_io_fortran.c index f6101bee3a..baceef75d1 100644 --- a/src/external/tng_io/src/lib/tng_io_fortran.c +++ b/src/external/tng_io/src/lib/tng_io_fortran.c @@ -1,6 +1,6 @@ /* This code is part of the tng binary trajectory format. * - * VERSION 1.4 + * VERSION 1.5 * * Written by Magnus Lundborg * Copyright (c) 2012-2013, The GROMACS development team. diff --git a/src/external/tng_io/src/tests/CMakeLists.txt b/src/external/tng_io/src/tests/CMakeLists.txt index a0cfc46c17..f465b6b7c0 100644 --- a/src/external/tng_io/src/tests/CMakeLists.txt +++ b/src/external/tng_io/src/tests/CMakeLists.txt @@ -23,7 +23,10 @@ if(TNG_BUILD_TEST) endif() if(TNG_BUILD_EXAMPLES) - if(TNG_USE_OPENMP AND OPENMP_FOUND) + find_package(OpenMP) + if(OPENMP_FOUND) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") add_executable(md_openmp md_openmp.c) target_link_libraries(md_openmp tng_io ${OpenMP_LIBS}) diff --git a/src/external/tng_io/src/tests/md_openmp.c b/src/external/tng_io/src/tests/md_openmp.c index 449810de43..b57eff41c8 100644 --- a/src/external/tng_io/src/tests/md_openmp.c +++ b/src/external/tng_io/src/tests/md_openmp.c @@ -127,11 +127,7 @@ int main () printf(" Cannot init trajectory.\n"); exit(1); } -#ifdef TNG_EXAMPLE_FILES_DIR tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_md_out.tng"); -#else - tng_output_file_set(traj, "/tmp/tng_md_out.tng"); -#endif diff --git a/src/external/tng_io/src/tests/md_openmp.f b/src/external/tng_io/src/tests/md_openmp.f index de05ca27bb..87b00b8597 100644 --- a/src/external/tng_io/src/tests/md_openmp.f +++ b/src/external/tng_io/src/tests/md_openmp.f @@ -161,7 +161,7 @@ c c c N.B. The TNG output file should be modified according to needs c - call tng_output_file_set(traj, "/tmp/tng_md_out_f77.tng") + call tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_md_out_f77.tng") write ( *, '(a)' ) ' Creating molecules in trajectory.' tng_n_particles = np diff --git a/src/external/tng_io/src/tests/md_openmp_util.c b/src/external/tng_io/src/tests/md_openmp_util.c index 006d2921cc..34b8964144 100644 --- a/src/external/tng_io/src/tests/md_openmp_util.c +++ b/src/external/tng_io/src/tests/md_openmp_util.c @@ -120,11 +120,7 @@ int main () printf("\n"); printf(" Initializing trajectory storage.\n"); /* Initialize the TNG trajectory */ -#ifdef TNG_EXAMPLE_FILES_DIR tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_md_out.tng", 'w', &traj); -#else - tng_util_trajectory_open("/tmp/tng_md_out.tng", 'w', &traj); -#endif diff --git a/src/external/tng_io/src/tests/tng_io_testing.c b/src/external/tng_io/src/tests/tng_io_testing.c index 8d8a68aa39..973ac4fb7b 100644 --- a/src/external/tng_io/src/tests/tng_io_testing.c +++ b/src/external/tng_io/src/tests/tng_io_testing.c @@ -474,11 +474,7 @@ static tng_function_status tng_test_write_and_read_traj(tng_trajectory_t *traj) tng_trajectory_destroy(traj); tng_trajectory_init(traj); -#ifdef TNG_EXAMPLE_FILES_DIR tng_input_file_set(*traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng"); -#else - tng_input_file_set(*traj, "/tmp/tng_test.tng"); -#endif stat = tng_file_headers_read(*traj, TNG_SKIP_HASH); @@ -592,13 +588,8 @@ int main() printf("Creation time: %s\n", time_str); -#ifdef TNG_EXAMPLE_FILES_DIR tng_input_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example.tng"); tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_example_out.tng"); -#else - tng_input_file_set(traj, "tng_example.tng"); - tng_output_file_set(traj, "/tmp/tng_example_out.tng"); -#endif if(tng_test_read_and_write_file(traj) == TNG_CRITICAL) @@ -633,11 +624,7 @@ int main() } -#ifdef TNG_EXAMPLE_FILES_DIR tng_output_file_set(traj, TNG_EXAMPLE_FILES_DIR "tng_test.tng"); -#else - tng_output_file_set(traj, "/tmp/tng_test.tng"); -#endif if(tng_test_write_and_read_traj(&traj) == TNG_CRITICAL) { @@ -671,11 +658,8 @@ int main() } -#ifdef TNG_EXAMPLE_FILES_DIR stat = tng_util_trajectory_open(TNG_EXAMPLE_FILES_DIR "tng_test.tng", 'r', &traj); -#else - stat = tng_util_trajectory_open("/tmp/tng_test.tng", 'r', &traj); -#endif + if(stat != TNG_SUCCESS) { printf("Test Utility function open:\t\t\tFailed. %s: %d.\n", diff --git a/src/gromacs/fileio/tngio_for_tools.cpp b/src/gromacs/fileio/tngio_for_tools.cpp index 9d74bcd7e0..04ac5169d6 100644 --- a/src/gromacs/fileio/tngio_for_tools.cpp +++ b/src/gromacs/fileio/tngio_for_tools.cpp @@ -421,8 +421,8 @@ gmx_bool gmx_read_next_tng_frame(tng_trajectory_t input, gmx_bool bOK = TRUE; tng_function_status stat; gmx_int64_t numberOfAtoms = -1, frameNumber = -1; - gmx_int64_t nBlocks, blockId, *blockIds = NULL; - char datatype = -1, codecId; + gmx_int64_t nBlocks, blockId, *blockIds = NULL, codecId; + char datatype = -1; void *values = NULL; double frameTime = -1.0; int size, blockDependency; @@ -773,7 +773,8 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t input, { #ifdef GMX_USE_TNG tng_function_status stat; - char datatype = -1, codecId; + char datatype = -1; + gmx_int64_t codecId; int blockDependency; void *data = 0; float localPrec; -- 2.22.0