mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-23 04:43:57 +01:00
add trexio_info function
This commit is contained in:
parent
7cb1ca8d68
commit
23c1601442
@ -4,18 +4,22 @@
|
|||||||
cat prefix_front.c > trexio.c
|
cat prefix_front.c > trexio.c
|
||||||
cat prefix_front.h > trexio.h
|
cat prefix_front.h > trexio.h
|
||||||
|
|
||||||
# parse the config-defined version attributes to pass them to Fortran module file
|
# parse the config-defined version attributes to pass them to the header files
|
||||||
VERSION_VAL=`grep "PACKAGE_VERSION" ../../include/config.h | cut -d " " -f 3`
|
VERSION_VAL=`grep "PACKAGE_VERSION" ../../include/config.h | cut -d " " -f 3`
|
||||||
VERSION_MAJOR_VAL=`grep "VERSION_MAJOR" ../../include/config.h | cut -d " " -f 3`
|
VERSION_MAJOR_VAL=`grep "VERSION_MAJOR" ../../include/config.h | cut -d " " -f 3`
|
||||||
VERSION_MINOR_VAL=`grep "VERSION_MINOR" ../../include/config.h | cut -d " " -f 3`
|
VERSION_MINOR_VAL=`grep "VERSION_MINOR" ../../include/config.h | cut -d " " -f 3`
|
||||||
VERSION_PATCH_VAL=`grep "VERSION_PATCH" ../../include/config.h | cut -d " " -f 3`
|
VERSION_PATCH_VAL=`grep "VERSION_PATCH" ../../include/config.h | cut -d " " -f 3`
|
||||||
|
|
||||||
|
# parse the config-defined GIT_HASH to pass them to the header files
|
||||||
|
GIT_HASH_STR=`grep "GIT_HASH" ../../include/config.h | cut -d " " -f 3`
|
||||||
|
|
||||||
# grep some usefull constants from the config.h
|
# grep some usefull constants from the config.h
|
||||||
echo "" >> trexio.h
|
echo "" >> trexio.h
|
||||||
echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL}" >> trexio.h
|
echo "#define TREXIO_PACKAGE_VERSION ${VERSION_VAL}" >> trexio.h
|
||||||
echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL}" >> trexio.h
|
echo "#define TREXIO_VERSION_MAJOR ${VERSION_MAJOR_VAL}" >> trexio.h
|
||||||
echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL}" >> trexio.h
|
echo "#define TREXIO_VERSION_MINOR ${VERSION_MINOR_VAL}" >> trexio.h
|
||||||
echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL}" >> trexio.h
|
echo "#define TREXIO_VERSION_PATCH ${VERSION_PATCH_VAL}" >> trexio.h
|
||||||
|
echo "#define TREXIO_GIT_HASH ${GIT_HASH_STR:='0000'}" >> trexio.h
|
||||||
echo "" >> trexio.h
|
echo "" >> trexio.h
|
||||||
|
|
||||||
cat prefix_s_front.h > trexio_s.h
|
cat prefix_s_front.h > trexio_s.h
|
||||||
@ -24,10 +28,11 @@ cat prefix_python.py > trexio.py
|
|||||||
|
|
||||||
# append version string and attributes to the Fortran module file
|
# append version string and attributes to the Fortran module file
|
||||||
echo "" >> trexio_f.f90
|
echo "" >> trexio_f.f90
|
||||||
echo "character(len = 12) :: TREXIO_PACKAGE_VERSION = ${VERSION_VAL}" >> trexio_f.f90
|
echo "character(len = 12) :: TREXIO_PACKAGE_VERSION = ${VERSION_VAL:='0.0.0'}" >> trexio_f.f90
|
||||||
echo "integer(4) :: TREXIO_VERSION_MAJOR = ${VERSION_MAJOR_VAL}" >> trexio_f.f90
|
echo "integer(4) :: TREXIO_VERSION_MAJOR = ${VERSION_MAJOR_VAL}" >> trexio_f.f90
|
||||||
echo "integer(4) :: TREXIO_VERSION_MINOR = ${VERSION_MINOR_VAL}" >> trexio_f.f90
|
echo "integer(4) :: TREXIO_VERSION_MINOR = ${VERSION_MINOR_VAL}" >> trexio_f.f90
|
||||||
echo "integer(4) :: TREXIO_VERSION_PATCH = ${VERSION_PATCH_VAL}" >> trexio_f.f90
|
echo "integer(4) :: TREXIO_VERSION_PATCH = ${VERSION_PATCH_VAL}" >> trexio_f.f90
|
||||||
|
echo "character(len = 64) :: TREXIO_GIT_HASH = ${GIT_HASH_STR:='0000'}" >> trexio_f.f90
|
||||||
echo "" >> trexio_f.f90
|
echo "" >> trexio_f.f90
|
||||||
|
|
||||||
# c front end
|
# c front end
|
||||||
@ -48,4 +53,3 @@ cat populated/pop_*.py >> trexio.py
|
|||||||
cat suffix_s_front.h >> trexio_s.h
|
cat suffix_s_front.h >> trexio_s.h
|
||||||
cat suffix_front.h >> trexio.h
|
cat suffix_front.h >> trexio.h
|
||||||
cat suffix_fortran.f90 >> trexio_f.f90
|
cat suffix_fortran.f90 >> trexio_f.f90
|
||||||
|
|
||||||
|
@ -3851,6 +3851,70 @@ def has_$group_str$(trexio_file) -> bool:
|
|||||||
return False
|
return False
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* General helper functions
|
||||||
|
|
||||||
|
This section contains general helper functions like ~trexio_info~.
|
||||||
|
|
||||||
|
~trexio_info~ prints information about the TREXIO configuration (see =config.h= file).
|
||||||
|
In particular:
|
||||||
|
|
||||||
|
1) ~TREXIO_PACKAGE_VERSION~ [string]
|
||||||
|
2) ~HAVE_HDF5~ [bool]
|
||||||
|
3) ~HDF5_VERSION~ [string] (optional, only if ~HAVE_HDF5~ is ~true~)
|
||||||
|
4) ~TREXIO_GIT_HASH~ [string]
|
||||||
|
|
||||||
|
** C
|
||||||
|
|
||||||
|
#+begin_src c :tangle prefix_front.h :exports none
|
||||||
|
trexio_exit_code trexio_info(void);
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src c :tangle prefix_front.c
|
||||||
|
trexio_exit_code
|
||||||
|
trexio_info (void)
|
||||||
|
{
|
||||||
|
printf("TREXIO_PACKAGE_VERSION : %s\n", TREXIO_PACKAGE_VERSION);
|
||||||
|
|
||||||
|
#ifdef TREXIO_GIT_HASH
|
||||||
|
printf("TREXIO_GIT_HASH : %s\n", TREXIO_GIT_HASH);
|
||||||
|
#else
|
||||||
|
printf("GIT_HASH is stored in the config.h file, which is missing.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_HDF5
|
||||||
|
printf("HAVE_HDF5 : true\n");
|
||||||
|
printf("%s\n", H5_VERS_INFO);
|
||||||
|
#else
|
||||||
|
printf("HAVE_HDF5 : false\n");
|
||||||
|
printf("TREXIO configured without the HDF5 library\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return TREXIO_SUCCESS;
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Fortran
|
||||||
|
|
||||||
|
#+begin_src f90 :tangle prefix_fortran.f90
|
||||||
|
interface
|
||||||
|
integer function trexio_info () bind(C)
|
||||||
|
use, intrinsic :: iso_c_binding
|
||||||
|
end function trexio_info
|
||||||
|
end interface
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Python
|
||||||
|
|
||||||
|
#+begin_src python :tangle basic_python.py
|
||||||
|
def info():
|
||||||
|
"""Print the info about the installed TREXIO library.
|
||||||
|
"""
|
||||||
|
|
||||||
|
rc = pytr.trexio_info()
|
||||||
|
if rc != TREXIO_SUCCESS:
|
||||||
|
raise Error(rc)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
* Fortran helper/wrapper functions
|
* Fortran helper/wrapper functions
|
||||||
|
|
||||||
The function below adapts the original C-based ~trexio_open~ for Fortran.
|
The function below adapts the original C-based ~trexio_open~ for Fortran.
|
||||||
|
Loading…
Reference in New Issue
Block a user