#include "trexio.h" #include #include #include #include #define TEST_BACKEND TREXIO_TEXT #define TREXIO_FILE "test_determinant.dir" #define RM_COMMAND "rm -f -- " TREXIO_FILE "/*.txt " TREXIO_FILE "/*.txt.size " TREXIO_FILE "/.lock && rm -fd -- " TREXIO_FILE #define SIZE 100 #define N_CHUNKS 5 #define STATE_TEST 2 #define MO_NUM 150 static int test_write_determinant (const char* file_name, const back_end_t backend, const int64_t offset) { /* Try to write an array of sparse data into the TREXIO file */ trexio_t* file = NULL; trexio_exit_code rc; /*================= START OF TEST ==================*/ // open file in 'write' mode file = trexio_open(file_name, 'w', backend, &rc); assert (file != NULL); assert (rc == TREXIO_SUCCESS); // parameters to be written int64_t* det_list; double* det_coef; int mo_num = MO_NUM; // write mo_num which will be used to determine the optimal size of int indices if (trexio_has_mo_num(file) == TREXIO_HAS_NOT) { rc = trexio_write_mo_num(file, mo_num); assert(rc == TREXIO_SUCCESS); } // get the number of int64 bit fields per determinant int int_num; rc = trexio_get_int64_num(file, &int_num); assert(rc == TREXIO_SUCCESS); assert(int_num == (MO_NUM-1)/64 + 1); // allocate memory and fill with values to be written det_list = (int64_t*) calloc(2 * int_num * SIZE, sizeof(int64_t)); det_coef = (double*) calloc(SIZE, sizeof(double)); for(int i=0; i size_max) offset_file_read = 97L; offset_data_read = 1; int64_t eof_read_size_check = SIZE - 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; chunk_read = read_size_check; // read one chunk that will reach EOF and return TREXIO_END code rc = trexio_read_determinant_list(file, offset_file_read, &chunk_read, &det_list_read[2*int_num*offset_data_read]); /* printf("%s\n", trexio_string_of_error(rc)); for (int i=0; i