1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-23 04:43:57 +01:00

Merge branch 'master' into unit-testing

This commit is contained in:
q-posev 2021-06-22 14:46:39 +02:00
commit 411334e2ee
7 changed files with 81 additions and 54 deletions

View File

@ -55,13 +55,13 @@ lib_LTLIBRARIES = src/libtrexio.la
SOURCES = \ SOURCES = \
$(trexio_h) \ $(trexio_h) \
$(srcdir)/src/trexio.c \ src/trexio.c \
$(srcdir)/src/trexio_private.h \ src/trexio_private.h \
$(srcdir)/src/trexio_s.h \ src/trexio_s.h \
$(srcdir)/src/trexio_hdf5.c \ src/trexio_hdf5.c \
$(srcdir)/src/trexio_hdf5.h \ src/trexio_hdf5.h \
$(srcdir)/src/trexio_text.c \ src/trexio_text.c \
$(srcdir)/src/trexio_text.h src/trexio_text.h
ORG_FILES = \ ORG_FILES = \
src/templates_front/templator_front.org \ src/templates_front/templator_front.org \
@ -99,6 +99,7 @@ check_PROGRAMS = $(TESTS)
# specify common options for all tests # specify common options for all tests
LDADD = src/libtrexio.la LDADD = src/libtrexio.la
# in principal, specifying -no-install (see example below) is not mandatory # in principal, specifying -no-install (see example below) is not mandatory
# for the tests to compile and pass, but the compilations itself differs # for the tests to compile and pass, but the compilations itself differs
tests_io_num_hdf5_LDFLAGS = -no-install tests_io_num_hdf5_LDFLAGS = -no-install
@ -124,18 +125,37 @@ tests_test_f_SOURCES = $(test_trexio_f) tests/test_f.f90
tests_test_f_LDFLAGS = -no-install tests_test_f_LDFLAGS = -no-install
HTML_FILES = docs/trexio.css \
docs/index.html \
docs/Sparse.html \
docs/templator_hdf5.html \
docs/trex.html \
docs/README.html \
docs/templator_front.html \
docs/templator_text.html
htmldir = $(docdir)
dist_html_DATA = $(HTML_FILES)
$(HTML_FILES): docs/index.html
if TREXIO_DEVEL if TREXIO_DEVEL
CLEANFILES += $(SOURCES) $(trexio_f) $(trexio_h) CLEANFILES += $(SOURCES) $(trexio_f) $(trexio_h)
BUILT_SOURCES = $(SOURCES) $(trexio_f) $(test_trexio_f) BUILT_SOURCES = $(SOURCES) $(trexio_f) $(test_trexio_f)
$(SOURCES): $(trexio_f) $(SOURCES): $(trexio_f)
src/trexio.c: $(trexio_h) src/trexio.c: $(trexio_h)
$(trexio_f): $(ORG_FILES) $(trexio_f): $(ORG_FILES)
cd $(srcdir)/tools && ./build_trexio.sh cd $(srcdir)/tools && ./build_trexio.sh
docs/index.html: $(SOURCES) $(srcdir)/src/README.org
cd $(srcdir)/tools && ./build_doc.sh
cppcheck: cppcheck.out cppcheck: cppcheck.out
cat cppcheck.out cat cppcheck.out

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69]) AC_PREREQ([2.69])
AC_INIT([trexio], [0.2.0], [https://github.com/TREX-CoE/trexio/issues]) AC_INIT([trexio], [0.3.0], [https://github.com/TREX-CoE/trexio/issues])
AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11]) AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11])
AM_MAINTAINER_MODE() AM_MAINTAINER_MODE()
LT_INIT LT_INIT
@ -72,7 +72,7 @@ AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdbool.h stdlib.h string.h unistd
PKG_HDF5="" PKG_HDF5=""
AX_LIB_HDF5([serial]) AX_LIB_HDF5()
if test "x${with_hdf5}" = xno; then if test "x${with_hdf5}" = xno; then
AC_MSG_WARN([ AC_MSG_WARN([

View File

@ -4,6 +4,7 @@
------------------ ------------------
- [[./trex.html][Data stored with TREXIO]]
- [[./templator_front.html][Front end API]] - [[./templator_front.html][Front end API]]
- [[./templator_hdf5.html][HDF5 back end]] - [[./templator_hdf5.html][HDF5 back end]]
- [[./templator_text.html][TEXT back end]] - [[./templator_text.html][TEXT back end]]

View File

@ -1643,6 +1643,7 @@ trexio_read_$group_dset$_low (trexio_t* const file, char* dset, const uint32_t m
,*/ ,*/
} }
return TREXIO_FAILURE;
} }
trexio_exit_code trexio_exit_code
@ -1803,7 +1804,6 @@ trexio_write_$group_dset$ (trexio_t* const file, const char** dset, const uint32
FREE(str_compiled); FREE(str_compiled);
return rc; return rc;
} }
#+end_src #+end_src
@ -1831,6 +1831,7 @@ trexio_has_$group_dset$ (trexio_t* const file)
break; break;
,*/ ,*/
} }
return TREXIO_FAILURE; return TREXIO_FAILURE;
} }
#+end_src #+end_src
@ -1968,6 +1969,7 @@ trexio_read_$group_str$ (trexio_t* const file, char* const str, const uint32_t m
,*/ ,*/
} }
return TREXIO_FAILURE;
} }
#+end_src #+end_src
@ -2000,6 +2002,7 @@ trexio_write_$group_str$ (trexio_t* const file, const char* str, const uint32_t
,*/ ,*/
} }
return TREXIO_FAILURE;
} }
#+end_src #+end_src

View File

@ -289,15 +289,6 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
const trexio_hdf5_t* f = (const trexio_hdf5_t*) file; const trexio_hdf5_t* f = (const trexio_hdf5_t*) file;
herr_t status;
int rrank;
// get the rank of the dataset in a file
status = H5LTget_dataset_ndims (f->$group$_group, $GROUP_DSET$_NAME, &rrank);
if (status < 0) return TREXIO_FAILURE;
if (rrank != (int) rank) return TREXIO_INVALID_ARG_3;
// open the dataset to get its dimensions // open the dataset to get its dimensions
hid_t dset_id = H5Dopen(f->$group$_group, $GROUP_DSET$_NAME, H5P_DEFAULT); hid_t dset_id = H5Dopen(f->$group$_group, $GROUP_DSET$_NAME, H5P_DEFAULT);
if (dset_id <= 0) return TREXIO_INVALID_ID; if (dset_id <= 0) return TREXIO_INVALID_ID;
@ -306,25 +297,34 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $
hsize_t* ddims = CALLOC( (int) rank, hsize_t); hsize_t* ddims = CALLOC( (int) rank, hsize_t);
if (ddims == NULL) return TREXIO_FAILURE; if (ddims == NULL) return TREXIO_FAILURE;
// read dimensions from the existing dataset // get the dataspace of the dataset
status = H5LDget_dset_dims(dset_id, ddims); hid_t dspace_id = H5Dget_space(dset_id);
// get the rank and dimensions of the dataset
int rrank = H5Sget_simple_extent_dims(dspace_id, ddims, NULL);
H5Dclose(dset_id); // check that dimensions are consistent
if (status < 0) { if (rrank != (int) rank) {
FREE(ddims); FREE(ddims);
return TREXIO_FAILURE; H5Sclose(dspace_id);
H5Dclose(dset_id);
return TREXIO_INVALID_ARG_3;
} }
for (uint32_t i=0; i<rank; ++i){ for (uint32_t i=0; i<rank; ++i){
if (ddims[i] != dims[i]) { if (ddims[i] != dims[i]) {
FREE(ddims); FREE(ddims);
H5Sclose(dspace_id);
H5Dclose(dset_id);
return TREXIO_INVALID_ARG_4; return TREXIO_INVALID_ARG_4;
} }
} }
FREE(ddims); FREE(ddims);
H5Sclose(dspace_id);
H5Dclose(dset_id);
/* High-level H5LT API. No need to deal with dataspaces and datatypes */ /* High-level H5LT API. No need to deal with dataspaces and datatypes */
status = H5LTread_dataset(f->$group$_group, herr_t status = H5LTread_dataset(f->$group$_group,
$GROUP_DSET$_NAME, $GROUP_DSET$_NAME,
H5T_$GROUP_DSET_H5_DTYPE$, H5T_$GROUP_DSET_H5_DTYPE$,
$group_dset$); $group_dset$);

View File

@ -99,10 +99,11 @@ function main() {
# Create documentation # Create documentation
cd ${SRC} cd ${SRC}
for dir in ${SRC}/templates_*/ for dir in ${SRC}/templates_*/ ${TREXIO_ROOT}/
do do
dir=${dir%*/} dir=${dir%*/}
echo ${dir} echo ${dir}
OLDPWD=$PWD
cd ${dir} cd ${dir}
for i in *.org for i in *.org
do do
@ -110,7 +111,7 @@ function main() {
echo "======= ${i} =======" echo "======= ${i} ======="
extract_doc ${i} ${dir} extract_doc ${i} ${dir}
done done
cd .. cd $OLDPWD
done done
echo echo

View File

@ -1,5 +1,7 @@
#+TITLE: TREX Configuration file #+TITLE: TREX Configuration file
#+STARTUP: latexpreview #+STARTUP: latexpreview
#+SETUPFILE: docs/theme.setup
All the quantities are saved in atomic units. All the quantities are saved in atomic units.
The dimensions of the arrays in the tables below are given in The dimensions of the arrays in the tables below are given in
@ -208,7 +210,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an
| ~shell_prim_num~ | ~int~ | ~(basis.num)~ | Number of primitives in the shell ($N_{\text{prim}}$) | | ~shell_prim_num~ | ~int~ | ~(basis.num)~ | Number of primitives in the shell ($N_{\text{prim}}$) |
| ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) | | ~shell_factor~ | ~float~ | ~(basis.num)~ | Normalization factor of the shell ($\mathcal{N}_s$) |
| ~shell_prim_index~ | ~index~ | ~(basis.num)~ | Index of the first primitive in the complete list | | ~shell_prim_index~ | ~index~ | ~(basis.num)~ | Index of the first primitive in the complete list |
| ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}) | | ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{ks}$) |
| ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) | | ~coefficient~ | ~float~ | ~(basis.prim_num)~ | Coefficients of the primitives ($a_{ks}$) |
| ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) | | ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) |
@ -375,8 +377,8 @@ prim_factor =
| ~overlap~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert q \rangle$ | | ~overlap~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert q \rangle$ |
| ~kinetic~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{T}_e \vert q \rangle$ | | ~kinetic~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{T}_e \vert q \rangle$ |
| ~potential_n_e~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ne}} \vert q \rangle$ | | ~potential_n_e~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ne}} \vert q \rangle$ |
| ~ecp_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,l} \vert q \rangle$ | | ~ecp_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,l}} \vert q \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,nl} \vert q \rangle$ | | ~ecp_non_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,nl}} \vert q \rangle$ |
| ~core_hamiltonian~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{h} \vert q \rangle$ | | ~core_hamiltonian~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{h} \vert q \rangle$ |
#+CALL: json(data=ao_1e_int, title="ao_1e_int") #+CALL: json(data=ao_1e_int, title="ao_1e_int")
@ -460,15 +462,15 @@ prim_factor =
** One-electron integrals ** One-electron integrals
The operators as the same as those defined in the The operators as the same as those defined in the
[[ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in [[#ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in
the basis of molecular orbitals. the basis of molecular orbitals.
#+NAME: mo_1e_int #+NAME: mo_1e_int
| ~overlap~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert j \rangle$ | | ~overlap~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert j \rangle$ |
| ~kinetic~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{T}_e \vert j \rangle$ | | ~kinetic~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{T}_e \vert j \rangle$ |
| ~potential_n_e~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ne}} \vert j \rangle$ | | ~potential_n_e~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ne}} \vert j \rangle$ |
| ~ecp_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,l} \vert j \rangle$ | | ~ecp_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,l}} \vert j \rangle$ |
| ~ecp_non_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,nl} \vert j \rangle$ | | ~ecp_non_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,nl}} \vert j \rangle$ |
| ~core_hamiltonian~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{h} \vert j \rangle$ | | ~core_hamiltonian~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{h} \vert j \rangle$ |
#+CALL: json(data=mo_1e_int, title="mo_1e_int") #+CALL: json(data=mo_1e_int, title="mo_1e_int")
@ -490,7 +492,7 @@ prim_factor =
** Two-electron integrals ** Two-electron integrals
The operators as the same as those defined in the The operators as the same as those defined in the
[[ao_two_e][AO two-electron integrals section]]. Here, the integrals are given in [[#ao_one_e][AO one-electron integrals section]]. Here, the integrals are given in
the basis of molecular orbitals. the basis of molecular orbitals.
#+NAME: mo_2e_int #+NAME: mo_2e_int
@ -532,7 +534,7 @@ prim_factor =
#+end_src #+end_src
:end: :end:
* Appendix :noexport: * Appendix
** Python script from table to json ** Python script from table to json
#+NAME: json #+NAME: json