1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-03-04 06:10:23 +01:00

TODO: properly populate dimensions in write_dset

This commit is contained in:
q-posev 2021-03-09 16:31:12 +01:00
parent 50841e1937
commit ba0f14a6cc
2 changed files with 30 additions and 8 deletions

View File

@ -85,10 +85,29 @@ files_funcs_nums = [f for f in files_funcs if 'num' in f]
files_auxil = [f for f in files if not ('read_' in f or 'write_' in f or 'rw_' in f)]
print(files_funcs_dsets)
# build files with functions
for fname in files_funcs_nums:
fname_new = 'populated/pop_' + fname
for dim in dim_variables.keys():
grname = dim.split('_')[0]
with open(f'{temp_path}/{fname}', 'r') as f_in :
with open(f'{temp_path}/{fname_new}', 'a') as f_out :
for line in f_in :
if '$' in line:
templine1 = line.replace('$GROUP_NUM$', dim.upper())
templine2 = templine1.replace('$group_num$', dim)
templine1 = templine2.replace('$group$', grname)
templine2 = templine1.replace('$GROUP$', grname.upper())
f_out.write(templine2)
else:
f_out.write(line)
# build files with functions
for fname in ['write_dset_hdf5.c']:
for fname in files_funcs_dsets:
fname_new = 'populated/pop_' + fname
for dset,params in datasets_nostr.items():
@ -119,8 +138,11 @@ for fname in ['write_dset_hdf5.c']:
if dim.isdigit():
continue
else:
print("TODO: this only populate 1 dim and not all !")
templine1 = templine2.replace('$group_dset_dim$', dim)
templine2 = templine1
f_out.write(templine2)
templine1 = templine2.replace('$group$', grname)
templine2 = templine1.replace('$GROUP$', grname.upper())

View File

@ -152,13 +152,13 @@ trexio_exit_code trexio_hdf5_finalize(trexio_t* file) {
** Template for HDF5 read/write a number
#+begin_src c :tangle rw_num_hdf5.h
trexio_exit_code trexio_hdf5_read_$group_num$(const trexio_t* file, uint64_t* num);
trexio_exit_code trexio_hdf5_write_$group_num$(const trexio_t* file, const uint64_t num);
trexio_exit_code trexio_hdf5_read_$group_num$ (const trexio_t* file, uint64_t* num);
trexio_exit_code trexio_hdf5_write_$group_num$ (const trexio_t* file, const uint64_t num);
#+end_src
#+begin_src c :tangle read_num_hdf5.c
trexio_exit_code trexio_hdf5_read_$group_num$const trexio_t* file, uint64_t* num) {
trexio_exit_code trexio_hdf5_read_$group_num$ (const trexio_t* file, uint64_t* num) {
assert (file != NULL);
assert (num != NULL);
@ -180,7 +180,7 @@ trexio_exit_code trexio_hdf5_read_$group_num$const trexio_t* file, uint64_t* num
#+begin_src c :tangle write_num_hdf5.c
trexio_exit_code trexio_hdf5_write_$group_num$(const trexio_t* file, const uint64_t num) {
trexio_exit_code trexio_hdf5_write_$group_num$ (const trexio_t* file, const uint64_t num) {
assert (file != NULL);
assert (num > 0L);
@ -213,10 +213,10 @@ trexio_exit_code trexio_hdf5_write_$group_num$(const trexio_t* file, const uint6
if (infile_num != num) {
if (infile_num != 0) {
printf("%ld -> %ld %s \n", num, infile_num,
printf("%ld -> %ld %s \n", num, infile_num,
"This variable already exists. Overwriting it is not supported");
H5Tclose(dtype);
return TREXIO_FAILURE;
return TREXIO_FAILURE;
} else {