From e70cadd9f3f6494ad55efa5e917a12cf18c60d26 Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Thu, 16 May 2013 10:55:44 +0200 Subject: Separated quantization and compression/uncompression more, to allow compression/uncompression of float data. Also added compression/uncompression of integer data, which will allow for recompression. diff --git a/include/compression/tng_compress.h b/include/compression/tng_compress.h index eefcfaa..14786d1 100644 --- a/include/compression/tng_compress.h +++ b/include/compression/tng_compress.h @@ -52,7 +52,16 @@ char DECLSPECDLLEXPORT *tng_compress_pos(double *pos, int natoms, int nframes, double desired_precision, int speed, int *algo, int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_pos_float(float *pos, int natoms, int nframes, + float desired_precision, + int speed, int *algo, + int *nitems); +char DECLSPECDLLEXPORT *tng_compress_pos_int(int *pos, int natoms, int nframes, + unsigned long prec_hi, unsigned long prec_lo, + int speed,int *algo, + int *nitems); /* The tng_compress_pos_find_algo works the same as tng_compress_pos, but it performs benchmarking to find the algorithms with the best @@ -84,6 +93,17 @@ char DECLSPECDLLEXPORT *tng_compress_pos_find_algo(double *pos, int natoms, int int speed, int *algo, int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_pos_float_find_algo(float *pos, int natoms, int nframes, + float desired_precision, + int speed, + int *algo, + int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_pos_int_find_algo(int *pos, int natoms, int nframes, + unsigned long prec_hi, unsigned long prec_lo, + int speed,int *algo, + int *nitems); /* This returns the number of integers required for the storage of the algorithm with the best compression ratio. */ @@ -98,6 +118,16 @@ char DECLSPECDLLEXPORT *tng_compress_vel(double *vel, int natoms, int nframes, double desired_precision, int speed, int *algo, int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_vel_float(float *vel, int natoms, int nframes, + float desired_precision, + int speed, int *algo, + int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_vel_int(int *vel, int natoms, int nframes, + unsigned long prec_hi, unsigned long prec_lo, + int speed, int *algo, + int *nitems); char DECLSPECDLLEXPORT *tng_compress_vel_find_algo(double *vel, int natoms, int nframes, double desired_precision, @@ -105,6 +135,18 @@ char DECLSPECDLLEXPORT *tng_compress_vel_find_algo(double *vel, int natoms, int int *algo, int *nitems); +char DECLSPECDLLEXPORT *tng_compress_vel_float_find_algo(float *vel, int natoms, int nframes, + float desired_precision, + int speed, + int *algo, + int *nitems); + +char DECLSPECDLLEXPORT *tng_compress_vel_int_find_algo(int *vel, int natoms, int nframes, + unsigned long prec_hi, unsigned long prec_lo, + int speed, + int *algo, + int *nitems); + /* From a compressed block, obtain information about whether it is a position or velocity block: *vel=1 means velocity block, *vel=0 means position block. @@ -120,6 +162,10 @@ int DECLSPECDLLEXPORT tng_compress_inquire(char *data,int *vel, int *natoms, */ int DECLSPECDLLEXPORT tng_compress_uncompress(char *data,double *posvel); +int DECLSPECDLLEXPORT tng_compress_uncompress_float(char *data,float *posvel); + +int DECLSPECDLLEXPORT tng_compress_uncompress_int(char *data,int *posvel, unsigned long *prec_hi, unsigned long *prec_lo); + /* Compression algorithms (matching the original trajng assignments) The compression backends require that some of the diff --git a/src/compression/tng_compress.c b/src/compression/tng_compress.c index e92f24d..ed3fca9 100644 --- a/src/compression/tng_compress.c +++ b/src/compression/tng_compress.c @@ -37,13 +37,17 @@ static void quantize(double *x, int natoms, int nframes, for (i=0; i1) @@ -1447,14 +1684,24 @@ static int tng_compress_uncompress_vel(char *data,double *vel) (coding==TNG_COMPRESS_ALGO_VEL_BWLZH_INTER)) { /* This requires that the first frame is already in one-to-one format. */ - unquantize_inter_differences(vel,natoms,nframes,PRECISION(prec_hi,prec_lo),quant); + if (veld) + unquantize_inter_differences(veld,natoms,nframes,PRECISION(*prec_hi,*prec_lo),quant); + else if (velf) + unquantize_inter_differences_float(velf,natoms,nframes,(float)PRECISION(*prec_hi,*prec_lo),quant); + else if (veli) + unquantize_inter_differences_int(veli,natoms,nframes,quant); } /* One-to-one compression? */ else if ((coding==TNG_COMPRESS_ALGO_VEL_STOPBIT_ONETOONE) || (coding==TNG_COMPRESS_ALGO_VEL_TRIPLET_ONETOONE) || (coding==TNG_COMPRESS_ALGO_VEL_BWLZH_ONETOONE)) { - unquantize(vel+natoms*3,natoms,nframes-1,PRECISION(prec_hi,prec_lo),quant+natoms*3); + if (veld) + unquantize(veld+natoms*3,natoms,nframes-1,PRECISION(*prec_hi,*prec_lo),quant+natoms*3); + else if (velf) + unquantize_float(velf+natoms*3,natoms,nframes-1,(float)PRECISION(*prec_hi,*prec_lo),quant+natoms*3); + else if (veli) + memcpy(veli+natoms*3,quant+natoms*3,natoms*3*(nframes-1)*sizeof *veli); } } error: @@ -1462,6 +1709,23 @@ static int tng_compress_uncompress_vel(char *data,double *vel) return rval; } +static int tng_compress_uncompress_vel(char *data,double *vel) +{ + unsigned long prec_hi, prec_lo; + return tng_compress_uncompress_vel_gen(data,vel,NULL,NULL,&prec_hi,&prec_lo); +} + +static int tng_compress_uncompress_vel_float(char *data,float *vel) +{ + unsigned long prec_hi, prec_lo; + return tng_compress_uncompress_vel_gen(data,NULL,vel,NULL,&prec_hi,&prec_lo); +} + +static int tng_compress_uncompress_vel_int(char *data,int *vel, unsigned long *prec_hi, unsigned long *prec_lo) +{ + return tng_compress_uncompress_vel_gen(data,NULL,NULL,vel,prec_hi,prec_lo); +} + /* Uncompresses any tng compress block, positions or velocities. It determines whether it is positions or velocities from the data buffer. The return value is 0 if ok, and 1 if not. */ int DECLSPECDLLEXPORT tng_compress_uncompress(char *data,double *posvel) @@ -1476,6 +1740,30 @@ int DECLSPECDLLEXPORT tng_compress_uncompress(char *data,double *posvel) return 1; } +int DECLSPECDLLEXPORT tng_compress_uncompress_float(char *data,float *posvel) +{ + int magic_int; + magic_int=(int)readbufferfix((unsigned char *)data,4); + if (magic_int==MAGIC_INT_POS) + return tng_compress_uncompress_pos_float(data,posvel); + else if (magic_int==MAGIC_INT_VEL) + return tng_compress_uncompress_vel_float(data,posvel); + else + return 1; +} + +int DECLSPECDLLEXPORT tng_compress_uncompress_int(char *data,int *posvel, unsigned long *prec_hi, unsigned long *prec_lo) +{ + int magic_int; + magic_int=(int)readbufferfix((unsigned char *)data,4); + if (magic_int==MAGIC_INT_POS) + return tng_compress_uncompress_pos_int(data,posvel,prec_hi,prec_lo); + else if (magic_int==MAGIC_INT_VEL) + return tng_compress_uncompress_vel_int(data,posvel,prec_hi,prec_lo); + else + return 1; +} + static char *compress_algo_pos[TNG_COMPRESS_ALGO_MAX]={ "Positions invalid algorithm", "Positions stopbits interframe", -- cgit v0.10.1 From 3fed6f767da30a5436c3667576eb9e4f5fa24f6d Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Thu, 16 May 2013 14:08:54 +0200 Subject: Properly compile the tng_compress testsuite using cmake. diff --git a/include/compression/tng_compress_testing.h.in b/include/compression/tng_compress_testing.h.in new file mode 100644 index 0000000..168764b --- /dev/null +++ b/include/compression/tng_compress_testing.h.in @@ -0,0 +1,6 @@ +#ifndef TNG_COMPRESS_TESTING_H +#define TNG_COMPRESS_TESTING_H + +#define TNG_COMPRESS_FILES_DIR "@TNG_COMPRESS_FILES_DIR@" + +#endif diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index e69de29..15b059b 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -0,0 +1,36 @@ +link_directories(${TRAJECTORY_BINARY_DIR}/src/lib) + +set(TNG_COMPRESS_FILES_DIR ${CMAKE_BINARY_DIR}/test_tng_compress_files/ CACHE STRING "Directory where to write tng_compress test files.") + +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test_tng_compress_files) +configure_file(${TRAJECTORY_SOURCE_DIR}/include/compression/tng_compress_testing.h.in ${CMAKE_BINARY_DIR}/generated/tng_compress_testing.h) + +include_directories(${CMAKE_SOURCE_DIR}/include/compression) +include_directories(${CMAKE_BINARY_DIR}/generated/) + +set(number 0) +set(numtests 59) + +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 m) +list(APPEND gen${number}_build_definitions GEN) +list(APPEND gen${number}_build_definitions TESTPARAM="test${number}.h") +set_target_properties(test_tng_compress_gen${number} PROPERTIES COMPILE_DEFINITIONS "${gen${number}_build_definitions}") +add_dependencies(test_tng_compress_gen${number} test${number}.h) + +add_executable(test_tng_compress_read${number} testsuite.c) +target_link_libraries(test_tng_compress_read${number} tng_compress m) +list(APPEND read${number}_build_definitions TESTPARAM="test${number}.h") +set_target_properties(test_tng_compress_read${number} PROPERTIES COMPILE_DEFINITIONS "${read${number}_build_definitions}") +add_dependencies(test_tng_compress_read${number} test${number}.h) + +endwhile() + +file(COPY test_tng_compress_write.sh DESTINATION ${CMAKE_BINARY_DIR}/bin) +file(COPY test_tng_compress_read.sh DESTINATION ${CMAKE_BINARY_DIR}/bin) +file(COPY test_tng_compress_write.bat DESTINATION ${CMAKE_BINARY_DIR}/bin) +file(COPY test_tng_compress_read.bat DESTINATION ${CMAKE_BINARY_DIR}/bin) diff --git a/src/tests/compression/test1.h b/src/tests/compression/test1.h index ad802e0..b45abc4 100644 --- a/src/tests/compression/test1.h +++ b/src/tests/compression/test1.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Intra frame triple algorithm. Cubic cell." -#define FILENAME "test1.tng" +#define FILENAME "test1.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test10.h b/src/tests/compression/test10.h index 471dcab..d5135eb 100644 --- a/src/tests/compression/test10.h +++ b/src/tests/compression/test10.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Triple intraframe algorithm. Cubic cell." -#define FILENAME "test10.tng" +#define FILENAME "test10.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test11.h b/src/tests/compression/test11.h index b9d7039..596d63c 100644 --- a/src/tests/compression/test11.h +++ b/src/tests/compression/test11.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Triple one-to-one algorithm. Cubic cell." -#define FILENAME "test11.tng" +#define FILENAME "test11.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test12.h b/src/tests/compression/test12.h index 5d692d8..43eb15d 100644 --- a/src/tests/compression/test12.h +++ b/src/tests/compression/test12.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. BWLZH interframe algorithm. Cubic cell." -#define FILENAME "test12.tng" +#define FILENAME "test12.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test13.h b/src/tests/compression/test13.h index b650f91..72aa99e 100644 --- a/src/tests/compression/test13.h +++ b/src/tests/compression/test13.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. BWLZH intraframe algorithm. Cubic cell." -#define FILENAME "test13.tng" +#define FILENAME "test13.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test14.h b/src/tests/compression/test14.h index 0db6853..382c70e 100644 --- a/src/tests/compression/test14.h +++ b/src/tests/compression/test14.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. XTC3 algorithm. Cubic cell." -#define FILENAME "test14.tng" +#define FILENAME "test14.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test15.h b/src/tests/compression/test15.h index 35f94ba..c593bf5 100644 --- a/src/tests/compression/test15.h +++ b/src/tests/compression/test15.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Automatic selection of algorithms. Cubic cell." -#define FILENAME "test15.tng" +#define FILENAME "test15.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test16.h b/src/tests/compression/test16.h index 5f972cb..a29c5e5 100644 --- a/src/tests/compression/test16.h +++ b/src/tests/compression/test16.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Automatic selection of algorithms. Cubic cell." -#define FILENAME "test16.tng" +#define FILENAME "test16.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test17.h b/src/tests/compression/test17.h index 226e34c..9787976 100644 --- a/src/tests/compression/test17.h +++ b/src/tests/compression/test17.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding of velocities. Stopbits one-to-one . Cubic cell." -#define FILENAME "test17.tng" +#define FILENAME "test17.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test18.h b/src/tests/compression/test18.h index 1248a6d..5a329ad 100644 --- a/src/tests/compression/test18.h +++ b/src/tests/compression/test18.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding of velocities. Triplet one-to-one. Cubic cell." -#define FILENAME "test18.tng" +#define FILENAME "test18.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test19.h b/src/tests/compression/test19.h index ac09bc2..b298309 100644 --- a/src/tests/compression/test19.h +++ b/src/tests/compression/test19.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding of velocities. BWLZH one-to-one. Cubic cell." -#define FILENAME "test19.tng" +#define FILENAME "test19.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test2.h b/src/tests/compression/test2.h index f2a0f9a..0e2c3b0 100644 --- a/src/tests/compression/test2.h +++ b/src/tests/compression/test2.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC2 algorithm. Cubic cell." -#define FILENAME "test2.tng" +#define FILENAME "test2.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test20.h b/src/tests/compression/test20.h index 7df8f09..4a45135 100644 --- a/src/tests/compression/test20.h +++ b/src/tests/compression/test20.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. Stopbit one-to-one. Cubic cell." -#define FILENAME "test20.tng" +#define FILENAME "test20.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test21.h b/src/tests/compression/test21.h index 2ea2353..773c1da 100644 --- a/src/tests/compression/test21.h +++ b/src/tests/compression/test21.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. Triplet inter. Cubic cell." -#define FILENAME "test21.tng" +#define FILENAME "test21.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test22.h b/src/tests/compression/test22.h index 8b16428..1d8cfa9 100644 --- a/src/tests/compression/test22.h +++ b/src/tests/compression/test22.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. Triplet one-to-one. Cubic cell." -#define FILENAME "test22.tng" +#define FILENAME "test22.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test23.h b/src/tests/compression/test23.h index 85025d6..950f7ee 100644 --- a/src/tests/compression/test23.h +++ b/src/tests/compression/test23.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. Stopbit interframe. Cubic cell." -#define FILENAME "test23.tng" +#define FILENAME "test23.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test24.h b/src/tests/compression/test24.h index dae943c..4b20897 100644 --- a/src/tests/compression/test24.h +++ b/src/tests/compression/test24.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. BWLZH interframe. Cubic cell." -#define FILENAME "test24.tng" +#define FILENAME "test24.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 25 diff --git a/src/tests/compression/test25.h b/src/tests/compression/test25.h index 6145cb9..37d777a 100644 --- a/src/tests/compression/test25.h +++ b/src/tests/compression/test25.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding of velocities. BWLZH one-to-one. Cubic cell." -#define FILENAME "test25.tng" +#define FILENAME "test25.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 25 diff --git a/src/tests/compression/test26.h b/src/tests/compression/test26.h index 74523ad..2c3b304 100644 --- a/src/tests/compression/test26.h +++ b/src/tests/compression/test26.h @@ -1,5 +1,5 @@ #define TESTNAME "XTC2 algorithm. Orthorhombic cell." -#define FILENAME "test26.tng" +#define FILENAME "test26.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test27.h b/src/tests/compression/test27.h index 30aea07..af7c9ff 100644 --- a/src/tests/compression/test27.h +++ b/src/tests/compression/test27.h @@ -1,5 +1,5 @@ #define TESTNAME "XTC3 algorithm. Orthorhombic cell." -#define FILENAME "test27.tng" +#define FILENAME "test27.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test28.h b/src/tests/compression/test28.h index 995b81c..99a70fc 100644 --- a/src/tests/compression/test28.h +++ b/src/tests/compression/test28.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Autoselect algorithm. Repetitive molecule. Cubic cell." -#define FILENAME "test28.tng" +#define FILENAME "test28.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test29.h b/src/tests/compression/test29.h index f48f909..be6a8bf 100644 --- a/src/tests/compression/test29.h +++ b/src/tests/compression/test29.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Autoselect algorithm. Repetitive molecule. Cubic cell." -#define FILENAME "test29.tng" +#define FILENAME "test29.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test3.h b/src/tests/compression/test3.h index c4bbebd..768a208 100644 --- a/src/tests/compression/test3.h +++ b/src/tests/compression/test3.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Triplet one-to-one algorithm. Cubic cell." -#define FILENAME "test3.tng" +#define FILENAME "test3.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test30.h b/src/tests/compression/test30.h index 2ea607b..b719c7b 100644 --- a/src/tests/compression/test30.h +++ b/src/tests/compression/test30.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Intra frame triple algorithm. Large system. Cubic cell." -#define FILENAME "test30.tng" +#define FILENAME "test30.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 1 diff --git a/src/tests/compression/test31.h b/src/tests/compression/test31.h index d5d86d4..c0763e8 100644 --- a/src/tests/compression/test31.h +++ b/src/tests/compression/test31.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC2 algorithm. Large system. Cubic cell." -#define FILENAME "test31.tng" +#define FILENAME "test31.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 1 diff --git a/src/tests/compression/test32.h b/src/tests/compression/test32.h index 7b66438..5f2e2f9 100644 --- a/src/tests/compression/test32.h +++ b/src/tests/compression/test32.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC3 algorithm. Large system. Cubic cell." -#define FILENAME "test32.tng" +#define FILENAME "test32.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 1 diff --git a/src/tests/compression/test33.h b/src/tests/compression/test33.h index 9463eeb..3d08a65 100644 --- a/src/tests/compression/test33.h +++ b/src/tests/compression/test33.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Intra frame BWLZH algorithm. Large system. Cubic cell." -#define FILENAME "test33.tng" +#define FILENAME "test33.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 1 diff --git a/src/tests/compression/test34.h b/src/tests/compression/test34.h index 14fe88f..4242c18 100644 --- a/src/tests/compression/test34.h +++ b/src/tests/compression/test34.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Stop bits algorithm. Large system. Cubic cell." -#define FILENAME "test34.tng" +#define FILENAME "test34.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test35.h b/src/tests/compression/test35.h index 44af4c4..8f742b7 100644 --- a/src/tests/compression/test35.h +++ b/src/tests/compression/test35.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Inter frame triple algorithm. Large system. Cubic cell." -#define FILENAME "test35.tng" +#define FILENAME "test35.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test36.h b/src/tests/compression/test36.h index 56f5dcd..fba6feb 100644 --- a/src/tests/compression/test36.h +++ b/src/tests/compression/test36.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Intra frame triple algorithm. Large system. Cubic cell." -#define FILENAME "test36.tng" +#define FILENAME "test36.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test37.h b/src/tests/compression/test37.h index 68b4872..d2722bf 100644 --- a/src/tests/compression/test37.h +++ b/src/tests/compression/test37.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. XTC2 algorithm. Large system. Cubic cell." -#define FILENAME "test37.tng" +#define FILENAME "test37.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test38.h b/src/tests/compression/test38.h index 7e43348..26a6740 100644 --- a/src/tests/compression/test38.h +++ b/src/tests/compression/test38.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. XTC3 algorithm. Large system. Cubic cell." -#define FILENAME "test38.tng" +#define FILENAME "test38.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test39.h b/src/tests/compression/test39.h index bb3ecc0..db09a18 100644 --- a/src/tests/compression/test39.h +++ b/src/tests/compression/test39.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Intra frame BWLZH algorithm. Large system. Cubic cell." -#define FILENAME "test39.tng" +#define FILENAME "test39.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test4.h b/src/tests/compression/test4.h index 63ec9da..dfda25d 100644 --- a/src/tests/compression/test4.h +++ b/src/tests/compression/test4.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. BWLZH one-to-one algorithm. Cubic cell." -#define FILENAME "test4.tng" +#define FILENAME "test4.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test40.h b/src/tests/compression/test40.h index 5eb9c0d..c7511e5 100644 --- a/src/tests/compression/test40.h +++ b/src/tests/compression/test40.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Inter frame BWLZH algorithm. Large system. Cubic cell." -#define FILENAME "test40.tng" +#define FILENAME "test40.tng_compress" #define ALGOTEST #define NATOMS 5000000 #define CHUNKY 2 diff --git a/src/tests/compression/test41.h b/src/tests/compression/test41.h index f673944..dab390c 100644 --- a/src/tests/compression/test41.h +++ b/src/tests/compression/test41.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Intra frame triple algorithm. High accuracy. Cubic cell." -#define FILENAME "test41.tng" +#define FILENAME "test41.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 1 diff --git a/src/tests/compression/test42.h b/src/tests/compression/test42.h index b40f963..4452924 100644 --- a/src/tests/compression/test42.h +++ b/src/tests/compression/test42.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC2 algorithm. High accuracy. Cubic cell." -#define FILENAME "test42.tng" +#define FILENAME "test42.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 1 diff --git a/src/tests/compression/test43.h b/src/tests/compression/test43.h index 38a59db..915d58e 100644 --- a/src/tests/compression/test43.h +++ b/src/tests/compression/test43.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC3 algorithm. High accuracy. Cubic cell." -#define FILENAME "test43.tng" +#define FILENAME "test43.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 1 diff --git a/src/tests/compression/test44.h b/src/tests/compression/test44.h index 0bab871..f749cce 100644 --- a/src/tests/compression/test44.h +++ b/src/tests/compression/test44.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. Intra frame BWLZH algorithm. High accuracy. Cubic cell." -#define FILENAME "test44.tng" +#define FILENAME "test44.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 1 diff --git a/src/tests/compression/test45.h b/src/tests/compression/test45.h index 095efed..e558083 100644 --- a/src/tests/compression/test45.h +++ b/src/tests/compression/test45.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Stop bits algorithm. High accuracy. Cubic cell." -#define FILENAME "test45.tng" +#define FILENAME "test45.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test46.h b/src/tests/compression/test46.h index dc0b8bb..dde45ab 100644 --- a/src/tests/compression/test46.h +++ b/src/tests/compression/test46.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Inter frame triple algorithm. High accuracy. Cubic cell." -#define FILENAME "test46.tng" +#define FILENAME "test46.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test47.h b/src/tests/compression/test47.h index 5a5182d..a668946 100644 --- a/src/tests/compression/test47.h +++ b/src/tests/compression/test47.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Intra frame triple algorithm. High accuracy. Cubic cell." -#define FILENAME "test47.tng" +#define FILENAME "test47.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test48.h b/src/tests/compression/test48.h index 1562779..3b2be95 100644 --- a/src/tests/compression/test48.h +++ b/src/tests/compression/test48.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. XTC2 algorithm. High accuracy. Cubic cell." -#define FILENAME "test48.tng" +#define FILENAME "test48.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test49.h b/src/tests/compression/test49.h index dcad4ec..6c618a0 100644 --- a/src/tests/compression/test49.h +++ b/src/tests/compression/test49.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. XTC3 algorithm. High accuracy. Cubic cell." -#define FILENAME "test49.tng" +#define FILENAME "test49.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test5.h b/src/tests/compression/test5.h index a933044..4c6a638 100644 --- a/src/tests/compression/test5.h +++ b/src/tests/compression/test5.h @@ -1,5 +1,5 @@ #define TESTNAME "Initial coding. XTC3 algorithm. Cubic cell." -#define FILENAME "test5.tng" +#define FILENAME "test5.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 1 diff --git a/src/tests/compression/test50.h b/src/tests/compression/test50.h index a00e209..130f1b9 100644 --- a/src/tests/compression/test50.h +++ b/src/tests/compression/test50.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Intra frame BWLZH algorithm. High accuracy. Cubic cell." -#define FILENAME "test50.tng" +#define FILENAME "test50.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test51.h b/src/tests/compression/test51.h index 4641b61..c3a57bf 100644 --- a/src/tests/compression/test51.h +++ b/src/tests/compression/test51.h @@ -1,5 +1,5 @@ #define TESTNAME "Position coding. Inter frame BWLZH algorithm. High accuracy. Cubic cell." -#define FILENAME "test51.tng" +#define FILENAME "test51.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test52.h b/src/tests/compression/test52.h index 2f49a8b..97f37c7 100644 --- a/src/tests/compression/test52.h +++ b/src/tests/compression/test52.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Stop bits algorithm. High accuracy. Cubic cell." -#define FILENAME "test52.tng" +#define FILENAME "test52.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test53.h b/src/tests/compression/test53.h index 679b680..583e0b2 100644 --- a/src/tests/compression/test53.h +++ b/src/tests/compression/test53.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Triple algorithm. High accuracy. Cubic cell." -#define FILENAME "test53.tng" +#define FILENAME "test53.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test54.h b/src/tests/compression/test54.h index c2c2869..50b051f 100644 --- a/src/tests/compression/test54.h +++ b/src/tests/compression/test54.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Interframe triple algorithm. High accuracy. Cubic cell." -#define FILENAME "test54.tng" +#define FILENAME "test54.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test55.h b/src/tests/compression/test55.h index a094d97..f8c98f9 100644 --- a/src/tests/compression/test55.h +++ b/src/tests/compression/test55.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Interframe stop-bits algorithm. High accuracy. Cubic cell." -#define FILENAME "test55.tng" +#define FILENAME "test55.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test56.h b/src/tests/compression/test56.h index 6655ad0..7fb9b23 100644 --- a/src/tests/compression/test56.h +++ b/src/tests/compression/test56.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Intraframe BWLZH algorithm. High accuracy. Cubic cell." -#define FILENAME "test56.tng" +#define FILENAME "test56.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test57.h b/src/tests/compression/test57.h index 2788e98..5c626d8 100644 --- a/src/tests/compression/test57.h +++ b/src/tests/compression/test57.h @@ -1,5 +1,5 @@ #define TESTNAME "Velocity coding. Interframe BWLZH algorithm. High accuracy. Cubic cell." -#define FILENAME "test57.tng" +#define FILENAME "test57.tng_compress" #define ALGOTEST #define NATOMS 100000 #define CHUNKY 10 diff --git a/src/tests/compression/test58.h b/src/tests/compression/test58.h new file mode 100644 index 0000000..18be47f --- /dev/null +++ b/src/tests/compression/test58.h @@ -0,0 +1,26 @@ +#define TESTNAME "Coding. Test float." +#define FILENAME "test58.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#define TEST_FLOAT +#define EXPECTED_FILESIZE 7237102. diff --git a/src/tests/compression/test59.h b/src/tests/compression/test59.h new file mode 100644 index 0000000..0b6079e --- /dev/null +++ b/src/tests/compression/test59.h @@ -0,0 +1,28 @@ +#define TESTNAME "Coding. Test write float, read double." +#define FILENAME "test59.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#ifdef GEN +#define TEST_FLOAT +#endif +#define EXPECTED_FILESIZE 7237102. diff --git a/src/tests/compression/test6.h b/src/tests/compression/test6.h index cd3cfee..ecbc443 100644 --- a/src/tests/compression/test6.h +++ b/src/tests/compression/test6.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. XTC2 algorithm. Cubic cell." -#define FILENAME "test6.tng" +#define FILENAME "test6.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test7.h b/src/tests/compression/test7.h index 90a2657..d0e3532 100644 --- a/src/tests/compression/test7.h +++ b/src/tests/compression/test7.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Stopbit interframe algorithm. Cubic cell." -#define FILENAME "test7.tng" +#define FILENAME "test7.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test8.h b/src/tests/compression/test8.h index 5a21053..2ce103c 100644 --- a/src/tests/compression/test8.h +++ b/src/tests/compression/test8.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Stopbit interframe algorithm with intraframe compression as initial. Cubic cell." -#define FILENAME "test8.tng" +#define FILENAME "test8.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test9.h b/src/tests/compression/test9.h index 1247beb..f0672e2 100644 --- a/src/tests/compression/test9.h +++ b/src/tests/compression/test9.h @@ -1,5 +1,5 @@ #define TESTNAME "Coding. Triple interframe algorithm. Cubic cell." -#define FILENAME "test9.tng" +#define FILENAME "test9.tng_compress" #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 diff --git a/src/tests/compression/test_tng_compress_read.bat b/src/tests/compression/test_tng_compress_read.bat new file mode 100644 index 0000000..01873f8 --- /dev/null +++ b/src/tests/compression/test_tng_compress_read.bat @@ -0,0 +1,13 @@ +@echo off +setlocal enableextensions enabledelayedexpansion +SET /A I=0 +:start +SET /A I+=1 +test_tng_compress_read%I% +IF "%I%" == "57" ( + GOTO end +) ELSE ( + GOTO start +) +:end +endlocal diff --git a/src/tests/compression/test_tng_compress_read.sh b/src/tests/compression/test_tng_compress_read.sh new file mode 100755 index 0000000..76f9193 --- /dev/null +++ b/src/tests/compression/test_tng_compress_read.sh @@ -0,0 +1,5 @@ +#!/bin/sh +numtests=57 +for x in $(seq 1 $numtests); do + ./test_tng_compress_read$x +done \ No newline at end of file diff --git a/src/tests/compression/test_tng_compress_write.bat b/src/tests/compression/test_tng_compress_write.bat new file mode 100644 index 0000000..ba1d93e --- /dev/null +++ b/src/tests/compression/test_tng_compress_write.bat @@ -0,0 +1,13 @@ +@echo off +setlocal enableextensions enabledelayedexpansion +SET /A I=0 +:start +SET /A I+=1 +test_tng_compress_gen%I% +IF "%I%" == "57" ( + GOTO end +) ELSE ( + GOTO start +) +:end +endlocal diff --git a/src/tests/compression/test_tng_compress_write.sh b/src/tests/compression/test_tng_compress_write.sh new file mode 100755 index 0000000..8f0ef01 --- /dev/null +++ b/src/tests/compression/test_tng_compress_write.sh @@ -0,0 +1,5 @@ +#!/bin/sh +numtests=57 +for x in $(seq 1 $numtests); do + ./test_tng_compress_gen$x +done \ No newline at end of file diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c index 1c5b613..cc38cb6 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -9,9 +9,19 @@ #include #include #include -#include +#include "tng_compress_testing.h" #include TESTPARAM +#ifdef TEST_FLOAT +#define REAL float +#else +#define REAL double +#endif + +#ifndef TNG_COMPRESS_FILES_DIR +#define TNG_COMPRESS_FILES_DIR "" +#endif + #define FUDGE 1.1 /* 10% off target precision is acceptable */ static void keepinbox(int *val) @@ -201,39 +211,39 @@ static void genivelbox(int *intvelbox, int iframe) #define GENVELPRECISION VELPRECISION #endif -static void realbox(int *intbox, double *realbox, int stride) +static void realbox(int *intbox, REAL *realbox, int stride) { int i,j; for (i=0; imaxdiff) - maxdiff=(double)fabs(arr1[i*stride1+j]-arr2[i*stride2+j]); + maxdiff=(REAL)fabs(arr1[i*stride1+j]-arr2[i*stride2+j]); } #if 0 for (i=0; iinitial_coding_parameter; algo[2]=tng_file->coding; algo[3]=tng_file->coding_parameter; +#ifdef TEST_FLOAT + buf=tng_compress_pos_float(tng_file->pos, + tng_file->natoms, + tng_file->nframes, + tng_file->precision, + tng_file->speed,algo,&nitems); +#else buf=tng_compress_pos(tng_file->pos, tng_file->natoms, tng_file->nframes, tng_file->precision, tng_file->speed,algo,&nitems); +#endif tng_file->initial_coding=algo[0]; tng_file->initial_coding_parameter=algo[1]; tng_file->coding=algo[2]; @@ -369,11 +387,19 @@ static void flush_tng_frames(struct tng_file *tng_file) algo[1]=tng_file->initial_velcoding_parameter; algo[2]=tng_file->velcoding; algo[3]=tng_file->velcoding_parameter; +#ifdef TEST_FLOAT + buf=tng_compress_vel_float(tng_file->vel, + tng_file->natoms, + tng_file->nframes, + tng_file->velprecision, + tng_file->speed,algo,&nitems); +#else buf=tng_compress_vel(tng_file->vel, tng_file->natoms, tng_file->nframes, tng_file->velprecision, tng_file->speed,algo,&nitems); +#endif tng_file->initial_velcoding=algo[0]; tng_file->initial_velcoding_parameter=algo[1]; tng_file->velcoding=algo[2]; @@ -386,7 +412,7 @@ static void flush_tng_frames(struct tng_file *tng_file) } static void write_tng_file(struct tng_file *tng_file, - double *pos,double *vel) + REAL *pos,REAL *vel) { memcpy(tng_file->pos+tng_file->nframes*tng_file->natoms*3,pos,tng_file->natoms*3*sizeof *tng_file->pos); if (tng_file->writevel) @@ -415,13 +441,19 @@ static struct tng_file *open_tng_file_read(char *filename, int writevel) tng_file->nframes=0; tng_file->nframes_delivered=0; tng_file->writevel=writevel; - fread_int_le(&tng_file->natoms,tng_file->f); + if (tng_file->f) + fread_int_le(&tng_file->natoms,tng_file->f); + else + { + free(tng_file); + tng_file=NULL; + } return tng_file; } static int read_tng_file(struct tng_file *tng_file, - double *pos, - double *vel) + REAL *pos, + REAL *vel) { if (tng_file->nframes==tng_file->nframes_delivered) { @@ -451,7 +483,11 @@ static int read_tng_file(struct tng_file *tng_file, printf("ivel=%d natoms=%d nframes=%d precision=%g initial pos=%s pos=%s\n",ivel,natoms,nframes,precision,initial_coding,coding); } #endif +#ifdef TEST_FLOAT + tng_compress_uncompress_float(buf,tng_file->pos); +#else tng_compress_uncompress(buf,tng_file->pos); +#endif free(buf); if (tng_file->writevel) { @@ -472,7 +508,11 @@ static int read_tng_file(struct tng_file *tng_file, printf("ivel=%d natoms=%d nframes=%d precision=%g initial vel=%s vel=%s\n",ivel,natoms,nframes,precision,initial_coding,coding); } #endif +#ifdef TEST_FLOAT + tng_compress_uncompress_float(buf,tng_file->vel); +#else tng_compress_uncompress(buf,tng_file->vel); +#endif free(buf); } tng_file->nframes_delivered=0; @@ -519,34 +559,34 @@ static void close_tng_file_read(struct tng_file *tng_file) static int algotest() { int i; - int *intbox=warnmalloc(NATOMS*3*sizeof *intbox); - int *intvelbox=warnmalloc(NATOMS*3*sizeof *intvelbox); - double *box1=warnmalloc(NATOMS*STRIDE1*sizeof *box1); - double *velbox1=warnmalloc(NATOMS*STRIDE1*sizeof *velbox1); - double time1, lambda1; - double H1[9]; + int *intbox=malloc(NATOMS*3*sizeof *intbox); + int *intvelbox=malloc(NATOMS*3*sizeof *intvelbox); + REAL *box1=malloc(NATOMS*STRIDE1*sizeof *box1); + REAL *velbox1=malloc(NATOMS*STRIDE1*sizeof *velbox1); + REAL time1, lambda1; + REAL H1[9]; int startframe=0; int endframe=NFRAMES; #ifdef GEN FILE *file; - double filesize; + REAL filesize; #else int i2; int readreturn; - double H2[9]; - double time2, lambda2; - double *box2=warnmalloc(NATOMS*STRIDE2*sizeof *box2); - double *velbox2=warnmalloc(NATOMS*STRIDE2*sizeof *velbox2); + REAL H2[9]; + REAL time2, lambda2; + REAL *box2=malloc(NATOMS*STRIDE2*sizeof *box2); + REAL *velbox2=malloc(NATOMS*STRIDE2*sizeof *velbox2); #endif #ifdef GEN - void *dumpfile=open_tng_file_write(FILENAME,NATOMS,CHUNKY, + void *dumpfile=open_tng_file_write(TNG_COMPRESS_FILES_DIR FILENAME,NATOMS,CHUNKY, PRECISION,WRITEVEL,VELPRECISION, INITIALCODING, INITIALCODINGPARAMETER,CODING,CODINGPARAMETER, INITIALVELCODING,INITIALVELCODINGPARAMETER, VELCODING,VELCODINGPARAMETER,SPEED); #else - void *dumpfile=open_tng_file_read(FILENAME,WRITEVEL); + void *dumpfile=open_tng_file_read(TNG_COMPRESS_FILES_DIR FILENAME,WRITEVEL); #endif if (!dumpfile) return 1; @@ -563,8 +603,8 @@ static int algotest() genivelbox(intvelbox,i); realvelbox(intvelbox,velbox1,STRIDE1); #endif - time1=(double)i; - lambda1=(double)(i+100); + time1=(REAL)i; + lambda1=(REAL)(i+100); #ifdef GEN write_tng_file(dumpfile,box1,velbox1); #else @@ -574,10 +614,10 @@ static int algotest() #endif #ifndef GEN /* Check for equality of boxes. */ - if (!equalarr(box1,box2,(double)PRECISION,NATOMS,3,STRIDE1,STRIDE2)) + if (!equalarr(box1,box2,(REAL)PRECISION,NATOMS,3,STRIDE1,STRIDE2)) return 4; #if WRITEVEL - if (!equalarr(velbox1,velbox2,(double)VELPRECISION,NATOMS,3,STRIDE1,STRIDE2)) + if (!equalarr(velbox1,velbox2,(REAL)VELPRECISION,NATOMS,3,STRIDE1,STRIDE2)) return 5; #endif #endif @@ -589,9 +629,9 @@ static int algotest() #endif #ifdef GEN /* Check against expected filesize for this test. */ - if (!(file=fopen(FILENAME,"rb"))) + if (!(file=fopen(TNG_COMPRESS_FILES_DIR FILENAME,"rb"))) { - fprintf(stderr,"ERROR: Cannot open file "FILENAME"\n"); + fprintf(stderr,"ERROR: Cannot open file "TNG_COMPRESS_FILES_DIR FILENAME"\n"); exit(EXIT_FAILURE); } filesize=0; diff --git a/src/tests/compression/testsuite.sh b/src/tests/compression/testsuite.sh deleted file mode 100755 index 6aecff5..0000000 --- a/src/tests/compression/testsuite.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -do_write_test="Yes" -if [ -n "$1" ]; then - do_write_test="" -fi -STARTTEST=1 -ENDTEST=57 -#CFLAGS="-Wall -O2 -I../../../include/compress" -CFLAGS="-O2 -I../../../include/compression" -LIBS="-L../../../build/lib -ltng_compress -lm" -LD_LIBRARY_PATH="../../../build/lib:$LD_LIBRARY_PATH" -export LD_LIBRARY_PATH -#CFLAGS="-O0 -Wall -g" -#LIBS="-lm -lefence" -CC="gcc" -# 32 bit -#CC="gcc -m32" -for testnum in $(seq $STARTTEST $ENDTEST); do - testname=$(grep "TESTNAME" test$testnum.h|sed 's/#define TESTNAME//') - sed "s/TESTPARAM/\"test$testnum.h\"/" test$testnum.c - if [ -n "$do_write_test" ]; then - echo Write test $testnum: $testname - $CC -DGEN $CFLAGS -o gen$testnum test$testnum.c -ltng_compress $LIBS - ./gen$testnum - rm -f gen$testnum - fi - echo Read test $testnum: $testname - $CC $CFLAGS -o read$testnum test$testnum.c -ltng_compress $LIBS - ./read$testnum - rm -f read$testnum - rm -f test$testnum.c -done - - - -- cgit v0.10.1 From 6ae393dbe7ffda9c2340503c82d062cb8d7c6f41 Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Thu, 16 May 2013 17:22:04 +0200 Subject: Several changes to get the compression testsuite working for recompression tests. diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index 15b059b..39c2078 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/compression) include_directories(${CMAKE_BINARY_DIR}/generated/) set(number 0) -set(numtests 59) +set(numtests 62) while( number LESS ${numtests}) diff --git a/src/tests/compression/test58.h b/src/tests/compression/test58.h index 18be47f..9988106 100644 --- a/src/tests/compression/test58.h +++ b/src/tests/compression/test58.h @@ -23,4 +23,4 @@ #define INTMAX3 10000 #define NFRAMES 1000 #define TEST_FLOAT -#define EXPECTED_FILESIZE 7237102. +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test59.h b/src/tests/compression/test59.h index 0b6079e..9817976 100644 --- a/src/tests/compression/test59.h +++ b/src/tests/compression/test59.h @@ -25,4 +25,4 @@ #ifdef GEN #define TEST_FLOAT #endif -#define EXPECTED_FILESIZE 7237102. +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test60.h b/src/tests/compression/test60.h new file mode 100644 index 0000000..cf94e3b --- /dev/null +++ b/src/tests/compression/test60.h @@ -0,0 +1,28 @@ +#define TESTNAME "Coding. Test write double, read float." +#define FILENAME "test60.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#ifndef GEN +#define TEST_FLOAT +#endif +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test61.h b/src/tests/compression/test61.h new file mode 100644 index 0000000..2b71cc8 --- /dev/null +++ b/src/tests/compression/test61.h @@ -0,0 +1,25 @@ +#define TESTNAME "Coding. Recompression test. Stage 1: Generate" +#define FILENAME "test61.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test62.h b/src/tests/compression/test62.h new file mode 100644 index 0000000..4b9e122 --- /dev/null +++ b/src/tests/compression/test62.h @@ -0,0 +1,26 @@ +#define TESTNAME "Coding. Recompression test. Stage 2: Recompress" +#define FILENAME "test62.tng_compress" +#define RECOMPRESS "test61.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.01 /* Changed on purpose. */ +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING -1 +#define INITIALCODINGPARAMETER -1 +#define CODING -1 +#define CODINGPARAMETER -1 +#define INITIALVELCODING -1 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING -1 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c index cc38cb6..e1b9710 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -284,6 +284,8 @@ struct tng_file int writevel; REAL *pos; REAL *vel; + int *ipos; + int *ivel; }; static size_t fwrite_int_le(int *x,FILE *f) @@ -328,6 +330,51 @@ static struct tng_file *open_tng_file_write(char *filename, struct tng_file *tng_file=malloc(sizeof *tng_file); tng_file->pos=NULL; tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; + tng_file->nframes=0; + tng_file->chunky=chunky; + tng_file->precision=precision; + tng_file->natoms=natoms; + tng_file->writevel=writevel; + tng_file->velprecision=velprecision; + tng_file->initial_coding=initial_coding; + tng_file->initial_coding_parameter=initial_coding_parameter; + tng_file->coding=coding; + tng_file->coding_parameter=coding_parameter; + tng_file->initial_velcoding=initial_velcoding; + tng_file->initial_velcoding_parameter=initial_velcoding_parameter; + tng_file->velcoding=velcoding; + tng_file->velcoding_parameter=velcoding_parameter; + tng_file->speed=speed; + tng_file->pos=malloc(natoms*chunky*3*sizeof *tng_file->pos); + tng_file->f=fopen(filename,"wb"); + if (writevel) + tng_file->vel=malloc(natoms*chunky*3*sizeof *tng_file->vel); + fwrite_int_le(&natoms,tng_file->f); + return tng_file; +} + +static struct tng_file *open_tng_file_write_int(char *filename, + int natoms,int chunky, + unsigned long prec_hi, unsigned long prec_lo, + int writevel, + unsigned long velprec_hi, unsigned long velprec_lo, + int initial_coding, + int initial_coding_parameter, + int coding, + int coding_parameter, + int initial_velcoding, + int initial_velcoding_parameter, + int velcoding, + int velcoding_parameter, + int speed) +{ + struct tng_file *tng_file=malloc(sizeof *tng_file); + tng_file->pos=NULL; + tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; tng_file->nframes=0; tng_file->chunky=chunky; tng_file->precision=precision; @@ -437,6 +484,8 @@ static struct tng_file *open_tng_file_read(char *filename, int writevel) struct tng_file *tng_file=malloc(sizeof *tng_file); tng_file->pos=NULL; tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; tng_file->f=fopen(filename,"rb"); tng_file->nframes=0; tng_file->nframes_delivered=0; @@ -561,6 +610,10 @@ static int algotest() int i; int *intbox=malloc(NATOMS*3*sizeof *intbox); int *intvelbox=malloc(NATOMS*3*sizeof *intvelbox); +#ifdef RECOMPRESS + unsigned long pos_prec_hi,pos_prec_lo; + unsigned long vel_prec_hi,vel_prec_lo; +#endif REAL *box1=malloc(NATOMS*STRIDE1*sizeof *box1); REAL *velbox1=malloc(NATOMS*STRIDE1*sizeof *velbox1); REAL time1, lambda1; @@ -588,6 +641,11 @@ static int algotest() #else void *dumpfile=open_tng_file_read(TNG_COMPRESS_FILES_DIR FILENAME,WRITEVEL); #endif +#ifdef RECOMPRESS + void *dumpfile_recompress=open_tng_file_read_int(TNG_COMPRESS_FILES_DIR RECOMPRESS,WRITEVEL); + if (!dumpfile_recompress) + return 1; +#endif if (!dumpfile) return 1; for (i=0; i<9; i++) @@ -597,16 +655,30 @@ static int algotest() H1[8]=INTMAX3*PRECISION*SCALE; for (i=startframe; i Date: Fri, 17 May 2013 18:54:01 +0200 Subject: Added conversion from unpacked integers to float/double. Added tests for recompression (uncompress to int, compress int) Added tests for conversion from unpacked integers to float/double. diff --git a/include/compression/tng_compress.h b/include/compression/tng_compress.h index 14786d1..5d43ffc 100644 --- a/include/compression/tng_compress.h +++ b/include/compression/tng_compress.h @@ -166,11 +166,21 @@ int DECLSPECDLLEXPORT tng_compress_uncompress_float(char *data,float *posvel); int DECLSPECDLLEXPORT tng_compress_uncompress_int(char *data,int *posvel, unsigned long *prec_hi, unsigned long *prec_lo); +/* This converts a block of integers, as obtained from tng_compress_uncompress_int, to floating point values + either double precision or single precision. */ +void DECLSPECDLLEXPORT tng_compress_int_to_double(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo, + int natoms,int nframes, + double *posvel_double); - /* Compression algorithms (matching the original trajng - assignments) The compression backends require that some of the - algorithms must have the same value. */ +void DECLSPECDLLEXPORT tng_compress_int_to_float(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo, + int natoms,int nframes, + float *posvel_float); + +/* Compression algorithms (matching the original trajng + assignments) The compression backends require that some of the + algorithms must have the same value. */ + #define TNG_COMPRESS_ALGO_STOPBIT 1 #define TNG_COMPRESS_ALGO_TRIPLET 2 #define TNG_COMPRESS_ALGO_BWLZH1 8 diff --git a/src/compression/tng_compress.c b/src/compression/tng_compress.c index ed3fca9..1219f6a 100644 --- a/src/compression/tng_compress.c +++ b/src/compression/tng_compress.c @@ -1764,6 +1764,20 @@ int DECLSPECDLLEXPORT tng_compress_uncompress_int(char *data,int *posvel, unsign return 1; } +void DECLSPECDLLEXPORT tng_compress_int_to_double(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo, + int natoms,int nframes, + double *posvel_double) +{ + unquantize(posvel_double,natoms,nframes,PRECISION(prec_hi,prec_lo),posvel_int); +} + +void DECLSPECDLLEXPORT tng_compress_int_to_float(int *posvel_int,unsigned long prec_hi, unsigned long prec_lo, + int natoms,int nframes, + float *posvel_float) +{ + unquantize_float(posvel_float,natoms,nframes,(float)PRECISION(prec_hi,prec_lo),posvel_int); +} + static char *compress_algo_pos[TNG_COMPRESS_ALGO_MAX]={ "Positions invalid algorithm", "Positions stopbits interframe", diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index 39c2078..694d27b 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/compression) include_directories(${CMAKE_BINARY_DIR}/generated/) set(number 0) -set(numtests 62) +set(numtests 64) while( number LESS ${numtests}) diff --git a/src/tests/compression/test61.h b/src/tests/compression/test61.h index 2b71cc8..373456d 100644 --- a/src/tests/compression/test61.h +++ b/src/tests/compression/test61.h @@ -21,5 +21,5 @@ #define INTMAX1 10000 #define INTMAX2 10000 #define INTMAX3 10000 -#define NFRAMES 1000 -#define EXPECTED_FILESIZE 6986313. +#define NFRAMES 100 +#define EXPECTED_FILESIZE 698801. diff --git a/src/tests/compression/test62.h b/src/tests/compression/test62.h index 4b9e122..c8a2b48 100644 --- a/src/tests/compression/test62.h +++ b/src/tests/compression/test62.h @@ -4,23 +4,23 @@ #define ALGOTEST #define NATOMS 1000 #define CHUNKY 100 -#define SCALE 0.01 /* Changed on purpose. */ +#define SCALE 0.1 #define PRECISION 0.01 #define WRITEVEL 1 #define VELPRECISION 0.1 -#define INITIALCODING -1 -#define INITIALCODINGPARAMETER -1 -#define CODING -1 -#define CODINGPARAMETER -1 -#define INITIALVELCODING -1 -#define INITIALVELCODINGPARAMETER -1 -#define VELCODING -1 -#define VELCODINGPARAMETER -1 +#define INITIALCODING 10 +#define INITIALCODINGPARAMETER 0 +#define CODING 10 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER 0 +#define VELCODING 8 +#define VELCODINGPARAMETER 0 #define INTMIN1 0 #define INTMIN2 0 #define INTMIN3 0 #define INTMAX1 10000 #define INTMAX2 10000 #define INTMAX3 10000 -#define NFRAMES 1000 -#define EXPECTED_FILESIZE 6986313. +#define NFRAMES 100 +#define EXPECTED_FILESIZE 151226. diff --git a/src/tests/compression/test63.h b/src/tests/compression/test63.h new file mode 100644 index 0000000..65a4768 --- /dev/null +++ b/src/tests/compression/test63.h @@ -0,0 +1,26 @@ +#define TESTNAME "Coding. Read int and convert to double." +#define FILENAME "test63.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 100 +#define INTTODOUBLE +#define EXPECTED_FILESIZE 698801. diff --git a/src/tests/compression/test64.h b/src/tests/compression/test64.h new file mode 100644 index 0000000..02f99b5 --- /dev/null +++ b/src/tests/compression/test64.h @@ -0,0 +1,27 @@ +#define TESTNAME "Coding. Read int and convert to float." +#define FILENAME "test64.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 100 +#define INTTOFLOAT +#define TEST_FLOAT +#define EXPECTED_FILESIZE 698801. diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c index e1b9710..3ed9f32 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -286,6 +286,8 @@ struct tng_file REAL *vel; int *ipos; int *ivel; + unsigned int prec_hi, prec_lo; + unsigned int velprec_hi, velprec_lo; }; static size_t fwrite_int_le(int *x,FILE *f) @@ -357,9 +359,7 @@ static struct tng_file *open_tng_file_write(char *filename, static struct tng_file *open_tng_file_write_int(char *filename, int natoms,int chunky, - unsigned long prec_hi, unsigned long prec_lo, int writevel, - unsigned long velprec_hi, unsigned long velprec_lo, int initial_coding, int initial_coding_parameter, int coding, @@ -377,10 +377,8 @@ static struct tng_file *open_tng_file_write_int(char *filename, tng_file->ivel=NULL; tng_file->nframes=0; tng_file->chunky=chunky; - tng_file->precision=precision; tng_file->natoms=natoms; tng_file->writevel=writevel; - tng_file->velprecision=velprecision; tng_file->initial_coding=initial_coding; tng_file->initial_coding_parameter=initial_coding_parameter; tng_file->coding=coding; @@ -390,15 +388,17 @@ static struct tng_file *open_tng_file_write_int(char *filename, tng_file->velcoding=velcoding; tng_file->velcoding_parameter=velcoding_parameter; tng_file->speed=speed; - tng_file->pos=malloc(natoms*chunky*3*sizeof *tng_file->pos); + tng_file->ipos=malloc(natoms*chunky*3*sizeof *tng_file->ipos); tng_file->f=fopen(filename,"wb"); if (writevel) - tng_file->vel=malloc(natoms*chunky*3*sizeof *tng_file->vel); + tng_file->ivel=malloc(natoms*chunky*3*sizeof *tng_file->ivel); fwrite_int_le(&natoms,tng_file->f); return tng_file; } -static void flush_tng_frames(struct tng_file *tng_file) +static void flush_tng_frames(struct tng_file *tng_file, + unsigned long prec_hi, unsigned long prec_lo, + unsigned long velprec_hi, unsigned long velprec_lo) { int algo[4]; char *buf; @@ -408,19 +408,27 @@ static void flush_tng_frames(struct tng_file *tng_file) algo[1]=tng_file->initial_coding_parameter; algo[2]=tng_file->coding; algo[3]=tng_file->coding_parameter; +#ifdef RECOMPRESS + buf=tng_compress_pos_int(tng_file->ipos, + tng_file->natoms, + tng_file->nframes, + prec_hi,prec_lo, + tng_file->speed,algo,&nitems); +#else /* RECOMPRESS */ #ifdef TEST_FLOAT buf=tng_compress_pos_float(tng_file->pos, tng_file->natoms, tng_file->nframes, tng_file->precision, tng_file->speed,algo,&nitems); -#else +#else /* TEST_FLOAT */ buf=tng_compress_pos(tng_file->pos, tng_file->natoms, tng_file->nframes, tng_file->precision, tng_file->speed,algo,&nitems); -#endif +#endif /* TEST_FLOAT */ +#endif /* RECOMPRESS */ tng_file->initial_coding=algo[0]; tng_file->initial_coding_parameter=algo[1]; tng_file->coding=algo[2]; @@ -434,19 +442,27 @@ static void flush_tng_frames(struct tng_file *tng_file) algo[1]=tng_file->initial_velcoding_parameter; algo[2]=tng_file->velcoding; algo[3]=tng_file->velcoding_parameter; +#ifdef RECOMPRESS + buf=tng_compress_vel_int(tng_file->ivel, + tng_file->natoms, + tng_file->nframes, + velprec_hi,velprec_lo, + tng_file->speed,algo,&nitems); +#else /* RECOMPRESS */ #ifdef TEST_FLOAT buf=tng_compress_vel_float(tng_file->vel, tng_file->natoms, tng_file->nframes, tng_file->velprecision, tng_file->speed,algo,&nitems); -#else +#else /* TEST_FLOAT */ buf=tng_compress_vel(tng_file->vel, tng_file->natoms, tng_file->nframes, tng_file->velprecision, tng_file->speed,algo,&nitems); -#endif +#endif /* TEST_FLOAT */ +#endif /* RECOMPRESS */ tng_file->initial_velcoding=algo[0]; tng_file->initial_velcoding_parameter=algo[1]; tng_file->velcoding=algo[2]; @@ -466,16 +482,35 @@ static void write_tng_file(struct tng_file *tng_file, memcpy(tng_file->vel+tng_file->nframes*tng_file->natoms*3,vel,tng_file->natoms*3*sizeof *tng_file->vel); tng_file->nframes++; if (tng_file->nframes==tng_file->chunky) - flush_tng_frames(tng_file); + flush_tng_frames(tng_file,0,0,0,0); +} + +static void write_tng_file_int(struct tng_file *tng_file, + int *ipos,int *ivel, + unsigned long prec_hi, unsigned long prec_lo, + unsigned long velprec_hi, unsigned long velprec_lo) +{ + memcpy(tng_file->ipos+tng_file->nframes*tng_file->natoms*3,ipos,tng_file->natoms*3*sizeof *tng_file->ipos); + if (tng_file->writevel) + memcpy(tng_file->ivel+tng_file->nframes*tng_file->natoms*3,ivel,tng_file->natoms*3*sizeof *tng_file->ivel); + tng_file->nframes++; + if (tng_file->nframes==tng_file->chunky) + flush_tng_frames(tng_file,prec_hi,prec_lo,velprec_hi,velprec_lo); + tng_file->prec_hi=prec_hi; + tng_file->prec_lo=prec_lo; + tng_file->velprec_hi=velprec_hi; + tng_file->velprec_lo=velprec_lo; } static void close_tng_file_write(struct tng_file *tng_file) { if (tng_file->nframes) - flush_tng_frames(tng_file); + flush_tng_frames(tng_file,tng_file->prec_hi,tng_file->prec_lo,tng_file->velprec_hi,tng_file->velprec_lo); fclose(tng_file->f); free(tng_file->pos); free(tng_file->vel); + free(tng_file->ipos); + free(tng_file->ivel); free(tng_file); } @@ -500,6 +535,27 @@ static struct tng_file *open_tng_file_read(char *filename, int writevel) return tng_file; } +static struct tng_file *open_tng_file_read_int(char *filename, int writevel) +{ + struct tng_file *tng_file=malloc(sizeof *tng_file); + tng_file->pos=NULL; + tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; + tng_file->f=fopen(filename,"rb"); + tng_file->nframes=0; + tng_file->nframes_delivered=0; + tng_file->writevel=writevel; + if (tng_file->f) + fread_int_le(&tng_file->natoms,tng_file->f); + else + { + free(tng_file); + tng_file=NULL; + } + return tng_file; +} + static int read_tng_file(struct tng_file *tng_file, REAL *pos, REAL *vel) @@ -573,10 +629,55 @@ static int read_tng_file(struct tng_file *tng_file, return 0; } +static int read_tng_file_int(struct tng_file *tng_file, + int *ipos, + int *ivel, + unsigned long *prec_hi, unsigned long *prec_lo, + unsigned long *velprec_hi, unsigned long *velprec_lo) +{ + if (tng_file->nframes==tng_file->nframes_delivered) + { + int nitems; + char *buf; + free(tng_file->ipos); + free(tng_file->ivel); + if (!fread_int_le(&tng_file->nframes,tng_file->f)) + return 1; + if (!fread_int_le(&nitems,tng_file->f)) + return 1; + buf=malloc(nitems); + if (!fread(buf,1,nitems,tng_file->f)) + return 1; + tng_file->ipos=malloc(tng_file->natoms*tng_file->nframes*3*sizeof *tng_file->ipos); + if (tng_file->writevel) + tng_file->ivel=malloc(tng_file->natoms*tng_file->nframes*3*sizeof *tng_file->ivel); + tng_compress_uncompress_int(buf,tng_file->ipos,prec_hi,prec_lo); + free(buf); + if (tng_file->writevel) + { + if (!fread_int_le(&nitems,tng_file->f)) + return 1; + buf=malloc(nitems); + if (!fread(buf,1,nitems,tng_file->f)) + return 1; + tng_compress_uncompress_int(buf,tng_file->ivel,velprec_hi,velprec_lo); + free(buf); + } + tng_file->nframes_delivered=0; + } + memcpy(ipos,tng_file->ipos+tng_file->nframes_delivered*tng_file->natoms*3,tng_file->natoms*3*sizeof *ipos); + if (tng_file->writevel) + memcpy(ivel,tng_file->ivel+tng_file->nframes_delivered*tng_file->natoms*3,tng_file->natoms*3*sizeof *ivel); + tng_file->nframes_delivered++; + return 0; +} + static void close_tng_file_read(struct tng_file *tng_file) { free(tng_file->vel); free(tng_file->pos); + free(tng_file->ivel); + free(tng_file->ipos); fclose(tng_file->f); free(tng_file); } @@ -631,6 +732,17 @@ static int algotest() REAL *box2=malloc(NATOMS*STRIDE2*sizeof *box2); REAL *velbox2=malloc(NATOMS*STRIDE2*sizeof *velbox2); #endif +#ifdef RECOMPRESS + void *dumpfile=open_tng_file_write_int(TNG_COMPRESS_FILES_DIR FILENAME,NATOMS,CHUNKY, + WRITEVEL, + INITIALCODING, + INITIALCODINGPARAMETER,CODING,CODINGPARAMETER, + INITIALVELCODING,INITIALVELCODINGPARAMETER, + VELCODING,VELCODINGPARAMETER,SPEED); + void *dumpfile_recompress=open_tng_file_read_int(TNG_COMPRESS_FILES_DIR RECOMPRESS,WRITEVEL); + if (!dumpfile_recompress) + return 1; +#else /* RECOMPRESS */ #ifdef GEN void *dumpfile=open_tng_file_write(TNG_COMPRESS_FILES_DIR FILENAME,NATOMS,CHUNKY, PRECISION,WRITEVEL,VELPRECISION, @@ -641,11 +753,7 @@ static int algotest() #else void *dumpfile=open_tng_file_read(TNG_COMPRESS_FILES_DIR FILENAME,WRITEVEL); #endif -#ifdef RECOMPRESS - void *dumpfile_recompress=open_tng_file_read_int(TNG_COMPRESS_FILES_DIR RECOMPRESS,WRITEVEL); - if (!dumpfile_recompress) - return 1; -#endif +#endif /* RECOMPRESS */ if (!dumpfile) return 1; for (i=0; i<9; i++) @@ -655,35 +763,54 @@ static int algotest() H1[8]=INTMAX3*PRECISION*SCALE; for (i=startframe; i Date: Fri, 17 May 2013 19:21:04 +0200 Subject: Updated number of tests in test suite scripts for tng compress. diff --git a/src/tests/compression/test_tng_compress_read.bat b/src/tests/compression/test_tng_compress_read.bat index 01873f8..8bedeb4 100644 --- a/src/tests/compression/test_tng_compress_read.bat +++ b/src/tests/compression/test_tng_compress_read.bat @@ -4,7 +4,7 @@ SET /A I=0 :start SET /A I+=1 test_tng_compress_read%I% -IF "%I%" == "57" ( +IF "%I%" == "64" ( GOTO end ) ELSE ( GOTO start diff --git a/src/tests/compression/test_tng_compress_read.sh b/src/tests/compression/test_tng_compress_read.sh index 76f9193..2d7a044 100755 --- a/src/tests/compression/test_tng_compress_read.sh +++ b/src/tests/compression/test_tng_compress_read.sh @@ -1,5 +1,5 @@ #!/bin/sh -numtests=57 +numtests=64 for x in $(seq 1 $numtests); do ./test_tng_compress_read$x done \ No newline at end of file diff --git a/src/tests/compression/test_tng_compress_write.bat b/src/tests/compression/test_tng_compress_write.bat index ba1d93e..7542fc8 100644 --- a/src/tests/compression/test_tng_compress_write.bat +++ b/src/tests/compression/test_tng_compress_write.bat @@ -4,7 +4,7 @@ SET /A I=0 :start SET /A I+=1 test_tng_compress_gen%I% -IF "%I%" == "57" ( +IF "%I%" == "64" ( GOTO end ) ELSE ( GOTO start diff --git a/src/tests/compression/test_tng_compress_write.sh b/src/tests/compression/test_tng_compress_write.sh index 8f0ef01..1a5700b 100755 --- a/src/tests/compression/test_tng_compress_write.sh +++ b/src/tests/compression/test_tng_compress_write.sh @@ -1,5 +1,5 @@ #!/bin/sh -numtests=57 +numtests=64 for x in $(seq 1 $numtests); do ./test_tng_compress_gen$x done \ No newline at end of file -- cgit v0.10.1 From 47bc4acb6a7373a359b3b3a73302ebd985dedd1b Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Fri, 17 May 2013 19:51:38 +0200 Subject: Only add math library on UNIX. Copy .sh files on UNIX. Copy .bat files on windows. diff --git a/src/compression/CMakeLists.txt b/src/compression/CMakeLists.txt index 35e01f7..605dac7 100644 --- a/src/compression/CMakeLists.txt +++ b/src/compression/CMakeLists.txt @@ -5,4 +5,6 @@ include_directories(${COMP_INC_DIR}) set(HEADER_FILES ${COMP_INC_DIR}/bwlzh.h ${COMP_INC_DIR}/bwt.h ${COMP_INC_DIR}/coder.h ${COMP_INC_DIR}/dict.h ${COMP_INC_DIR}/fixpoint.h ${COMP_INC_DIR}/huffman.h ${COMP_INC_DIR}/lz77.h ${COMP_INC_DIR}/merge_sort.h ${COMP_INC_DIR}/mtf.h ${COMP_INC_DIR}/my64bit.h ${COMP_INC_DIR}/rle.h ${COMP_INC_DIR}/tng_compress.h ${COMP_INC_DIR}/vals16.h ${COMP_INC_DIR}/warnmalloc.h ${COMP_INC_DIR}/widemuldiv.h) add_library(tng_compress SHARED 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) -target_link_libraries(tng_compress m) \ No newline at end of file +if(UNIX) +target_link_libraries(tng_compress m) +endif() diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6320769..42de927 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -12,7 +12,9 @@ configure_file(${TRAJECTORY_SOURCE_DIR}/include/tng_io_testing.h.in ${CMAKE_BINA include_directories(${CMAKE_BINARY_DIR}/generated/) add_executable(tng_testing tng_io_testing.c) +if(UNIX) target_link_libraries(tng_testing tng_io m) +endif() if(HAVE_INTTYPES_H) set_target_properties(tng_testing PROPERTIES COMPILE_DEFINITIONS USE_STD_INTTYPES_H=1) @@ -20,14 +22,21 @@ endif() if(OPENMP_FOUND) add_executable(md_openmp md_openmp.c) - target_link_libraries(md_openmp tng_io ${OpenMP_LIBS} m) + target_link_libraries(md_openmp tng_io ${OpenMP_LIBS}) + if(UNIX) + target_link_libraries(md_openmp m) + endif() endif() add_executable(tng_io_read_pos tng_io_read_pos.c) +if(UNIX) target_link_libraries(tng_io_read_pos tng_io m) +endif() add_executable(tng_parallel_read tng_parallel_read.c) +if(UNIX) target_link_libraries(tng_parallel_read tng_io m) +endif() if(BUILD_FORTRAN) # This does not work due to a bug in CMake. Remove lines below if no fortran compiler is found. diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index 694d27b..33dfb61 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -16,21 +16,29 @@ while( number LESS ${numtests}) math( EXPR number "${number} + 1" ) add_executable(test_tng_compress_gen${number} testsuite.c) +if(UNIX) target_link_libraries(test_tng_compress_gen${number} tng_compress m) +endif() list(APPEND gen${number}_build_definitions GEN) list(APPEND gen${number}_build_definitions TESTPARAM="test${number}.h") set_target_properties(test_tng_compress_gen${number} PROPERTIES COMPILE_DEFINITIONS "${gen${number}_build_definitions}") add_dependencies(test_tng_compress_gen${number} test${number}.h) add_executable(test_tng_compress_read${number} testsuite.c) +if(UNIX) target_link_libraries(test_tng_compress_read${number} tng_compress m) +endif() list(APPEND read${number}_build_definitions TESTPARAM="test${number}.h") set_target_properties(test_tng_compress_read${number} PROPERTIES COMPILE_DEFINITIONS "${read${number}_build_definitions}") add_dependencies(test_tng_compress_read${number} test${number}.h) endwhile() +if(UNIX) file(COPY test_tng_compress_write.sh DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY test_tng_compress_read.sh DESTINATION ${CMAKE_BINARY_DIR}/bin) +endif() +if(WIN32) file(COPY test_tng_compress_write.bat DESTINATION ${CMAKE_BINARY_DIR}/bin) file(COPY test_tng_compress_read.bat DESTINATION ${CMAKE_BINARY_DIR}/bin) +endif() -- cgit v0.10.1 From 494702b3a59f3670af8da7acf7e8baf6ae4f7dd4 Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Fri, 17 May 2013 20:17:17 +0200 Subject: Fix errors introduced when doing if(UNIX) in CMakeLists.txt Fix declaration of variables not at beginning of scope (breaks C89) in tng compress testsuite. diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 42de927..303035e 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -12,8 +12,9 @@ configure_file(${TRAJECTORY_SOURCE_DIR}/include/tng_io_testing.h.in ${CMAKE_BINA include_directories(${CMAKE_BINARY_DIR}/generated/) add_executable(tng_testing tng_io_testing.c) +target_link_libraries(tng_testing tng_io) if(UNIX) -target_link_libraries(tng_testing tng_io m) +target_link_libraries(tng_testing m) endif() if(HAVE_INTTYPES_H) @@ -29,13 +30,15 @@ if(OPENMP_FOUND) endif() add_executable(tng_io_read_pos tng_io_read_pos.c) +target_link_libraries(tng_io_read_pos tng_io) if(UNIX) -target_link_libraries(tng_io_read_pos tng_io m) +target_link_libraries(tng_io_read_pos m) endif() add_executable(tng_parallel_read tng_parallel_read.c) +target_link_libraries(tng_parallel_read tng_io) if(UNIX) -target_link_libraries(tng_parallel_read tng_io m) +target_link_libraries(tng_parallel_read m) endif() if(BUILD_FORTRAN) diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index 33dfb61..930bcfc 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -16,8 +16,9 @@ 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) if(UNIX) -target_link_libraries(test_tng_compress_gen${number} tng_compress m) +target_link_libraries(test_tng_compress_gen${number} m) endif() list(APPEND gen${number}_build_definitions GEN) list(APPEND gen${number}_build_definitions TESTPARAM="test${number}.h") @@ -25,8 +26,9 @@ set_target_properties(test_tng_compress_gen${number} PROPERTIES COMPILE_DEFINITI add_dependencies(test_tng_compress_gen${number} test${number}.h) add_executable(test_tng_compress_read${number} testsuite.c) +target_link_libraries(test_tng_compress_read${number} tng_compress) if(UNIX) -target_link_libraries(test_tng_compress_read${number} tng_compress m) +target_link_libraries(test_tng_compress_read${number} m) endif() list(APPEND read${number}_build_definitions TESTPARAM="test${number}.h") set_target_properties(test_tng_compress_read${number} PROPERTIES COMPILE_DEFINITIONS "${read${number}_build_definitions}") diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c index 3ed9f32..27450d6 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -782,28 +782,32 @@ static int algotest() write_tng_file(dumpfile,box1,velbox1); #else /* GEN */ #ifdef INTTOFLOAT - unsigned long prec_hi, prec_lo; - unsigned long velprec_hi, velprec_lo; - readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo); - if (!readreturn) - { - tng_compress_int_to_float(intbox,prec_hi,prec_lo,NATOMS,1,box2); + { + unsigned long prec_hi, prec_lo; + unsigned long velprec_hi, velprec_lo; + readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo); + if (!readreturn) + { + tng_compress_int_to_float(intbox,prec_hi,prec_lo,NATOMS,1,box2); #if WRITEVEL - tng_compress_int_to_float(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2); + tng_compress_int_to_float(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2); #endif - } + } + } #else /* INTTOFLOAT */ #ifdef INTTODOUBLE - unsigned long prec_hi, prec_lo; - unsigned long velprec_hi, velprec_lo; - readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo); - if (!readreturn) - { - tng_compress_int_to_double(intbox,prec_hi,prec_lo,NATOMS,1,box2); + { + unsigned long prec_hi, prec_lo; + unsigned long velprec_hi, velprec_lo; + readreturn=read_tng_file_int(dumpfile,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo); + if (!readreturn) + { + tng_compress_int_to_double(intbox,prec_hi,prec_lo,NATOMS,1,box2); #if WRITEVEL - tng_compress_int_to_double(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2); + tng_compress_int_to_double(intvelbox,velprec_hi,velprec_lo,NATOMS,1,velbox2); #endif - } + } + } #else /* INTTODOUBLE */ readreturn=read_tng_file(dumpfile,box2,velbox2); #endif /* INTTODOUBLE */ -- cgit v0.10.1 From 0f36e7de86f181eed7e49eedb3d66a0c6ab6f8cd Mon Sep 17 00:00:00 2001 From: Daniel Spangberg Date: Sat, 18 May 2013 17:33:23 +0200 Subject: Changes to allow compilation on windows with msvc. Bugfixes. diff --git a/include/compression/tng_compress.h b/include/compression/tng_compress.h index 5d43ffc..0858952 100644 --- a/include/compression/tng_compress.h +++ b/include/compression/tng_compress.h @@ -19,11 +19,13 @@ #endif /* win32... */ #endif /* not defined USE_WINDOWS */ +#ifndef DECLSPECDLLEXPORT #ifdef USE_WINDOWS #define DECLSPECDLLEXPORT __declspec(dllexport) -#else +#else /* USE_WINDOWS */ #define DECLSPECDLLEXPORT -#endif +#endif /* USE_WINDOWS */ +#endif /* DECLSPECDLLEXPORT */ #ifdef __cplusplus extern "C" { diff --git a/include/md5.h b/include/md5.h index 3652594..d618489 100644 --- a/include/md5.h +++ b/include/md5.h @@ -49,12 +49,6 @@ #ifndef md5_INCLUDED # define md5_INCLUDED -#ifndef USE_WINDOWS -#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) -#define USE_WINDOWS -#endif /* win32... */ -#endif /* not defined USE_WINDOWS */ - /* * This package supports both compile-time and run-time determination of CPU * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be @@ -80,14 +74,28 @@ extern "C" { #endif +#ifndef USE_WINDOWS +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#define USE_WINDOWS +#endif /* win32... */ +#endif /* not defined USE_WINDOWS */ + +#ifndef DECLSPECDLLEXPORT +#ifdef USE_WINDOWS +#define DECLSPECDLLEXPORT __declspec(dllexport) +#else /* USE_WINDOWS */ +#define DECLSPECDLLEXPORT +#endif /* USE_WINDOWS */ +#endif /* DECLSPECDLLEXPORT */ + /* Initialize the algorithm. */ -void md5_init(md5_state_t *pms); +void DECLSPECDLLEXPORT tng_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 DECLSPECDLLEXPORT tng_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 DECLSPECDLLEXPORT tng_md5_finish(md5_state_t *pms, md5_byte_t digest[16]); #ifdef __cplusplus } /* end extern "C" */ diff --git a/include/tng_io.h b/include/tng_io.h index 12e21cb..06e8be1 100644 --- a/include/tng_io.h +++ b/include/tng_io.h @@ -334,6 +334,21 @@ typedef unsigned long long int uint64_t; #endif +#ifndef USE_WINDOWS +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#define USE_WINDOWS +#endif /* win32... */ +#endif /* not defined USE_WINDOWS */ + +#ifndef DECLSPECDLLEXPORT +#ifdef USE_WINDOWS +#define DECLSPECDLLEXPORT __declspec(dllexport) +#else /* USE_WINDOWS */ +#define DECLSPECDLLEXPORT +#endif /* USE_WINDOWS */ +#endif /* DECLSPECDLLEXPORT */ + + /** The version of this TNG build */ #define TNG_VERSION 2 @@ -349,7 +364,7 @@ typedef unsigned long long int uint64_t; /** The maximum allowed length of a string */ #define TNG_MAX_STR_LEN 1024 - +#if 0 /** Inline function for finding the lowest of two values */ #define tng_min(a,b) \ ({ __typeof__ (a) _a = (a); \ @@ -361,6 +376,7 @@ typedef unsigned long long int uint64_t; ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) +#endif /** Flag to specify the endianness of a TNG file */ typedef enum {TNG_BIG_ENDIAN, @@ -492,7 +508,7 @@ extern "C" * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p); +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init(tng_trajectory_t *tng_data_p); /** * @brief Clean up a trajectory data container. @@ -501,7 +517,7 @@ tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p); * tng_data_p itself. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p); +tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy(tng_trajectory_t *tng_data_p); /** * @brief Copy a trajectory data container (dest is setup as well). @@ -515,7 +531,7 @@ tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p); * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src, +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajectory_t src, tng_trajectory_t *dest_p); /** @@ -528,7 +544,7 @@ tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_input_file_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_get(const tng_trajectory_t tng_data, char *file_name, const int max_len); /** @@ -538,7 +554,7 @@ tng_function_status tng_input_file_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_input_file_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_set(tng_trajectory_t tng_data, const char *file_name); /** @@ -551,7 +567,7 @@ tng_function_status tng_input_file_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_output_file_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_output_file_get(const tng_trajectory_t tng_data, char *file_name, const int max_len); /** @@ -561,7 +577,7 @@ tng_function_status tng_output_file_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_output_file_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_output_file_set(tng_trajectory_t tng_data, const char *file_name); /** @@ -572,7 +588,7 @@ tng_function_status tng_output_file_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness * could not be retrieved. */ -tng_function_status tng_output_file_endianness_get +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get (tng_trajectory_t tng_data, tng_file_endianness *endianness); /** @@ -585,7 +601,7 @@ tng_function_status tng_output_file_endianness_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness * could not be set. */ -tng_function_status tng_output_file_endianness_set +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set (tng_trajectory_t tng_data, const tng_file_endianness endianness); @@ -599,7 +615,7 @@ tng_function_status tng_output_file_endianness_set * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -609,7 +625,7 @@ tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -622,7 +638,7 @@ tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -632,7 +648,7 @@ tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -645,7 +661,7 @@ tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -655,7 +671,7 @@ tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -668,7 +684,7 @@ tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -678,7 +694,7 @@ tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -691,7 +707,7 @@ tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -701,7 +717,7 @@ tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -714,7 +730,7 @@ tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -724,7 +740,7 @@ tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -737,7 +753,7 @@ tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_signature_get(const tng_trajectory_t tng_data, char *signature, const int max_len); /** @@ -747,7 +763,7 @@ tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_first_signature_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_signature_set(tng_trajectory_t tng_data, const char *signature); /** @@ -760,7 +776,7 @@ tng_function_status tng_first_signature_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_signature_get(const tng_trajectory_t tng_data, char *signature, const int max_len); /** @@ -770,7 +786,7 @@ tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_last_signature_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_signature_set(tng_trajectory_t tng_data, const char *signature); /** @@ -783,7 +799,7 @@ tng_function_status tng_last_signature_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (source string longer than destination string). */ -tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get(const tng_trajectory_t tng_data, char *name, const int max_len); /** @@ -793,7 +809,7 @@ tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set(tng_trajectory_t tng_data, const char *new_name); /** @@ -802,7 +818,7 @@ tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data, * @param len is pointing to a value set to the stride length. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_medium_stride_length_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get(const tng_trajectory_t tng_data, int64_t *len); /** @@ -812,7 +828,7 @@ tng_function_status tng_medium_stride_length_get(const tng_trajectory_t tng_data * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred. */ -tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set(tng_trajectory_t tng_data, const int64_t len); /** @@ -821,7 +837,7 @@ tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data, * @param len is pointing to a value set to the stride length. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_long_stride_length_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get(const tng_trajectory_t tng_data, int64_t *len); /** @@ -831,7 +847,7 @@ tng_function_status tng_long_stride_length_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred. */ -tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set(tng_trajectory_t tng_data, const int64_t len); /** @@ -840,7 +856,7 @@ tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data, * @param len is pointing to a value set to the file length. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_input_file_len_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get(const tng_trajectory_t tng_data, int64_t *len); /** @@ -850,7 +866,7 @@ tng_function_status tng_input_file_len_get(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred (could not find last frame set). */ -tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_num_frames_get(const tng_trajectory_t tng_data, int64_t *n); /** @@ -861,7 +877,7 @@ tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data, * the number of particles in the current frame set. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_num_particles_get(const tng_trajectory_t tng_data, int64_t *n); /** @@ -872,7 +888,7 @@ tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data, * the total number of molecules in the current frame set. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get(const tng_trajectory_t tng_data, int64_t *n); /** @@ -882,7 +898,7 @@ tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data, * @param n is pointing to a value set to the number of frames per frame set. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_num_frames_per_frame_set_get +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get (const tng_trajectory_t tng_data, int64_t *n); @@ -896,7 +912,7 @@ tng_function_status tng_num_frames_per_frame_set_get * betfore creating any frame sets. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_num_frames_per_frame_set_set +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set (const tng_trajectory_t tng_data, const int64_t n); @@ -908,7 +924,7 @@ tng_function_status tng_num_frames_per_frame_set_set * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_num_frame_sets_get +tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get (const tng_trajectory_t tng_data, int64_t *n); @@ -919,7 +935,7 @@ tng_function_status tng_num_frame_sets_get * the found frame set. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_current_frame_set_get +tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get (tng_trajectory_t tng_data, tng_trajectory_frame_set_t *frame_set_p); @@ -932,7 +948,7 @@ tng_function_status tng_current_frame_set_get * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find(tng_trajectory_t tng_data, const int64_t nr); /** @@ -944,7 +960,7 @@ tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find(tng_trajectory_t tng_data, const int64_t frame); /** @@ -955,7 +971,7 @@ tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data, * @param pos is pointing to a value set to the file position. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_frame_set_next_frame_set_file_pos_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos); @@ -968,7 +984,7 @@ tng_function_status tng_frame_set_next_frame_set_file_pos_get * @param pos is pointing to a value set to the file position. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_frame_set_prev_frame_set_file_pos_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos); @@ -981,7 +997,7 @@ tng_function_status tng_frame_set_prev_frame_set_file_pos_get * @param last_frame is set to the last frame of the frame set. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_frame_set_frame_range_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *first_frame, @@ -994,7 +1010,7 @@ tng_function_status tng_frame_set_frame_range_get * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_molecule_init(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_init(const tng_trajectory_t tng_data, tng_molecule_t molecule); /** @@ -1006,7 +1022,7 @@ tng_function_status tng_molecule_init(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy(const tng_trajectory_t tng_data, tng_molecule_t molecule); /** @@ -1017,7 +1033,7 @@ tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_molecule_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_add(tng_trajectory_t tng_data, const char *name, tng_molecule_t *molecule); @@ -1029,7 +1045,7 @@ tng_function_status tng_molecule_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set(tng_trajectory_t tng_data, tng_molecule_t molecule, const char *new_name); @@ -1041,7 +1057,7 @@ tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get(tng_trajectory_t tng_data, tng_molecule_t molecule, int64_t *cnt); @@ -1053,9 +1069,9 @@ tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set(tng_trajectory_t tng_data, tng_molecule_t molecule, - int64_t cnt); + const int64_t cnt); /** * @brief Find a chain in a molecule. @@ -1071,7 +1087,7 @@ tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data, * @details If name is an empty string and id is -1 the first chain will be * found. */ -tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find(tng_trajectory_t tng_data, tng_molecule_t molecule, const char *name, int64_t id, @@ -1086,7 +1102,7 @@ tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add(tng_trajectory_t tng_data, tng_molecule_t molecule, const char *name, tng_chain_t *chain); @@ -1099,7 +1115,7 @@ tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_chain_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_chain_name_set(tng_trajectory_t tng_data, tng_chain_t chain, const char *new_name); @@ -1113,7 +1129,7 @@ tng_function_status tng_chain_name_set(tng_trajectory_t tng_data, * residue is not found. * @details If name is an empty string the first residue will be found. */ -tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_chain_residue_find(tng_trajectory_t tng_data, tng_chain_t chain, const char *name, int64_t id, @@ -1128,7 +1144,7 @@ tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add(tng_trajectory_t tng_data, tng_chain_t chain, const char *name, tng_residue_t *residue); @@ -1141,7 +1157,7 @@ tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_residue_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_residue_name_set(tng_trajectory_t tng_data, tng_residue_t residue, const char *new_name); @@ -1155,7 +1171,7 @@ tng_function_status tng_residue_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add(tng_trajectory_t tng_data, tng_residue_t residue, const char *atom_name, const char *atom_type, @@ -1169,7 +1185,7 @@ tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_atom_name_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_atom_name_set(tng_trajectory_t tng_data, tng_atom_t atom, const char *new_name); @@ -1181,7 +1197,7 @@ tng_function_status tng_atom_name_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_atom_type_set(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_atom_type_set(tng_trajectory_t tng_data, tng_atom_t atom, const char *new_type); @@ -1195,7 +1211,7 @@ tng_function_status tng_atom_type_set(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error * has occured. */ -tng_function_status tng_molecule_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -1211,7 +1227,7 @@ tng_function_status tng_molecule_name_of_particle_nr_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error * has occured. */ -tng_function_status tng_chain_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -1227,7 +1243,7 @@ tng_function_status tng_chain_name_of_particle_nr_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error * has occured. */ -tng_function_status tng_residue_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -1243,7 +1259,7 @@ tng_function_status tng_residue_name_of_particle_nr_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error * has occured. */ -tng_function_status tng_atom_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -1259,7 +1275,7 @@ tng_function_status tng_atom_name_of_particle_nr_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error * has occured. */ -tng_function_status tng_atom_type_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *type, @@ -1284,7 +1300,7 @@ tng_function_status tng_atom_type_of_particle_nr_get * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_particle_mapping_add +tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add (tng_trajectory_t tng_data, const int64_t first_particle_number, const int64_t n_particles, @@ -1304,7 +1320,7 @@ tng_function_status tng_particle_mapping_add * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_file_headers_read(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_file_headers_read(tng_trajectory_t tng_data, const tng_hash_mode hash_mode); /** @@ -1320,7 +1336,7 @@ tng_function_status tng_file_headers_read(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major * error has occured. */ -tng_function_status tng_file_headers_write(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_file_headers_write(tng_trajectory_t tng_data, const tng_hash_mode hash_mode); /** @@ -1339,7 +1355,7 @@ tng_function_status tng_file_headers_write(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_block_read_next(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_block_read_next(tng_trajectory_t tng_data, tng_gen_block_t block_data, const tng_hash_mode hash_mode); @@ -1356,7 +1372,7 @@ tng_function_status tng_block_read_next(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_set_read_next(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next(tng_trajectory_t tng_data, const tng_hash_mode hash_mode); /** @@ -1371,7 +1387,7 @@ tng_function_status tng_frame_set_read_next(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_set_write(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_write(tng_trajectory_t tng_data, const tng_hash_mode hash_mode); /** @@ -1383,7 +1399,7 @@ tng_function_status tng_frame_set_write(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_new(tng_trajectory_t tng_data, const int64_t first_frame, const int64_t n_frames); @@ -1408,7 +1424,7 @@ tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_data_block_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_data_block_add(tng_trajectory_t tng_data, const int64_t id, const char *block_name, const tng_data_type datatype, @@ -1443,7 +1459,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add(tng_trajectory_t tng_data, const int64_t id, const char *block_name, const tng_data_type datatype, @@ -1471,7 +1487,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_data_write(tng_trajectory_t tng_data, const int64_t frame_nr, const int64_t block_id, const void *data, @@ -1496,7 +1512,7 @@ tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write(tng_trajectory_t tng_data, const int64_t frame_nr, const int64_t block_id, const int64_t val_first_particle, @@ -1513,7 +1529,7 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, * @param type is the data type of the data in the array (e.g. int/float/char). * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_data_values_free(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_data_values_free(const tng_trajectory_t tng_data, union data_values **values, const int64_t n_frames, const int64_t n_values_per_frame, @@ -1529,7 +1545,7 @@ tng_function_status tng_data_values_free(const tng_trajectory_t tng_data, * @param type is the data type of the data in the array (e.g. int/float/char). * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_particle_data_values_free(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free(const tng_trajectory_t tng_data, union data_values ***values, const int64_t n_frames, const int64_t n_particles, @@ -1555,7 +1571,7 @@ tng_function_status tng_particle_data_values_free(const tng_trajectory_t tng_dat * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_data_get(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_data_get(tng_trajectory_t tng_data, const int64_t block_id, union data_values ***values, int64_t *n_frames, @@ -1584,7 +1600,7 @@ tng_function_status tng_data_get(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_data_interval_get(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_data_interval_get(tng_trajectory_t tng_data, const int64_t block_id, const int64_t start_frame_nr, const int64_t end_frame_nr, @@ -1617,7 +1633,7 @@ tng_function_status tng_data_interval_get(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_particle_data_get(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_particle_data_get(tng_trajectory_t tng_data, const int64_t block_id, union data_values ****values, int64_t *n_frames, @@ -1652,7 +1668,7 @@ tng_function_status tng_particle_data_get(tng_trajectory_t tng_data, * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error * has occurred or TNG_CRITICAL (2) if a major error has occured. */ -tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get(tng_trajectory_t tng_data, const int64_t block_id, const int64_t start_frame_nr, const int64_t end_frame_nr, @@ -1668,7 +1684,7 @@ tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data, must be reserved beforehand. * @return TNG_SUCCESS (0) if successful. */ -tng_function_status tng_time_get_str(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_time_get_str(const tng_trajectory_t tng_data, char *time); diff --git a/src/lib/md5.c b/src/lib/md5.c index 57c2138..8bd79b9 100644 --- a/src/lib/md5.c +++ b/src/lib/md5.c @@ -41,6 +41,18 @@ #define ARCH_IS_BIG_ENDIAN 0 #endif +#ifndef USE_WINDOWS +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#define USE_WINDOWS +#endif /* win32... */ +#endif /* not defined USE_WINDOWS */ + +#ifdef USE_WINDOWS +#define TNG_INLINE __inline +#else +#define TNG_INLINE inline +#endif + /* Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. @@ -169,11 +181,7 @@ #define T63 0x2ad7d2bb #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) -#ifdef USE_WINDOWS -static inline void -#else -static __inline void -#endif +static TNG_INLINE void md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) { md5_word_t @@ -355,8 +363,8 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) pms->abcd[3] += d; } -void -md5_init(md5_state_t *pms) +void DECLSPECDLLEXPORT +tng_md5_init(md5_state_t *pms) { pms->count[0] = pms->count[1] = 0; pms->abcd[0] = 0x67452301; @@ -365,8 +373,8 @@ md5_init(md5_state_t *pms) pms->abcd[3] = 0x10325476; } -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +void DECLSPECDLLEXPORT +tng_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) { const md5_byte_t *p = data; int left = nbytes; @@ -403,8 +411,8 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) memcpy(pms->buf, p, left); } -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) +void DECLSPECDLLEXPORT +tng_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, @@ -419,9 +427,9 @@ md5_finish(md5_state_t *pms, md5_byte_t digest[16]) for (i = 0; i < 8; ++i) 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); + tng_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); /* Append the length. */ - md5_append(pms, data, 8); + tng_md5_append(pms, data, 8); for (i = 0; i < 16; ++i) digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); } diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 1205d96..f43de8f 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -339,8 +339,35 @@ struct tng_trajectory { struct tng_non_particle_data *non_tr_data; }; +#ifndef USE_WINDOWS +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#define USE_WINDOWS +#endif /* win32... */ +#endif /* not defined USE_WINDOWS */ + +#ifdef USE_WINDOWS +#define TNG_INLINE __inline +#define TNG_SNPRINTF _snprintf +#else +#define TNG_INLINE inline +#define TNG_SNPRINTF snprintf +#endif +static TNG_INLINE int tng_min(int a, int b) +{ + int r=a; + if (ba) + r=b; + return r; +} /** This function swaps the byte order of a 32 bit numerical variable * to big endian. @@ -536,10 +563,10 @@ static tng_function_status tng_block_hash_generate(tng_gen_block_t block) { md5_state_t md5_state; - md5_init(&md5_state); - md5_append(&md5_state, (md5_byte_t *)block->block_contents, + tng_md5_init(&md5_state); + tng_md5_append(&md5_state, (md5_byte_t *)block->block_contents, block->block_contents_size); - md5_finish(&md5_state, (md5_byte_t *)block->hash); + tng_md5_finish(&md5_state, (md5_byte_t *)block->hash); return(TNG_SUCCESS); } @@ -564,10 +591,10 @@ static tng_function_status hash_match_verify(tng_gen_block_t block, *results = TNG_TRUE; return(TNG_FAILURE); } - md5_init(&md5_state); - md5_append(&md5_state, (md5_byte_t *)block->block_contents, + tng_md5_init(&md5_state); + tng_md5_append(&md5_state, (md5_byte_t *)block->block_contents, block->block_contents_size); - md5_finish(&md5_state, (md5_byte_t *)hash); + tng_md5_finish(&md5_state, (md5_byte_t *)hash); if(strncmp(block->hash, hash, 16) != 0) { @@ -823,7 +850,7 @@ static tng_function_status tng_block_header_read } /* Move the reading position to the beginning of the header. */ - fseek(tng_data->input_file, -sizeof(block->header_contents_size), + fseek(tng_data->input_file, -(long)sizeof(block->header_contents_size), SEEK_CUR); /* If there is already memory allocated for the contents free it (we do not @@ -6358,9 +6385,9 @@ static tng_function_status tng_atom_destroy(tng_atom_t atom) return(TNG_SUCCESS); } -tng_function_status tng_molecule_add(tng_trajectory_t tng_data, - const char *name, - tng_molecule_t *molecule) +tng_function_status DECLSPECDLLEXPORT tng_molecule_add(tng_trajectory_t tng_data, + const char *name, + tng_molecule_t *molecule) { tng_molecule_t new_molecules; int64_t *new_molecule_cnt_list; @@ -6430,9 +6457,9 @@ tng_function_status tng_molecule_add(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *new_name) { int len; @@ -6461,9 +6488,9 @@ tng_function_status tng_molecule_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t *cnt) +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get(tng_trajectory_t tng_data, + tng_molecule_t molecule, + int64_t *cnt) { int i, index = -1; @@ -6484,9 +6511,9 @@ tng_function_status tng_molecule_cnt_get(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const int64_t cnt) +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const int64_t cnt) { int i, index = -1, old_cnt; @@ -6511,11 +6538,11 @@ tng_function_status tng_molecule_cnt_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *name, - int64_t nr, - tng_chain_t *chain) +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *name, + int64_t nr, + tng_chain_t *chain) { int i, n_chains; @@ -6539,10 +6566,10 @@ tng_function_status tng_molecule_chain_find(tng_trajectory_t tng_data, } /* FIXME: For v. 2 the chain nr should also be possible to specify. */ -tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *name, - tng_chain_t *chain) +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *name, + tng_chain_t *chain) { tng_chain_t new_chains; @@ -6576,9 +6603,9 @@ tng_function_status tng_molecule_chain_add(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_chain_name_set(tng_trajectory_t tng_data, - tng_chain_t chain, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_chain_name_set(tng_trajectory_t tng_data, + tng_chain_t chain, + const char *new_name) { int len; @@ -6607,11 +6634,11 @@ tng_function_status tng_chain_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data, - tng_chain_t chain, - const char *name, - int64_t nr, - tng_residue_t *residue) +tng_function_status DECLSPECDLLEXPORT tng_chain_residue_find(tng_trajectory_t tng_data, + tng_chain_t chain, + const char *name, + int64_t nr, + tng_residue_t *residue) { int i, n_residues; @@ -6635,10 +6662,10 @@ tng_function_status tng_chain_residue_find(tng_trajectory_t tng_data, } /* FIXME: For v. 2 the residue nr should also be possible to specify. */ -tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data, - tng_chain_t chain, - const char *name, - tng_residue_t *residue) +tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add(tng_trajectory_t tng_data, + tng_chain_t chain, + const char *name, + tng_residue_t *residue) { int curr_index; tng_residue_t new_residues, temp_residue, last_residue; @@ -6713,9 +6740,9 @@ tng_function_status tng_chain_residue_add(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_residue_name_set(tng_trajectory_t tng_data, - tng_residue_t residue, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_residue_name_set(tng_trajectory_t tng_data, + tng_residue_t residue, + const char *new_name) { int len; @@ -6745,11 +6772,11 @@ tng_function_status tng_residue_name_set(tng_trajectory_t tng_data, } /* FIXME: For v. 2 the atom nr should also be possible to specify. */ -tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data, - tng_residue_t residue, - const char *atom_name, - const char *atom_type, - tng_atom_t *atom) +tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add(tng_trajectory_t tng_data, + tng_residue_t residue, + const char *atom_name, + const char *atom_type, + tng_atom_t *atom) { tng_atom_t new_atoms; tng_molecule_t molecule = residue->chain->molecule; @@ -6791,8 +6818,8 @@ tng_function_status tng_residue_atom_add(tng_trajectory_t tng_data, } -tng_function_status tng_molecule_init(const tng_trajectory_t tng_data, - tng_molecule_t molecule) +tng_function_status DECLSPECDLLEXPORT tng_molecule_init(const tng_trajectory_t tng_data, + tng_molecule_t molecule) { molecule->quaternary_str = 1; molecule->name = 0; @@ -6808,8 +6835,8 @@ tng_function_status tng_molecule_init(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data, - tng_molecule_t molecule) +tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy(const tng_trajectory_t tng_data, + tng_molecule_t molecule) { int i; @@ -6870,11 +6897,11 @@ tng_function_status tng_molecule_destroy(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_molecule_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get (const tng_trajectory_t tng_data, - const int64_t nr, - char *name, - int max_len) + const int64_t nr, + char *name, + int max_len) { int64_t cnt = 0, i, *molecule_cnt_list; tng_molecule_t mol; @@ -6916,7 +6943,7 @@ tng_function_status tng_molecule_name_of_particle_nr_get return(TNG_SUCCESS); } -tng_function_status tng_chain_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -6968,7 +6995,7 @@ tng_function_status tng_chain_name_of_particle_nr_get return(TNG_SUCCESS); } -tng_function_status tng_residue_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -7020,7 +7047,7 @@ tng_function_status tng_residue_name_of_particle_nr_get return(TNG_SUCCESS); } -tng_function_status tng_atom_name_of_particle_nr_get +tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -7116,7 +7143,7 @@ tng_function_status tng_atom_type_of_particle_nr_get return(TNG_SUCCESS); } -tng_function_status tng_particle_mapping_add +tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add (tng_trajectory_t tng_data, const int64_t num_first_particle, const int64_t n_particles, @@ -7200,7 +7227,7 @@ tng_function_status tng_particle_mapping_add return(TNG_SUCCESS); } -tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p) +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init(tng_trajectory_t *tng_data_p) { time_t seconds; tng_trajectory_frame_set_t frame_set; @@ -7288,56 +7315,59 @@ tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p) tng_data->molecule_cnt_list = 0; tng_data->n_particles = 0; - /* Check the endianness of the computer */ - static int32_t endianness_32 = 0x01234567; - /* 0x01234567 */ - if ( *(const uint8_t*)&endianness_32 == 0x01 ) - { - tng_data->endianness_32 = TNG_BIG_ENDIAN_32; - } - - /* 0x67452301 */ - else if( *(const uint8_t*)&endianness_32 == 0x67 ) - { - tng_data->endianness_32 = TNG_LITTLE_ENDIAN_32; - - } - - /* 0x45670123 */ - else if ( *(const uint8_t*)&endianness_32 == 0x45 ) - { - tng_data->endianness_32 = TNG_BYTE_PAIR_SWAP_32; - } - - static int64_t endianness_64 = 0x0123456789ABCDEF; - /* 0x0123456789ABCDEF */ - if ( *(const uint8_t*)&endianness_64 == 0x01 ) - { - tng_data->endianness_64 = TNG_BIG_ENDIAN_64; - } - - /* 0xEFCDAB8967452301 */ - else if ( *(const uint8_t*)&endianness_64 == 0xEF ) { - tng_data->endianness_64 = TNG_LITTLE_ENDIAN_64; - } - - /* 0x89ABCDEF01234567 */ - else if ( *(const uint8_t*)&endianness_64 == 0x89 ) - { - tng_data->endianness_64 = TNG_QUAD_SWAP_64; - } - - /* 0x45670123CDEF89AB */ - else if ( *(const uint8_t*)&endianness_64 == 0x45 ) - { - tng_data->endianness_64 = TNG_BYTE_PAIR_SWAP_64; - } - - /* 0x23016745AB89EFCD */ - else if ( *(const uint8_t*)&endianness_64 == 0x23 ) - { - tng_data->endianness_64 = TNG_BYTE_SWAP_64; + /* Check the endianness of the computer */ + static int32_t endianness_32 = 0x01234567; + /* 0x01234567 */ + if ( *(const uint8_t*)&endianness_32 == 0x01 ) + { + tng_data->endianness_32 = TNG_BIG_ENDIAN_32; + } + + /* 0x67452301 */ + else if( *(const uint8_t*)&endianness_32 == 0x67 ) + { + tng_data->endianness_32 = TNG_LITTLE_ENDIAN_32; + + } + + /* 0x45670123 */ + else if ( *(const uint8_t*)&endianness_32 == 0x45 ) + { + tng_data->endianness_32 = TNG_BYTE_PAIR_SWAP_32; + } + } + { + static int64_t endianness_64 = 0x0123456789ABCDEF; + /* 0x0123456789ABCDEF */ + if ( *(const uint8_t*)&endianness_64 == 0x01 ) + { + tng_data->endianness_64 = TNG_BIG_ENDIAN_64; + } + + /* 0xEFCDAB8967452301 */ + else if ( *(const uint8_t*)&endianness_64 == 0xEF ) + { + tng_data->endianness_64 = TNG_LITTLE_ENDIAN_64; + } + + /* 0x89ABCDEF01234567 */ + else if ( *(const uint8_t*)&endianness_64 == 0x89 ) + { + tng_data->endianness_64 = TNG_QUAD_SWAP_64; + } + + /* 0x45670123CDEF89AB */ + else if ( *(const uint8_t*)&endianness_64 == 0x45 ) + { + tng_data->endianness_64 = TNG_BYTE_PAIR_SWAP_64; + } + + /* 0x23016745AB89EFCD */ + else if ( *(const uint8_t*)&endianness_64 == 0x23 ) + { + tng_data->endianness_64 = TNG_BYTE_SWAP_64; + } } /* By default do not swap the byte order, i.e. keep the byte order of the @@ -7356,7 +7386,7 @@ tng_function_status tng_trajectory_init(tng_trajectory_t *tng_data_p) return(TNG_SUCCESS); } -tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p) +tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy(tng_trajectory_t *tng_data_p) { int64_t n_particles; int i; @@ -7597,7 +7627,7 @@ tng_function_status tng_trajectory_destroy(tng_trajectory_t *tng_data_p) return(TNG_SUCCESS); } -tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src, +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajectory_t src, tng_trajectory_t *dest_p) { tng_trajectory_frame_set_t frame_set; @@ -7709,7 +7739,7 @@ tng_function_status tng_trajectory_init_from_src(tng_trajectory_t src, return(TNG_SUCCESS); } -tng_function_status tng_input_file_get(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_get(const tng_trajectory_t tng_data, char *file_name, const int max_len) { strncpy(file_name, tng_data->input_file_path, max_len - 1); @@ -7722,8 +7752,8 @@ tng_function_status tng_input_file_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_input_file_set(tng_trajectory_t tng_data, - const char *file_name) +tng_function_status DECLSPECDLLEXPORT tng_input_file_set(tng_trajectory_t tng_data, + const char *file_name) { int len; char *temp; @@ -7768,8 +7798,8 @@ tng_function_status tng_output_file_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_output_file_set(tng_trajectory_t tng_data, - const char *file_name) +tng_function_status DECLSPECDLLEXPORT tng_output_file_set(tng_trajectory_t tng_data, + const char *file_name) { int len; char *temp; @@ -7801,7 +7831,7 @@ tng_function_status tng_output_file_set(tng_trajectory_t tng_data, return(tng_output_file_init(tng_data)); } -tng_function_status tng_output_file_endianness_get +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get (tng_trajectory_t tng_data, tng_file_endianness *endianness) { tng_endianness_32 end_32; @@ -7875,7 +7905,7 @@ tng_function_status tng_output_file_endianness_get return(TNG_SUCCESS); } -tng_function_status tng_output_file_endianness_set +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set (tng_trajectory_t tng_data, const tng_file_endianness endianness) { @@ -7936,8 +7966,9 @@ tng_function_status tng_output_file_endianness_set return(TNG_FAILURE); } -tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->first_program_name, max_len - 1); name[max_len - 1] = 0; @@ -7949,8 +7980,8 @@ tng_function_status tng_first_program_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set(tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -7977,8 +8008,9 @@ tng_function_status tng_first_program_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->last_program_name, max_len - 1); name[max_len - 1] = 0; @@ -7990,8 +8022,9 @@ tng_function_status tng_last_program_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8018,8 +8051,9 @@ tng_function_status tng_last_program_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->first_user_name, max_len - 1); name[max_len - 1] = 0; @@ -8031,8 +8065,9 @@ tng_function_status tng_first_user_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8061,8 +8096,9 @@ tng_function_status tng_first_user_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->last_user_name, max_len - 1); name[max_len - 1] = 0; @@ -8074,8 +8110,9 @@ tng_function_status tng_last_user_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8104,8 +8141,9 @@ tng_function_status tng_last_user_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->first_computer_name, max_len - 1); name[max_len - 1] = 0; @@ -8117,8 +8155,9 @@ tng_function_status tng_first_computer_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8147,8 +8186,9 @@ tng_function_status tng_first_computer_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->last_computer_name, max_len - 1); name[max_len - 1] = 0; @@ -8160,8 +8200,9 @@ tng_function_status tng_last_computer_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8191,8 +8232,9 @@ tng_function_status tng_last_computer_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data, - char *signature, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_first_signature_get + (const tng_trajectory_t tng_data, + char *signature, const int max_len) { strncpy(signature, tng_data->first_pgp_signature, max_len - 1); signature[max_len - 1] = 0; @@ -8204,8 +8246,9 @@ tng_function_status tng_first_signature_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_first_signature_set(tng_trajectory_t tng_data, - const char *signature) +tng_function_status DECLSPECDLLEXPORT tng_first_signature_set + (tng_trajectory_t tng_data, + const char *signature) { int len; @@ -8235,8 +8278,9 @@ tng_function_status tng_first_signature_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data, - char *signature, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_last_signature_get + (const tng_trajectory_t tng_data, + char *signature, const int max_len) { strncpy(signature, tng_data->last_pgp_signature, max_len - 1); signature[max_len - 1] = 0; @@ -8248,8 +8292,9 @@ tng_function_status tng_last_signature_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_last_signature_set(tng_trajectory_t tng_data, - const char *signature) +tng_function_status DECLSPECDLLEXPORT tng_last_signature_set + (tng_trajectory_t tng_data, + const char *signature) { int len; @@ -8279,8 +8324,9 @@ tng_function_status tng_last_signature_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get + (const tng_trajectory_t tng_data, + char *name, const int max_len) { strncpy(name, tng_data->forcefield_name, max_len - 1); name[max_len - 1] = 0; @@ -8292,8 +8338,9 @@ tng_function_status tng_forcefield_name_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data, - const char *new_name) +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set + (tng_trajectory_t tng_data, + const char *new_name) { int len; @@ -8322,16 +8369,18 @@ tng_function_status tng_forcefield_name_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_medium_stride_length_get(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get + (const tng_trajectory_t tng_data, + int64_t *len) { *len = tng_data->medium_stride_length; return(TNG_SUCCESS); } -tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data, - const int64_t len) +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set + (tng_trajectory_t tng_data, + const int64_t len) { if(len >= tng_data->long_stride_length) { @@ -8342,16 +8391,18 @@ tng_function_status tng_medium_stride_length_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_long_stride_length_get(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get + (const tng_trajectory_t tng_data, + int64_t *len) { *len = tng_data->long_stride_length; return(TNG_SUCCESS); } -tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data, - const int64_t len) +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set + (tng_trajectory_t tng_data, + const int64_t len) { if(len <= tng_data->medium_stride_length) { @@ -8362,16 +8413,18 @@ tng_function_status tng_long_stride_length_set(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_input_file_len_get(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get + (const tng_trajectory_t tng_data, + int64_t *len) { *len = tng_data->input_file_len; return(TNG_SUCCESS); } -tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_frames_get + (const tng_trajectory_t tng_data, + int64_t *n) { tng_gen_block_t block; tng_function_status stat; @@ -8414,8 +8467,9 @@ tng_function_status tng_num_frames_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_particles_get + (const tng_trajectory_t tng_data, + int64_t *n) { if(tng_data->var_num_atoms_flag == TNG_CONSTANT_N_ATOMS) { @@ -8429,8 +8483,9 @@ tng_function_status tng_num_particles_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get + (const tng_trajectory_t tng_data, + int64_t *n) { int64_t *cnt_list, cnt = 0, i; @@ -8453,7 +8508,7 @@ tng_function_status tng_num_molecules_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_num_frames_per_frame_set_get +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get (const tng_trajectory_t tng_data, int64_t *n) { @@ -8462,7 +8517,7 @@ tng_function_status tng_num_frames_per_frame_set_get return(TNG_SUCCESS); } -tng_function_status tng_num_frames_per_frame_set_set +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set (const tng_trajectory_t tng_data, const int64_t n) { @@ -8471,8 +8526,9 @@ tng_function_status tng_num_frames_per_frame_set_set return(TNG_SUCCESS); } -tng_function_status tng_num_frame_sets_get(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get + (const tng_trajectory_t tng_data, + int64_t *n) { int64_t long_stride_length, medium_stride_length; int64_t file_pos; @@ -8610,7 +8666,7 @@ tng_function_status tng_num_frame_sets_get(const tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_current_frame_set_get +tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get (tng_trajectory_t tng_data, tng_trajectory_frame_set_t *frame_set_p) { @@ -8619,8 +8675,9 @@ tng_function_status tng_current_frame_set_get return(TNG_SUCCESS); } -tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data, - const int64_t nr) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find + (tng_trajectory_t tng_data, + const int64_t nr) { int64_t long_stride_length, medium_stride_length; int64_t file_pos, curr_nr = 0, n_frame_sets; @@ -8933,8 +8990,9 @@ tng_function_status tng_frame_set_nr_find(tng_trajectory_t tng_data, return(TNG_FAILURE); } -tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data, - const int64_t frame) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find + (tng_trajectory_t tng_data, + const int64_t frame) { int64_t first_frame, last_frame, n_frames_per_frame_set; int64_t long_stride_length, medium_stride_length; @@ -9274,7 +9332,7 @@ tng_function_status tng_frame_set_of_frame_find(tng_trajectory_t tng_data, return(TNG_FAILURE); } -tng_function_status tng_frame_set_next_frame_set_file_pos_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos) @@ -9284,7 +9342,7 @@ tng_function_status tng_frame_set_next_frame_set_file_pos_get return(TNG_SUCCESS); } -tng_function_status tng_frame_set_prev_frame_set_file_pos_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos) @@ -9294,7 +9352,7 @@ tng_function_status tng_frame_set_prev_frame_set_file_pos_get return(TNG_SUCCESS); } -tng_function_status tng_frame_set_frame_range_get +tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *first_frame, @@ -9314,7 +9372,7 @@ tng_function_status tng_frame_set_frame_range_get * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the mapping * cannot be found. */ -static inline tng_function_status tng_particle_mapping_get_real_particle +static TNG_INLINE tng_function_status tng_particle_mapping_get_real_particle (const tng_trajectory_frame_set_t frame_set, const int64_t local, int64_t *real) @@ -9350,7 +9408,7 @@ static inline tng_function_status tng_particle_mapping_get_real_particle * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the mapping * cannot be found. */ -static inline tng_function_status tng_particle_mapping_get_local_particle +static TNG_INLINE tng_function_status tng_particle_mapping_get_local_particle (const tng_trajectory_frame_set_t frame_set, const int64_t real, int64_t *local) @@ -9378,7 +9436,7 @@ static inline tng_function_status tng_particle_mapping_get_local_particle } -tng_function_status tng_file_headers_read(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_file_headers_read(tng_trajectory_t tng_data, const tng_hash_mode hash_mode) { int cnt = 0, prev_pos = 0; @@ -9425,7 +9483,7 @@ tng_function_status tng_file_headers_read(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_file_headers_write(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_file_headers_write(tng_trajectory_t tng_data, const tng_hash_mode hash_mode) { int i; @@ -9475,7 +9533,7 @@ tng_function_status tng_file_headers_write(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_block_read_next(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_block_read_next(tng_trajectory_t tng_data, tng_gen_block_t block, const tng_hash_mode hash_mode) { @@ -9504,7 +9562,7 @@ tng_function_status tng_block_read_next(tng_trajectory_t tng_data, } -tng_function_status tng_frame_set_read_next(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next(tng_trajectory_t tng_data, const tng_hash_mode hash_mode) { long int file_pos; @@ -9678,9 +9736,10 @@ tng_function_status tng_frame_set_write(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, - const int64_t first_frame, - const int64_t n_frames) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_new + (tng_trajectory_t tng_data, + const int64_t first_frame, + const int64_t n_frames) { int i; tng_gen_block_t block; @@ -9870,22 +9929,24 @@ tng_function_status tng_frame_set_new(tng_trajectory_t tng_data, -tng_function_status tng_data_block_add(tng_trajectory_t tng_data, - const int64_t id, - const char *block_name, - const tng_data_type datatype, - const tng_block_type block_type_flag, - int64_t n_frames, - const int64_t n_values_per_frame, - int64_t stride_length, - const int64_t codec_id, - void *new_data) +tng_function_status DECLSPECDLLEXPORT tng_data_block_add + (tng_trajectory_t tng_data, + const int64_t id, + const char *block_name, + const tng_data_type datatype, + const tng_block_type block_type_flag, + int64_t n_frames, + const int64_t n_values_per_frame, + int64_t stride_length, + const int64_t codec_id, + void *new_data) { int i, j, block_index, size, len; tng_trajectory_frame_set_t frame_set; tng_non_particle_data_t data; union data_values *first_dim_values; - void *orig; + char *orig; + char *new_data_c=new_data; frame_set = &tng_data->current_trajectory_frame_set; @@ -9977,7 +10038,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, break; } - if(new_data) + if(new_data_c) { /* Allocate memory */ if(tng_allocate_data_mem(tng_data, data, n_frames, stride_length, @@ -9989,7 +10050,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, return(TNG_CRITICAL); } - orig = new_data; + orig = new_data_c; if(n_frames > frame_set->n_written_frames) { @@ -10005,8 +10066,8 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, for(j = 0; j < n_values_per_frame; j++) { memcpy(&first_dim_values[j].f, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } break; @@ -10016,7 +10077,7 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, first_dim_values = data->values[i]; for(j = 0; j < n_values_per_frame; j++) { - len = tng_min(strlen(new_data) + 1, + len = tng_min(strlen(new_data_c) + 1, TNG_MAX_STR_LEN); if(first_dim_values[j].c) { @@ -10030,8 +10091,8 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, return(TNG_CRITICAL); } strncpy(first_dim_values[j].c, - new_data, len); - new_data += len; + new_data_c, len); + new_data_c += len; } } break; @@ -10042,8 +10103,8 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, for(j = 0; j < n_values_per_frame; j++) { memcpy(&first_dim_values[j].i, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } break; @@ -10055,13 +10116,13 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, for(j = 0; j < n_values_per_frame; j++) { memcpy(&first_dim_values[j].d, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } } - new_data = orig; + new_data_c = orig; } // else // { @@ -10078,25 +10139,27 @@ tng_function_status tng_data_block_add(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, - const int64_t id, - const char *block_name, - const tng_data_type datatype, - const tng_block_type block_type_flag, - int64_t n_frames, - const int64_t n_values_per_frame, - int64_t stride_length, - const int64_t num_first_particle, - const int64_t n_particles, - const int64_t codec_id, - void *new_data) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add + (tng_trajectory_t tng_data, + const int64_t id, + const char *block_name, + const tng_data_type datatype, + const tng_block_type block_type_flag, + int64_t n_frames, + const int64_t n_values_per_frame, + int64_t stride_length, + const int64_t num_first_particle, + const int64_t n_particles, + const int64_t codec_id, + void *new_data) { int i, j, k, block_index, size, len; int64_t tot_n_particles; union data_values **first_dim_values, *second_dim_values; tng_trajectory_frame_set_t frame_set; tng_particle_data_t data; - void *orig; + char *orig; + char *new_data_c=new_data; frame_set = &tng_data->current_trajectory_frame_set; @@ -10184,7 +10247,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, } /* If data values are supplied add that data to the data block. */ - if(new_data) + if(new_data_c) { /* Allocate memory */ if(tng_allocate_particle_data_mem(tng_data, data, n_frames, @@ -10197,7 +10260,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, return(TNG_CRITICAL); } - orig = new_data; + orig = new_data_c; if(n_frames > frame_set->n_written_frames) { @@ -10218,8 +10281,8 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, for(k = 0; k < n_values_per_frame; k++) { memcpy(&second_dim_values[k].f, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } } @@ -10236,8 +10299,8 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, for(k = 0; k < n_values_per_frame; k++) { memcpy(&second_dim_values[k].i, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } } @@ -10252,7 +10315,7 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, second_dim_values = first_dim_values[j]; for(k = 0; k < n_values_per_frame; k++) { - len = tng_min(strlen(new_data) + 1, + len = tng_min(strlen(new_data_c) + 1, TNG_MAX_STR_LEN); if(second_dim_values[k].c) { @@ -10266,8 +10329,8 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, return(TNG_CRITICAL); } strncpy(second_dim_values[k].c, - new_data, len); - new_data += len; + new_data_c, len); + new_data_c += len; } } } @@ -10285,15 +10348,15 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, for(k = 0; k < n_values_per_frame; k++) { memcpy(&second_dim_values[k].d, - new_data, size); - new_data += size; + new_data_c, size); + new_data_c += size; } } } break; } - new_data = orig; + new_data_c = orig; } /* Otherwise fill the data block with zeroes */ // else @@ -10317,11 +10380,12 @@ tng_function_status tng_particle_data_block_add(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, - const int64_t frame_nr, - const int64_t block_id, - const void *values, - const tng_hash_mode hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_data_write + (tng_trajectory_t tng_data, + const int64_t frame_nr, + const int64_t block_id, + const void *values, + const tng_hash_mode hash_mode) { int64_t header_pos, file_pos; int64_t output_file_len, n_values_per_frame, size, contents_size; @@ -10727,13 +10791,14 @@ tng_function_status tng_frame_data_write(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, - const int64_t frame_nr, - const int64_t block_id, - const int64_t val_first_particle, - const int64_t val_n_particles, - const void *values, - const tng_hash_mode hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write + (tng_trajectory_t tng_data, + const int64_t frame_nr, + const int64_t block_id, + const int64_t val_first_particle, + const int64_t val_n_particles, + const void *values, + const tng_hash_mode hash_mode) { int64_t header_pos, file_pos, tot_n_particles; int64_t output_file_len, n_values_per_frame, size, contents_size; @@ -11257,11 +11322,12 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_data_values_free(const tng_trajectory_t tng_data, - union data_values **values, - const int64_t n_frames, - const int64_t n_values_per_frame, - const tng_data_type type) +tng_function_status DECLSPECDLLEXPORT tng_data_values_free + (const tng_trajectory_t tng_data, + union data_values **values, + const int64_t n_frames, + const int64_t n_values_per_frame, + const tng_data_type type) { int i, j; @@ -11294,7 +11360,7 @@ tng_function_status tng_data_values_free(const tng_trajectory_t tng_data, } -tng_function_status tng_particle_data_values_free +tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free (const tng_trajectory_t tng_data, union data_values ***values, const int64_t n_frames, @@ -11338,12 +11404,13 @@ tng_function_status tng_particle_data_values_free } -tng_function_status tng_data_get(tng_trajectory_t tng_data, - const int64_t block_id, - union data_values ***values, - int64_t *n_frames, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_data_get + (tng_trajectory_t tng_data, + const int64_t block_id, + union data_values ***values, + int64_t *n_frames, + int64_t *n_values_per_frame, + tng_data_type *type) { int64_t file_pos; int i, j, block_index, len; @@ -11491,14 +11558,15 @@ tng_function_status tng_data_get(tng_trajectory_t tng_data, return(TNG_SUCCESS); } -tng_function_status tng_data_interval_get(tng_trajectory_t tng_data, - const int64_t block_id, - const int64_t start_frame_nr, - const int64_t end_frame_nr, - const tng_hash_mode hash_mode, - union data_values ***values, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_data_interval_get + (tng_trajectory_t tng_data, + const int64_t block_id, + const int64_t start_frame_nr, + const int64_t end_frame_nr, + const tng_hash_mode hash_mode, + union data_values ***values, + int64_t *n_values_per_frame, + tng_data_type *type) { int64_t i, j, n_frames, file_pos, current_frame_pos; int block_index, len; @@ -11681,13 +11749,14 @@ tng_function_status tng_data_interval_get(tng_trajectory_t tng_data, } -tng_function_status tng_particle_data_get(tng_trajectory_t tng_data, - const int64_t block_id, - union data_values ****values, - int64_t *n_frames, - int64_t *n_particles, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_get + (tng_trajectory_t tng_data, + const int64_t block_id, + union data_values ****values, + int64_t *n_frames, + int64_t *n_particles, + int64_t *n_values_per_frame, + tng_data_type *type) { int64_t i, j, k, mapping, file_pos; int block_index, len; @@ -11878,15 +11947,16 @@ tng_function_status tng_particle_data_get(tng_trajectory_t tng_data, } -tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data, - const int64_t block_id, - const int64_t start_frame_nr, - const int64_t end_frame_nr, - const tng_hash_mode hash_mode, - union data_values ****values, - int64_t *n_particles, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get + (tng_trajectory_t tng_data, + const int64_t block_id, + const int64_t start_frame_nr, + const int64_t end_frame_nr, + const tng_hash_mode hash_mode, + union data_values ****values, + int64_t *n_particles, + int64_t *n_values_per_frame, + tng_data_type *type) { int64_t i, j, k, mapping, n_frames, file_pos, current_frame_pos; int block_index, len; @@ -12098,8 +12168,9 @@ tng_function_status tng_particle_data_interval_get(tng_trajectory_t tng_data, } -tng_function_status tng_time_get_str(const tng_trajectory_t tng_data, - char *time) +tng_function_status DECLSPECDLLEXPORT tng_time_get_str + (const tng_trajectory_t tng_data, + char *time) { struct tm *time_data; time_t secs; @@ -12107,7 +12178,7 @@ tng_function_status tng_time_get_str(const tng_trajectory_t tng_data, secs = tng_data->time; time_data = localtime(&secs); // Returns a statically allocated variable. - snprintf(time, TNG_MAX_DATE_STR_LEN, + TNG_SNPRINTF(time, TNG_MAX_DATE_STR_LEN, "%4d-%02d-%02d %02d:%02d:%02d", time_data->tm_year+1900, time_data->tm_mon+1, time_data->tm_mday, time_data->tm_hour, time_data->tm_min, time_data->tm_sec); @@ -12119,29 +12190,29 @@ tng_function_status tng_time_get_str(const tng_trajectory_t tng_data, #ifdef BUILD_FORTRAN /* The following is for calling the library from fortran */ -tng_function_status tng_trajectory_init_(tng_trajectory_t *tng_data_p) +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_(tng_trajectory_t *tng_data_p) { return(tng_trajectory_init(tng_data_p)); } -tng_function_status tng_trajectory_destroy_(tng_trajectory_t *tng_data_p) +tng_function_status DECLSPECDLLEXPORT tng_trajectory_destroy_(tng_trajectory_t *tng_data_p) { return(tng_trajectory_destroy(tng_data_p)); } -tng_function_status tng_trajectory_init_from_src_(tng_trajectory_t src, +tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src_(tng_trajectory_t src, tng_trajectory_t *dest_p) { return(tng_trajectory_init_from_src(src, dest_p)); } -tng_function_status tng_input_file_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_get_(const tng_trajectory_t tng_data, char *file_name, const int max_len) { return(tng_input_file_get(tng_data, file_name, max_len)); } -tng_function_status tng_input_file_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_input_file_set_(tng_trajectory_t tng_data, const char *file_name, int name_len) { char *name = malloc(name_len + 1); @@ -12154,13 +12225,13 @@ tng_function_status tng_input_file_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_output_file_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_output_file_get_(const tng_trajectory_t tng_data, char *file_name, const int max_len) { return(tng_output_file_get(tng_data, file_name, max_len)); } -tng_function_status tng_output_file_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_output_file_set_(tng_trajectory_t tng_data, const char *file_name, int name_len) { char *name = malloc(name_len + 1); @@ -12173,25 +12244,25 @@ tng_function_status tng_output_file_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_first_program_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_first_program_name_get(tng_data, name, max_len)); } -tng_function_status tng_output_file_endianness_get_ +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_get_ (tng_trajectory_t tng_data, tng_file_endianness *endianness) { return(tng_output_file_endianness_get(tng_data, endianness)); } -tng_function_status tng_output_file_endianness_set_ +tng_function_status DECLSPECDLLEXPORT tng_output_file_endianness_set_ (tng_trajectory_t tng_data, const tng_file_endianness *endianness) { return(tng_output_file_endianness_set(tng_data, *endianness)); } -tng_function_status tng_first_program_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_program_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12205,13 +12276,13 @@ tng_function_status tng_first_program_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_last_program_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_last_program_name_get(tng_data, name, max_len)); } -tng_function_status tng_last_program_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_program_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12225,13 +12296,13 @@ tng_function_status tng_last_program_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_first_user_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_first_user_name_get(tng_data, name, max_len)); } -tng_function_status tng_first_user_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_user_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12245,13 +12316,13 @@ tng_function_status tng_first_user_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_last_user_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_last_user_name_get(tng_data, name, max_len)); } -tng_function_status tng_last_user_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_user_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12265,13 +12336,13 @@ tng_function_status tng_last_user_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_first_computer_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_first_computer_name_get(tng_data, name, max_len)); } -tng_function_status tng_first_computer_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_computer_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12285,13 +12356,13 @@ tng_function_status tng_first_computer_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_last_computer_name_get_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_get_(const tng_trajectory_t tng_data, char *name, const int max_len) { return(tng_last_computer_name_get(tng_data, name, max_len)); } -tng_function_status tng_last_computer_name_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_last_computer_name_set_(tng_trajectory_t tng_data, const char *new_name, int name_len) { @@ -12305,13 +12376,14 @@ tng_function_status tng_last_computer_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_first_signature_get_(const tng_trajectory_t tng_data, - char *signature, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_first_signature_get_ + (const tng_trajectory_t tng_data, + char *signature, const int max_len) { return(tng_first_signature_get(tng_data, signature, max_len)); } -tng_function_status tng_first_signature_set_(tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_first_signature_set_(tng_trajectory_t tng_data, const char *signature, int sign_len) { @@ -12325,15 +12397,17 @@ tng_function_status tng_first_signature_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_last_signature_get_(const tng_trajectory_t tng_data, - char *signature, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_last_signature_get_ + (const tng_trajectory_t tng_data, + char *signature, const int max_len) { return(tng_last_signature_get(tng_data, signature, max_len)); } -tng_function_status tng_last_signature_set_(tng_trajectory_t tng_data, - const char *signature, - int sign_len) +tng_function_status DECLSPECDLLEXPORT tng_last_signature_set_ + (tng_trajectory_t tng_data, + const char *signature, + int sign_len) { char *sign = malloc(sign_len + 1); tng_function_status stat; @@ -12345,15 +12419,17 @@ tng_function_status tng_last_signature_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_forcefield_name_get_(const tng_trajectory_t tng_data, - char *name, const int max_len) +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_get_ + (const tng_trajectory_t tng_data, + char *name, const int max_len) { return(tng_forcefield_name_get(tng_data, name, max_len)); } -tng_function_status tng_forcefield_name_set_(tng_trajectory_t tng_data, - const char *new_name, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_forcefield_name_set_ + (tng_trajectory_t tng_data, + const char *new_name, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12365,95 +12441,104 @@ tng_function_status tng_forcefield_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_medium_stride_length_get_(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_get_ + (const tng_trajectory_t tng_data, + int64_t *len) { return(tng_medium_stride_length_get(tng_data, len)); } -tng_function_status tng_medium_stride_length_set_(tng_trajectory_t tng_data, - const int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_medium_stride_length_set_ + (tng_trajectory_t tng_data, + const int64_t *len) { return(tng_medium_stride_length_set(tng_data, *len)); } -tng_function_status tng_long_stride_length_get_(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_get_ + (const tng_trajectory_t tng_data, + int64_t *len) { return(tng_long_stride_length_get(tng_data, len)); } -tng_function_status tng_long_stride_length_set_(tng_trajectory_t tng_data, - const int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_long_stride_length_set_ + (tng_trajectory_t tng_data, + const int64_t *len) { return(tng_long_stride_length_set(tng_data, *len)); } -tng_function_status tng_input_file_len_get_(const tng_trajectory_t tng_data, - int64_t *len) +tng_function_status DECLSPECDLLEXPORT tng_input_file_len_get_ + (const tng_trajectory_t tng_data, + int64_t *len) { return(tng_input_file_len_get(tng_data, len)); } -tng_function_status tng_num_frames_get_(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_frames_get_ + (const tng_trajectory_t tng_data, + int64_t *n) { return(tng_num_frames_get(tng_data, n)); } -tng_function_status tng_num_particles_get_(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_particles_get_ + (const tng_trajectory_t tng_data, + int64_t *n) { return(tng_num_particles_get(tng_data, n)); } -tng_function_status tng_num_molecules_get_(const tng_trajectory_t tng_data, - int64_t *n) +tng_function_status DECLSPECDLLEXPORT tng_num_molecules_get_ + (const tng_trajectory_t tng_data, + int64_t *n) { return(tng_num_molecules_get(tng_data, n)); } -tng_function_status tng_num_frames_per_frame_set_get_ +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_get_ (const tng_trajectory_t tng_data, int64_t *n) { return(tng_num_frames_per_frame_set_get(tng_data, n)); } -tng_function_status tng_num_frames_per_frame_set_set_ +tng_function_status DECLSPECDLLEXPORT tng_num_frames_per_frame_set_set_ (const tng_trajectory_t tng_data, int64_t *n) { return(tng_num_frames_per_frame_set_set(tng_data, *n)); } -tng_function_status tng_num_frame_sets_get_ +tng_function_status DECLSPECDLLEXPORT tng_num_frame_sets_get_ (const tng_trajectory_t tng_data, int64_t *n) { return(tng_num_frame_sets_get(tng_data, n)); } -tng_function_status tng_current_frame_set_get_ +tng_function_status DECLSPECDLLEXPORT tng_current_frame_set_get_ (tng_trajectory_t tng_data, tng_trajectory_frame_set_t *frame_set_p) { return(tng_current_frame_set_get(tng_data, frame_set_p)); } -tng_function_status tng_frame_set_nr_find_(tng_trajectory_t tng_data, - const int64_t *nr) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_nr_find_(tng_trajectory_t tng_data, + const int64_t *nr) { return(tng_frame_set_nr_find(tng_data, *nr)); } -tng_function_status tng_frame_set_of_frame_find_(tng_trajectory_t tng_data, - const int64_t *frame) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_of_frame_find_ + (tng_trajectory_t tng_data, + const int64_t *frame) { return(tng_frame_set_of_frame_find(tng_data, *frame)); } -tng_function_status tng_frame_set_next_frame_set_file_pos_get_ +tng_function_status DECLSPECDLLEXPORT tng_frame_set_next_frame_set_file_pos_get_ (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos) @@ -12461,7 +12546,7 @@ tng_function_status tng_frame_set_next_frame_set_file_pos_get_ return(tng_frame_set_next_frame_set_file_pos_get(tng_data, frame_set, pos)); } -tng_function_status tng_frame_set_prev_frame_set_file_pos_get_ +tng_function_status DECLSPECDLLEXPORT tng_frame_set_prev_frame_set_file_pos_get_ (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *pos) @@ -12469,7 +12554,7 @@ tng_function_status tng_frame_set_prev_frame_set_file_pos_get_ return(tng_frame_set_prev_frame_set_file_pos_get(tng_data, frame_set, pos)); } -tng_function_status tng_frame_set_frame_range_get_ +tng_function_status DECLSPECDLLEXPORT tng_frame_set_frame_range_get_ (const tng_trajectory_t tng_data, const tng_trajectory_frame_set_t frame_set, int64_t *first_frame, @@ -12479,22 +12564,23 @@ tng_function_status tng_frame_set_frame_range_get_ last_frame)); } -tng_function_status tng_molecule_init_(const tng_trajectory_t tng_data, +tng_function_status DECLSPECDLLEXPORT tng_molecule_init_(const tng_trajectory_t tng_data, tng_molecule_t molecule) { return(tng_molecule_init(tng_data, molecule)); } -tng_function_status tng_molecule_destroy_(const tng_trajectory_t tng_data, - tng_molecule_t molecule) +tng_function_status DECLSPECDLLEXPORT tng_molecule_destroy_ + (const tng_trajectory_t tng_data, + tng_molecule_t molecule) { return(tng_molecule_destroy(tng_data, molecule)); } -tng_function_status tng_molecule_add_(tng_trajectory_t tng_data, - const char *name, - tng_molecule_t *molecule, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_molecule_add_(tng_trajectory_t tng_data, + const char *name, + tng_molecule_t *molecule, + int name_len) { char *n = malloc(name_len + 1); tng_function_status stat; @@ -12506,10 +12592,10 @@ tng_function_status tng_molecule_add_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_molecule_name_set_(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *new_name, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_set_(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *new_name, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12521,26 +12607,26 @@ tng_function_status tng_molecule_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_molecule_cnt_get_(tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t *cnt) +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_get_(tng_trajectory_t tng_data, + tng_molecule_t molecule, + int64_t *cnt) { return(tng_molecule_cnt_get(tng_data, molecule, cnt)); } -tng_function_status tng_molecule_cnt_set_(tng_trajectory_t tng_data, - tng_molecule_t molecule, - int64_t *cnt) +tng_function_status DECLSPECDLLEXPORT tng_molecule_cnt_set_(tng_trajectory_t tng_data, + tng_molecule_t molecule, + int64_t *cnt) { return(tng_molecule_cnt_set(tng_data, molecule, *cnt)); } -tng_function_status tng_molecule_chain_find_(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *name, - int64_t id, - tng_chain_t *chain, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_find_(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *name, + int64_t id, + tng_chain_t *chain, + int name_len) { char *n = malloc(name_len + 1); tng_function_status stat; @@ -12552,11 +12638,11 @@ tng_function_status tng_molecule_chain_find_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_molecule_chain_add_(tng_trajectory_t tng_data, - tng_molecule_t molecule, - const char *name, - tng_chain_t *chain, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_molecule_chain_add_(tng_trajectory_t tng_data, + tng_molecule_t molecule, + const char *name, + tng_chain_t *chain, + int name_len) { char *n = malloc(name_len + 1); tng_function_status stat; @@ -12568,10 +12654,10 @@ tng_function_status tng_molecule_chain_add_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_chain_name_set_(tng_trajectory_t tng_data, - tng_chain_t chain, - const char *new_name, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_chain_name_set_(tng_trajectory_t tng_data, + tng_chain_t chain, + const char *new_name, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12583,11 +12669,11 @@ tng_function_status tng_chain_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_chain_residue_add_(tng_trajectory_t tng_data, - tng_chain_t chain, - const char *name, - tng_residue_t *residue, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_chain_residue_add_(tng_trajectory_t tng_data, + tng_chain_t chain, + const char *name, + tng_residue_t *residue, + int name_len) { char *n = malloc(name_len + 1); tng_function_status stat; @@ -12599,10 +12685,10 @@ tng_function_status tng_chain_residue_add_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_residue_name_set_(tng_trajectory_t tng_data, - tng_residue_t residue, - const char *new_name, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_residue_name_set_(tng_trajectory_t tng_data, + tng_residue_t residue, + const char *new_name, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12614,13 +12700,13 @@ tng_function_status tng_residue_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_residue_atom_add_(tng_trajectory_t tng_data, - tng_residue_t residue, - const char *atom_name, - const char *atom_type, - tng_atom_t *atom, - int name_len, - int type_len) +tng_function_status DECLSPECDLLEXPORT tng_residue_atom_add_(tng_trajectory_t tng_data, + tng_residue_t residue, + const char *atom_name, + const char *atom_type, + tng_atom_t *atom, + int name_len, + int type_len) { char *name = malloc(name_len + 1); char *type = malloc(type_len + 1); @@ -12636,10 +12722,10 @@ tng_function_status tng_residue_atom_add_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_atom_name_set_(tng_trajectory_t tng_data, - tng_atom_t atom, - const char *new_name, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_atom_name_set_(tng_trajectory_t tng_data, + tng_atom_t atom, + const char *new_name, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12651,10 +12737,10 @@ tng_function_status tng_atom_name_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_atom_type_set_(tng_trajectory_t tng_data, - tng_atom_t atom, - const char *new_type, - int type_len) +tng_function_status DECLSPECDLLEXPORT tng_atom_type_set_(tng_trajectory_t tng_data, + tng_atom_t atom, + const char *new_type, + int type_len) { char *type = malloc(type_len + 1); tng_function_status stat; @@ -12666,16 +12752,16 @@ tng_function_status tng_atom_type_set_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_molecule_name_of_particle_nr_get_ +tng_function_status DECLSPECDLLEXPORT tng_molecule_name_of_particle_nr_get_ (const tng_trajectory_t tng_data, - const int64_t nr, - char *name, + const int64_t nr, + char *name, int max_len) { return(tng_molecule_name_of_particle_nr_get(tng_data, nr, name, max_len)); } -tng_function_status tng_chain_name_of_particle_nr_get_ +tng_function_status DECLSPECDLLEXPORT tng_chain_name_of_particle_nr_get_ (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -12684,7 +12770,7 @@ tng_function_status tng_chain_name_of_particle_nr_get_ return(tng_chain_name_of_particle_nr_get(tng_data, nr, name, max_len)); } -tng_function_status tng_residue_name_of_particle_nr_get_ +tng_function_status DECLSPECDLLEXPORT tng_residue_name_of_particle_nr_get_ (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -12693,7 +12779,7 @@ tng_function_status tng_residue_name_of_particle_nr_get_ return(tng_residue_name_of_particle_nr_get(tng_data, nr, name, max_len)); } -tng_function_status tng_atom_name_of_particle_nr_get_ +tng_function_status DECLSPECDLLEXPORT tng_atom_name_of_particle_nr_get_ (const tng_trajectory_t tng_data, const int64_t nr, char *name, @@ -12702,7 +12788,7 @@ tng_function_status tng_atom_name_of_particle_nr_get_ return(tng_atom_name_of_particle_nr_get(tng_data, nr, name, max_len)); } -tng_function_status tng_atom_type_of_particle_nr_get_ +tng_function_status DECLSPECDLLEXPORT tng_atom_type_of_particle_nr_get_ (const tng_trajectory_t tng_data, const int64_t nr, char *type, @@ -12711,7 +12797,7 @@ tng_function_status tng_atom_type_of_particle_nr_get_ return(tng_atom_type_of_particle_nr_get(tng_data, nr, type, max_len)); } -tng_function_status tng_particle_mapping_add_ +tng_function_status DECLSPECDLLEXPORT tng_particle_mapping_add_ (tng_trajectory_t tng_data, const int64_t *first_particle_number, const int64_t *n_particles, @@ -12721,55 +12807,59 @@ tng_function_status tng_particle_mapping_add_ *n_particles, mapping_table)); } -tng_function_status tng_file_headers_read_(tng_trajectory_t tng_data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_file_headers_read_(tng_trajectory_t tng_data, + const tng_hash_mode *hash_mode) { return(tng_file_headers_read(tng_data, *hash_mode)); } -tng_function_status tng_file_headers_write_(tng_trajectory_t tng_data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_file_headers_write_ + (tng_trajectory_t tng_data, + const tng_hash_mode *hash_mode) { return(tng_file_headers_write(tng_data, *hash_mode)); } -tng_function_status tng_block_read_next_(tng_trajectory_t tng_data, - tng_gen_block_t block_data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_block_read_next_ + (tng_trajectory_t tng_data, + tng_gen_block_t block_data, + const tng_hash_mode *hash_mode) { return(tng_block_read_next(tng_data, block_data, *hash_mode)); } -tng_function_status tng_frame_set_read_next_(tng_trajectory_t tng_data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_read_next_ + (tng_trajectory_t tng_data, + const tng_hash_mode *hash_mode) { return(tng_frame_set_read_next(tng_data, *hash_mode)); } -tng_function_status tng_frame_set_write_(tng_trajectory_t tng_data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_write_(tng_trajectory_t tng_data, + const tng_hash_mode *hash_mode) { return(tng_frame_set_write(tng_data, *hash_mode)); } -tng_function_status tng_frame_set_new_(tng_trajectory_t tng_data, - const int64_t *first_frame, - const int64_t *n_frames) +tng_function_status DECLSPECDLLEXPORT tng_frame_set_new_(tng_trajectory_t tng_data, + const int64_t *first_frame, + const int64_t *n_frames) { return(tng_frame_set_new(tng_data, *first_frame, *n_frames)); } -tng_function_status tng_data_block_add_(tng_trajectory_t tng_data, - const int64_t *id, - const char *block_name, - const tng_data_type *datatype, - const tng_block_type *block_type_flag, - int64_t *n_frames, - const int64_t *n_values_per_frame, - const int64_t *stride_length, - const int64_t *codec_id, - void *new_data, - int name_len) +tng_function_status DECLSPECDLLEXPORT tng_data_block_add_ + (tng_trajectory_t tng_data, + const int64_t *id, + const char *block_name, + const tng_data_type *datatype, + const tng_block_type *block_type_flag, + int64_t *n_frames, + const int64_t *n_values_per_frame, + const int64_t *stride_length, + const int64_t *codec_id, + void *new_data, + int name_len) { char *name = malloc(name_len + 1); tng_function_status stat; @@ -12783,7 +12873,7 @@ tng_function_status tng_data_block_add_(tng_trajectory_t tng_data, return(stat); } -tng_function_status tng_particle_data_block_add_ +tng_function_status DECLSPECDLLEXPORT tng_particle_data_block_add_ (tng_trajectory_t tng_data, const int64_t *id, const char *block_name, @@ -12812,96 +12902,104 @@ tng_function_status tng_particle_data_block_add_ return(stat); } -tng_function_status tng_frame_data_write_(tng_trajectory_t tng_data, - const int64_t *frame_nr, - const int64_t *block_id, - const void *data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_data_write_ + (tng_trajectory_t tng_data, + const int64_t *frame_nr, + const int64_t *block_id, + const void *data, + const tng_hash_mode *hash_mode) { return(tng_frame_data_write(tng_data, *frame_nr, *block_id, data, *hash_mode)); } -tng_function_status tng_frame_particle_data_write_(tng_trajectory_t tng_data, - const int64_t *frame_nr, - const int64_t *block_id, - const int64_t *val_first_particle, - const int64_t *val_n_particles, - const void *data, - const tng_hash_mode *hash_mode) +tng_function_status DECLSPECDLLEXPORT tng_frame_particle_data_write_ + (tng_trajectory_t tng_data, + const int64_t *frame_nr, + const int64_t *block_id, + const int64_t *val_first_particle, + const int64_t *val_n_particles, + const void *data, + const tng_hash_mode *hash_mode) { return(tng_frame_particle_data_write(tng_data, *frame_nr, *block_id, *val_first_particle, *val_n_particles, data, *hash_mode)); } -tng_function_status tng_data_values_free_(const tng_trajectory_t tng_data, - union data_values **values, - const int64_t *n_frames, - const int64_t *n_values_per_frame, - const tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_data_values_free_ + (const tng_trajectory_t tng_data, + union data_values **values, + const int64_t *n_frames, + const int64_t *n_values_per_frame, + const tng_data_type *type) { return(tng_data_values_free(tng_data, values, *n_frames, *n_values_per_frame, *type)); } -tng_function_status tng_particle_data_values_free_(const tng_trajectory_t tng_data, - union data_values ***values, - const int64_t *n_frames, - const int64_t *n_particles, - const int64_t *n_values_per_frame, - const tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_values_free_ + (const tng_trajectory_t tng_data, + union data_values ***values, + const int64_t *n_frames, + const int64_t *n_particles, + const int64_t *n_values_per_frame, + const tng_data_type *type) { return(tng_particle_data_values_free(tng_data, values, *n_frames, *n_particles, *n_values_per_frame, *type)); } -tng_function_status tng_data_get_(tng_trajectory_t tng_data, - const int64_t *block_id, - union data_values ***values, - int64_t *n_frames, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_data_get_ + (tng_trajectory_t tng_data, + const int64_t *block_id, + union data_values ***values, + int64_t *n_frames, + int64_t *n_values_per_frame, + tng_data_type *type) { return(tng_data_get(tng_data, *block_id, values, n_frames, n_values_per_frame, type)); } -tng_function_status tng_data_interval_get_(tng_trajectory_t tng_data, - const int64_t *block_id, - const int64_t *start_frame_nr, - const int64_t *end_frame_nr, - const tng_hash_mode *hash_mode, - union data_values ***values, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_data_interval_get_ + (tng_trajectory_t tng_data, + const int64_t *block_id, + const int64_t *start_frame_nr, + const int64_t *end_frame_nr, + const tng_hash_mode *hash_mode, + union data_values ***values, + int64_t *n_values_per_frame, + tng_data_type *type) { return(tng_data_interval_get(tng_data, *block_id, *start_frame_nr, *end_frame_nr, *hash_mode, values, n_values_per_frame, type)); } -tng_function_status tng_particle_data_get_(tng_trajectory_t tng_data, - const int64_t *block_id, - union data_values ****values, - int64_t *n_frames, - int64_t *n_particles, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_get_ + (tng_trajectory_t tng_data, + const int64_t *block_id, + union data_values ****values, + int64_t *n_frames, + int64_t *n_particles, + int64_t *n_values_per_frame, + tng_data_type *type) { return(tng_particle_data_get(tng_data, *block_id, values, n_frames, n_particles, n_values_per_frame, type)); } -tng_function_status tng_particle_data_interval_get_(tng_trajectory_t tng_data, - const int64_t *block_id, - const int64_t *start_frame_nr, - const int64_t *end_frame_nr, - const tng_hash_mode *hash_mode, - union data_values ****values, - int64_t *n_particles, - int64_t *n_values_per_frame, - tng_data_type *type) +tng_function_status DECLSPECDLLEXPORT tng_particle_data_interval_get_ + (tng_trajectory_t tng_data, + const int64_t *block_id, + const int64_t *start_frame_nr, + const int64_t *end_frame_nr, + const tng_hash_mode *hash_mode, + union data_values ****values, + int64_t *n_particles, + int64_t *n_values_per_frame, + tng_data_type *type) { return(tng_particle_data_interval_get(tng_data, *block_id, *start_frame_nr, *end_frame_nr, *hash_mode, values, @@ -12909,8 +13007,9 @@ tng_function_status tng_particle_data_interval_get_(tng_trajectory_t tng_data, type)); } -tng_function_status tng_time_get_str_(const tng_trajectory_t tng_data, - char *time, int64_t str_len) +tng_function_status DECLSPECDLLEXPORT tng_time_get_str_ + (const tng_trajectory_t tng_data, + char *time, int64_t str_len) { return(tng_time_get_str(tng_data, time)); } -- cgit v0.10.1