Skip to content

Commit

Permalink
toolchain: add libvori
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Dec 8, 2020
1 parent d7872ff commit c24c685
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 3 deletions.
3 changes: 3 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ SIRIUS is a domain specific library for electronic structure calculations.
electron density in the Voronoi cell of each atom.
- Add `-D__LIBVORI` to DFLAGS to enable support for LibVori.
- see <https://brehm-research.de/voronoi> for more information.
- LibVori also enables support for the BQB file format for compressed trajectories,
please see <https://brehm-research.de/bqb.php> for more information as well as
the `bqbtool` to inspect BQB files.

### 2u. LibMaxwell (External Maxwell Solver)

Expand Down
1 change: 1 addition & 0 deletions tools/toolchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ be installed separately by the user.
| hdf5 | [BSD 3-Clause](https://support.hdfgroup.org/ftp/HDF5/releases/COPYING) | Yes |
| libint | [GPL](https://github.com/evaleev/libint/blob/master/LICENSE) | Yes |
| libsmm | [GPL](https://github.com/cp2k/cp2k/blob/master/LICENSE) | Yes |
| libvori | LGPL-3 | Yes |
| libvdwxc | [GPL](https://gitlab.com/libvdwxc/libvdwxc/blob/master/LICENSE) | Yes |
| libxc | [MPL](https://gitlab.com/libxc/libxc/blob/master/COPYING) | Yes |
| libxsmm | [BSD 3-Clause](https://github.com/hfp/libxsmm/blob/master/LICENSE.md) | Yes |
Expand Down
14 changes: 11 additions & 3 deletions tools/toolchain/install_cp2k_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ The --with-PKG options follow the rules:
Default = install
--with-cosma Enable cosma as a replacement for scalapack matrix multiplication
Default = install
--with-libvori Enable libvori for the Voronoi integration (and the BQB compressed trajectory format)
Default = install
FURTHER INSTRUCTIONS
Expand Down Expand Up @@ -258,7 +260,8 @@ tool_list="gcc cmake valgrind"
mpi_list="mpich openmpi intelmpi"
math_list="mkl acml openblas reflapack"
lib_list="fftw libint libxc libsmm libxsmm cosma scalapack elpa plumed \
spfft ptscotch superlu pexsi quip gsl spglib hdf5 libvdwxc sirius"
spfft ptscotch superlu pexsi quip gsl spglib hdf5 libvdwxc sirius
libvori"
package_list="$tool_list $mpi_list $math_list $lib_list"
# ------------------------------------------------------------------------

Expand Down Expand Up @@ -303,6 +306,7 @@ with_elpa="__INSTALL__"
with_libvdwxc="__INSTALL__"
with_spfft=__INSTALL__
with_cosma=__INSTALL__
with_libvori=__INSTALL__
# for MPI, we try to detect system MPI variant
with_openmpi=__SYSTEM__
with_mpich=__SYSTEM__
Expand Down Expand Up @@ -608,6 +612,9 @@ while [ $# -ge 1 ] ; do
--with-cosma*)
with_cosma=$(read_with $1)
;;
--with-libvori*)
with_libvori=$(read_with $1)
;;
--help*)
show_help
exit 0
Expand Down Expand Up @@ -723,8 +730,8 @@ else
fi
fi

# spg library requires cmake.
if [ "$with_spglib" = "__INSTALL__" ] ; then
# spglib and libvori require cmake.
if [ "$with_spglib" = "__INSTALL__" ] || [ "$with_libvori" = "__INSTALL__" ] ; then
[ "$with_cmake" = "__DONTUSE__" ] && with_cmake="__INSTALL__"
fi

Expand Down Expand Up @@ -938,6 +945,7 @@ else
./scripts/install_hdf5.sh
./scripts/install_libvdwxc.sh
./scripts/install_sirius.sh
./scripts/install_libvori.sh
./scripts/generate_arch_files.sh
fi

Expand Down
105 changes: 105 additions & 0 deletions tools/toolchain/scripts/install_libvori.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash -e
# shellcheck disable=SC1090

[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"

libvori_ver="201208"
libvori_sha256="b1e2ab335542cda2e4eb62c72c09990bf3a5cda7df53e63db98948c83d82e2d5"

# shellcheck source=/dev/null
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
source "${INSTALLDIR}"/toolchain.conf
source "${INSTALLDIR}"/toolchain.env

[ -f "${BUILDDIR}/setup_libvori" ] && rm "${BUILDDIR}/setup_libvori"

! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"

case "${with_libvori:=__INSTALL__}" in
__INSTALL__)
echo "==================== Installing libvori ===================="
pkg_install_dir="${INSTALLDIR}/libvori-${libvori_ver}"
install_lock_file="${pkg_install_dir}/install_successful"
if verify_checksums "${install_lock_file}" ; then
echo "libvori-${libvori_ver} is already installed, skipping it."
else
if [ -f libvori-${libvori_ver}.tar.gz ] ; then
echo "libvori-${libvori_ver}.tar.gz is found"
else
# shellcheck disable=SC2086
download_pkg ${DOWNLOADER_FLAGS} ${libvori_sha256} \
"https://www.cp2k.org/static/downloads/libvori-${libvori_ver}.tar.gz"
fi

echo "Installing from scratch into ${pkg_install_dir}"
[ -d libvori-${libvori_ver} ] && rm -rf libvori-${libvori_ver}
tar -xzf libvori-${libvori_ver}.tar.gz

mkdir "libvori-${libvori_ver}/build"
cd "libvori-${libvori_ver}/build"
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \
.. > cmake.log 2>&1
CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . > build.log 2>&1
CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target test > test.log 2>&1
CMAKE_BUILD_PARALLEL_LEVEL="${NPROCS}" cmake --build . --target install > install.log 2>&1

write_checksums "${install_lock_file}" "${SCRIPT_DIR}/$(basename "${SCRIPT_NAME}")"
fi
LIBVORI_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding libvori from system paths ===================="
check_lib -lvori "libvori"
add_lib_from_paths LIBVORI_LDFLAGS "libvori.*" "$LIB_PATHS"
;;
__DONTUSE__)
;;
*)
echo "==================== Linking libvori to user paths ===================="
pkg_install_dir="${with_libvori}"

# use the lib64 directory if present (multi-abi distros may link lib/ to lib32/ instead)
LIBVORI_LIBDIR="${pkg_install_dir}/lib"
[ -d "${pkg_install_dir}/lib64" ] && LIBVORI_LIBDIR="${pkg_install_dir}/lib64"

check_dir "${LIBVORI_LIBDIR}"
LIBVORI_LDFLAGS="-L'${LIBVORI_LIBDIR}' -Wl,-rpath='${LIBVORI_LIBDIR}'"
;;
esac

if [ "$with_libvori" != "__DONTUSE__" ] ; then
LIBVORI_LIBS="-lvori"
if [ "$with_libvori" != "__SYSTEM__" ] ; then
cat << EOF > "${BUILDDIR}/setup_libvori"
prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib"
prepend_path LD_RUN_PATH "${pkg_install_dir}/lib"
prepend_path LIBRARY_PATH "${pkg_install_dir}/lib"
export LIBVORI_LIBS="-lvori"
export LIBVORI_ROOT="${pkg_install_dir}"
EOF
fi
cat << EOF >> "${BUILDDIR}/setup_libvori"
export LIBVORI_ROOT="${pkg_install_dir}"
export LIBVORI_VERSION=${libvori_ver}
export LIBVORI_LDFLAGS="${LIBVORI_LDFLAGS}"
export LIBVORI_LIBRARY="-lvori"
export CP_DFLAGS="\${CP_DFLAGS} -D__LIBVORI"
export CP_LDFLAGS="\${CP_LDFLAGS} ${LIBVORI_LDFLAGS}"
export CP_LIBS="\${CP_LIBS} ${LIBVORI_LIBS}"
EOF
cat "${BUILDDIR}/setup_libvori" >> "${SETUPFILE}"
fi

load "${BUILDDIR}/setup_libvori"
write_toolchain_env "${INSTALLDIR}"

cd "${ROOTDIR}"
report_timing "libvori"

0 comments on commit c24c685

Please sign in to comment.