From c9f639e0e873dab9e5ab583b74304bad26b454c8 Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 17 Jun 2021 20:20:46 +0200 Subject: [PATCH 1/7] fix compiler warning from MacOS --- src/templates_front/templator_front.org | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/templates_front/templator_front.org b/src/templates_front/templator_front.org index 6602c47..c1dd4fd 100644 --- a/src/templates_front/templator_front.org +++ b/src/templates_front/templator_front.org @@ -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 @@ -1803,7 +1804,6 @@ trexio_write_$group_dset$ (trexio_t* const file, const char** dset, const uint32 FREE(str_compiled); return rc; - } #+end_src @@ -1831,6 +1831,7 @@ trexio_has_$group_dset$ (trexio_t* const file) break; ,*/ } + return TREXIO_FAILURE; } #+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 @@ -2000,6 +2002,7 @@ trexio_write_$group_str$ (trexio_t* const file, const char* str, const uint32_t ,*/ } + return TREXIO_FAILURE; } #+end_src From ec0db01f0c49d1193ed7e6cbb1a83cf0df9a147e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 18 Jun 2021 12:04:03 +0200 Subject: [PATCH 2/7] Documentation in dist --- Makefile.am | 18 ++++++++++++++++++ configure.ac | 2 +- src/README.org | 1 + tools/build_doc.sh | 5 +++-- trex.org | 38 +++++++++++++++++++------------------- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2560b5a..37c1fd5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,6 +87,23 @@ tests_test_f_SOURCES = $(test_trexio_f) tests/test_f.f90 tests_test_f_LDADD = src/libtrexio.la 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) + +docs/index.html: $(SOURCES) src/README.org + cd tools && ./build_doc.sh + +$(HTML_FILES): docs/index.html + $(test_trexio_f): $(trexio_f) cp $(trexio_f) $(test_trexio_f) @@ -99,6 +116,7 @@ CLEANFILES += $(SOURCES) $(trexio_f) $(trexio_h) BUILT_SOURCES = $(SOURCES) $(trexio_f) $(test_trexio_f) + $(SOURCES): $(trexio_f) src/trexio.c: $(trexio_h) diff --git a/configure.ac b/configure.ac index 014a604..69c9a07 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. 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_MAINTAINER_MODE() LT_INIT diff --git a/src/README.org b/src/README.org index 984f66d..d9569e9 100644 --- a/src/README.org +++ b/src/README.org @@ -4,6 +4,7 @@ ------------------ + - [[./trex.html][Data stored with TREXIO]] - [[./templator_front.html][Front end API]] - [[./templator_hdf5.html][HDF5 back end]] - [[./templator_text.html][TEXT back end]] diff --git a/tools/build_doc.sh b/tools/build_doc.sh index 2549581..1c7f366 100755 --- a/tools/build_doc.sh +++ b/tools/build_doc.sh @@ -99,10 +99,11 @@ function main() { # Create documentation cd ${SRC} - for dir in ${SRC}/templates_*/ + for dir in ${SRC}/templates_*/ ${TREXIO_ROOT}/ do dir=${dir%*/} echo ${dir} + OLDPWD=$PWD cd ${dir} for i in *.org do @@ -110,7 +111,7 @@ function main() { echo "======= ${i} =======" extract_doc ${i} ${dir} done - cd .. + cd $OLDPWD done echo diff --git a/trex.org b/trex.org index 06befce..a386c73 100644 --- a/trex.org +++ b/trex.org @@ -11,12 +11,12 @@ In Fortran, the arrays are 1-based and in most other languages the arrays are 0-base. Hence, we introduce the ~index~ type which is an 1-based ~int~ in the Fortran interface and 0-based otherwise. - #+begin_src python :tangle trex.json + #+begin_src python :tangle trex.json { #+end_src * Metadata - + As we expect our files to be archived in open-data repositories, we need to give the possibility to the users to store some metadata inside the files. We propose to store the list of names of the codes @@ -175,7 +175,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an R_s(\mathbf{r}) = \mathcal{N}_s \vert\mathbf{r}-\mathbf{R}_A\vert^{n_s} \sum_{k=1}^{N_{\text{prim}}} a_{ks}\, f_{ks}(\gamma_{ks},p)\, \exp \left( - \gamma_{ks} - \vert \mathbf{r}-\mathbf{R}_A \vert ^p \right). + \vert \mathbf{r}-\mathbf{R}_A \vert ^p \right). \] In the case of Gaussian functions, $n_s$ is always zero. @@ -190,7 +190,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an combination of /normalized/ primitives. This implies that a normalization constant for the primitive $ks$ needs to be computed and stored. If this normalization factor is not required, $f_{ks}=1$. - + Some codes assume that the basis function are normalized. This implies the computation of an extra normalization factor, $\mathcal{N}_s$. If the the basis function is not considered normalized, $\mathcal{N}_s=1$. @@ -211,7 +211,7 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an | ~exponent~ | ~float~ | ~(basis.prim_num)~ | Exponents of the primitives ($\gamma_{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}$) | - + #+CALL: json(data=basis, title="basis") #+RESULTS: @@ -221,12 +221,12 @@ arrays are 0-base. Hence, we introduce the ~index~ type which is an "type" : [ "str" , [] ] , "num" : [ "int" , [] ] , "prim_num" : [ "int" , [] ] - , "nucleus_index" : [ "index" , [ "nucleus.num" ] ] + , "nucleus_index" : [ "index", [ "nucleus.num" ] ] , "nucleus_shell_num" : [ "int" , [ "nucleus.num" ] ] , "shell_ang_mom" : [ "int" , [ "basis.num" ] ] , "shell_prim_num" : [ "int" , [ "basis.num" ] ] , "shell_factor" : [ "float", [ "basis.num" ] ] - , "shell_prim_index" : [ "index" , [ "basis.num" ] ] + , "shell_prim_index" : [ "index", [ "basis.num" ] ] , "exponent" : [ "float", [ "basis.prim_num" ] ] , "coefficient" : [ "float", [ "basis.prim_num" ] ] , "prim_factor" : [ "float", [ "basis.prim_num" ] ] @@ -324,9 +324,9 @@ prim_factor = shell, as in the GAMESS convention where $\mathcal{N}_{x^2} \ne \mathcal{N}_{xy}$ because \[ \left[ \iiint \left(x-X_A \right)^2 R_{\theta(i)} - (\mathbf{r}) dx\, dy\, dz \right]^{-1/2} \ne + (\mathbf{r}) dx\, dy\, dz \right]^{-1/2} \ne \left[ \iiint \left( x-X_A \right) \left( y-Y_A \right) R_{\theta(i)} - (\mathbf{r}) dx\, dy\, dz \right]^{-1/2}. \] + (\mathbf{r}) dx\, dy\, dz \right]^{-1/2}. \] In such a case, one should set the normalization of the shell (in the [[Basis set][Basis set]] section) to $\mathcal{N}_{z^2}$, which is the @@ -353,7 +353,7 @@ prim_factor = } , #+end_src :end: - + ** One-electron integrals :PROPERTIES: :CUSTOM_ID: ao_one_e @@ -362,7 +362,7 @@ prim_factor = - \[ \hat{V}_{\text{ne}} = \sum_{A=1}^{N_\text{nucl}} \sum_{i=1}^{N_\text{elec}} \frac{-Z_A }{\vert \mathbf{R}_A - \mathbf{r}_i \vert} \] : electron-nucleus attractive potential, - - \[ \hat{T}_{\text{e}} = + - \[ \hat{T}_{\text{e}} = \sum_{i=1}^{N_\text{elec}} -\frac{1}{2}\hat{\Delta}_i \] : electronic kinetic energy - $\hat{h} = \hat{T}_\text{e} + \hat{V}_\text{ne} + \hat{V}_\text{ecp,l} + \hat{V}_\text{ecp,nl}$ : core electronic Hamiltonian @@ -409,7 +409,7 @@ prim_factor = notation. # TODO: Physicist / Chemist functions - + - \[ \hat{W}_{\text{ee}} = \sum_{i=2}^{N_\text{elec}} \sum_{j=1}^{i-1} \frac{1}{\vert \mathbf{r}_i - \mathbf{r}_j \vert} \] : electron-electron repulsive potential operator. - \[ \hat{W}^{lr}_{\text{ee}} = \sum_{i=2}^{N_\text{elec}} \sum_{j=1}^{i-1} \frac{\text{erf}(\vert \mathbf{r}_i - @@ -460,9 +460,9 @@ prim_factor = ** One-electron integrals 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. - + #+NAME: mo_1e_int | ~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$ | @@ -490,7 +490,7 @@ prim_factor = ** Two-electron integrals 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. #+NAME: mo_2e_int @@ -511,7 +511,7 @@ prim_factor = * TODO Slater determinants * TODO Reduced density matrices - + #+NAME: rdm | ~one_e~ | ~float~ | ~(mo.num, mo.num)~ | | ~one_e_up~ | ~float~ | ~(mo.num, mo.num)~ | @@ -532,12 +532,12 @@ prim_factor = #+end_src :end: -* Appendix :noexport: +* Appendix ** Python script from table to json #+NAME: json - #+begin_src python :var data=nucleus title="nucleus" last=0 :results output drawer -print("""#+begin_src python :tangle trex.json""") + #+begin_src python :var data=nucleus title="nucleus" last=0 :results output drawer +print("""#+begin_src python :tangle trex.json""") print(""" "%s": {"""%(title)) indent = " " f1 = 0 ; f2 = 0 ; f3 = 0 From bf44792d1ece66b4e3dfc9f1a7e3f7425cb130d2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 18 Jun 2021 12:10:40 +0200 Subject: [PATCH 3/7] Fixed html --- trex.org | 2 ++ 1 file changed, 2 insertions(+) diff --git a/trex.org b/trex.org index a386c73..6ada35c 100644 --- a/trex.org +++ b/trex.org @@ -1,5 +1,7 @@ #+TITLE: TREX Configuration file #+STARTUP: latexpreview +#+SETUPFILE: docs/theme.setup + All the quantities are saved in atomic units. The dimensions of the arrays in the tables below are given in From cba3a4e60a4d89c68983433e7eb438d978beccb5 Mon Sep 17 00:00:00 2001 From: q-posev Date: Fri, 18 Jun 2021 12:30:57 +0200 Subject: [PATCH 4/7] fix typos --- trex.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trex.org b/trex.org index 6ada35c..6de2586 100644 --- a/trex.org +++ b/trex.org @@ -210,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_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 | - | ~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}$) | | ~prim_factor~ | ~float~ | ~(basis.prim_num)~ | Normalization coefficients for the primitives ($f_{ks}$) | @@ -377,8 +377,8 @@ prim_factor = | ~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$ | | ~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_non_local~ | ~float~ | ~(ao.num, ao.num)~ | $\langle p \vert \hat{V}_{\text{ecp,nl} \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$ | | ~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") @@ -469,8 +469,8 @@ prim_factor = | ~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$ | | ~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_non_local~ | ~float~ | ~(mo.num, mo.num)~ | $\langle i \vert \hat{V}_{\text{ecp,nl} \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$ | | ~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") From b0f91978b7c258e22e35f563caa4e22837c7b4da Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 22 Jun 2021 11:30:46 +0200 Subject: [PATCH 5/7] fix compilation issue on CALMIP; Close #51 --- Makefile.am | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index 37c1fd5..4d93e55 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,13 +55,13 @@ lib_LTLIBRARIES = src/libtrexio.la SOURCES = \ $(trexio_h) \ - $(srcdir)/src/trexio.c \ - $(srcdir)/src/trexio_private.h \ - $(srcdir)/src/trexio_s.h \ - $(srcdir)/src/trexio_hdf5.c \ - $(srcdir)/src/trexio_hdf5.h \ - $(srcdir)/src/trexio_text.c \ - $(srcdir)/src/trexio_text.h + src/trexio.c \ + src/trexio_private.h \ + src/trexio_s.h \ + src/trexio_hdf5.c \ + src/trexio_hdf5.h \ + src/trexio_text.c \ + src/trexio_text.h ORG_FILES = \ src/templates_front/templator_front.org \ @@ -99,9 +99,6 @@ HTML_FILES = docs/trexio.css \ htmldir = $(docdir) dist_html_DATA = $(HTML_FILES) -docs/index.html: $(SOURCES) src/README.org - cd tools && ./build_doc.sh - $(HTML_FILES): docs/index.html $(test_trexio_f): $(trexio_f) @@ -123,6 +120,9 @@ src/trexio.c: $(trexio_h) $(trexio_f): $(ORG_FILES) cd $(srcdir)/tools && ./build_trexio.sh +docs/index.html: $(SOURCES) $(srcdir)/src/README.org + cd $(srcdir)/tools && ./build_doc.sh + cppcheck: cppcheck.out cat cppcheck.out From 6b18a64a8e3721b16d8db6d3294428df84321553 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 22 Jun 2021 11:37:54 +0200 Subject: [PATCH 6/7] more general HDF5 detection do not restrict to serial builds but enable also parallel ones (common on HPCs) --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 69c9a07..d34b670 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,7 @@ AC_CHECK_HEADERS([fcntl.h inttypes.h stdint.h stdbool.h stdlib.h string.h unistd PKG_HDF5="" -AX_LIB_HDF5([serial]) +AX_LIB_HDF5() if test "x${with_hdf5}" = xno; then AC_MSG_WARN([ From 3bd730557c0e5abdcb87d37ee297da61fada0ce6 Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 22 Jun 2021 12:21:25 +0200 Subject: [PATCH 7/7] remove H5LDget_dset_dims to be compatible with HDF5 v.1.8.21 --- src/templates_hdf5/templator_hdf5.org | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/templates_hdf5/templator_hdf5.org b/src/templates_hdf5/templator_hdf5.org index 83146e8..94ec721 100644 --- a/src/templates_hdf5/templator_hdf5.org +++ b/src/templates_hdf5/templator_hdf5.org @@ -298,15 +298,6 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $ 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 hid_t dset_id = H5Dopen(f->$group$_group, $GROUP_DSET$_NAME, H5P_DEFAULT); if (dset_id <= 0) return TREXIO_INVALID_ID; @@ -315,28 +306,37 @@ trexio_hdf5_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $ hsize_t* ddims = CALLOC( (int) rank, hsize_t); if (ddims == NULL) return TREXIO_FAILURE; - // read dimensions from the existing dataset - status = H5LDget_dset_dims(dset_id, ddims); + // get the dataspace of the dataset + 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); - if (status < 0) { + // check that dimensions are consistent + if (rrank != (int) rank) { FREE(ddims); - return TREXIO_FAILURE; + H5Sclose(dspace_id); + H5Dclose(dset_id); + return TREXIO_INVALID_ARG_3; } for (uint32_t i=0; i$group$_group, - $GROUP_DSET$_NAME, - H5T_$GROUP_DSET_H5_DTYPE$, - $group_dset$); + herr_t status = H5LTread_dataset(f->$group$_group, + $GROUP_DSET$_NAME, + H5T_$GROUP_DSET_H5_DTYPE$, + $group_dset$); if (status < 0) return TREXIO_FAILURE; return TREXIO_SUCCESS;