1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-07-22 18:57:39 +02:00

prepare templates and files for datasets with strings [all]

This commit is contained in:
q-posev 2021-05-27 15:14:01 +02:00
parent 7ddb9228f1
commit 42f81b2cc6
5 changed files with 132 additions and 39 deletions

View File

@ -705,6 +705,7 @@ trexio_exit_code transform_str (char** dest, const char** src, uint64_t str_max_
#+end_src c
* Templates for front end
** Description
Consider the following block of ~trex.json~:
@ -1051,7 +1052,7 @@ interface
end interface
#+end_src
** Templates for front end has/read/write a dataset
** Templates for front end has/read/write a dataset of numerical data
This section concerns API calls related to datasets.
@ -1074,7 +1075,7 @@ end interface
The basic (non-suffixed) API call on datasets deals with double precision (see Table above).
#+begin_src c :tangle hrw_dset_front.h :exports none
#+begin_src c :tangle hrw_dset_data_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, $group_dset_dtype_default$* const $group_dset$);
trexio_exit_code trexio_write_$group_dset$(trexio_t* const file, const $group_dset_dtype_default$* $group_dset$);
@ -1084,7 +1085,7 @@ trexio_exit_code trexio_read_$group_dset$_64(trexio_t* const file, $group_dset_d
trexio_exit_code trexio_write_$group_dset$_64(trexio_t* const file, const $group_dset_dtype_double$* $group_dset$);
#+end_src
#+begin_src c :tangle read_dset_64_front.c
#+begin_src c :tangle read_dset_data_64_front.c
trexio_exit_code
trexio_read_$group_dset$_64 (trexio_t* const file, $group_dset_dtype_double$* const $group_dset$)
{
@ -1124,7 +1125,7 @@ trexio_read_$group_dset$_64 (trexio_t* const file, $group_dset_dtype_double$* co
}
#+end_src
#+begin_src c :tangle write_dset_64_front.c
#+begin_src c :tangle write_dset_data_64_front.c
trexio_exit_code
trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_double$* $group_dset$)
{
@ -1164,7 +1165,7 @@ trexio_write_$group_dset$_64 (trexio_t* const file, const $group_dset_dtype_doub
}
#+end_src
#+begin_src c :tangle read_dset_32_front.c
#+begin_src c :tangle read_dset_data_32_front.c
trexio_exit_code
trexio_read_$group_dset$_32 (trexio_t* const file, $group_dset_dtype_single$* const $group_dset$)
{
@ -1225,7 +1226,7 @@ trexio_read_$group_dset$_32 (trexio_t* const file, $group_dset_dtype_single$* co
}
#+end_src
#+begin_src c :tangle write_dset_32_front.c
#+begin_src c :tangle write_dset_data_32_front.c
trexio_exit_code
trexio_write_$group_dset$_32 (trexio_t* const file, const $group_dset_dtype_single$* $group_dset$)
{
@ -1284,7 +1285,7 @@ trexio_write_$group_dset$_32 (trexio_t* const file, const $group_dset_dtype_sing
}
#+end_src
#+begin_src c :tangle read_dset_def_front.c
#+begin_src c :tangle read_dset_data_def_front.c
trexio_exit_code
trexio_read_$group_dset$ (trexio_t* const file, $group_dset_dtype_default$* const $group_dset$)
{
@ -1292,7 +1293,7 @@ trexio_read_$group_dset$ (trexio_t* const file, $group_dset_dtype_default$* cons
}
#+end_src
#+begin_src c :tangle write_dset_def_front.c
#+begin_src c :tangle write_dset_data_def_front.c
trexio_exit_code
trexio_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype_default$* $group_dset$)
{
@ -1300,7 +1301,7 @@ trexio_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype_default
}
#+end_src
#+begin_src c :tangle has_dset_front.c
#+begin_src c :tangle has_dset_data_front.c
trexio_exit_code
trexio_has_$group_dset$ (trexio_t* const file)
{
@ -1333,7 +1334,7 @@ trexio_has_$group_dset$ (trexio_t* const file)
The ~Fortran~ templates that provide an access to the ~C~ API calls from ~Fortran~.
These templates are based on the use of ~iso_c_binding~. Pointers have to be passed by value.
#+begin_src f90 :tangle write_dset_64_front_fortran.f90
#+begin_src f90 :tangle write_dset_data_64_front_fortran.f90
interface
integer function trexio_write_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1343,7 +1344,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle read_dset_64_front_fortran.f90
#+begin_src f90 :tangle read_dset_data_64_front_fortran.f90
interface
integer function trexio_read_$group_dset$_64 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1353,7 +1354,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle write_dset_32_front_fortran.f90
#+begin_src f90 :tangle write_dset_data_32_front_fortran.f90
interface
integer function trexio_write_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1363,7 +1364,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle read_dset_32_front_fortran.f90
#+begin_src f90 :tangle read_dset_data_32_front_fortran.f90
interface
integer function trexio_read_$group_dset$_32 (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1373,7 +1374,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle write_dset_def_front_fortran.f90
#+begin_src f90 :tangle write_dset_data_def_front_fortran.f90
interface
integer function trexio_write_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1383,7 +1384,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle read_dset_def_front_fortran.f90
#+begin_src f90 :tangle read_dset_data_def_front_fortran.f90
interface
integer function trexio_read_$group_dset$ (trex_file, dset) bind(C)
use, intrinsic :: iso_c_binding
@ -1393,7 +1394,7 @@ interface
end interface
#+end_src
#+begin_src f90 :tangle has_dset_front_fortran.f90
#+begin_src f90 :tangle has_dset_data_front_fortran.f90
interface
integer function trexio_has_$group_dset$ (trex_file) bind(C)
use, intrinsic :: iso_c_binding

View File

@ -7,14 +7,10 @@ cat populated/pop_def_hdf5.c >> trexio_hdf5.c
cat populated/pop_struct_hdf5.h >> trexio_hdf5.h
cat populated/pop_basic_hdf5.c >> trexio_hdf5.c
cat populated/pop_has_dset_hdf5.c >> trexio_hdf5.c
cat populated/pop_has_num_hdf5.c >> trexio_hdf5.c
cat populated/pop_read_dset_hdf5.c >> trexio_hdf5.c
cat populated/pop_read_num_hdf5.c >> trexio_hdf5.c
cat populated/pop_write_dset_hdf5.c >> trexio_hdf5.c
cat populated/pop_write_num_hdf5.c >> trexio_hdf5.c
cat populated/pop_hrw_num_hdf5.h >> trexio_hdf5.h
cat populated/pop_hrw_dset_hdf5.h >> trexio_hdf5.h
cat populated/pop_has_*.c >> trexio_hdf5.c
cat populated/pop_read_*.c >> trexio_hdf5.c
cat populated/pop_write_*.c >> trexio_hdf5.c
cat populated/pop_hrw_*.h >> trexio_hdf5.h
cat suffix_hdf5.h >> trexio_hdf5.h

View File

@ -279,15 +279,15 @@ trexio_hdf5_has_$group_num$ (trexio_t* const file)
}
#+end_src
** Template for HDF5 has/read/write a dataset
** Template for HDF5 has/read/write a dataset of numerical data
#+begin_src c :tangle hrw_dset_hdf5.h :exports none
#+begin_src c :tangle hrw_dset_data_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, $group_dset_dtype$* const $group_dset$, const uint32_t rank, const uint64_t* dims);
trexio_exit_code trexio_hdf5_write_$group_dset$(trexio_t* const file, const $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims);
#+end_src
#+begin_src c :tangle read_dset_hdf5.c
#+begin_src c :tangle read_dset_data_hdf5.c
trexio_exit_code
trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$,
const uint32_t rank, const uint64_t* dims)
@ -343,7 +343,7 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
}
#+end_src
#+begin_src c :tangle write_dset_hdf5.c
#+begin_src c :tangle write_dset_data_hdf5.c
trexio_exit_code
trexio_hdf5_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$* $group_dset$,
const uint32_t rank, const uint64_t* dims)
@ -389,7 +389,59 @@ trexio_hdf5_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$*
}
#+end_src
#+begin_src c :tangle has_dset_hdf5.c
#+begin_src c :tangle has_dset_data_hdf5.c
trexio_exit_code
trexio_hdf5_has_$group_dset$ (trexio_t* const file)
{
if (file == NULL) return TREXIO_INVALID_ARG_1;
trexio_hdf5_t* f = (trexio_hdf5_t*) file;
herr_t status = H5LTfind_dataset(f->$group$_group, $GROUP_DSET$_NAME);
/* H5LTfind_dataset returns 1 if dataset exists, 0 otherwise */
if (status == 1){
return TREXIO_SUCCESS;
} else if (status == 0) {
return TREXIO_HAS_NOT;
} else {
return TREXIO_FAILURE;
}
}
#+end_src
** Template for HDF5 has/read/write a dataset of strings
#+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, $group_dset_dtype$* const $group_dset$, const uint32_t rank, const uint64_t* dims);
trexio_exit_code trexio_hdf5_write_$group_dset$(trexio_t* const file, const $group_dset_dtype$* $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, $group_dset_dtype$* const $group_dset$,
const uint32_t rank, const uint64_t* dims)
{
return TREXIO_SUCCESS;
}
#+end_src
#+begin_src c :tangle write_dset_str_hdf5.c
trexio_exit_code
trexio_hdf5_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$* $group_dset$,
const uint32_t rank, const uint64_t* dims)
{
return TREXIO_SUCCESS;
}
#+end_src
#+begin_src c :tangle has_dset_str_hdf5.c
trexio_exit_code
trexio_hdf5_has_$group_dset$ (trexio_t* const file)
{

View File

@ -17,14 +17,18 @@ cat populated/pop_free_group_text.h >> trexio_text.h
cat populated/pop_read_group_text.h >> trexio_text.h
cat populated/pop_flush_group_text.h >> trexio_text.h
cat populated/pop_has_dset_text.c >> trexio_text.c
cat populated/pop_has_dset_data_text.c >> trexio_text.c
#cat populated/pop_has_dset_str_text.c >> trexio_text.c
cat populated/pop_has_num_text.c >> trexio_text.c
cat populated/pop_read_dset_text.c >> trexio_text.c
cat populated/pop_read_dset_data_text.c >> trexio_text.c
#cat populated/pop_read_dset_str_text.c >> trexio_text.c
cat populated/pop_read_num_text.c >> trexio_text.c
cat populated/pop_write_dset_text.c >> trexio_text.c
cat populated/pop_write_dset_data_text.c >> trexio_text.c
#cat populated/pop_write_dset_str_text.c >> trexio_text.c
cat populated/pop_write_num_text.c >> trexio_text.c
cat populated/pop_hrw_num_text.h >> trexio_text.h
cat populated/pop_hrw_dset_text.h >> trexio_text.h
cat populated/pop_hrw_dset_data_text.h >> trexio_text.h
#cat populated/pop_hrw_dset_str_text.h >> trexio_text.h
cat rdm_text.c >> trexio_text.c
cat rdm_text.h >> trexio_text.h

View File

@ -505,7 +505,7 @@ trexio_text_free_$group$ (trexio_text_t* const file)
}
#+end_src
** Template for has/read/write the ~$group_num$~ attribute
** Template for has/read/write the num attribute
#+begin_src c :tangle hrw_num_text.h :exports none
trexio_exit_code trexio_text_has_$group_num$ (trexio_t* const file);
@ -568,17 +568,17 @@ trexio_text_has_$group_num$ (trexio_t* const file)
}
#+end_src
** Template for has/read/write the ~$group_dset$~ dataset
** Template for has/read/write the dataset of numerical data
The ~group_dset~ array is assumed allocated with the appropriate size.
#+begin_src c :tangle hrw_dset_text.h :exports none
#+begin_src c :tangle hrw_dset_data_text.h :exports none
trexio_exit_code trexio_text_has_$group_dset$ (trexio_t* const file);
trexio_exit_code trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$, const uint32_t rank, const uint64_t* dims);
trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, const $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims);
#+end_src
#+begin_src c :tangle read_dset_text.c
#+begin_src c :tangle read_dset_data_text.c
trexio_exit_code
trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$,
const uint32_t rank, const uint64_t* dims)
@ -607,7 +607,7 @@ trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
}
#+end_src
#+begin_src c :tangle write_dset_text.c
#+begin_src c :tangle write_dset_data_text.c
trexio_exit_code
trexio_text_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$* $group_dset$,
const uint32_t rank, const uint64_t* dims)
@ -645,7 +645,7 @@ trexio_text_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$*
}
#+end_src
#+begin_src c :tangle has_dset_text.c
#+begin_src c :tangle has_dset_data_text.c
trexio_exit_code
trexio_text_has_$group_dset$ (trexio_t* const file)
{
@ -663,7 +663,47 @@ trexio_text_has_$group_dset$ (trexio_t* const file)
}
#+end_src
** Template for has/read/write the dataset of strings
The ~group_dset~ array is assumed allocated with the appropriate size.
#+begin_src c :tangle hrw_dset_str_text.h :exports none
trexio_exit_code trexio_text_has_$group_dset$ (trexio_t* const file);
trexio_exit_code trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$, const uint32_t rank, const uint64_t* dims);
trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, const $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims);
#+end_src
#+begin_src c :tangle read_dset_str_text.c
trexio_exit_code
trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$,
const uint32_t rank, const uint64_t* dims)
{
return TREXIO_SUCCESS;
}
#+end_src
#+begin_src c :tangle write_dset_str_text.c
trexio_exit_code
trexio_text_write_$group_dset$ (trexio_t* const file, const $group_dset_dtype$* $group_dset$,
const uint32_t rank, const uint64_t* dims)
{
return TREXIO_SUCCESS;
}
#+end_src
#+begin_src c :tangle has_dset_str_text.c
trexio_exit_code
trexio_text_has_$group_dset$ (trexio_t* const file)
{
return TREXIO_SUCCESS;
}
#+end_src
** RDM struct (hard-coded)
*** Read the complete struct