mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-11 05:28:33 +01:00
fix for dset_dtype calloc and fscanf/fprintf
This commit is contained in:
parent
6e7b9a370d
commit
8a02ea07e2
@ -15,8 +15,8 @@ del config0['metadata']
|
|||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
for k,v in config0.items():
|
for k,v in config0.items():
|
||||||
#if k == 'nucleus' or k == 'ecp':
|
if k == 'nucleus' or k == 'ecp':
|
||||||
if k == 'nucleus':
|
#if k == 'nucleus':
|
||||||
config[k] = v
|
config[k] = v
|
||||||
|
|
||||||
#print(config)
|
#print(config)
|
||||||
@ -146,6 +146,18 @@ for fname in files_funcs_groups:
|
|||||||
|
|
||||||
templine1 = loop_body.replace('$group_dset$', dset)
|
templine1 = loop_body.replace('$group_dset$', dset)
|
||||||
templine2 = templine1.replace('$group$', grname)
|
templine2 = templine1.replace('$group$', grname)
|
||||||
|
|
||||||
|
templine1 = templine2.replace('$group_dset_dtype$', params['dtype'])
|
||||||
|
templine2 = templine1
|
||||||
|
|
||||||
|
if params['dtype'] == 'double':
|
||||||
|
std_dtype = 'lf'
|
||||||
|
elif params['dtype'] == 'int64_t':
|
||||||
|
std_dtype = 'ld'
|
||||||
|
|
||||||
|
templine1 = templine2.replace('$group_dset_std_dtype$', std_dtype)
|
||||||
|
templine2 = templine1
|
||||||
|
|
||||||
f_out.write(templine2)
|
f_out.write(templine2)
|
||||||
elif do_num:
|
elif do_num:
|
||||||
#for dim in dim_variables.keys():
|
#for dim in dim_variables.keys():
|
||||||
@ -269,6 +281,7 @@ for fname in files_funcs_dsets:
|
|||||||
templine1 = templine2.replace('$group_dset_h5_dtype$', h5_dtype)
|
templine1 = templine2.replace('$group_dset_h5_dtype$', h5_dtype)
|
||||||
templine2 = templine1.replace('$group_dset_h5_dtype$'.upper(), h5_dtype.upper())
|
templine2 = templine1.replace('$group_dset_h5_dtype$'.upper(), h5_dtype.upper())
|
||||||
|
|
||||||
|
|
||||||
templine1 = templine2.replace('$group_dset_rank$', str(params['rank']))
|
templine1 = templine2.replace('$group_dset_rank$', str(params['rank']))
|
||||||
templine2 = templine1
|
templine2 = templine1
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ DEBUG
|
|||||||
// START REPEAT GROUP_DSET
|
// START REPEAT GROUP_DSET
|
||||||
|
|
||||||
/* Allocate arrays */
|
/* Allocate arrays */
|
||||||
$group$->$group_dset$ = (double*) calloc(size_$group_dset$, sizeof(double));
|
$group$->$group_dset$ = ($group_dset_dtype$*) calloc(size_$group_dset$, sizeof($group_dset_dtype$));
|
||||||
assert (!($group$->$group_dset$ == NULL));
|
assert (!($group$->$group_dset$ == NULL));
|
||||||
if ($group$->$group_dset$ == NULL) {
|
if ($group$->$group_dset$ == NULL) {
|
||||||
FREE(buffer);
|
FREE(buffer);
|
||||||
@ -393,7 +393,7 @@ DEBUG
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint64_t i=0 ; i<size_$group_dset$ ; i++) {
|
for (uint64_t i=0 ; i<size_$group_dset$ ; i++) {
|
||||||
rc = fscanf(f, "%lf", &($group$->$group_dset$[i]));
|
rc = fscanf(f, "%$group_dset_std_dtype$", &($group$->$group_dset$[i]));
|
||||||
assert(!(rc != 1));
|
assert(!(rc != 1));
|
||||||
if (rc != 1) {
|
if (rc != 1) {
|
||||||
FREE(buffer);
|
FREE(buffer);
|
||||||
@ -479,7 +479,7 @@ trexio_exit_code trexio_text_flush_$group$(const trexio_text_t* file) {
|
|||||||
|
|
||||||
fprintf(f, "$group_dset$\n");
|
fprintf(f, "$group_dset$\n");
|
||||||
for (uint64_t i=0 ; i<size_$group_dset$ ; i++) {
|
for (uint64_t i=0 ; i<size_$group_dset$ ; i++) {
|
||||||
fprintf(f, "%lf\n", $group$->$group_dset$[i]);
|
fprintf(f, "%$group_dset_std_dtype$\n", $group$->$group_dset$[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// END REPEAT GROUP_DSET
|
// END REPEAT GROUP_DSET
|
||||||
@ -627,7 +627,7 @@ trexio_exit_code trexio_text_write_$group_dset$(const trexio_t* file, const $gro
|
|||||||
dim_size *= dims[i];
|
dim_size *= dims[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
$group$->$group_dset$ = (double*) calloc(dim_size, sizeof(double));
|
$group$->$group_dset$ = ($group_dset_dtype$*) calloc(dim_size, sizeof($group_dset_dtype$));
|
||||||
|
|
||||||
for (uint64_t i=0 ; i<dim_size ; i++) {
|
for (uint64_t i=0 ; i<dim_size ; i++) {
|
||||||
$group$->$group_dset$[i] = $group_dset$[i];
|
$group$->$group_dset$[i] = $group_dset$[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user