summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/tng_io.c32
-rw-r--r--src/lib/tng_io.h8
-rw-r--r--src/tests/md_openmp.c2
-rw-r--r--src/tests/md_openmp.f2
4 files changed, 33 insertions, 11 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index ddf3e0d..5b5f801 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -438,6 +438,26 @@ static tng_function_status hash_match_verify(tng_gen_block_t block,
if(strncmp(block->hash, hash, 16) != 0)
{
*results = FALSE;
+// int i;
+// printf("Hash in file: ");
+// for(i = 0; i<16; i++)
+// {
+// printf("%hhX ", block->hash[i]);
+// }
+// printf("\n");
+// printf("Expected hash: ");
+// for(i = 0; i<16; i++)
+// {
+// printf("%hhX ", hash[i]);
+// }
+// printf("\n");
+// if(block->block_contents_size < 100)
+// {
+// for(i = 0; i < block->block_contents_size; i++)
+// {
+// printf("%hhX ", block->block_contents[i]);
+// }
+// }
}
else
{
@@ -2185,6 +2205,9 @@ static tng_function_status tng_frame_set_block_read
/* FIXME: Does not check if the size of the contents matches the expected
* size or if the contents can be read. */
+ file_pos = ftell(tng_data->input_file) -
+ (block->block_contents_size + block->header_contents_size);
+
if(hash_mode == TNG_USE_HASH)
{
if(hash_match_verify(block, &same_hash) != TNG_SUCCESS)
@@ -2194,16 +2217,13 @@ static tng_function_status tng_frame_set_block_read
}
if(same_hash != TRUE)
{
- printf("Frame set block contents corrupt. Hashes do not match. "
+ printf("Frame set block contents corrupt. File pos %d Hashes do not match. "
"%s: %d\n",
- __FILE__, __LINE__);
+ file_pos, __FILE__, __LINE__);
// return(TNG_FAILURE);
}
}
- file_pos = ftell(tng_data->input_file) -
- (block->block_contents_size + block->header_contents_size);
-
tng_data->current_trajectory_frame_set_input_file_pos = file_pos;
if(frame_set->n_mapping_blocks && frame_set->mappings)
@@ -7885,7 +7905,7 @@ tng_function_status tng_frame_particle_data_write(tng_trajectory_t tng_data,
contents_size = block->block_contents_size;
header_size = block->header_contents_size;
- header_pos = file_pos;
+ header_pos = ftell(tng_data->output_file) - header_size;
frame_set = &tng_data->current_trajectory_frame_set;
fread(&datatype, sizeof(datatype), 1, tng_data->input_file);
diff --git a/src/lib/tng_io.h b/src/lib/tng_io.h
index 33af0c1..36aa23f 100644
--- a/src/lib/tng_io.h
+++ b/src/lib/tng_io.h
@@ -49,9 +49,11 @@
*
* @subsection C
*
- * #include <stdlib.h>
- * #include <stdio.h>
- * #include <tng_io.h>
+ * // These includes must be fixed in order to compile the example.
+ * // They do not include the # in order to compile the header file.
+ * include <stdlib.h>
+ * include <stdio.h>
+ * include <tng_io.h>
*
* int main(int argc, char **argv)
* {
diff --git a/src/tests/md_openmp.c b/src/tests/md_openmp.c
index 4bf6601..95c5368 100644
--- a/src/tests/md_openmp.c
+++ b/src/tests/md_openmp.c
@@ -265,7 +265,7 @@ int main ( int argc, char *argv[] )
}
/* Write the frame set to disk */
- if(tng_frame_set_write(traj, TNG_SKIP_HASH) != TNG_SUCCESS)
+ if(tng_frame_set_write(traj, TNG_USE_HASH) != TNG_SUCCESS)
{
printf("Error writing frame set. %s: %d\n", __FILE__, __LINE__);
exit(1);
diff --git a/src/tests/md_openmp.f b/src/tests/md_openmp.f
index 0220a56..58f4e90 100644
--- a/src/tests/md_openmp.f
+++ b/src/tests/md_openmp.f
@@ -271,7 +271,7 @@ c
c
c Write the frame set to disk
c
- call tng_frame_set_write(traj, TNG_SKIP_HASH)
+ call tng_frame_set_write(traj, TNG_USE_HASH)
wtime = omp_get_wtime ( )
contact: Jan Huwald // Impressum