diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 9ea77cb..e62f7ae 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -1520,13 +1520,13 @@ trexio_read_chunk_ao_2e_int_eri_value_64(trexio_t* const file, #+begin_src c :tangle hrw_dset_str_front.h :exports none trexio_exit_code trexio_has_$group_dset$(trexio_t* const file); -trexio_exit_code trexio_read_$group_dset$(trexio_t* const file, char* const dset, const uint32_t max_str_len); +trexio_exit_code trexio_read_$group_dset$(trexio_t* const file, char* dset, const uint32_t max_str_len); trexio_exit_code trexio_write_$group_dset$(trexio_t* const file, const char* dset, const uint32_t max_str_len); #+end_src #+begin_src c :tangle read_dset_str_front.c trexio_exit_code -trexio_read_$group_dset$ (trexio_t* const file, char* const dset, const uint32_t max_str_len) +trexio_read_$group_dset$ (trexio_t* const file, char* dset, const uint32_t max_str_len) { if (file == NULL) return TREXIO_INVALID_ARG_1; @@ -1546,22 +1546,70 @@ trexio_read_$group_dset$ (trexio_t* const file, char* const dset, const uint32_t assert(file->back_end < TREXIO_INVALID_BACK_END); + char* tmp_str = CALLOC(dims[0]*(128+1)+1, char); + if (tmp_str == NULL) return TREXIO_ALLOCATION_FAILED; + switch (file->back_end) { case TREXIO_TEXT: - //return trexio_text_read_$group_dset$(file, dset_str, rank, dims); + //rc = trexio_text_read_$group_dset$(file, dset_str, rank, dims); break; case TREXIO_HDF5: - return trexio_hdf5_read_$group_dset$(file, dset, rank, dims, max_str_len); + rc = trexio_hdf5_read_$group_dset$(file, tmp_str, rank, dims); break; /* case TREXIO_JSON: - return trexio_json_read_$group_dset$(file, dset, rank, dims); + rc = trexio_json_read_$group_dset$(file, dset, rank, dims); break; ,*/ } + if (rc != TREXIO_SUCCESS) { + FREE(tmp_str); + return rc; + } + + size_t len_read; + size_t len_accum = 0; + char * pch; + char buf[32]; + + printf("%s\n", tmp_str); + + strcpy(dset, ""); + for(uint64_t i=0; i max_str_len) { FREE(dset_str[0]); FREE(dset_str); - return TREXIO_INVALID_STR_LEN; + return TREXIO_INVALID_ARG_3; } dset_str[i]=tmp_str; diff --git a/src/templates_hdf5/templator_hdf5.org b/src/templates_hdf5/templator_hdf5.org index 8965cca..6b2cc8b 100644 --- a/src/templates_hdf5/templator_hdf5.org +++ b/src/templates_hdf5/templator_hdf5.org @@ -414,13 +414,13 @@ trexio_hdf5_has_$group_dset$ (trexio_t* const file) #+begin_src c :tangle hrw_dset_str_hdf5.h :exports none trexio_exit_code trexio_hdf5_has_$group_dset$(trexio_t* const file); -trexio_exit_code trexio_hdf5_read_$group_dset$(trexio_t* const file, char* const $group_dset$, const uint32_t rank, const uint64_t* dims, const uint32_t max_str_len); +trexio_exit_code trexio_hdf5_read_$group_dset$(trexio_t* const file, char* const $group_dset$, const uint32_t rank, const uint64_t* dims); trexio_exit_code trexio_hdf5_write_$group_dset$(trexio_t* const file, const char** $group_dset$, const uint32_t rank, const uint64_t* dims); #+end_src #+begin_src c :tangle read_dset_str_hdf5.c trexio_exit_code -trexio_hdf5_read_$group_dset$ (trexio_t* const file, char* const $group_dset$, const uint32_t rank, const uint64_t* dims, const uint32_t max_str_len) +trexio_hdf5_read_$group_dset$ (trexio_t* const file, char* const $group_dset$, const uint32_t rank, const uint64_t* dims) { if (file == NULL) return TREXIO_INVALID_ARG_1; @@ -495,22 +495,14 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, char* const $group_dset$, c // copy contents of temporary rdata buffer into the group_dset otherwise they are lost // after calling H5Treclaim or H5Dvlen_reclaim functions + size_t max_str_len = 2; strcpy($group_dset$, ""); - for (uint64_t i=0; i max_str_len) { - // this function is introduced in HDF5 v.1.12.0 - //status = H5Treclaim (memtype, dspace, H5P_DEFAULT, rdata); - // this function is deprecated but used in v.<1.12.0 - status = H5Dvlen_reclaim (memtype, dspace, H5P_DEFAULT, rdata); - FREE(rdata); - H5Dclose(dset_id); - H5Sclose(dspace); - H5Tclose(memtype); - return TREXIO_INVALID_STR_LEN; + for (uint64_t i=0; i