1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-11-03 20:54:07 +01:00

fixed to compile

This commit is contained in:
q-posev 2021-03-16 19:05:05 +01:00
parent aa67877948
commit cc02849689
3 changed files with 50 additions and 19 deletions

View File

@ -85,10 +85,10 @@ templ_path_hdf5 = join(fileDir,'templates_hdf5')
templ_path_front = join(fileDir,'templates_front')
#clean the populated/ directory
for popdir in [templ_path_front, templ_path_front, templ_path_text]:
cleandir = join(popdir, 'populated')
for f in scandir(cleandir):
remove(f.path)
#for popdir in [templ_path_front, templ_path_front, templ_path_text]:
# cleandir = join(popdir, 'populated')
# for f in scandir(cleandir):
# remove(f.path)
files_exclude = ['prefix_hdf5.c', 'prefix_hdf5.h', 'suffix_hdf5.h',
'prefix_text.c', 'prefix_text.h', 'suffix_text.h',
@ -329,8 +329,8 @@ for fname in ['def_hdf5.c', 'basic_hdf5.c', 'basic_text_group.c',
templine2 = templine1.replace('$group_dset$', dset)
f_out.write(templine2)
elif '$group_num$' in line or '$GROUP_NUM$' in line :
#for num in dim_variables.keys():
for num in numbers.keys():
for num in dim_variables.keys():
#for num in numbers.keys():
templine1 = line.replace('$GROUP_NUM$', num.upper())
templine2 = templine1.replace('$group_num$', num)
f_out.write(templine2)

View File

@ -1,4 +1,4 @@
g+Title: Templator for frontend
#+Title: Templator for frontend
* Constant file prefixes (not used by generator) :noxport:
@ -50,6 +50,41 @@ g+Title: Templator for frontend
#include <assert.h>
#+end_src
* Coding conventions
- integer types will be defined using types given in ~stdint.h~
- pointers are always initialized to ~NULL~
- when memory is freed, the pointer is set to ~NULL~
- ~assert.h~ should be used extensively
- variable names are in lower case
- ~#define~ constants are in upper case
- structs are suffixed by ~_s~
- types are suffixed by ~_t~
** Memory allocation
Memory allocation of structures can be facilitated by using the
following macro, which ensures that the size of the allocated
object is the same as the size of the data type pointed by the pointer.
#+begin_src c :tangle trexio_private.h
#define MALLOC(T) (T*) malloc (sizeof(T));
#define CALLOC(N,T) (T*) calloc ((N),sizeof(T));
#+end_src
When a pointer is freed, it should be set to ~NULL~.
This can be facilitated by the use of the following macro:
#+begin_src c :tangle trexio_private.h
#define FREE(X) { free(X) ; (X)=NULL; }
#+end_src
* Front end
All calls to TREXIO are thread-safe.
** Error handling
#+begin_src c :tangle prefix_front.h
typedef int32_t trexio_exit_code;
@ -65,7 +100,9 @@ typedef int32_t trexio_exit_code;
#define TREXIO_READONLY ( (trexio_exit_code) 11 )
#define TREXIO_ERRNO ( (trexio_exit_code) 12 )
#define TREXIO_INVALID_ID ( (trexio_exit_code) 20 )
#define TREXIO_INVALID_NUM ( (trexio_exit_code) 21 )
#define TREXIO_ALLOCATION_FAILED ( (trexio_exit_code) 21 )
#define TREXIO_INVALID_NUM ( (trexio_exit_code) 22 )
#+end_src
** Back ends
@ -318,7 +355,7 @@ trexio_exit_code trexio_close(trexio_t* file) {
#+end_src
* Front end
* Templates for front end
** Template for frontend read/write a number
@ -405,16 +442,13 @@ trexio_exit_code trexio_read_$group$_$group_dset$(trexio_t* file, $group_dset_dt
rc = trexio_hdf5_read_$group_dset_dim$(file, &$group_dset_dim$);
if ($group_dset_dim$ <= 0L) return TREXIO_INVALID_NUM;
int64_t dim_total = nucleus_num*3;
if (dim_total < 0) return TREXIO_FAILURE;
uint32_t rank = $group_dset_rank$;
uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$};
switch (file->back_end) {
case TREXIO_TEXT:
return trexio_text_read_$group$_$group_dset$(file, $group_dset$, (uint64_t) dim_total);
return trexio_text_read_$group$_$group_dset$(file, $group_dset$, rank, dims);
break;
case TREXIO_HDF5:
@ -443,16 +477,13 @@ trexio_exit_code trexio_write_$group$_$group_dset$(trexio_t* file, const $group_
rc = trexio_hdf5_read_$group_dset_dim$(file, &$group_dset_dim$);
if ($group_dset_dim$ <= 0L) return TREXIO_INVALID_NUM;
int64_t dim_total = nucleus_num*3;
if (dim_total < 0) return TREXIO_FAILURE;
uint32_t rank = $group_dset_rank$;
uint64_t dims[$group_dset_rank$] = {$group_dset_dim_list$};
switch (file->back_end) {
case TREXIO_TEXT:
return trexio_text_write_$group$_$group_dset$(file, $group_dset$, (uint64_t) dim_total);
return trexio_text_write_$group$_$group_dset$(file, $group_dset$, rank, dims);
break;
case TREXIO_HDF5:

View File

@ -583,7 +583,7 @@ trexio_exit_code trexio_text_write_$group_dset$(const trexio_t* file, const $gro
trexio_exit_code trexio_text_read_$group_dset$(const trexio_t* file, $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
if (coord == NULL) return TREXIO_INVALID_ARG_2;
if ($group_dset$ == NULL) return TREXIO_INVALID_ARG_2;
$group$_t* $group$ = trexio_text_read_$group$((trexio_text_t*) file);
if ($group$ == NULL) return TREXIO_FAILURE;
@ -608,7 +608,7 @@ trexio_exit_code trexio_text_read_$group_dset$(const trexio_t* file, $group_dset
trexio_exit_code trexio_text_write_$group_dset$(const trexio_t* file, const $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
if (coord == NULL) return TREXIO_INVALID_ARG_2;
if ($group_dset$ == NULL) return TREXIO_INVALID_ARG_2;
if (file->mode == 'r') return TREXIO_READONLY;