Initial integration of sirius in cp2k

the SIRIUS dependency is only build when cp2k is build with mpi and omp (with or
without cuda). Right now, we would need two versions of SIRIUS with and
without GPU support in order to compile cp2k+sirius with or without GPU
support. This is not a problem with sirius since we can build the two flavors,
but cp2k does not seem to have a macro similar to IF_OMP or IF_MPI for CUDA.
This commit is contained in:
Mathieu Taillefumier 2018-10-16 09:55:35 +02:00 committed by Tiziano Müller
commit 6242210fa7
18 changed files with 1364 additions and 11 deletions

View file

@ -6,7 +6,7 @@
! **************************************************************************************************
MODULE atom_upf
#if defined(__JSON)
USE json_module
USE json_module, ONLY: json_file
#endif
USE cp_parser_methods, ONLY: parser_get_next_line, &
parser_get_object, &
@ -1014,7 +1014,6 @@ CONTAINS
TYPE(json_file) :: json
LOGICAL :: found
CHARACTER(LEN=:), ALLOCATABLE :: symbol
CHARACTER(LEN=default_string_length) :: nametag
REAL(KIND=dp) :: z_valence
#endif

View file

@ -298,7 +298,7 @@ CONTAINS
WRITE (iunit, '(T2,A)') '! Copyright (C) 2004, 2005, 2006, 2007 CP2K developers group !'
WRITE (iunit, '(T2,A)') '! Copyright (C) 2008, 2009, 2010, 2011 CP2K developers group !'
WRITE (iunit, '(T2,A)') '! Copyright (C) 2012, 2013, 2014, 2015 CP2K developers group !'
WRITE (iunit, '(T2,A)') '! Copyright (C) 2016 CP2K developers group !'
WRITE (iunit, '(T2,A)') '! Copyright (C) 2016, 2017, 2018 CP2K developers group !'
WRITE (iunit, '(T2,A)') '! !'
WRITE (iunit, '(T2,A)') '! This program is free software; you can redistribute it and/or modify !'
WRITE (iunit, '(T2,A)') '! it under the terms of the GNU General Public License as published by !'
@ -381,4 +381,3 @@ CONTAINS
END SUBROUTINE write_restart_header
END MODULE cp2k_info

View file

@ -11,7 +11,7 @@
! **************************************************************************************************
MODULE sirius_interface
#if defined(__JSON)
USE json_module
USE json_module, ONLY: json_file
#endif
#if defined(__SIRIUS)
USE sirius, ONLY: &
@ -107,7 +107,7 @@ CONTAINS
CHARACTER(len=*), PARAMETER :: routineN = 'cp_sirius_finalize', &
routineP = moduleN//':'//routineN
CALL sirius_finalize(bool(.FALSE.))
CALL sirius_finalize(bool(.FALSE.), bool(.FALSE.), bool(.FALSE.))
END SUBROUTINE cp_sirius_finalize
#else
@ -198,7 +198,7 @@ CONTAINS
#endif
CPASSERT(npool >= 1)
num_ranks_k = para_env%num_pe/npool
i = SQRT(REAL(num_ranks_k, KIND=dp)+1.0e-10_dp)
i = INT(SQRT(REAL(num_ranks_k, KIND=dp)+1.0e-10_dp))
IF (i*i /= num_ranks_k) THEN
dims(1) = 1
dims(2) = num_ranks_k
@ -447,7 +447,7 @@ CONTAINS
DEALLOCATE (cforces)
cstress = 0.0_C_DOUBLE
!deb what is the correct label?
!deb CALL sirius_get_stress_tensor(gs_handler,string('total'),cstress(1,1))
CALL sirius_get_stress_tensor(gs_handler, string('total'), cstress(1, 1))
stress(1:3, 1:3) = cstress(1:3, 1:3)
CALL pwdft_env_set(pwdft_env=pwdft_env, stress=stress)

View file

@ -3,6 +3,7 @@
# Directories have been reordered according the execution time needed for a gfortran pdbg run using 2 MPI tasks
# in case a new directory is added just add it at the top of the list..
# the order will be regularly checked and modified...
sirius/regtest-1 libxc sirius elpa scalapack mpiranks=4
QS/regtest-almo-strong
QS/regtest-elpa-2 elpa
QS/regtest-cdft-5
@ -231,4 +232,4 @@ QS/regtest-fftw fftw3
Fist/regtest-quip quip
ATOM/regtest-libxc libxc
Fist/regtest-plumed2 plumed2
QS/regtest-sto
QS/regtest-sto

View file

@ -83,8 +83,9 @@ HOMO SCF Cycle: 4!9
DEBUG| Sum of differences:!5
1\[\ \ \ 1\]\ -\ 2\[\ \ \ 1\]!7
Ionization potential of the excited atom:!7
( SIRIUS ) !9
#
# these are the tests the can be selected for regtesting.
# these are the tests the can be selected for regtesting.
# do regtest will grep for test_grep (first column) and look if the numeric value
# at column test_col (second col) changes with respect to the reference.
# the test number in TEST_FILES corresponds to the lines in this file.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,58 @@
&FORCE_EVAL
METHOD SIRIUS
&PW_DFT
&CONTROL
"processing_unit" : "cpu",
"std_evp_solver_type" : "lapack",
"gen_evp_solver_type" : "lapack",
"verbosity" : 1,
"cyclic_block_size" : 2,
"print_forces" : true,
"print_stress" : true,
"cyclic block size" : 32
&END CONTROL
&PARAMETER
"electronic_structure_method" : "pseudopotential",
"xc_functionals" : ["XC_LDA_X", "XC_LDA_C_PZ"],
"smearing_width" : 0.01,
"use_symmetry" : true,
"num_mag_dims" : 3,
"spin_orbit" : true,
"gk_cutoff" : 6.0,
"pw_cutoff" : 20.00,
"energy_tol" : 1e-10,
"potential_tol" : 1e-8,
"num_dft_iter" : 100,
"ngridk" : [2,2,2]
&END PARAMETER
&SOLVER
"tolerance" : 1e-5,
"num_steps" : 20,
"subspace_size" : 4,
"type" : "davidson",
"converge_by_energy" : 1
&END SOLVER
&MIXER
"type" : "broyden1",
"max_history" : 8
&END MIXER
&END PW_DFT
&SUBSYS
&CELL
A -3.85500000000000000000 0.0 3.85500000000000000000
B 0.0 3.85500000000000000000 3.85500000000000000000
C -3.85500000000000000000 3.85500000000000000000 0.0
&END CELL
&COORD
SCALED
Au 0.0 0.0 0.0
&END COORD
&KIND Au
POTENTIAL UPF Au-sp_r.upf.json
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PROJECT Gold
PRINT_LEVEL MEDIUM
&END GLOBAL

View file

@ -0,0 +1,58 @@
&FORCE_EVAL
METHOD SIRIUS
&PW_DFT
&CONTROL
"cyclic_block_size" : 16,
"processing_unit" : "cpu",
"std_evp_solver_type" : "lapack",
"gen_evp_solver_type" : "lapack",
"verbosity" : 1,
"verification" : 0,
"print_forces" : true,
"print_stress" : true
&END CONTROL
&PARAMETER
"electronic_structure_method" : "pseudopotential",
"xc_functionals" : ["XC_LDA_X", "XC_LDA_C_PZ"],
"smearing_width" : 0.02,
"use_symmetry" : true,
"num_mag_dims" : 1,
"gk_cutoff" : 6.0,
"pw_cutoff" : 25.00,
"energy_tol" : 1e-8,
"num_dft_iter" : 100,
"ngridk" : [4,4,4],
"reduce_gvec": 1
&END PARAMETER
&SOLVER
"energy_tolerance" : 1e-2,
"residual_tolerance" : 1e-6,
"num_steps" : 20,
"subspace_size" : 4,
"type" : "davidson",
"converge_by_energy" : 1
&END SOLVER
&MIXER
"beta" : 0.7,
"type" : "broyden1",
"max_history" : 8
&END MIXER
&END PW_DFT
&SUBSYS
&CELL
ABC 5.5415878223 5.5415878223 5.5415878223
&END CELL
&COORD
SCALED
Fe 0.0 0.0 0.0
Fe 0.5 0.5 0.5
&END COORD
&KIND Fe
POTENTIAL UPF Fe.pbe-spn-rrkjus_psl.0.2.1.UPF.json
&END KIND
&END SUBSYS
&END FORCE_EVAL
&GLOBAL
PROJECT Fe
PRINT_LEVEL MEDIUM
&END GLOBAL

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
# runs are executed in the same order as in this file
# the second field tells which test should be run in order to compare with the last available output
# e.g. 0 means do not compare anything, running is enough
# 1 compares the last total energy in the file
# for details see cp2k/tools/do_regtest
#
# Sirius will run in serial and parallel with or without cuda
#
# testing global tree creation using single exact potential, the deterministic random number generator
# with the standard move types, check i
# fully test non colinear magnetism with spin orbit coupling
Au.inp 85 1.0E-5 -147.171051899887289
Fe.inp 85 1.0E-5 -253.181250028399461
#EOF

View file

@ -0,0 +1,4 @@
Au.inp
Fe.inp
Au-sp_r.upf.json
Fe.pz-spn-rrkjus_psl.0.2.1.UPF.json

View file

@ -204,6 +204,17 @@ The --with-PKG options follow the rules:
Default = no
--with-quip Enable interface to QUIP library
Default = no
--with-sirius Enable interface to the plane wave SIRIUS library
Default = no
--with-gsl Enable the gnu scientific library library
Default = no
--with-spglib Enable the spg library (search of symmetry groups)
Default = no
--with-hdf5 Enable the hdf5 library (use by sirius library)
Default = no
--with-json-fortran Enable the json fortran library (used by cp2k when sirius is activated)
Default = no
FURTHER INSTRUCTIONS
@ -240,7 +251,7 @@ tool_list="binutils lcov valgrind make cmake gcc"
mpi_list="mpich openmpi"
math_list="mkl acml openblas reflapack"
lib_list="fftw libint libxc libsmm libxsmm scalapack elpa \
ptscotch parmetis metis superlu pexsi quip"
ptscotch parmetis metis superlu pexsi quip gsl spglib hdf5 sirius json_fortran"
package_list="$tool_list $mpi_list $math_list $lib_list"
# ------------------------------------------------------------------------
@ -526,6 +537,21 @@ while [ $# -ge 1 ] ; do
--with-quip*)
with_quip=$(read_with $1)
;;
--with-sirius*)
with_sirius=$(read_with $1)
;;
--with-gsl*)
with_gsl=$(read_with $1)
;;
--with-spglib*)
with_spglib=$(read_with $1)
;;
--with-hdf5*)
with_hdf5=$(read_with $1)
;;
--with-json*)
with_json_fortran=$(read_with $1)
;;
--help*)
show_help
exit 0
@ -645,6 +671,59 @@ if [ "$with_parmetis" = "__INSTALL__" ] ; then
with_metis="__INSTALL__"
fi
# SIRIUS dependencies. Remove the gsl library from the dependencies if SIRIUS is not activated
if [ "$with_sirius" = "__INSTALL__" ] ; then
echo "====================== Warning =========================================="
echo " "
echo " Sirius needs these libraries to work properly "
echo " gsl, elpa, libxc, scalapack fftw, spglib, hdf5, and json "
echo " they will be activated by default unless the right options are given to "
echo " install_cp2k_toolchain.sh. Please look at the help "
echo " "
echo "========================================================================="
[ "$with_gsl" = "__DONTUSE__" ] && with_gsl="__INSTALL__"
[ "$with_elpa" = "__DONTUSE__" ] && with_elpa="__INSTALL__"
[ "$with_libxc" = "__DONTUSE__" ] && with_libxc="__INSTALL__"
[ "$with_scalapack" = "__DONTUSE__" ] && with_scalapack="__INSTALL__"
[ "$with_fftw" = "__DONTUSE__" ] && with_fftw="__INSTALL__"
[ "$with_spglib" = "__DONTUSE__" ] && with_spglib="__INSTALL__"
[ "$with_hdf5" = "__DONTUSE__" ] && with_hdf5="__INSTALL__"
[ "$with_json_fortran" = "__DONTUSE__" ] && with_json_fortran="__INSTALL__"
else
if [ "$with_gsl" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working gsl library use --with-gsl option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_elpa" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working ELPA library use --with-elpa option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_libxc" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working libxc library use --with-libxc option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_scalpack" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working scalapack library use --with-scalapack option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_fftw" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working fftw library use --with-fftw option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_spglib" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working spglib library use --with-spglib option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_hdf5" = "__DONTUSE__" ] ; then
report_error "For SIRIUS to work you need a working hdf5 library use --with-hdf5 option to specify if you wish to install the library or specify its location."
exit 1
fi
if [ "$with_json_fortran" = "__DONTUSE__" ] ; then
report_error "For sirius intergration tro cp2k to work you need a working json-fortran library use --with-json option to specify if you wish to install it or specify its location."
exit 1
fi
fi
# ------------------------------------------------------------------------
# Preliminaries
# ------------------------------------------------------------------------

View file

@ -92,4 +92,10 @@ af300723841062db6ae24e38e61aaf4fbf3f6e5d9fd3bf60ebbdbf95db4e9f09 *gcc-8.1.0.tar.
9fc7a9783d3d2ea002aa1348f851875a2636116c433677453cc1d1acc3fc4d55 *make-4.1.tar.gz
e968ce3c57ad39a593a92339e23eb148af6296b9f40aa453a9a9202c99d34436 *make-4.2.tar.gz
#SIRIUS package dependencies
0460ad7c2542caaddc6729762952d345374784100223995eb14d614861f2258d *gsl-2.5.tar.gz
1267ff06aaedc04ca25f7c6026687ea2884b837043431195f153401d942b28df *hdf5-1.10.4.tar.bz2
6a15a324a821ad9d3e615e120d9c5e704e284d8eb1f076aa21741a23fbcf08df *spglib-1.10.4.tar.gz
13be3b336a3b665228fd68af3b7143457dfbf655d49e7458cd811f8adb8323fa *SIRIUS-5.8.3.tar.gz
bf19159372f580eab12e711fef8ac637624d32766dd3c30534007d1b4091f092 *json-fortran-6.9.0.tar.gz
#EOF

View file

@ -0,0 +1,94 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
gsl_ver=${gsl_ver:-2.5}
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
with_gsl=${1:-__INSTALL__}
[ -f "${BUILDDIR}/setup_gsl" ] && rm "${BUILDDIR}/setup_gsl"
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_gsl" in
__INSTALL__)
echo "==================== Installing gsl ===================="
pkg_install_dir="${INSTALLDIR}/gsl-${gsl_ver}"
install_lock_file="$pkg_install_dir/install_successful"
if [ -f "${install_lock_file}" ] ; then
echo "gsl-${gsl_ver} is already installed, skipping it."
else
if [ -f gsl-${gsl_ver}.tar.gz ] ; then
echo "gsl-${gsl_ver}.tar.gz is found"
else
download_pkg ${DOWNLOADER_FLAGS} \
https://ftp.gnu.org/gnu/gsl/gsl-${gsl_ver}.tar.gz
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d gsl-${gsl_ver} ] && rm -rf gsl-${gsl_ver}
tar -xzf gsl-${gsl_ver}.tar.gz
cd gsl-${gsl_ver}
./configure --prefix="${pkg_install_dir}" \
--libdir="${pkg_install_dir}/lib" \
--enable-shared \
--enable-static > configure.log 2>&1
make -j $NPROCS > make.log 2>&1
make -j $NPROCS install > install.log 2>&1
cd ..
touch "${install_lock_file}"
fi
GSL_CFLAGS="-I'${pkg_install_dir}/include'"
GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding gsl from system paths ===================="
check_command pkg-config --modversion gsl
add_include_from_paths GSL_CFLAGS "gsl.h" $INCLUDE_PATHS
add_lib_from_paths GSL_LDFLAGS "libgsl.*" $LIB_PATHS
;;
__DONTUSE__)
;;
*)
echo "==================== Linking gsl to user paths ===================="
pkg_install_dir="$with_gsl"
check_dir "$pkg_install_dir/lib"
check_dir "$pkg_install_dir/lib64"
check_dir "$pkg_install_dir/include"
GSL_CFLAGS="-I'${pkg_install_dir}/include'"
GSL_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
esac
if [ "$with_gsl" != "__DONTUSE__" ] ; then
GSL_LIBS="-lgsl -lgslcblas"
if [ "$with_gsl" != "__SYSTEM__" ] ; then
cat << EOF > "${BUILDDIR}/setup_gsl"
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"
prepend_path CPATH "$pkg_install_dir/include"
EOF
fi
cat << EOF > "${BUILDDIR}/setup_gsl"
export GSL_CFLAGS="${GSL_CFLAGS}"
export GSL_LDFLAGS="${GSL_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(IF_OMP(-D__GSL|)|)"
export CP_CFLAGS="\${CP_CFLAGS} ${GSL_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${GSL_LDFLAGS}"
##########################################################
#
# I only include the library when SIRIUS is activated
# which depends explicitly on MPI and OMP
#
##########################################################
export CP_LIBS="IF_MPI(IF_OMP(${GSL_LIBS}|)|) \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_gsl" >> $SETUPFILE
fi
cd "${ROOTDIR}"

View file

@ -0,0 +1,83 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
hdf5_ver=${hdf5_ver:-1.10.4}
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
with_hdf5=${1:-__INSTALL__}
[ -f "${BUILDDIR}/setup_hdf5" ] && rm "${BUILDDIR}/setup_hdf5"
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_hdf5" in
__INSTALL__)
echo "==================== Installing hdf5 ===================="
pkg_install_dir="${INSTALLDIR}/hdf5-${hdf5_ver}"
install_lock_file="$pkg_install_dir/install_successful"
if [ -f "${install_lock_file}" ] ; then
echo "hdf5-${hdf5_ver} is already installed, skipping it."
else
if [ -f hdf5-${hdf5_ver}.tar.bz2 ] ; then
echo "hdf5-${hdf5_ver}.tar.bz2 is found"
else
download_pkg -o hdf5-1.10.4.tar.bz2 \
"https://www.hdfgroup.org/package/source-bzip-2/?wpdmdl=13047&refresh=5bc5a5e3a0aed1539679715"
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d hdf5-${hdf5_ver} ] && rm -rf hdf5-${hdf5_ver}
tar xf hdf5-${hdf5_ver}.tar.bz2
cd hdf5-${hdf5_ver}
./configure --prefix="${pkg_install_dir}" --enable-shared > configure.log 2>&1
make -j $NPROCS > make.log 2>&1
make -j $NPROCS install > install.log 2>&1
cd ..
touch "${install_lock_file}"
fi
HDF5_CFLAGS="-I${pkg_install_dir}/include"
HDF5_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding hdf5 from system paths ===================="
check_command pkg-config --modversion hdf5
add_include_from_paths HDF5_CFLAGS "hdf5.h" $INCLUDE_PATHS
add_lib_from_paths HDF5_LDFLAGS "libhdf5.*" $LIB_PATHS
;;
__DONTUSE__)
;;
*)
;;
esac
if [ "$with_hdf5" != "__DONTUSE__" ] ; then
HDF5_LIBS="-lhdf5"
if [ "$with_hdf5" != "__SYSTEM__" ] ; then
cat <<EOF > "${BUILDDIR}/setup_hdf5"
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"
prepend_path CPATH "$pkg_install_dir/include"
EOF
fi
cat <<EOF > "${BUILDDIR}/setup_hdf5"
export HDF5_CFLAGS="${HDF5_CFLAGS}"
export HDF5_LDFLAGS="${HDF5_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(IF_OMP(-D__HDF5|)|)"
export CP_CFLAGS="\${CP_CFLAGS} ${HDF5_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${HDF5_LDFLAGS}"
####################################################
#
# inlcude hdf5 only if sirius is activated and build
# depends them on mpi and omp
#
####################################################
export CP_LIBS="IF_MPI(IF_OMP(${HDF5_LIBS}|)|) \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_hdf5" >> $SETUPFILE
fi
cd "${ROOTDIR}"

View file

@ -0,0 +1,81 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
json_fortran_ver=${json_fortran_ver:-6.9.0}
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
with_json_fortran=${1:-__INSTALL__}
[ -f "${BUILDDIR}/setup_json_fortran" ] && rm -f "${BUILDDIR}/setup_json_fortram"
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_json_fortran" in
__INSTALL__)
echo "==================== Installing json_fortran ===================="
pkg_install_dir="${INSTALLDIR}/json_fortran-${json_fortran_ver}"
install_lock_file="$pkg_install_dir/install_successful"
if [ -f "${install_lock_file}" ] ; then
echo "json-fortran-${json_fortran_ver} is already installed, skipping it."
else
if [ -f json-fortran-${json_fortran_ver}.tar.gz ] ; then
echo "json-fortran-${json_fortran_ver}.tar.gz is found"
else
wget -O json-fortran-${json_fortran_ver}.tar.gz \
https://github.com/jacobwilliams/json-fortran/archive/6.9.0.tar.gz
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d json-fortran-${json_fortran_ver} ] && rm -rf josn-fortran-${json_fortran_ver}
tar -xzf json-fortran-${json_fortran_ver}.tar.gz
cd json-fortran-${json_fortran_ver}
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" -DUSE_GNU_INSTALL_CONVENTION=on -DSKIP_DOC_GEN=true -DCMAKE_INSTALL_LIBDIR=lib ..
make -j $NPROCS > make.log 2>&1
make -j $NPROCS install > install.log 2>&1
cd ../..
touch "${install_lock_file}"
fi
JSON_CFLAGS="-I'${pkg_install_dir}/include'"
JSON_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding json-fortran from system paths ===================="
add_include_from_paths JSON_CFLAGS "json_file_module.mod" $INCLUDE_PATHS
add_lib_from_paths JSON_LDFLAGS "libjsonfortran.*" $LIB_PATHS
;;
__DONTUSE__)
;;
*)
echo "==================== Linking json-fortran to user paths ===================="
pkg_install_dir="$with_json"
check_dir "$pkg_install_dir/lib"
check_dir "$pkg_install_dir/lib64"
check_dir "$pkg_install_dir/include"
JSON_CFLAGS="-I'${pkg_install_dir}/include'"
JSON_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
esac
if [ "$with_json_fortran" != "__DONTUSE__" ] ; then
JSON_LIBS="-ljsonfortran"
if [ "$with_json_fortran" != "__SYSTEM__" ] ; then
cat << EOF > "${BUILDDIR}/setup_json_fortran"
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"
prepend_path CPATH "$pkg_install_dir/include"
export JSON_CFLAGS="${JSON_CFLAGS}"
export JSON_LDFLAGS="${JSON_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} -D__JSON"
export CP_CFLAGS="\${CP_CFLAGS} ${JSON_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${JSON_LDFLAGS}"
export CP_LIBS="${JSON_LIBS} \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_json_fortran" >> $SETUPFILE
fi
fi
cd "${ROOTDIR}"

View file

@ -0,0 +1,221 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
sirius_ver=${sirius_ver:-5.8.3}
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
with_sirius=${1:-__INSTALL__}
if [ $MPI_MODE = no ] ; then
if [ "$ENABLE_OMP" = "__FALSE__"] ; then
report_warning $LINENO "MPI is disabled, skipping sirius installation"
cat <<EOF > "${BUILDDIR}/setup_sirius"
with_sirius="__FALSE__"
EOF
exit 0
fi
fi
[ -f "${BUILDDIR}/setup_sirius" ] && rm "${BUILDDIR}/setup_sirius"
SIRIUS_CFLAGS=''
SIRIUS_LDFLAGS=''
SIRIUS_LIBS=''
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_sirius" in
__INSTALL__)
echo "==================== Installing SIRIUS ========================================="
echo " "
echo " note that this package depends on gsl, libspg, elpa, scalapack, json-fortran "
echo " hdf5 and libxc. this package can not work without these libraries dependencies "
echo " activated. "
echo " "
echo "================================================================================"
require_env FFTW_LDFLAGS
require_env FFTW_LIBS
require_env FFTW_CFLAGS
require_env ELPA_LDFLAGS
require_env ELPA_LIBS
require_env ELPHA_CFLAGS
require_env GSL_LDFLAGS
require_env GSL_CFLAGS
require_env GSL_LIBS
require_env MATH_LIBS
require_env MPI_LDFLAGS
require_env MPI_LIBS
require_env SCALAPACK_LDFLAGS
require_env SCALAPACK_CFLAGS
require_env SCALAPACK_LIBS
require_env LIBXC_LIBS
require_env LIBXC_CFLAGS
require_env LIBXC_LDFLAGS
require_env SPGLIB_LIBS
require_env SPGLIB_CFLAGS
require_env SPGLIB_LDFLAGS
require_env HDF5_LIBS
require_env HDF5_CFLAGS
require_env HDF5_LDFLAGS
pkg_install_dir="${INSTALLDIR}/sirius-${sirius_ver}"
install_lock_file="${pkg_install_dir}/install_successful"
if [ -f "${install_lock_file}" ] ; then
echo "sirius_dist-${sirius_ver} is already installed, skipping it."
else
if [ -f SIRIUS-${sirius_ver}.tar.gz ] ; then
echo "sirius_v${sirius_ver}.tar.gz is found"
else
download_pkg -o SIRIUS-${sirius_ver}.tar.gz \
https://github.com/electronic-structure/SIRIUS/archive/v${sirius_ver}.tar.gz
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d sirius-${sirius_ver} ] && rm -rf sirius-${sirius_ver}
tar -xzf SIRIUS-${sirius_ver}.tar.gz
cd SIRIUS-${sirius_ver}
# rm -fr build
# mkdir build
# cd build
# if [ "$ENABLE_CUDA" = __TRUE__ ] ; then
# cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} ..
# else
# cmake -DCMAKE_INSTALL_PREFIX=${pkg_install_dir} -DUSE_CUDA=off ..
# fi
# make
# make install
# cd ../..
#touch "${install_lock_file}"
cat <<EOF > make.inc
CXX = \$(MPICXX)
BASIC_CXX_OPT = -O3 -DNDEBUG -mtune=native -ftree-loop-vectorize ${MATH_CFLAGS}
CXX_OPT = \$(BASIC_CXX_OPT) -fopenmp -std=c++11 -D__SCALAPACK -D__ELPA
EOF
if [ "$ENABLE_CUDA" = __TRUE__ ] ; then
cat <<EOF >> make.inc
CXX_OPT := \$(CXX_OPT) -D__GPU -I${CUDA_SDK}/include -I${CUDA_ROOT}/include
NVCC=nvcc -O3 -arch=sm_60
LIBS := ${CUDA_LIBS}
CXX_OPT := \$(CXX_OPT) ${CUDA_CFLAGS}
EOF
fi
cat <<EOF >> make.inc
CXX_OPT := \$(CXX_OPT) -I${PWD}/src
CXX_OPT := \$(CXX_OPT) -I${PWD}/src/SDDK
CXX_OPT := \$(CXX_OPT) ${ELPA_CFLAGS}
CXX_OPT := \$(CXX_OPT) ${GSL_CFLAGS}
CXX_OPT := \$(CXX_OPT) ${SPGLIB_CFLAGS}
CXX_OPT := \$(CXX_OPT) ${HDF5_CFLAGS}
MPI_FC = ${MPIFC}
MPI_FC_OPT = -g -O2 -fopenmp -cpp
LIBS := ${LIBXC_LDFLAGS} ${FFTW_LDFLAGS} ${ELPA_LDFLAGS} ${SCALAPACK_LDFLAGS} ${GSL_LDFLAGS} ${SPG_LDFLAGS}
LIBS := \$(LIBS) ${SPGLIB_LIBS} ${FFTW_LIBS} ${GSL_LIBS} ${SCALAPACK_LIBS} ${ELPA_LIBS}
EOF
# this a hack needs to be fixed permanently
sed -i -e "s/: log/: /g" src/Makefile
cat > src/version.hpp <<EOF
#ifndef __VERSION_H__
#define __VERSION_H__
const char* const git_hash = "6ec392682d7ffda6090ee3124d6841adc6a5fd0d";
const char* const git_branchname = "heads/develop";
const char* const build_date = "Thu, 23 Aug 2018 13:58:38";
#endif
EOF
# a fix to indicate that spglib has changed the directory where the header file is located
sed -i -e "s/spglib\///g" src/Unit_cell/unit_cell_symmetry.hpp
# small patch to fix an error in sirius. It is already fixed in the develop branch. just waiting for a new release
sed -i -e "s/mpi_fin = call_mpi_fin/mpi_fin = *call_mpi_fin/g" src/sirius_api.cpp
sed -i -e "s/device_reset = call_device_reset/device_reset = *call_device_reset/g" src/sirius_api.cpp
sed -i -e "s/fftw_fin = call_fftw_fin/fftw_fin = *call_fftw_fin/g" src/sirius_api.cpp
make -C src
install -v -d ${pkg_install_dir}/include
install -v -d ${pkg_install_dir}/lib
cp -Rv src/* ${pkg_install_dir}/include
rm -f ${pkg_install_dir}/include/*.f90
#rm -f ${pkg_install_dir}/include/*.mod
rm -f ${pkg_install_dir}/include/*.o
install -v -m 644 src/*.a ${pkg_install_dir}/lib
install -v -m 644 src/*.mod ${pkg_install_dir}/lib
fi
SIRIUS_CFLAGS="-I'${pkg_install_dir}/include'"
SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
touch "${install_lock_file}"
;;
__SYSTEM__)
echo "==================== Finding SIRIUS_DIST from system paths ===================="
echo "Warning very unlickely you have this package installed by default "
echo " "
echo " note that this package depends on gsl, libspg, elpa, scalapack, json-fortran "
echo " hdf5 and libxc. this package can not work without these libraries dependencies "
echo " activated. "
echo " "
echo "==============================================================================="
require_env FFTW_LDFLAGS
require_env FFTW_LIBS
require_env FFTW_CFLAGS
require_env ELPA_LDFLAGS
require_env ELPA_LIBS
require_env ELPA_CFLAGS
require_env GSL_LDFLAGS
require_env GSL_CFLAGS
require_env GSL_LIBS
require_env MATH_LIBS
require_env MPI_LDFLAGS
require_env MPI_LIBS
require_env SCALAPACK_LDFLAGS
require_env SCALAPACK_CFLAGS
require_env SCALAPACK_LIBS
require_env LIBXC_LIBS
require_env LIBXC_CFLAGS
require_env LIBXC_LDFLAGS
require_env SPGLIB_LIBS
require_env SPGLIB_CFLAGS
require_env SPGLIB_LDFLAGS
require_env HDF5_LIBS
require_env HDF5_CFLAGS
require_env HDF5_LDFLAGS
check_lib -lsirius "sirius"
add_include_from_paths SIRIUS_CFLAGS "sirius*" $INCLUDE_PATHS
add_lib_from_paths SIRIUS_LDFLAGS "libsirius.*" $LIB_PATHS
;;
__DONTUSE__)
;;
*)
echo "==================== Linking SIRIUS_Dist to user paths ===================="
pkg_install_dir="$with_sirius"
check_dir "${pkg_install_dir}/lib"
check_dir "${pkg_install_dir}/include"
;;
esac
if [ "$with_sirius" != "__DONTUSE__" ] ; then
SIRIUS_LIBS="-lsirius_f -lsirius"
if [ "$with_sirius" != "__SYSTEM__" ] ; then
cat <<EOF > "${BUILDDIR}/setup_sirius"
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"
prepend_path CPATH "$pkg_install_dir/include"
EOF
cat "${BUILDDIR}/setup_sirius" >> $SETUPFILE
fi
cat <<EOF >> "${BUILDDIR}/setup_sirius"
export SIRIUS_CFLAGS="-I'${pkg_install_dir}/include'"
export SIRIUS_FFLAGS="-I'${pkg_install_dir}/include'"
export SIRIUS_LDFLAGS="${SIRIUS_LDFLAGS}"
export SIRIUS_LIBS="${SIRIUS_LIBS}"
export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(IF_OMP(-D__SIRIUS|)|)"
export CP_CFLAGS="\${CP_CFLAGS} IF_MPI(IF_OMP(-I'${pkg_install_dir}/include'|)|)"
export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(IF_OMP(${SIRIUS_LDFLAGS}|)|)"
export CP_LIBS="IF_MPI(IF_OMP(${SIRIUS_LIBS}|)|) \${CP_LIBS}"
EOF
fi
cd "${ROOTDIR}"

View file

@ -0,0 +1,92 @@
#!/bin/bash -e
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"
spglib_ver=${spglib_ver:-1.10.4}
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
with_spglib=${1:-__INSTALL__}
[ -f "${BUILDDIR}/setup_spglib" ] && rm "${BUILDDIR}/setup_spglib"
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_spglib" in
__INSTALL__)
echo "==================== Installing spglib ===================="
pkg_install_dir="${INSTALLDIR}/spglib-${spglib_ver}"
install_lock_file="$pkg_install_dir/install_successful"
if [ -f "${install_lock_file}" ] ; then
echo "spglib-${spglib_ver} is already installed, skipping it."
else
if [ -f spglib-${spglib_ver}.tar.gz ] ; then
echo "spglib-${spglib_ver}.tar.gz is found"
else
download_pkg -o spglib-1.10.4.tar.gz \
https://github.com/atztogo/spglib/archive/v1.10.4.tar.gz
fi
echo "Installing from scratch into ${pkg_install_dir}"
[ -d spglib-${spglib_ver} ] && rm -rf spglib-${spglib_ver}
tar -xzf spglib-${spglib_ver}.tar.gz
cd spglib-${spglib_ver}
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" -DCMAKE_BUILD_TYPE=Release .. > configure.log 2>&1
make > make.log 2>&1
make install >> make.log 2>&1
cd ..
touch "${install_lock_file}"
fi
SPGLIB_CFLAGS="-I${pkg_install_dir}/include"
SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
__SYSTEM__)
echo "==================== Finding spglib from system paths ===================="
check_command pkg-config --modversion spglib
add_include_from_paths SPGLIB_CFLAGS "spglib.h" $INCLUDE_PATHS
add_lib_from_paths SPGLIB_LDFLAGS "libspglib.*" $LIB_PATHS
;;
__DONTUSE__)
;;
*)
echo "==================== Linking spglib to user paths ===================="
pkg_install_dir="$with_spglib"
check_dir "$pkg_install_dir/lib"
check_dir "$pkg_install_dir/lib64"
check_dir "$pkg_install_dir/include"
SPGLIB_CFLAGS="-I'${pkg_install_dir}/include'"
SPGLIB_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath='${pkg_install_dir}/lib'"
;;
esac
if [ "$with_spglib" != "__DONTUSE__" ] ; then
SPGLIB_LIBS="-lsymspg"
if [ "$with_spglib" != "__SYSTEM__" ] ; then
cat <<EOF > "${BUILDDIR}/setup_spglib"
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"
prepend_path CPATH "$pkg_install_dir/include"
EOF
fi
cat <<EOF > "${BUILDDIR}/setup_spglib"
export SPGLIB_CFLAGS="-I$pkg_install_dir/include ${SPGLIB_CFLAGS}"
export SPGLIB_LDFLAGS="${SPGLIB_LDFLAGS}"
export CP_DFLAGS="\${CP_DFLAGS} -D__SPGLIB"
export CP_CFLAGS="\${CP_CFLAGS} ${SPGLIB_CFLAGS}"
export CP_LDFLAGS="\${CP_LDFLAGS} ${SPGLIB_LDFLAGS}"
###################################################################
#
# NB : spglib is only used and compiled when sirius is activated.
# So right now I only include the library when I detect MPI and OMP
#
###################################################################
export CP_LIBS="IF_MPI(IF_OMP(${SPGLIB_LIBS}|)|) \${CP_LIBS}"
EOF
cat "${BUILDDIR}/setup_spglib" >> $SETUPFILE
fi
cd "${ROOTDIR}"