1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-22 20:35:44 +01:00

[WIP] adapt generator for string datasets

This commit is contained in:
q-posev 2021-05-31 16:39:21 +02:00
parent 9142c21130
commit 1647e76fcf
2 changed files with 23 additions and 13 deletions

View File

@ -18,12 +18,14 @@ print('Strings I/O currently not supported')
# -------------------- GET ATTRIBUTES FROM THE CONFIGURATION ---------------- #
group_dict = get_group_dict(trex_config)
detailed_num = get_detailed_num_dict(trex_config)
# helper dictionaries contain group, num or dset names as keys
datasets = get_dset_dict(trex_config)
detailed_dset_nostr, detailed_dset_str = split_dset_dict_detailed(datasets)
detailed_nums = get_detailed_num_dict(trex_config)
# helper dictionaries that contain names of groups, nums or dsets as keys
dsets = get_dset_dict(trex_config)
detailed_dsets_nostr, detailed_dsets_str = split_dset_dict_detailed(dsets)
detailed_dsets = detailed_dsets_nostr.copy()
detailed_dsets.update(detailed_dsets_str)
# consistency check for dimensioning variables
check_dim_consistency(detailed_num, datasets)
check_dim_consistency(detailed_nums, dsets)
# --------------------------------------------------------------------------- #
# -------------------- GET TEMPLATED FILES TO BE POPULATED ------------------ #
@ -40,18 +42,22 @@ files_todo = get_files_todo(source_files)
# populate files with iterative scheme, i.e. for unique functions
for fname in files_todo['auxiliary']:
iterative_populate_file(fname, template_paths, group_dict, detailed_dset_nostr, detailed_num)
iterative_populate_file(fname, template_paths, group_dict, detailed_dsets, detailed_nums)
# populate has/read/write_num functions with recursive scheme
for fname in files_todo['num']:
recursive_populate_file(fname, template_paths, detailed_num)
recursive_populate_file(fname, template_paths, detailed_nums)
# populate has/read/write_dset functions with recursive scheme
# populate has/read/write_dset (numerical) functions with recursive scheme
for fname in files_todo['dset_data']:
recursive_populate_file(fname, template_paths, detailed_dset_nostr)
recursive_populate_file(fname, template_paths, detailed_dsets_nostr)
# populate has/read/write_dset (strings) functions with recursive scheme
for fname in files_todo['dset_str']:
recursive_populate_file(fname, template_paths, detailed_dsets_str)
# populate group-related functions with mixed (iterative+recursive) scheme [text backend]
for fname in files_todo['group']:
special_populate_text_group(fname, template_paths, group_dict, detailed_dset_nostr, detailed_num)
special_populate_text_group(fname, template_paths, group_dict, detailed_dsets_nostr, detailed_nums)
# --------------------------------------------------------------------------- #

View File

@ -485,8 +485,12 @@ def split_dset_dict_detailed (datasets: dict) -> tuple:
group_dset_std_dtype_out = '" PRId64 "'
group_dset_std_dtype_in = '" SCNd64 "'
elif v[0] == 'str':
# TODO
datatype = 'string'
datatype = 'char*'
group_dset_h5_dtype = 'c_s1'
group_dset_f_dtype_default = 'character(len=*)'
group_dset_dtype_default = 'char*'
group_dset_std_dtype_out = 's'
group_dset_std_dtype_in = 's'
# add the dset name for templates
tmp_dict['group_dset'] = k
@ -527,7 +531,7 @@ def split_dset_dict_detailed (datasets: dict) -> tuple:
tmp_dict['group'] = v[2]
# split datasets in numeric- and string- based
if (datatype == 'string'):
if (datatype == 'char*'):
dset_string_dict[k] = tmp_dict
else:
dset_numeric_dict[k] = tmp_dict