mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-22 12:23:54 +01:00
Adapt the generator for dim readonly
This commit is contained in:
parent
ddeb452715
commit
24b1ce6b35
@ -120,8 +120,10 @@ def recursive_populate_file(fname: str, paths: dict, detailed_source: dict) -> N
|
|||||||
|
|
||||||
for item in detailed_source.keys():
|
for item in detailed_source.keys():
|
||||||
|
|
||||||
# special case to exclude write_determinant_num funcs from the public APIs
|
# special case to exclude write functions for readonly dimensions (like determinant_num) from the public API
|
||||||
if 'determinant_num' in item and 'write' in fname and 'front' in fname and ('.f90' in fname or '.py' in fname):
|
if 'write' in fname and 'front' in fname and ('.f90' in fname or '.py' in fname):
|
||||||
|
if 'trex_json_int_type' in detailed_source[item].keys():
|
||||||
|
if 'readonly' in detailed_source[item]['trex_json_int_type']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
with open(join(templ_path,fname), 'r') as f_in :
|
with open(join(templ_path,fname), 'r') as f_in :
|
||||||
@ -145,19 +147,22 @@ def recursive_populate_file(fname: str, paths: dict, detailed_source: dict) -> N
|
|||||||
continue
|
continue
|
||||||
# special case to uncomment check for positive dimensioning variables in templates
|
# special case to uncomment check for positive dimensioning variables in templates
|
||||||
elif 'uncommented by the generator for dimensioning' in line:
|
elif 'uncommented by the generator for dimensioning' in line:
|
||||||
# only uncomment and write the line if `num` is in the name
|
# only uncomment and write the line if `dim` is in the name
|
||||||
if 'dim' in detailed_source[item]['trex_json_int_type']:
|
if 'dim' in detailed_source[item]['trex_json_int_type']:
|
||||||
templine = line.replace('//', '')
|
templine = line.replace('//', '')
|
||||||
f_out.write(templine)
|
f_out.write(templine)
|
||||||
# general case of recursive replacement of inline triggers
|
# general case of recursive replacement of inline triggers
|
||||||
else:
|
else:
|
||||||
populated_line = recursive_replace_line(line, triggers, detailed_source[item])
|
populated_line = recursive_replace_line(line, triggers, detailed_source[item])
|
||||||
# special case to include write_determinant_num funcs in the private header
|
# special case to include some functions in the private header
|
||||||
if 'determinant_num' in item and 'write' in line and 'front.h' in fname:
|
if 'trex_json_int_type' in detailed_source[item].keys():
|
||||||
|
if 'readonly' in detailed_source[item]['trex_json_int_type'] and 'write' in line and 'front.h' in fname:
|
||||||
with open(join(templ_path,'populated/private_pop_front.h'), 'a') as f_priv:
|
with open(join(templ_path,'populated/private_pop_front.h'), 'a') as f_priv:
|
||||||
f_priv.write(populated_line)
|
f_priv.write(populated_line)
|
||||||
else:
|
else:
|
||||||
f_out.write(populated_line)
|
f_out.write(populated_line)
|
||||||
|
else:
|
||||||
|
f_out.write(populated_line)
|
||||||
|
|
||||||
f_out.write("\n")
|
f_out.write("\n")
|
||||||
|
|
||||||
@ -490,7 +495,7 @@ def get_dtype_dict (dtype: str, target: str, rank = None, int_len_printf = None)
|
|||||||
f'group_{target}_format_scanf' : 'lf',
|
f'group_{target}_format_scanf' : 'lf',
|
||||||
f'group_{target}_py_dtype' : 'float'
|
f'group_{target}_py_dtype' : 'float'
|
||||||
})
|
})
|
||||||
elif dtype in ['int', 'dim', 'index']:
|
elif dtype in ['int', 'dim', 'dim readonly', 'index']:
|
||||||
dtype_dict.update({
|
dtype_dict.update({
|
||||||
'default_prec' : '32',
|
'default_prec' : '32',
|
||||||
f'group_{target}_dtype' : 'int64_t',
|
f'group_{target}_dtype' : 'int64_t',
|
||||||
@ -581,16 +586,17 @@ def get_detailed_num_dict (configuration: dict) -> dict:
|
|||||||
tmp_num = f'{k1}_{k2}'
|
tmp_num = f'{k1}_{k2}'
|
||||||
if not 'str' in v2[0]:
|
if not 'str' in v2[0]:
|
||||||
tmp_dict = {}
|
tmp_dict = {}
|
||||||
|
|
||||||
tmp_dict['group'] = k1
|
tmp_dict['group'] = k1
|
||||||
tmp_dict['group_num'] = tmp_num
|
tmp_dict['group_num'] = tmp_num
|
||||||
num_dict[tmp_num] = tmp_dict
|
|
||||||
|
|
||||||
tmp_dict.update(get_dtype_dict(v2[0], 'num'))
|
tmp_dict.update(get_dtype_dict(v2[0], 'num'))
|
||||||
if v2[0] in ['int', 'dim']:
|
if v2[0] in ['int', 'dim', 'dim readonly']:
|
||||||
tmp_dict['trex_json_int_type'] = v2[0]
|
tmp_dict['trex_json_int_type'] = v2[0]
|
||||||
else:
|
else:
|
||||||
tmp_dict['trex_json_int_type'] = ''
|
tmp_dict['trex_json_int_type'] = ''
|
||||||
|
|
||||||
|
num_dict[tmp_num] = tmp_dict
|
||||||
|
|
||||||
return num_dict
|
return num_dict
|
||||||
|
|
||||||
|
|
||||||
@ -775,7 +781,10 @@ def check_dim_consistency(num: dict, dset: dict) -> None:
|
|||||||
if dim not in dim_tocheck:
|
if dim not in dim_tocheck:
|
||||||
dim_tocheck.append(dim)
|
dim_tocheck.append(dim)
|
||||||
|
|
||||||
num_onlyDim = [attr_name for attr_name, specs in num.items() if specs['trex_json_int_type']=='dim']
|
num_onlyDim = [
|
||||||
|
attr_name for attr_name, specs in num.items()
|
||||||
|
if 'dim' in specs['trex_json_int_type']
|
||||||
|
]
|
||||||
|
|
||||||
for dim in dim_tocheck:
|
for dim in dim_tocheck:
|
||||||
if not dim in num_onlyDim:
|
if not dim in num_onlyDim:
|
||||||
|
Loading…
Reference in New Issue
Block a user