From cafed105a4e031dab73c3dfa5cbafcd329381559 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 13 May 2023 12:01:00 +0200 Subject: [PATCH] Multiple tests for io_dset_sparse --- tests/io_dset_sparse.c | 54 +++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/io_dset_sparse.c b/tests/io_dset_sparse.c index 4f0259b..2167b61 100644 --- a/tests/io_dset_sparse.c +++ b/tests/io_dset_sparse.c @@ -41,13 +41,19 @@ static int test_write_dset_sparse (const char* file_name, const back_end_t backe assert(rc == TREXIO_SUCCESS); // write dataset chunks of sparse data in the file (including FAKE statements) - uint64_t chunk_size = (uint64_t) size/N_CHUNKS+1; + uint64_t chunk_size = (uint64_t) size/N_CHUNKS; + chunk_size = chunk_size > 0 ? chunk_size : (uint64_t) size; + int n_chunks = size/chunk_size; + printf("chunk_size = %ld\n", chunk_size); + printf("n_chunks = %d\n", n_chunks); + uint64_t offset_f = 0UL; uint64_t offset_d = 0UL; if (offset != 0L) offset_f += offset; // write n_chunks times using write_sparse - for(int i=0; i size) chunk_size = size-offset_f; rc = trexio_write_mo_2e_int_eri(file, offset_f, chunk_size, &index[4*offset_d], &value[offset_d]); printf("%5d: %s\n", __LINE__, trexio_string_of_error(rc)); assert(rc == TREXIO_SUCCESS); @@ -142,44 +148,42 @@ static int test_read_dset_sparse (const char* file_name, const back_end_t backen // specify the read parameters, here: // 1 chunk of 10 elements using offset of 40 (i.e. lines No. 40--59) into elements of the array starting from 5 int64_t chunk_read = size/3; - int64_t offset_file_read = size/3; - int offset_data_read = 2L; + chunk_read = chunk_read < 2 ? 2 : chunk_read; + int64_t offset_file_read = 1; int64_t read_size_check; read_size_check = chunk_read; if (offset != 0L) offset_file_read += offset; // read one chunk using the aforementioned parameters - rc = trexio_read_mo_2e_int_eri(file, offset_file_read, &chunk_read, &index_read[4*offset_data_read], &value_read[offset_data_read]); + rc = trexio_read_mo_2e_int_eri(file, offset_file_read, &chunk_read, &index_read[0], &value_read[0]); printf("%5d: %s\n", __LINE__, trexio_string_of_error(rc)); +/* for (int i=0 ; i size_max) int64_t size_max; rc = trexio_read_mo_2e_int_eri_size(file, &size_max); assert(rc == TREXIO_SUCCESS); - offset_file_read = size_max-chunk_read+1L; - offset_data_read = 1L; + offset_file_read = size_max-chunk_read+1; int64_t eof_read_size_check = size_max - offset_file_read; // if offset_file_read=97 => only 3 integrals will be read out of total of 100 if (offset != 0L) offset_file_read += offset; // read one chunk that will reach EOF and return TREXIO_END code - rc = trexio_read_mo_2e_int_eri(file, offset_file_read, &chunk_read, &index_read[4*offset_data_read], &value_read[offset_data_read]); + rc = trexio_read_mo_2e_int_eri(file, offset_file_read, &chunk_read, &index_read[0], &value_read[0]); + printf("%5d: %s\n", __LINE__, trexio_string_of_error(rc)); assert(rc == TREXIO_END); - for (int i=0 ; i