diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d419ede..8ab0b0b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,12 @@ jobs: # Switch from openmpi to mpich, since installing openmpi-mpifort # from the conda-forge channel downgrades gfortran at the moment mpi: [nompi, mpich] + libxc: [6, 7] config: [Debug] + # Serial binary is tested with libxc 7 + exclude: + - mpi: nompi + libxc: 6 steps: - name: Checkout code @@ -63,36 +68,46 @@ jobs: - name: Install BLAS run: mamba install openblas libopenblas - - name: Install libxc + - name: Install libxc (6.2.2) + if: contains(matrix.libxc, '6') run: mamba install libxc=6.2.2 + - name: Install libxc (7.0.0) + if: contains(matrix.libxc, '7') + run: mamba install libxc=7.0.0 + - name: Set libxc search path run: echo "CMAKE_PREFIX_PATH=${CONDA_PREFIX}/" >> $GITHUB_ENV - name: Install requirements (conda) run: mamba install cmake fypp numpy scipy - - name: Configure build + - name: Configure build (-DTEST_MPI_PROCS=1) + if: contains(matrix.mpi, 'nompi') || contains(matrix.libxc, '6') + run: | + cmake -B ${BUILD_DIR} -DWITH_MPI=${WITH_MPI} \ + -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} \ + -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DTEST_MPI_PROCS=1 . + + - name: Configure build (-DTEST_MPI_PROCS=2) + if: "! contains(matrix.mpi, 'nompi') && ! contains(matrix.libxc, '6')" run: | cmake -B ${BUILD_DIR} -DWITH_MPI=${WITH_MPI} \ -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} \ - -DCMAKE_BUILD_TYPE=${{ matrix.config }} . + -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DTEST_MPI_PROCS=2 . - name: Build project run: cmake --build ${BUILD_DIR} - - name: Run regression tests + - name: Run regression tests (-j2) + if: contains(matrix.mpi, 'nompi') || contains(matrix.libxc, '6') run: | pushd ${BUILD_DIR} ctest -j2 --output-on-failure popd - - name: Configure build (TEST_MPI_PROCS=2) - if: contains(matrix.mpi, 'openmpi') || contains(matrix.mpi, 'mpich') - run: cmake -B ${BUILD_DIR} -DTEST_MPI_PROCS=2 . - - - name: Run regression tests (TEST_MPI_PROCS=2) - if: contains(matrix.mpi, 'openmpi') || contains(matrix.mpi, 'mpich') + - name: Run regression tests (-j1) + if: "! contains(matrix.mpi, 'nompi') && ! contains(matrix.libxc, '6')" run: | pushd ${BUILD_DIR} ctest -j1 --output-on-failure diff --git a/cmake/SkProgsUtils.cmake b/cmake/SkProgsUtils.cmake index d9f5dfdf..4b442d46 100644 --- a/cmake/SkProgsUtils.cmake +++ b/cmake/SkProgsUtils.cmake @@ -55,6 +55,8 @@ function (skprogs_add_fypp_defines fyppflags) list(APPEND _fyppflags -DWITH_MPI) endif() + list(APPEND _fyppflags -DLIBXC_VERSION_MAJOR="${Libxc_VERSION_MAJOR}") + set(${fyppflags} ${_fyppflags} PARENT_SCOPE) endfunction() diff --git a/common/include/common.fypp b/common/include/common.fypp index 17ad7d6a..e5ccc492 100644 --- a/common/include/common.fypp +++ b/common/include/common.fypp @@ -15,6 +15,7 @@ #:set DEBUG = getvar('DEBUG', 0) #:set WITH_ASSERT = defined('WITH_ASSERT') or DEBUG > 0 #:set WITH_MPI = defined('WITH_MPI') +#:set LIBXC_VERSION_MAJOR = getvar('LIBXC_VERSION_MAJOR') #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/sktwocnt/lib/twocnt.F90 b/sktwocnt/lib/twocnt.F90 index 44f5c63a..754efe74 100644 --- a/sktwocnt/lib/twocnt.F90 +++ b/sktwocnt/lib/twocnt.F90 @@ -30,10 +30,17 @@ module twocnt use, intrinsic :: iso_c_binding, only : c_size_t +#:if LIBXC_VERSION_MAJOR == 6 use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,& & xc_f03_gga_vxc, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,& & XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,& & XC_HYB_GGA_XC_CAMY_B3LYP, XC_UNPOLARIZED, xc_f03_func_set_ext_params +#:elif LIBXC_VERSION_MAJOR == 7 + use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_vxc,& + & xc_f03_gga_vxc, xc_f03_func_set_ext_params, XC_UNPOLARIZED + use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_C_PBE,& + & XC_GGA_X_B88, XC_GGA_C_LYP, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP +#:endif implicit none private diff --git a/slateratom/lib/CMakeLists.txt b/slateratom/lib/CMakeLists.txt index 1c47c778..03df19ba 100644 --- a/slateratom/lib/CMakeLists.txt +++ b/slateratom/lib/CMakeLists.txt @@ -25,7 +25,6 @@ set(sources-f90 output.f90 total_energy.f90 utilities.f90 - xcfunctionals.f90 zora_routines.f90) set(sources-fpp @@ -34,7 +33,8 @@ set(sources-fpp confinement.F90 input.F90 lapackroutines.F90 - simplemixer.F90) + simplemixer.F90 + xcfunctionals.F90) skprogs_preprocess("${FYPP}" "${fypp_flags}" "F90" "f90" "${sources-fpp}" sources-f90-preproc) diff --git a/slateratom/lib/xcfunctionals.f90 b/slateratom/lib/xcfunctionals.F90 similarity index 98% rename from slateratom/lib/xcfunctionals.f90 rename to slateratom/lib/xcfunctionals.F90 index cb20cd34..7f4904f6 100644 --- a/slateratom/lib/xcfunctionals.f90 +++ b/slateratom/lib/xcfunctionals.F90 @@ -1,3 +1,5 @@ +#:include 'common.fypp' + !> Module related to supported xc-functionals of the slateratom code. module xcfunctionals @@ -5,10 +7,18 @@ module xcfunctionals use common_accuracy, only : dp use common_constants, only : rec4pi use utilities, only : zeroOutCpotOfEmptyDensitySpinChannels +#:if LIBXC_VERSION_MAJOR == 6 use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,& & xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW,& & XC_GGA_X_PBE, XC_GGA_X_B88, XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP,& & XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE, XC_GGA_C_LYP, XC_POLARIZED +#:elif LIBXC_VERSION_MAJOR == 7 + use xc_f03_lib_m, only : xc_f03_func_t, xc_f03_func_init, xc_f03_func_end, xc_f03_lda_exc_vxc,& + & xc_f03_gga_exc_vxc, xc_f03_func_set_ext_params, XC_POLARIZED + use xc_f03_funcs_m, only : XC_LDA_X, XC_LDA_X_YUKAWA, XC_LDA_C_PW, XC_GGA_X_PBE, XC_GGA_X_B88,& + & XC_GGA_X_SFAT_PBE, XC_HYB_GGA_XC_B3LYP, XC_HYB_GGA_XC_CAMY_B3LYP, XC_GGA_C_PBE,& + & XC_GGA_C_LYP +#:endif implicit none private