mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-22 04:14:40 +01:00
Merge branch 'master' into csf
This commit is contained in:
commit
41c8d1ad27
22
.github/workflows/actions.yml
vendored
22
.github/workflows/actions.yml
vendored
@ -52,10 +52,10 @@ jobs:
|
||||
./configure --enable-silent-rules
|
||||
|
||||
- name: compile TREXIO
|
||||
run: make -j 2
|
||||
run: make -j2
|
||||
|
||||
- name: check TREXIO
|
||||
run: make check
|
||||
run: make -j2 check
|
||||
|
||||
- name: create virtual environment
|
||||
run: |
|
||||
@ -82,8 +82,22 @@ jobs:
|
||||
name: pytrexio-source
|
||||
path: ./trexio-*.tar.gz
|
||||
|
||||
- name: clean
|
||||
run: make clean
|
||||
- name: maintainer clean
|
||||
run: make maintainer-clean
|
||||
|
||||
- name: reconfigure with clang and AddressSanitizer
|
||||
run: |
|
||||
./autogen.sh
|
||||
./configure CC=clang-11 CFLAGS="-O2 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" --enable-silent-rules
|
||||
|
||||
- name: recompile TREXIO
|
||||
run: make -j2
|
||||
|
||||
- name: recheck TREXIO for memory leaks
|
||||
run: make -j2 check
|
||||
|
||||
- name: maintainer clean
|
||||
run: make maintainer-clean
|
||||
|
||||
trexio_macos:
|
||||
|
||||
|
@ -4,6 +4,7 @@ CHANGES
|
||||
2.3
|
||||
---
|
||||
|
||||
- Added trexio_to_bitfield_list functionality
|
||||
- Added `trexio_has_group` functionality
|
||||
- Added OCaml binding
|
||||
- Added spin and energy in MOs
|
||||
|
21
Makefile.am
21
Makefile.am
@ -34,7 +34,11 @@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
CLEANFILES = trexio.mod
|
||||
if HAVE_FORTRAN
|
||||
BUILT_SOURCES = trexio.mod
|
||||
else
|
||||
BUILT_SOURCES =
|
||||
endif
|
||||
EXTRA_DIST = .git_hash
|
||||
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
@ -48,7 +52,10 @@ pkgconfig_DATA = pkgconfig/trexio.pc
|
||||
trexio_h = $(srcdir)/include/trexio.h
|
||||
trexio_f = $(srcdir)/include/trexio_f.f90
|
||||
|
||||
include_HEADERS = $(trexio_h) $(trexio_f)
|
||||
include_HEADERS = $(trexio_h)
|
||||
if HAVE_FORTRAN
|
||||
include_HEADERS += $(trexio_f)
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/include
|
||||
|
||||
@ -136,15 +143,19 @@ TESTS_C += \
|
||||
tests/overwrite_all_hdf5
|
||||
endif
|
||||
|
||||
TESTS = $(TESTS_C)
|
||||
if HAVE_FORTRAN
|
||||
TESTS_F = \
|
||||
tests/test_f
|
||||
TESTS += $(TESTS_F)
|
||||
endif
|
||||
|
||||
TESTS = $(TESTS_C) $(TESTS_F)
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
# specify common LDADD options for all tests
|
||||
LDADD = src/libtrexio.la
|
||||
|
||||
if HAVE_FORTRAN
|
||||
test_trexio_f = $(srcdir)/tests/trexio_f.f90
|
||||
|
||||
$(test_trexio_f): $(trexio_f)
|
||||
@ -153,10 +164,16 @@ $(test_trexio_f): $(trexio_f)
|
||||
trexio.mod: tests/trexio_f.o
|
||||
|
||||
tests_test_f_SOURCES = $(test_trexio_f) tests/test_f.f90
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
-rm -rf -- *.dir/ *.h5 __pycache__/
|
||||
|
||||
# =============== GUIX MANIFEST =============== #
|
||||
|
||||
trexio_scm = $(srcdir)/tools/trexio.scm
|
||||
EXTRA_DIST += $(trexio_scm)
|
||||
|
||||
# =============== DOCUMENTATION =============== #
|
||||
|
||||
HTML_TANGLED = docs/index.html \
|
||||
|
27
README.md
27
README.md
@ -77,6 +77,33 @@ conda install trexio -c conda-forge
|
||||
More details can be found in the corresponding [trexio-feedstock](https://github.com/conda-forge/trexio-feedstock).
|
||||
Note that both parallel (see `mpi_openmpi` prefix) and serial (`nompi`) variants are provided.
|
||||
|
||||
## Installation procedure for Guix users
|
||||
|
||||
The official releases of TREXIO `>=2.0.0` can be installed using the
|
||||
[GNU Guix](https://guix.gnu.org) functional package manager.
|
||||
The [trexio.scm](https://github.com/TREX-CoE/trexio/blob/master/tools/trexio.scm)
|
||||
Schema file contains the manifest specification for the `trexio` package.
|
||||
It can be installed within the selected `$GUIX_PROFILE` as follows:
|
||||
|
||||
```
|
||||
guix package \
|
||||
--profile=$GUIX_PROFILE \
|
||||
--cores=<n_cores> \
|
||||
--install-from-file=trexio.scm
|
||||
```
|
||||
|
||||
## Installation procedure for Spack users
|
||||
|
||||
The official releases `>=2.0.0` and the development version of TREXIO can be installed using the
|
||||
[Spack](https://spack.io/) package manager.
|
||||
The [trexio/package.py](https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/trexio/package.py)
|
||||
file contains the Spack specifications required to build different variants of `trexio` library.
|
||||
It can be installed as follows
|
||||
|
||||
```
|
||||
spack install --jobs <n_cores> trexio
|
||||
```
|
||||
|
||||
## Compilation without the HDF5 library
|
||||
|
||||
By default, the configuration step proceeds to search for the [HDF5 library](https://portal.hdfgroup.org/display/HDF5/HDF5).
|
||||
|
49
configure.ac
49
configure.ac
@ -19,8 +19,8 @@ LT_INIT
|
||||
# Activate developer mode when the source is the git repository.
|
||||
# Otherwise, it is the source distribution and the developer mode should not be activated.
|
||||
TEST_IFEXISTS=".git"
|
||||
AC_CHECK_FILE([$TEST_IFEXISTS],
|
||||
[enable_maintainer_mode="yes"],
|
||||
AS_IF([test -d $TEST_IFEXISTS],
|
||||
[enable_maintainer_mode="yes"]
|
||||
)
|
||||
|
||||
VERSION_MAJOR=`echo ${PACKAGE_VERSION} | cut -d. -f1`
|
||||
@ -50,12 +50,18 @@ AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
|
||||
[AC_MSG_ERROR([The compiler does not support C99])])
|
||||
AC_PROG_CC_C_O
|
||||
|
||||
# Fortran
|
||||
AC_PROG_FC
|
||||
AC_FC_FREEFORM
|
||||
AC_FC_SRCEXT([f90])
|
||||
AC_PROG_FC_C_O
|
||||
AC_FC_LIBRARY_LDFLAGS
|
||||
|
||||
# Fortran API [default: --with-fortran], do not disable in the dev mode
|
||||
AC_ARG_WITH(fortran, [AS_HELP_STRING([--without-fortran],[do not test and install the Fortran API])], ok=$withval, ok=yes)
|
||||
if test "$ok" = "yes"; then
|
||||
AC_PROG_FC
|
||||
AC_FC_FREEFORM
|
||||
AC_FC_SRCEXT([f90])
|
||||
AC_PROG_FC_C_O
|
||||
AC_FC_LIBRARY_LDFLAGS
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_FORTRAN],[test "$ok" = "yes"])
|
||||
|
||||
# pkg-config
|
||||
PKG_PROG_PKG_CONFIG()
|
||||
@ -66,6 +72,31 @@ AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_GREP
|
||||
|
||||
# Specific options required with some compilers
|
||||
case $FC in
|
||||
*gfortran*)
|
||||
FCFLAGS="$FCFLAGS -fPIC"
|
||||
;;
|
||||
*flang*)
|
||||
FCFLAGS="$FCFLAGS -fPIC"
|
||||
;;
|
||||
*ifort*)
|
||||
FCFLAGS="$FCFLAGS -fPIC"
|
||||
;;
|
||||
esac
|
||||
|
||||
case $CC in
|
||||
*gcc*)
|
||||
CFLAGS="$CFLAGS -fPIC"
|
||||
;;
|
||||
*clang*)
|
||||
CFLAGS="$CFLAGS -fPIC"
|
||||
;;
|
||||
*icc*)
|
||||
CFLAGS="$CFLAGS -fPIC"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
## ---------
|
||||
## Libraries
|
||||
@ -138,7 +169,7 @@ AC_TYPE_UINT32_T
|
||||
AC_TYPE_UINT64_T
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_MALLOC
|
||||
# AC_FUNC_MALLOC
|
||||
AC_CHECK_FUNCS([memset mkdir strerror])
|
||||
|
||||
if test "x$enable_maintainer_mode" == "xyes"; then
|
||||
|
@ -257,7 +257,7 @@ HDF5 support is being disabled (equivalent to --with-hdf5=no).
|
||||
AC_MSG_WARN([Unable to compile HDF5 test program])
|
||||
fi
|
||||
dnl Look for HDF5's high level library
|
||||
AC_HAVE_LIBRARY([hdf5_hl], [HDF5_LIBS="-lhdf5_hl $HDF5_LIBS"], [], [])
|
||||
AC_CHECK_LIB([hdf5_hl], [main],[HDF5_LIBS="-lhdf5_hl $HDF5_LIBS"], [], [])
|
||||
|
||||
CC=$ax_lib_hdf5_save_CC
|
||||
CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS
|
||||
|
@ -94,6 +94,7 @@ pytrexio_module = Extension('pytrexio._pytrexio',
|
||||
include_dirs = [h5_cflags, srcpath, numpy_includedir],
|
||||
libraries = ['hdf5', 'hdf5_hl'],
|
||||
extra_compile_args = [
|
||||
'-std=c99',
|
||||
'-Wno-discarded-qualifiers',
|
||||
'-Wno-unused-variable',
|
||||
'-Wno-unused-but-set-variable'
|
||||
|
@ -43,4 +43,7 @@ dets = [i for i in range(det_num * int64_num * 2)]
|
||||
coeffs = [float(i/det_num) for i in range(det_num)]
|
||||
coeffs_s2 = [float(i*2/det_num) for i in range(det_num)]
|
||||
|
||||
det_test = [1, 2, 3, 2, 1, 3]
|
||||
det_test = [1, 2, 3, 2, 1, 3]
|
||||
|
||||
orb_up_test = [0, 65, 128, 129]
|
||||
orb_dn_test = [1, 64, 128, 129]
|
||||
|
@ -39,6 +39,17 @@ def test_orbital_list():
|
||||
assert orb_list_dn[0] == 1
|
||||
|
||||
|
||||
def test_bitfield_list():
|
||||
"""Convert lists of occupied up- and down-spin orbitals into determinants."""
|
||||
# convert det_test list into a numpy array for .all() assertion to work
|
||||
det_test_np = np.array(det_test, dtype=np.int64)
|
||||
|
||||
det_list_up = trexio.to_bitfield_list(int64_num, orb_up_test)
|
||||
assert (det_list_up == det_test_np[:int64_num]).all()
|
||||
det_list_dn = trexio.to_bitfield_list(int64_num, orb_dn_test)
|
||||
assert (det_list_dn == det_test_np[int64_num:]).all()
|
||||
|
||||
|
||||
class TestIO:
|
||||
"""Unit tests for writing/reading different blocks of the TREXIO file."""
|
||||
|
||||
|
@ -104,6 +104,9 @@ import_array();
|
||||
%apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_up_out, const int64_t dim_up_out)};
|
||||
%apply (int64_t* ARGOUT_ARRAY1, int64_t DIM1) {(int64_t* const dset_dn_out, const int64_t dim_dn_out)};
|
||||
%apply (bitfield_t* IN_ARRAY1, int64_t DIM1) {(const bitfield_t* dset_in, const int64_t dim_in)};
|
||||
%apply (int32_t* IN_ARRAY1, int32_t DIM1) {(const int32_t* orb_list, const int32_t occupied_num)};
|
||||
/* For some reasons SWIG does not apply the proper bitfield_t typemap, so one has to manually specify int64_t* ARGOUT_ARRAY1 below */
|
||||
%apply (int64_t* ARGOUT_ARRAY1, int32_t DIM1) {(bitfield_t* const bit_list, const int32_t N_int)};
|
||||
|
||||
/* This tells SWIG to treat char ** dset_in pattern as a special case
|
||||
Enables access to trexio_[...]_write_dset_str set of functions directly, i.e.
|
||||
|
@ -5281,6 +5281,9 @@ def has_determinant_coefficient(trexio_file) -> bool:
|
||||
~trexio_to_orbital_list_up_dn~ function does the same but for both up- and down-spin components
|
||||
of the determinant and returns two list of orbitals each corresponding to a different component.
|
||||
|
||||
~trexio_to_bitfield_list~ function converts the list of occupied orbitals (up- or down-spin)
|
||||
into the corresponding ~int64_t~ bitfield representation of the determinant.
|
||||
|
||||
** C
|
||||
|
||||
#+begin_src c :tangle prefix_front.h
|
||||
@ -5289,16 +5292,50 @@ trexio_exit_code trexio_mark_safety(trexio_t* const file, const int32_t safety_f
|
||||
|
||||
typedef int64_t bitfield_t;
|
||||
|
||||
#define TREXIO_ORBITAL_SHIFT 1
|
||||
#define TREXIO_INT_SIZE 64
|
||||
#define TREXIO_NORB_PER_INT ( 8*sizeof(bitfield_t) )
|
||||
#
|
||||
#define TREXIO_ORBITAL_SHIFT 1
|
||||
#define TREXIO_INT_SIZE 64
|
||||
#define TREXIO_NORB_PER_INT ( 8*sizeof(bitfield_t) )
|
||||
#define TREXIO_NORB_PER_INT_SHIFT ( trailz( TREXIO_NORB_PER_INT ) )
|
||||
|
||||
trexio_exit_code trexio_to_orbital_list (const int32_t N_int, const bitfield_t* d1, int32_t* const list, int32_t* const occupied_num);
|
||||
trexio_exit_code trexio_to_orbital_list_up_dn (const int32_t N_int, const bitfield_t* d1, int32_t* const list_up, int32_t* const list_dn, int32_t* const occ_num_up, int32_t* const occ_num_dn);
|
||||
trexio_exit_code trexio_safe_to_orbital_list (const int32_t N_int, const bitfield_t* dset_in, const int64_t dim_in, int32_t* const dset_out, const int64_t dim_out, int32_t* const num);
|
||||
trexio_exit_code trexio_safe_to_orbital_list_up_dn (const int32_t N_int, const bitfield_t* dset_in, const int64_t dim_in, int32_t* const dset_up_out, const int64_t dim_up_out, int32_t* const dset_dn_out, const int64_t dim_dn_out, int32_t* const num_up, int32_t* const num_dn);
|
||||
trexio_exit_code trexio_to_bitfield_list (const int32_t* orb_list, const int32_t occupied_num, bitfield_t* const bit_list, const int32_t N_int);
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src c :tangle prefix_front.c
|
||||
trexio_exit_code trexio_to_bitfield_list (const int32_t* orb_list,
|
||||
const int32_t occupied_num,
|
||||
bitfield_t* const bit_list,
|
||||
const int32_t N_int)
|
||||
{
|
||||
if (orb_list == NULL) return TREXIO_INVALID_ARG_1;
|
||||
if (occupied_num <= 0) return TREXIO_INVALID_ARG_2;
|
||||
if (bit_list == NULL) return TREXIO_INVALID_ARG_3;
|
||||
if (N_int <= 0) return TREXIO_INVALID_ARG_4;
|
||||
|
||||
uint32_t i;
|
||||
uint32_t k;
|
||||
uint32_t iorb;
|
||||
|
||||
for (int32_t j = 0 ; j < N_int ; j++) {
|
||||
bit_list[j] = (bitfield_t) 0;
|
||||
}
|
||||
|
||||
for (int32_t pos = 0 ; pos < occupied_num ; pos++) {
|
||||
iorb = ((uint32_t) (orb_list[pos] + 1)) - TREXIO_ORBITAL_SHIFT;
|
||||
i = (uint32_t) (iorb >> TREXIO_NORB_PER_INT_SHIFT);
|
||||
k = (uint32_t) (iorb & (TREXIO_NORB_PER_INT - 1) );
|
||||
bit_list[i] |= ((bitfield_t) 1) << k;
|
||||
}
|
||||
|
||||
return TREXIO_SUCCESS;
|
||||
}
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src c :tangle prefix_front.c
|
||||
trexio_exit_code trexio_to_orbital_list(const int32_t N_int,
|
||||
const bitfield_t* d1,
|
||||
@ -5478,10 +5515,24 @@ interface
|
||||
end interface
|
||||
#+end_src
|
||||
|
||||
#+begin_src f90 :tangle prefix_fortran.f90
|
||||
interface
|
||||
integer(trexio_exit_code) function trexio_to_bitfield_list_c(list, occupied_num, det_list, N_int) &
|
||||
bind(C, name="trexio_to_bitfield_list")
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int32_t), intent(in) :: list(*)
|
||||
integer(c_int32_t), intent(in), value :: occupied_num
|
||||
integer(c_int64_t), intent(inout) :: det_list(*)
|
||||
integer(c_int32_t), intent(in), value :: N_int
|
||||
end function trexio_to_bitfield_list_c
|
||||
end interface
|
||||
#+end_src
|
||||
|
||||
#+begin_src f90 :tangle prefix_fortran.f90
|
||||
interface
|
||||
integer(trexio_exit_code) function trexio_to_orbital_list_c(N_int, d1, list, occupied_num) bind(C, name="trexio_to_orbital_list")
|
||||
integer(trexio_exit_code) function trexio_to_orbital_list_c(N_int, d1, list, occupied_num) &
|
||||
bind(C, name="trexio_to_orbital_list")
|
||||
use, intrinsic :: iso_c_binding
|
||||
import
|
||||
integer(c_int32_t), intent(in), value :: N_int
|
||||
@ -5520,6 +5571,33 @@ def info():
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src python :tangle basic_python.py
|
||||
def to_bitfield_list(n_int: int, orbitals: list) -> list:
|
||||
"""Convert a list of occupied orbitals into a bitfield determinant.
|
||||
|
||||
Input:
|
||||
~orbitals~ - list of occupied orbital indices fields (integers)
|
||||
~n_int~ - number of bitfields per determinant of a given spin
|
||||
|
||||
Returns:
|
||||
~bitfield_list~: list
|
||||
|
||||
Raises:
|
||||
- Exception from AssertionError if TREXIO return code ~rc~ is different from TREXIO_SUCCESS and prints the error message using trexio_string_of_error.
|
||||
- Exception from some other error (e.g. RuntimeError).
|
||||
"""
|
||||
|
||||
|
||||
rc, bitfield_list = pytr.trexio_to_bitfield_list(orbitals, n_int)
|
||||
if rc != TREXIO_SUCCESS:
|
||||
raise Error(rc)
|
||||
if len(bitfield_list) != n_int:
|
||||
raise Exception("Inconsistent size of the bitfield_list.")
|
||||
|
||||
return bitfield_list
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src python :tangle basic_python.py
|
||||
def to_orbital_list(n_int: int, determinant: list) -> list:
|
||||
"""Convert a given determinant into a list of occupied orbitals.
|
||||
@ -5546,8 +5624,10 @@ def to_orbital_list(n_int: int, determinant: list) -> list:
|
||||
raise Exception("Inconsistent size of the orbital_list.")
|
||||
|
||||
return orbital_list[0:occ_num]
|
||||
#+end_src
|
||||
|
||||
|
||||
#+begin_src python :tangle basic_python.py
|
||||
def to_orbital_list_up_dn(n_int: int, determinant: list) -> tuple:
|
||||
"""Convert a given determinant into two lists of occupied orbitals.
|
||||
|
||||
@ -5631,6 +5711,29 @@ contains
|
||||
by 1 since in Fortran arrays are 1-based and C/Python they are 0-based.
|
||||
|
||||
#+begin_src f90 :tangle helper_fortran.f90
|
||||
integer(trexio_exit_code) function trexio_to_bitfield_list(list, occupied_num, det_list, N_int)
|
||||
use, intrinsic :: iso_c_binding
|
||||
implicit none
|
||||
|
||||
integer(c_int32_t), intent(in) :: list(*)
|
||||
integer(c_int32_t), intent(in), value :: occupied_num
|
||||
integer(c_int64_t), intent(out) :: det_list(*)
|
||||
integer(c_int32_t), intent(in), value :: N_int
|
||||
integer(c_int32_t) :: list_0based(occupied_num)
|
||||
|
||||
integer :: i
|
||||
do i = 1,occupied_num
|
||||
list_0based(i) = list(i) - 1
|
||||
enddo
|
||||
|
||||
trexio_to_bitfield_list = trexio_to_bitfield_list_c(list_0based, occupied_num, det_list, N_int)
|
||||
if (trexio_to_bitfield_list /= TREXIO_SUCCESS) then
|
||||
return
|
||||
endif
|
||||
|
||||
end function trexio_to_bitfield_list
|
||||
|
||||
|
||||
integer(trexio_exit_code) function trexio_to_orbital_list(N_int, d1, list, occupied_num)
|
||||
use, intrinsic :: iso_c_binding
|
||||
implicit none
|
||||
|
@ -143,7 +143,15 @@ trexio_text_inquire (const char* file_name)
|
||||
|
||||
if (file_exists) {
|
||||
|
||||
bool is_a_directory = st.st_mode & S_IFDIR;
|
||||
bool is_a_directory = false;
|
||||
#ifdef S_IFDIR
|
||||
is_a_directory = st.st_mode & S_IFDIR;
|
||||
#elif S_ISDIR
|
||||
is_a_directory = S_ISDIR(s.st_mode);
|
||||
#else
|
||||
printf("Some important macros are missing for directory handling.\n");
|
||||
return TREXIO_FAILURE;
|
||||
#endif
|
||||
if (!is_a_directory) return TREXIO_FILE_ERROR;
|
||||
|
||||
return TREXIO_SUCCESS;
|
||||
@ -420,13 +428,14 @@ trexio_text_read_$group$ (trexio_text_t* const file)
|
||||
/* conventional fcanf with "%s" only return the string before the first space character
|
||||
* to read string with spaces use "%[^\n]" possible with space before or after, i.e. " %[^\n]"
|
||||
*/
|
||||
rc = fscanf(f, " %1023[^\n]", tmp_$group_dset$);
|
||||
rc = fscanf(f, " %1023[^\n]", buffer);
|
||||
if (rc != 1) {
|
||||
trexio_text_free_read_$group$(buffer, f, file, $group$);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t tmp_$group_dset$_len = strlen($group$->$group_dset$[i]);
|
||||
size_t tmp_$group_dset$_len = strlen(buffer);
|
||||
strncpy(tmp_$group_dset$, buffer, 32);
|
||||
tmp_$group_dset$ += tmp_$group_dset$_len + 1;
|
||||
}
|
||||
}
|
||||
@ -484,14 +493,15 @@ trexio_text_read_$group$ (trexio_text_t* const file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = fscanf(f, " %1023[^\n]", $group$->$group_str$);
|
||||
rc = fscanf(f, " %1023[^\n]", buffer);
|
||||
if (rc != 1) {
|
||||
trexio_text_free_read_$group$(buffer, f, file, $group$);
|
||||
return NULL;
|
||||
}
|
||||
/* Safer string conversion to avoid buffer overflow in fscanf */
|
||||
strncpy($group$->$group_str$, buffer, $group$->len_$group_str$);
|
||||
|
||||
}
|
||||
|
||||
// END REPEAT GROUP_ATTR_STR
|
||||
} else {
|
||||
continue;
|
||||
|
@ -307,6 +307,14 @@ static int test_read_determinant (const char* file_name, const back_end_t backen
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
// check conversion of one orbital list into the bitfield determinant representation
|
||||
int64_t* det_list_check = (int64_t*) calloc(int_num, sizeof(int64_t));
|
||||
|
||||
rc = trexio_to_bitfield_list (orb_list_up, occ_num_up, det_list_check, int_num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
for (int i=0; i<int_num; i++) {
|
||||
assert (det_list_check[i] == det_list_read[2*int_num*5+i]);
|
||||
}
|
||||
|
||||
// close current session
|
||||
rc = trexio_close(file);
|
||||
@ -316,6 +324,7 @@ static int test_read_determinant (const char* file_name, const back_end_t backen
|
||||
free(det_list_read);
|
||||
free(det_coef_read);
|
||||
free(det_coef_s2_read);
|
||||
free(det_list_check);
|
||||
free(orb_list_up);
|
||||
free(orb_list_dn);
|
||||
|
||||
|
@ -307,6 +307,14 @@ static int test_read_determinant (const char* file_name, const back_end_t backen
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
// check conversion of one orbital list into the bitfield determinant representation
|
||||
int64_t* det_list_check = (int64_t*) calloc(int_num, sizeof(int64_t));
|
||||
|
||||
rc = trexio_to_bitfield_list (orb_list_up, occ_num_up, det_list_check, int_num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
for (int i=0; i<int_num; i++) {
|
||||
assert (det_list_check[i] == det_list_read[2*int_num*5+i]);
|
||||
}
|
||||
|
||||
// close current session
|
||||
rc = trexio_close(file);
|
||||
@ -316,6 +324,7 @@ static int test_read_determinant (const char* file_name, const back_end_t backen
|
||||
free(det_list_read);
|
||||
free(det_coef_read);
|
||||
free(det_coef_s2_read);
|
||||
free(det_list_check);
|
||||
free(orb_list_up);
|
||||
free(orb_list_dn);
|
||||
|
||||
|
@ -6,11 +6,11 @@ program test_trexio
|
||||
integer :: rc
|
||||
logical :: have_hdf5
|
||||
|
||||
print * , "============================================"
|
||||
print'(a)' , "============================================"
|
||||
print'(a,a)' , " TREXIO VERSION STRING : ", TREXIO_PACKAGE_VERSION
|
||||
print'(a,i3)', " TREXIO MAJOR VERSION : ", TREXIO_VERSION_MAJOR
|
||||
print'(a,i3)', " TREXIO MINOR VERSION : ", TREXIO_VERSION_MINOR
|
||||
print * , "============================================"
|
||||
print'(a)' , "============================================"
|
||||
|
||||
rc = trexio_info()
|
||||
|
||||
@ -288,6 +288,7 @@ subroutine test_read(file_name, back_end)
|
||||
|
||||
! determinant data
|
||||
integer*8 :: det_list(6,50)
|
||||
integer*8 :: det_list_check(3)
|
||||
integer*8 :: read_buf_det_size = 20
|
||||
integer*8 :: offset_det_read = 10
|
||||
integer*8 :: offset_det_data_read = 5
|
||||
@ -349,9 +350,11 @@ subroutine test_read(file_name, back_end)
|
||||
endif
|
||||
|
||||
|
||||
rc = trexio_read_nucleus_label(trex_file, label, 2)
|
||||
rc = trexio_read_nucleus_label(trex_file, label, 4)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS)
|
||||
if (trim(label(2)) == 'Na') then
|
||||
if (trim(label(2)) == 'Na' .and. &
|
||||
trim(label(4)) == 'C 66' .and. &
|
||||
trim(label(5)) == 'C') then
|
||||
write(*,*) 'SUCCESS READ LABEL'
|
||||
else
|
||||
print *, 'FAILURE LABEL CHECK'
|
||||
@ -477,6 +480,26 @@ subroutine test_read(file_name, back_end)
|
||||
call exit(-1)
|
||||
endif
|
||||
|
||||
! convert one orbital list into a bitfield determinant representation
|
||||
rc = trexio_to_bitfield_list(orb_list_up, occ_num_up, det_list_check, 3)
|
||||
!write(*,*) occ_num_up, occ_num_dn
|
||||
! Print occupied orbitals for an up-spin component of a given determinant
|
||||
!write(*,*) orb_list_up(1:occ_num_up)
|
||||
! Print integers representanting a given determinant fully (up- and down-spin components)
|
||||
!write(*,*) det_list(1:3, offset_det_data_read+1)
|
||||
!write(*,*) det_list_check(1:3)
|
||||
! Print binary representation of the first integer bit field of a given determinant
|
||||
!write(*,'(B64.64)') det_list(1, offset_det_data_read+1)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS)
|
||||
if (det_list_check(1) == det_list(1, offset_det_data_read+1) .and. &
|
||||
det_list_check(2) == det_list(2, offset_det_data_read+1) .and. &
|
||||
det_list_check(3) == det_list(3, offset_det_data_read+1)) then
|
||||
write(*,*) 'SUCCESS CONVERT ORB LIST'
|
||||
else
|
||||
print *, 'FAILURE ORB CONVERT CHECK'
|
||||
call exit(-1)
|
||||
endif
|
||||
|
||||
rc = trexio_read_mo_num(trex_file, mo_num)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS)
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
(define-module (gnu packages trexio)
|
||||
(define-module (trexio)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (gnu packages pkg-config)
|
||||
#:use-module (gnu packages glib)
|
||||
#:use-module (gnu packages gcc)
|
||||
#:use-module (gnu packages autotools)
|
||||
#:use-module (gnu packages maths)
|
||||
#:use-module (gnu packages maths) ;; contains hdf5
|
||||
#:use-module (guix download)
|
||||
#:use-module (guix build-system gnu)
|
||||
#:use-module (guix licenses))
|
||||
|
||||
(define-public trexio
|
||||
(define-public trexio-2.0
|
||||
(package
|
||||
(name "trexio")
|
||||
(version "2.0")
|
||||
@ -20,15 +20,48 @@
|
||||
".tar.gz"))
|
||||
(sha256
|
||||
(base32
|
||||
;; the hash below is produced by guix download <url>
|
||||
"1d2cn4w2r9gfid5b9wrq9q290kqdnbjdmvli76s1i5r58kdg5vkf"
|
||||
))))
|
||||
(build-system gnu-build-system)
|
||||
(arguments '(#:configure-flags '("--enable-silent-rules")))
|
||||
(inputs `(("hdf5" ,hdf5-1.12) ("gfortran", gfortran)))
|
||||
(synopsis "TREX I/O lbrary: trexio package")
|
||||
(description "APIs in C and Fortran to exchange wavefunction data.
|
||||
Supports HDF5 and TEXT back ends.")
|
||||
(inputs `(("hdf5" ,hdf5) ("gfortran", gfortran)))
|
||||
(synopsis "TREX I/O library")
|
||||
(description "The TREXIO library defines a standard format for storing wave functions, together with
|
||||
an C-compatible API such that it can be easily used in any programming language.")
|
||||
(home-page "https://trex-coe.github.io/trexio")
|
||||
(license bsd-3)))
|
||||
|
||||
(define-public trexio-2.1
|
||||
(package/inherit trexio-2.0
|
||||
(version "2.1.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>
|
||||
"10syfw4mq3wpp9anahmxnm7660bm1ya5xd9l5njai3xr8g4nca13"
|
||||
))))))
|
||||
|
||||
(define-public trexio-2.2
|
||||
(package/inherit trexio-2.0
|
||||
(version "2.2.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>
|
||||
"1n9n1gbk5hgvg73am991xrv7ap002rz719a3nvh8m8ff9x10qd76"
|
||||
))))))
|
||||
|
||||
(define-public trexio
|
||||
;; Default version of TREXIO.
|
||||
trexio-2.2)
|
||||
|
||||
trexio
|
||||
|
Loading…
Reference in New Issue
Block a user