diff options
Diffstat (limited to 'src/tests/compression')
71 files changed, 617 insertions, 137 deletions
diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index e69de29..930bcfc 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -0,0 +1,46 @@ +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 64) + +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} 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) +target_link_libraries(test_tng_compress_read${number} tng_compress) +if(UNIX) +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}") +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() 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..9988106 --- /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 6986313. diff --git a/src/tests/compression/test59.h b/src/tests/compression/test59.h new file mode 100644 index 0000000..9817976 --- /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 6986313. 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/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..373456d --- /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 100 +#define EXPECTED_FILESIZE 698801. diff --git a/src/tests/compression/test62.h b/src/tests/compression/test62.h new file mode 100644 index 0000000..c8a2b48 --- /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.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.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 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/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..8bedeb4 --- /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%" == "64" ( + 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..2d7a044 --- /dev/null +++ b/src/tests/compression/test_tng_compress_read.sh @@ -0,0 +1,5 @@ +#!/bin/sh +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 new file mode 100644 index 0000000..7542fc8 --- /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%" == "64" ( + 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..1a5700b --- /dev/null +++ b/src/tests/compression/test_tng_compress_write.sh @@ -0,0 +1,5 @@ +#!/bin/sh +numtests=64 +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..27450d6 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -9,9 +9,19 @@ #include <string.h> #include <math.h> #include <tng_compress.h> -#include <warnmalloc.h> +#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; i<NATOMS; i++) { for (j=0; j<3; j++) - realbox[i*stride+j]=(double)(intbox[i*3+j]*GENPRECISION*SCALE); + realbox[i*stride+j]=(REAL)(intbox[i*3+j]*GENPRECISION*SCALE); for (j=3; j<stride; j++) realbox[i*stride+j]=0.; } } -static void realvelbox(int *intbox, double *realbox, int stride) +static void realvelbox(int *intbox, REAL *realbox, int stride) { int i,j; for (i=0; i<NATOMS; i++) { for (j=0; j<3; j++) - realbox[i*stride+j]=(double)(intbox[i*3+j]*GENVELPRECISION*SCALE); + realbox[i*stride+j]=(REAL)(intbox[i*3+j]*GENVELPRECISION*SCALE); for (j=3; j<stride; j++) realbox[i*stride+j]=0.; } } -static int equalarr(double *arr1, double *arr2, double prec, int len, int itemlen, int stride1, int stride2) +static int equalarr(REAL *arr1, REAL *arr2, REAL prec, int len, int itemlen, int stride1, int stride2) { - double maxdiff=0.; + REAL maxdiff=0.; int i,j; for (i=0; i<len; i++) { for (j=0; j<itemlen; j++) if (fabs(arr1[i*stride1+j]-arr2[i*stride2+j])>maxdiff) - 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; i<len; i++) @@ -258,8 +268,8 @@ struct tng_file FILE *f; int natoms; int chunky; - double precision; - double velprecision; + REAL precision; + REAL velprecision; int initial_coding; int initial_coding_parameter; int coding; @@ -272,8 +282,12 @@ struct tng_file int nframes; int nframes_delivered; int writevel; - double *pos; - double *vel; + REAL *pos; + 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) @@ -302,9 +316,9 @@ static size_t fread_int_le(int *x,FILE *f) static struct tng_file *open_tng_file_write(char *filename, int natoms,int chunky, - double precision, + REAL precision, int writevel, - double velprecision, + REAL velprecision, int initial_coding, int initial_coding_parameter, int coding, @@ -318,6 +332,8 @@ 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; @@ -341,7 +357,48 @@ static struct tng_file *open_tng_file_write(char *filename, return tng_file; } -static void flush_tng_frames(struct tng_file *tng_file) +static struct tng_file *open_tng_file_write_int(char *filename, + int natoms,int chunky, + int writevel, + 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->natoms=natoms; + tng_file->writevel=writevel; + 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->ipos=malloc(natoms*chunky*3*sizeof *tng_file->ipos); + tng_file->f=fopen(filename,"wb"); + if (writevel) + 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, + unsigned long prec_hi, unsigned long prec_lo, + unsigned long velprec_hi, unsigned long velprec_lo) { int algo[4]; char *buf; @@ -351,11 +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 /* TEST_FLOAT */ buf=tng_compress_pos(tng_file->pos, tng_file->natoms, tng_file->nframes, tng_file->precision, tng_file->speed,algo,&nitems); +#endif /* TEST_FLOAT */ +#endif /* RECOMPRESS */ tng_file->initial_coding=algo[0]; tng_file->initial_coding_parameter=algo[1]; tng_file->coding=algo[2]; @@ -369,11 +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 /* TEST_FLOAT */ buf=tng_compress_vel(tng_file->vel, tng_file->natoms, tng_file->nframes, tng_file->velprecision, tng_file->speed,algo,&nitems); +#endif /* TEST_FLOAT */ +#endif /* RECOMPRESS */ tng_file->initial_velcoding=algo[0]; tng_file->initial_velcoding_parameter=algo[1]; tng_file->velcoding=algo[2]; @@ -386,23 +475,42 @@ 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) 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); } @@ -411,17 +519,46 @@ 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; + 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 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; - 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 +588,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 +613,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; @@ -484,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); } @@ -519,35 +709,51 @@ 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); +#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; + 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 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(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 +#endif /* RECOMPRESS */ if (!dumpfile) return 1; for (i=0; i<9; i++) @@ -557,41 +763,82 @@ static int algotest() H1[8]=INTMAX3*PRECISION*SCALE; for (i=startframe; i<endframe; i++) { +#ifdef RECOMPRESS + unsigned long prec_hi, prec_lo; + unsigned long velprec_hi, velprec_lo; + if (read_tng_file_int(dumpfile_recompress,intbox,intvelbox,&prec_hi,&prec_lo,&velprec_hi,&velprec_lo)) + return 1; + write_tng_file_int(dumpfile,intbox,intvelbox,prec_hi,prec_lo,velprec_hi,velprec_lo); +#else /* RECOMPRESS */ genibox(intbox,i); realbox(intbox,box1,STRIDE1); #if WRITEVEL 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 +#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); +#if WRITEVEL + 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); +#if WRITEVEL + 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 */ +#endif /* INTTOFLOAT */ if (readreturn==1) /* general read error */ return 1; -#endif +#endif /* GEN */ #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 +#endif /* GEN */ +#endif /* RECOMPRESS */ } #ifdef GEN close_tng_file_write(dumpfile); #else close_tng_file_read(dumpfile); #endif +#ifdef RECOMPRESS + close_tng_file_read(dumpfile_recompress); +#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; @@ -621,9 +868,9 @@ int main() exit(EXIT_FAILURE); } #ifdef GEN - printf("Tng compress testsuite generating test: %s\n",TESTNAME); + printf("Tng compress testsuite generating (writing) test: %s\n",TESTNAME); #else - printf("Tng compress testsuite running test: %s\n",TESTNAME); + printf("Tng compress testsuite running (reading) test: %s\n",TESTNAME); #endif testval=algotest(); if (testval==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\"/" <testsuite.c >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 - - - |