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

Merge branch 'master' into cppcheck

This commit is contained in:
Anthony Scemama 2023-05-02 09:44:12 +02:00
commit 3a4691e667
10 changed files with 102 additions and 75 deletions

View File

@ -20,7 +20,7 @@ jobs:
message: ${{ steps.commit_message.outputs.message }} message: ${{ steps.commit_message.outputs.message }}
steps: steps:
- name: Checkout the repo - name: Checkout the repo
uses: actions/checkout@v2 uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
# Gets the correct commit message for pull request # Gets the correct commit message for pull request
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
@ -31,15 +31,13 @@ jobs:
COMMIT_MSG=$(git log --no-merges -1 --oneline) COMMIT_MSG=$(git log --no-merges -1 --oneline)
echo "::set-output name=message::$COMMIT_MSG" echo "::set-output name=message::$COMMIT_MSG"
trexio_ubuntu: trexio_ubuntu:
runs-on: ubuntu-20.04
name: x86 Ubuntu 20.04 name: x86 Ubuntu 20.04
runs-on: ubuntu-20.04
needs: get_commit_message needs: get_commit_message
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
- name: install dependencies - name: install dependencies
run: | run: |
@ -84,7 +82,7 @@ jobs:
if: >- if: >-
contains(needs.get_commit_message.outputs.message, '[wheel build]') || contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
github.event_name == 'release' github.event_name == 'release'
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with: with:
name: pytrexio-source name: pytrexio-source
path: ./trexio-*.tar.gz path: ./trexio-*.tar.gz
@ -114,12 +112,11 @@ jobs:
run: make maintainer-clean run: make maintainer-clean
trexio_macos: trexio_macos:
runs-on: macos-11
name: x86 MacOS 11 name: x86 MacOS 11
runs-on: macos-11
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
- name: install dependencies - name: install dependencies
run: | run: |
@ -133,10 +130,10 @@ jobs:
./configure FC=gfortran-10 --enable-silent-rules ./configure FC=gfortran-10 --enable-silent-rules
- name: compile TREXIO - name: compile TREXIO
run: make -j 2 run: make -j3
- name: check TREXIO - name: check TREXIO
run: make check run: make -j3 check
- name: Archive test log file - name: Archive test log file
if: failure() if: failure()

View File

@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16)
# Initialize the CMake project. # Initialize the CMake project.
project(Trexio project(Trexio
VERSION 2.3.0 VERSION 2.3.1
DESCRIPTION "TREX I/O library" DESCRIPTION "TREX I/O library"
LANGUAGES C Fortran LANGUAGES C Fortran
) )

View File

@ -22,8 +22,8 @@ TREX library for efficient I/O.
2. `gzip -cd trexio-<version>.tar.gz | tar xvf -` 2. `gzip -cd trexio-<version>.tar.gz | tar xvf -`
3. `cd trexio-<version>` 3. `cd trexio-<version>`
4. `./configure` 4. `./configure`
5. `make` 5. ```make -j`getconf _NPROCESSORS_ONLN` ```
6. `make check` 6. ```make -j`getconf _NPROCESSORS_ONLN` check```
7. `sudo make install` 7. `sudo make install`
@ -45,8 +45,8 @@ TREX library for efficient I/O.
2. `cd trexio` 2. `cd trexio`
3. `./autogen.sh` 3. `./autogen.sh`
4. `./configure` 4. `./configure`
5. `make` 5. ```make -j`getconf _NPROCESSORS_ONLN` ```
6. `make check` 6. ```make -j`getconf _NPROCESSORS_ONLN` check```
7. `sudo make install` 7. `sudo make install`
## Installation procedure for CMake users (from the tarball or GitHub repo clone): ## Installation procedure for CMake users (from the tarball or GitHub repo clone):
@ -56,8 +56,8 @@ The aforementioned instructions rely on [Autotools](https://www.gnu.org/software
1. `cmake -S. -Bbuild` 1. `cmake -S. -Bbuild`
2. `cd build` 2. `cd build`
3. `make` 3. ```make -j`getconf _NPROCESSORS_ONLN` ```
4. `ctest` (or `make test`) 4. ```ctest -j`getconf _NPROCESSORS_ONLN` ```
5. `sudo make install` 5. `sudo make install`
**Note: on systems with no `sudo` access, one can add `-DCMAKE_INSTALL_PREFIX=build` as an argument to the `cmake` command so that `make install/uninstall` can be run without `sudo` privileges.** **Note: on systems with no `sudo` access, one can add `-DCMAKE_INSTALL_PREFIX=build` as an argument to the `cmake` command so that `make install/uninstall` can be run without `sudo` privileges.**
@ -73,7 +73,7 @@ The official releases of TREXIO `>2.0.0` are also available via the `conda-forge
The pre-compiled stable binaries of `trexio` can be installed as follows: The pre-compiled stable binaries of `trexio` can be installed as follows:
``` ```
conda install trexio -c conda-forge conda install -c conda-forge trexio
``` ```
More details can be found in the corresponding [trexio-feedstock](https://github.com/conda-forge/trexio-feedstock). More details can be found in the corresponding [trexio-feedstock](https://github.com/conda-forge/trexio-feedstock).
@ -88,7 +88,7 @@ Schema file contains the manifest specification for the `trexio` package.
It can be installed as follows: It can be installed as follows:
``` ```
guix package --cores=<n_cores> --install-from-file=trexio.scm guix package --cores=`getconf _NPROCESSORS_ONLN` --install-from-file=trexio.scm
``` ```
## Installation procedure for Spack users ## Installation procedure for Spack users
@ -100,7 +100,7 @@ file contains the Spack specifications required to build different variants of `
It can be installed as follows It can be installed as follows
``` ```
spack install --jobs <n_cores> trexio spack install --jobs `getconf _NPROCESSORS_ONLN` trexio
``` ```
## Installation procedure for Debian/Ubuntu users ## Installation procedure for Debian/Ubuntu users
@ -127,14 +127,14 @@ To build TREXIO without HDF5 back end, append `--without-hdf5` option to `config
## Linking to your program ## Linking to your program
The `make install` command takes care of installing the TREXIO shared library on the user machine. The `make install` command takes care of installing the TREXIO shared library on the user machine.
Once installed, add `-ltrexio` to the list of compiler options. After installation, append `-ltrexio` to the list of compiler (`$LIBS`) options.
In some cases (e.g. when using custom `prefix` during configuration), the TREXIO library might end up installed in a directory, which is absent in the default `$LIBRARY_PATH`. In some cases (e.g. when using custom installation prefix during configuration), the TREXIO library might end up installed in a directory, which is absent in the default `$LD_LIBRARY_PATH`.
In order to link the program against TREXIO, the search paths can be modified as follows: In order to link the program against TREXIO, the search path can be modified as follows:
`export LIBRARY_PATH=$LIBRARY_PATH:<path_to_trexio>/lib` `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path_to_trexio>/lib`
(same holds for `$LD_LIBRARY_PATH`). The `<path_to_trexio>` has to be replaced by the prefix used during the installation. where the `<path_to_trexio>` has to be replaced by the prefix used during the installation.
If your project relies on CMake build system, feel free to use the If your project relies on CMake build system, feel free to use the
[FindTREXIO.cmake](https://github.com/TREX-CoE/trexio/blob/master/cmake/FindTREXIO.cmake) [FindTREXIO.cmake](https://github.com/TREX-CoE/trexio/blob/master/cmake/FindTREXIO.cmake)

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],[2.3.0],[https://github.com/TREX-CoE/trexio/issues]) AC_INIT([trexio],[2.3.1],[https://github.com/TREX-CoE/trexio/issues])
AC_CONFIG_SRCDIR([Makefile.in]) AC_CONFIG_SRCDIR([Makefile.in])
AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_HEADERS([include/config.h])

View File

@ -1 +1 @@
__version__ = "1.3.0" __version__ = "1.3.1"

View File

@ -66,7 +66,7 @@ option(ENABLE_HDF5 "Enable HDF5 support" ON)
if(ENABLE_HDF5) if(ENABLE_HDF5)
# Try to detect HDF5 installation using built-in FindHDF5.cmake macro. # Try to detect HDF5 installation using built-in FindHDF5.cmake macro.
find_package(HDF5 REQUIRED COMPONENTS C HL) find_package(HDF5 REQUIRED COMPONENTS C)
if(HDF5_FOUND) if(HDF5_FOUND)
message(STATUS "HDF5 version :: ${HDF5_VERSION}") message(STATUS "HDF5 version :: ${HDF5_VERSION}")
@ -87,9 +87,7 @@ if(ENABLE_HDF5)
# - include directories with HDF5 header files # - include directories with HDF5 header files
target_include_directories(trexio PRIVATE ${HDF5_C_INCLUDE_DIRS}) target_include_directories(trexio PRIVATE ${HDF5_C_INCLUDE_DIRS})
# - link to HDF5 C libraries # - link to HDF5 C libraries
target_link_libraries(trexio PRIVATE target_link_libraries(trexio PRIVATE ${HDF5_C_LIBRARIES})
${HDF5_C_HL_LIBRARIES}
${HDF5_C_LIBRARIES})
endif() endif()
# Private headers have to be listed as sources, otherwise they are installed # Private headers have to be listed as sources, otherwise they are installed

View File

@ -3327,7 +3327,7 @@ trexio_read_$group_dset$(trexio_t* const file,
/* To be set by generator : number of unique dimensions /* To be set by generator : number of unique dimensions
(e.g. 1 for ERI in AO basis because only ao_num is present in the list of dimensions) */ (e.g. 1 for ERI in AO basis because only ao_num is present in the list of dimensions) */
const uint32_t unique_rank = $group_dset_unique_rank$; #define unique_rank $group_dset_unique_rank$
int64_t unique_dims[$group_dset_unique_rank$]; int64_t unique_dims[$group_dset_unique_rank$];
// Below part is populated by the generator when unique_rank > 1 // Below part is populated by the generator when unique_rank > 1
@ -3335,11 +3335,12 @@ trexio_read_$group_dset$(trexio_t* const file,
/* Find the maximal value along all dimensions to define the compression technique in the back end */ /* Find the maximal value along all dimensions to define the compression technique in the back end */
int64_t max_dim = unique_dims[0]; int64_t max_dim = unique_dims[0];
if (unique_rank != 1) { #if (unique_rank != 1)
for (uint32_t i = 1; i < unique_rank; i++) { for (uint32_t i = 1; i < unique_rank; i++) {
if (unique_dims[i] > max_dim) max_dim = unique_dims[i]; if (unique_dims[i] > max_dim) max_dim = unique_dims[i];
}
} }
#endif
#undef unique_rank
// introduce a new variable which will be modified with the number of integrals being read if EOF is encountered // introduce a new variable which will be modified with the number of integrals being read if EOF is encountered
int64_t eof_read_size = 0L; int64_t eof_read_size = 0L;
@ -3459,7 +3460,7 @@ trexio_write_$group_dset$(trexio_t* const file,
/* To be set by generator : number of unique dimensions /* To be set by generator : number of unique dimensions
(e.g. 1 for ERI in AO basis because only ao_num is present in the list of dimensions) */ (e.g. 1 for ERI in AO basis because only ao_num is present in the list of dimensions) */
const uint32_t unique_rank = $group_dset_unique_rank$; #define unique_rank $group_dset_unique_rank$
int64_t unique_dims[$group_dset_unique_rank$]; int64_t unique_dims[$group_dset_unique_rank$];
// Below part is populated by the generator when unique_rank > 1 // Below part is populated by the generator when unique_rank > 1
@ -3467,11 +3468,12 @@ trexio_write_$group_dset$(trexio_t* const file,
/* Find the maximal value along all dimensions to define the compression technique in the back end */ /* Find the maximal value along all dimensions to define the compression technique in the back end */
int64_t max_dim = unique_dims[0]; int64_t max_dim = unique_dims[0];
if (unique_rank != 1) { #if (unique_rank != 1)
for (uint32_t i = 1; i < unique_rank; i++) { for (uint32_t i = 1; i < unique_rank; i++) {
if (unique_dims[i] > max_dim) max_dim = unique_dims[i]; if (unique_dims[i] > max_dim) max_dim = unique_dims[i];
}
} }
#endif
#undef unique_rank
// shift indices to be zero-based if Fortran API is used // shift indices to be zero-based if Fortran API is used
if (file->one_based) { if (file->one_based) {
@ -5619,19 +5621,15 @@ trexio_exit_code trexio_to_bitfield_list (const int32_t* orb_list,
bit_list[j] = (bitfield_t) 0; bit_list[j] = (bitfield_t) 0;
} }
uint32_t i;
uint32_t k;
uint32_t iorb;
bitfield_t mask;
uint32_t nswaps = 0; uint32_t nswaps = 0;
for (int32_t pos = 0 ; pos < occupied_num ; pos++) { for (int32_t pos = 0 ; pos < occupied_num ; pos++) {
iorb = ((uint32_t) (orb_list[pos] + 1)) - TREXIO_ORBITAL_SHIFT; const uint32_t iorb = ((uint32_t) (orb_list[pos] + 1)) - TREXIO_ORBITAL_SHIFT;
// Set the bit of to one // Set the bit of to one
i = (uint32_t) (iorb >> TREXIO_NORB_PER_INT_SHIFT); const uint32_t i = (uint32_t) (iorb >> TREXIO_NORB_PER_INT_SHIFT);
k = (uint32_t) (iorb & (TREXIO_NORB_PER_INT - 1) ); const uint32_t k = (uint32_t) (iorb & (TREXIO_NORB_PER_INT - 1) );
mask = ((bitfield_t) 1) << k; bitfield_t mask = ((bitfield_t) 1) << k;
bit_list[i] |= mask; bit_list[i] |= mask;
// Check for phase changes // Check for phase changes
@ -5662,21 +5660,16 @@ trexio_exit_code trexio_to_orbital_list(const int32_t N_int,
if (list == NULL) return TREXIO_INVALID_ARG_3; if (list == NULL) return TREXIO_INVALID_ARG_3;
if (occupied_num == NULL) return TREXIO_INVALID_ARG_4; if (occupied_num == NULL) return TREXIO_INVALID_ARG_4;
bitfield_t tmp; int32_t k = 0;
int32_t shift; int32_t shift = TREXIO_ORBITAL_SHIFT;
int32_t k;
int32_t pos;
k = 0;
shift = TREXIO_ORBITAL_SHIFT;
for (int32_t i=0 ; i<N_int ; i++) for (int32_t i=0 ; i<N_int ; i++)
{ {
tmp = d1[i]; bitfield_t tmp = d1[i];
while (tmp != (bitfield_t) 0) while (tmp != (bitfield_t) 0)
{ {
pos = trailz(tmp); const int32_t pos = trailz(tmp);
if (pos < 0) return TREXIO_FAILURE; if (pos < 0) return TREXIO_FAILURE;
list[k] = ( (int32_t) pos) + shift - 1; list[k] = ( (int32_t) pos) + shift - 1;

View File

@ -145,10 +145,10 @@ trexio_text_inquire (const char* file_name)
if (file_exists) { if (file_exists) {
bool is_a_directory = false; bool is_a_directory = false;
#ifdef S_IFDIR #if defined(S_IFDIR)
is_a_directory = st.st_mode & S_IFDIR; is_a_directory = st.st_mode & S_IFDIR;
#elif S_ISDIR #elif defined(S_ISDIR)
is_a_directory = S_ISDIR(s.st_mode); is_a_directory = S_ISDIR(st.st_mode);
#else #else
printf("Some important macros are missing for directory handling.\n"); printf("Some important macros are missing for directory handling.\n");
return TREXIO_FAILURE; return TREXIO_FAILURE;
@ -162,6 +162,29 @@ trexio_text_inquire (const char* file_name)
} }
#+end_src #+end_src
On non-POSIX file systems, the function ~mkdtemp~ might is not defined.
In that case, we define an alternate one, which is not as safe as the original one.
#+begin_src c :tangle basic_text.c
#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L
#else
char* mkdtemp(char* template) {
char* dir = NULL;
dir = tmpnam(dir);
if (dir == NULL) return NULL;
if (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
return NULL;
}
strcpy(template, dir);
return template;
}
#endif
#+end_src
#+begin_src c :tangle basic_text.c #+begin_src c :tangle basic_text.c
trexio_exit_code trexio_exit_code
trexio_text_init (trexio_t* const file) trexio_text_init (trexio_t* const file)

View File

@ -60,8 +60,22 @@
"1n9n1gbk5hgvg73am991xrv7ap002rz719a3nvh8m8ff9x10qd76" "1n9n1gbk5hgvg73am991xrv7ap002rz719a3nvh8m8ff9x10qd76"
)))))) ))))))
(define-public trexio-2.3
(package/inherit trexio-2.0
(version "2.3.0")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/TREX-CoE/trexio/releases/download/v" version
"/trexio-" version
".tar.gz"))
(sha256
(base32
;; the hash below is produced by guix download <url>
"183wljg1avsia2pf2wb59s2i2qw6y19qfw164ffy1g024b6362ii"
))))))
(define-public trexio (define-public trexio
;; Default version of TREXIO. ;; Default version of TREXIO.
trexio-2.2) trexio-2.3)
trexio trexio

View File

@ -386,20 +386,22 @@ prim_factor =
\[ \[
V_A^{\text{ECP}} = V_A^{\text{ECP}} =
V_{A \ell_{\max}+1} + V_{A \ell_{\max}+1} +
\sum_{\ell=0}^{\ell_{\max}} V_{A \ell} \sum_{\ell=0}^{\ell_{\max}}
\sum_{m=-\ell}^{\ell} | Y_{\ell m} \rangle \langle Y_{\ell m} | \delta V_{A \ell}\sum_{m=-\ell}^{\ell} | Y_{\ell m} \rangle \langle Y_{\ell m} |
\] \]
The first term in the equation above is sometimes attributed to the local channel, The first term in this equation is attributed to the local channel, while
while the remaining terms correspond to the non-local channel projections. the remaining terms correspond to non-local channel projections. $\ell_{\max}$
refers to the maximum angular momentum in the non-local component of the ECP.
All the functions $V_{A\ell}$ are parameterized as: The functions \(\delta V_{A \ell}\) and \(V_{A \ell_{\max}+1}\) are parameterized as:
\[ \begin{eqnarray}
V_{A \ell}(\mathbf{r}) = \delta V_{A \ell}(\mathbf{r}) &=&
\sum_{q=1}^{N_{q \ell}} \sum_{q=1}^{N_{q \ell}}
\beta_{A q \ell}\, |\mathbf{r}-\mathbf{R}_{A}|^{n_{A q \ell}}\, \beta_{A q \ell}\, |\mathbf{r}-\mathbf{R}_{A}|^{n_{A q \ell}}\,
e^{-\alpha_{A q \ell} |\mathbf{r}-\mathbf{R}_{A}|^2 } e^{-\alpha_{A q \ell} |\mathbf{r}-\mathbf{R}_{A}|^2 } \nonumber\\
\]. V_{A \ell_{\max}+1}(\mathbf{r}) &=& -\frac{Z_\text{eff}}{|\mathbf{r}-\mathbf{R}_{A}|}+\delta V_{A \ell_{\max}+1}(\mathbf{r})
\end{eqnarray}
where $Z_\text{eff}$ is the effective nuclear charge of the center.
See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006 for more info. See http://dx.doi.org/10.1063/1.4984046 or https://doi.org/10.1063/1.5121006 for more info.