mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-11-03 20:54:07 +01:00
Merge branch 'master' into swig-python
This commit is contained in:
commit
4faee98092
@ -21,6 +21,11 @@ AC_SUBST([VERSION_MAJOR])
|
||||
AC_SUBST([VERSION_MINOR])
|
||||
AC_SUBST([VERSION_PATCH])
|
||||
|
||||
## Save system information, e.g. user name
|
||||
|
||||
UNAME=`echo ${USER}`
|
||||
AC_DEFINE_UNQUOTED(TREXIO_USER_NAME, ["${UNAME}"], [user name])
|
||||
AC_SUBST([UNAME])
|
||||
|
||||
## -------------------
|
||||
## Checks for programs
|
||||
@ -49,6 +54,7 @@ PKG_CFLAGS=""
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_GREP
|
||||
|
||||
|
||||
## ---------
|
||||
|
@ -3,6 +3,11 @@
|
||||
# prefixes
|
||||
cat prefix_front.c > trexio.c
|
||||
cat prefix_front.h > trexio.h
|
||||
# grep some usefull constants from the config.h
|
||||
echo "" >> trexio.h
|
||||
grep "_VERSION" ../../include/config.h >> trexio.h
|
||||
echo "" >> trexio.h
|
||||
|
||||
cat prefix_s_front.h > trexio_s.h
|
||||
cat prefix_fortran.f90 > trexio_f.f90
|
||||
|
||||
|
@ -438,6 +438,7 @@ typedef struct trexio_s trexio_t;
|
||||
#+begin_src c :tangle prefix_s_front.h
|
||||
struct trexio_s {
|
||||
char file_name[TREXIO_MAX_FILENAME_LENGTH];
|
||||
char version[16];
|
||||
pthread_mutex_t thread_lock;
|
||||
back_end_t back_end;
|
||||
char mode;
|
||||
@ -534,6 +535,12 @@ trexio_open(const char* file_name, const char mode,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy(result->version, PACKAGE_VERSION, 16);
|
||||
if (result->version[15] != '\0') {
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result->back_end = back_end;
|
||||
result->mode = mode;
|
||||
result->one_based = false; // Need to be flipped in Fortran interface
|
||||
@ -567,6 +574,36 @@ trexio_open(const char* file_name, const char mode,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = trexio_has_metadata_package_version(result);
|
||||
if (rc == TREXIO_FAILURE) {
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (rc == TREXIO_HAS_NOT) {
|
||||
switch (back_end) {
|
||||
|
||||
case TREXIO_TEXT:
|
||||
rc = trexio_text_write_metadata_package_version(result, PACKAGE_VERSION);
|
||||
break;
|
||||
|
||||
case TREXIO_HDF5:
|
||||
rc = trexio_hdf5_write_metadata_package_version(result, PACKAGE_VERSION);
|
||||
break;
|
||||
/*
|
||||
case TREXIO_JSON:
|
||||
rc = trexio_json_write_metadata_package_version(result, PACKAGE_VERSION);
|
||||
break;
|
||||
,*/
|
||||
}
|
||||
}
|
||||
|
||||
if (rc != TREXIO_SUCCESS) {
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* File locking */
|
||||
|
||||
rc = TREXIO_LOCK_ERROR;
|
||||
|
30
trex.org
30
trex.org
@ -33,27 +33,29 @@ arrays are 0-based. Hence, we introduce the ~index~ type which is an
|
||||
authors of the file, and a textual description.
|
||||
|
||||
#+NAME: metadata
|
||||
| Variable | Type | Dimensions (for arrays) | Description |
|
||||
|---------------+-------+-------------------------+------------------------------------------|
|
||||
| ~code_num~ | ~int~ | | Number of codes used to produce the file |
|
||||
| ~code~ | ~str~ | ~(metadata.code_num)~ | Names of the codes used |
|
||||
| ~author_num~ | ~int~ | | Number of authors of the file |
|
||||
| ~author~ | ~str~ | ~(metadata.author_num)~ | Names of the authors of the file |
|
||||
| ~description~ | ~str~ | | Text describing the content of file |
|
||||
| Variable | Type | Dimensions (for arrays) | Description |
|
||||
|-------------------+-------+-------------------------+------------------------------------------|
|
||||
| ~code_num~ | ~int~ | | Number of codes used to produce the file |
|
||||
| ~code~ | ~str~ | ~(metadata.code_num)~ | Names of the codes used |
|
||||
| ~author_num~ | ~int~ | | Number of authors of the file |
|
||||
| ~author~ | ~str~ | ~(metadata.author_num)~ | Names of the authors of the file |
|
||||
| ~package_version~ | ~str~ | | TREXIO version used to produce the file |
|
||||
| ~description~ | ~str~ | | Text describing the content of file |
|
||||
|
||||
#+CALL: json(data=metadata, title="metadata")
|
||||
#+RESULTS:
|
||||
:results:
|
||||
:RESULTS:
|
||||
#+begin_src python :tangle trex.json
|
||||
"metadata": {
|
||||
"code_num" : [ "int", [] ]
|
||||
, "code" : [ "str", [ "metadata.code_num" ] ]
|
||||
, "author_num" : [ "int", [] ]
|
||||
, "author" : [ "str", [ "metadata.author_num" ] ]
|
||||
, "description" : [ "str", [] ]
|
||||
"code_num" : [ "int", [] ]
|
||||
, "code" : [ "str", [ "metadata.code_num" ] ]
|
||||
, "author_num" : [ "int", [] ]
|
||||
, "author" : [ "str", [ "metadata.author_num" ] ]
|
||||
, "package_version" : [ "str", [] ]
|
||||
, "description" : [ "str", [] ]
|
||||
} ,
|
||||
#+end_src
|
||||
:end:
|
||||
:END:
|
||||
|
||||
* Electron (electron group)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user