Skip to content

Commit

Permalink
Merge branch 'release-0.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Jul 6, 2023
2 parents 6de24f2 + be9299a commit 054c961
Show file tree
Hide file tree
Showing 158 changed files with 29,189 additions and 5,781 deletions.
194 changes: 194 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: CI
on: [push, pull_request]

env:
CI: "ON"
HOMEBREW_NO_ANALYTICS: "ON"
HOMEBREW_NO_AUTO_UPDATE: "ON"
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
HOMEBREW_NO_GITHUB_API: "ON"
HOMEBREW_NO_INSTALL_CLEANUP: "ON"
BUILD_DIR: _build
INSTALL_DIR: _install

jobs:
gcc-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
config: [Debug]
version: [11]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.x'

# Note: xcode version 14.0 (default on macos-latest @ 2022-11-23) fails to link gfortran compiled
# code. Therefore, 14.1 is selected below (which seems to be installed.)
- name: Install GCC (OSX)
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install gcc@${{ matrix.version }} openblas
ln -s /usr/local/bin/gfortran-${{ matrix.version }} /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-${{ matrix.version }} /usr/local/bin/gcc
ln -s /usr/local/bin/g++-${{ matrix.version }} /usr/local/bin/g++
echo "PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig" >> $GITHUB_ENV
xcversion select 14.1
- name: Install GCC (Linux)
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-${{ matrix.version}} gfortran-${{ matrix.version }}
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.version }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.version }}
- name: Set Compiler (Linux)
if: contains(matrix.os, 'ubuntu')
run: |
echo "FC=gfortran" >> $GITHUB_ENV
echo "CC=gcc" >> $GITHUB_ENV
- name: Set Compiler (OSX)
if: contains(matrix.os, 'macos')
run: |
echo "FC=gfortran-${{ matrix.version }}" >> $GITHUB_ENV
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
- name: Compile and Install libXC
run: |
git clone https://gitlab.com/libxc/libxc.git
cd libxc/
git checkout 6.1.0
FC=gfortran CC=gcc cmake -H. -B ${BUILD_DIR} -DENABLE_FORTRAN=True -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR}
cd ${BUILD_DIR}
make -j
make install
cd ../../
- name: Set libXC search path
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
echo "CMAKE_PREFIX_PATH=./libxc/${BUILD_DIR}/${INSTALL_DIR}/" >> $GITHUB_ENV
- name: Install requirements (pip)
run: |
pip3 install --upgrade pip
pip3 install wheel
pip3 install cmake fypp numpy scipy
- name: Configure build
run: |
cmake -B ${BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} -DCMAKE_BUILD_TYPE=Debug .
- name: Build project
run: cmake --build ${BUILD_DIR}

- name: Run regression tests
run: |
pushd ${BUILD_DIR}
ctest -j 2 --output-on-failure
popd
- name: Install project
run: |
cmake --install ${BUILD_DIR}
intel-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
fc: [ifort]
cc: [icc]
env:
FC: ${{ matrix.fc }}
CC: ${{ matrix.cc }}
APT_PACKAGES: >-
intel-oneapi-compiler-fortran
intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
intel-oneapi-mkl
intel-oneapi-mkl-devel
CMAKE_OPTIONS: >-
-DCMAKE_BUILD_TYPE=RelWithDebInfo
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Add Intel repository
if: contains(matrix.os, 'ubuntu')
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: Install Intel oneAPI compiler
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install ${APT_PACKAGES}
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Compile and install libXC
if: contains(matrix.os, 'ubuntu')
run: |
git clone https://gitlab.com/libxc/libxc.git
cd libxc/
git checkout 6.1.0
cmake -H. -B ${BUILD_DIR} -DENABLE_FORTRAN=True -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR}
cd ${BUILD_DIR}
make -j
make install
cd ../../
- name: Set libXC search path
if: contains(matrix.os, 'ubuntu')
run: |
echo "CMAKE_PREFIX_PATH=./libxc/${BUILD_DIR}/${INSTALL_DIR}/" >> $GITHUB_ENV
- name: Install requirements (pip)
run: |
pip3 install --upgrade pip
pip3 install wheel
pip3 install cmake fypp numpy scipy
- name: Set extra CMake flags (Linux)
run: |
echo "CMAKE_OPTIONS=${CMAKE_OPTIONS}" >> $GITHUB_ENV
- name: Configure build
run: |
cmake -B ${BUILD_DIR} -DCMAKE_INSTALL_PREFIX=${PWD}/${BUILD_DIR}/${INSTALL_DIR} .
- name: Build project
run: cmake --build ${BUILD_DIR}

- name: Run regression tests
run: |
pushd ${BUILD_DIR}
ctest -j 2 --output-on-failure
popd
- name: Install project
run: |
cmake --install ${BUILD_DIR}
58 changes: 47 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
cmake_minimum_required(VERSION 3.16)

project(SkProgs VERSION 22.1 LANGUAGES Fortran)
project(SkProgs VERSION 0.2 LANGUAGES Fortran)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
include(SkProgsUtils)

skprogs_ensure_out_of_source_build()
skprogs_load_build_settings()
skprogs_setup_build_type()
skprogs_load_toolchain_settings()
skprogs_setup_global_compiler_flags()

include(GNUInstallDirs)

Expand All @@ -20,33 +29,61 @@ endif()
#################### External dependencies ####################

find_package(Libxc QUIET)

if (Libxc_FOUND AND Libxc_VERSION VERSION_LESS "6.0.0")
message(FATAL_ERROR "SkProgs requires libXC version >=6.0.0 to work properly.")
endif()

if (NOT Libxc_FOUND)
message(STATUS "Libxc: No CMake export file found, trying to find with pkg-config")
find_package(PkgConfig QUIET)
pkg_check_modules(pc_libxc REQUIRED libxc)
pkg_check_modules(pc_libxcf90 REQUIRED libxcf90)
pkg_check_modules(pc_libxc REQUIRED libxc>=6.0.0)
pkg_check_modules(pc_libxcf03 REQUIRED libxcf03>=6.0.0)
add_library(Libxc::xc INTERFACE IMPORTED)
target_link_libraries(Libxc::xc INTERFACE ${pc_libxc_LINK_LIBRARIES})
target_include_directories(Libxc::xc INTERFACE ${pc_libxc_INCLUDE_DIRS})
add_library(Libxc::xcf90 INTERFACE IMPORTED)
target_link_libraries(Libxc::xcf90 INTERFACE ${pc_libxcf90_LINK_LIBRARIES})
target_include_directories(Libxc::xc INTERFACE ${pc_libxcf90_INCLUDE_DIRS})
elseif(NOT TARGET Libxc::xcf90)
message(FATAL_ERROR "Libxc CMake export file found, but target Libxc::xcf90 is missing "
add_library(Libxc::xcf03 INTERFACE IMPORTED)
target_link_libraries(Libxc::xcf03 INTERFACE ${pc_libxcf03_LINK_LIBRARIES})
target_include_directories(Libxc::xc INTERFACE ${pc_libxcf03_INCLUDE_DIRS})
elseif(NOT TARGET Libxc::xcf03)
message(FATAL_ERROR "Libxc CMake export file found, but target Libxc::xcf03 is missing "
"(maybe Libxc was built without the -DENABLE_FORTRAN=True switch?")
endif()

find_package(CustomBlas REQUIRED)
find_package(CustomLapack REQUIRED)

find_package(Python3 COMPONENTS Interpreter REQUIRED)
set(PYTHON_INTERPRETER "${Python3_EXECUTABLE}")
set(PYTHON_VERSION_MAJOR_MINOR "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")

#################### Preprocessor details #####################

set(FYPP "${PROJECT_SOURCE_DIR}/external/fypp/bin/fypp" CACHE FILEPATH "Fypp preprocessor")
skprogs_add_fypp_defines(FYPP_FLAGS)

set(FYPP_CONFIG_FLAGS "${FYPP_FLAGS}")
# Make sure, the line-marker option is not set
list(REMOVE_ITEM FYPP_CONFIG_FLAGS "-n")
set(FYPP_BUILD_FLAGS "${FYPP_FLAGS}" "$<IF:$<CONFIG:Debug>,-DDEBUG=1,-DDEBUG=0>")

set(PYTHON_INTERPRETER "python3" CACHE STRING
"Python interpreter to use for installing and test python components")

#################### Add source components ####################

add_subdirectory(common/lib)
add_subdirectory(common)
add_subdirectory(slateratom)
add_subdirectory(sktwocnt)
add_subdirectory(sktools)

#################### Extra install ####################
########################### Testing ###########################

string(CONFIGURE "${TEST_RUNNER_TEMPLATE}" TEST_RUNNER)
enable_testing()
add_subdirectory(test)

######################## Extra install ########################

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/utils/export/skprogs-activate.sh.in
Expand All @@ -56,4 +93,3 @@ configure_file(
install(
PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/skprogs-activate.sh"
DESTINATION "${CMAKE_INSTALL_BINDIR}/")

61 changes: 52 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,29 @@ risk!
Installing
==========

|build status|

Prerequisites
-------------

* Fortran 2003 compiler
* Fortran 2003 compliant compiler

* CMake (>= 3.16)

* Python3
* Python3 (>= 3.2)

* LAPACK/BLAS libraries (or compatible equivalents)

* libXC library with f03 interface (version >=6.0.0)

* LibXC library with f90 interface (tested with version 4.3.4, version 5.x does
not work due to inteface changes in LibXC)


Building the code
-----------------

Follow the usual CMake build workflow:

* Configure the project, specify your compiler (e.g. ``gfortran``), the install
location (e.g. ``$HOME/opt/skprogs``) and the build directory
* Configure the project, specify your compilers (e.g. ``gfortran``),
the install location (e.g. ``$HOME/opt/skprogs``) and the build directory
(e.g. ``_build``)::

FC=gfortran cmake -DCMAKE_INSTALL_PREFIX=$HOME/opt/skprogs -B _build .
Expand All @@ -44,18 +47,54 @@ Follow the usual CMake build workflow:
with autotools) in order to guide the library search::

CMAKE_PREFIX_PATH=YOUR_LIBXC_INSTALL_FOLDER FC=gfortan cmake [...]

PKG_CONFIG_PATH=FOLDER_WITH_LIBXC_PC_FILES FC=gfortran cmake [...]

* If the configuration was successful, build the code ::

cmake --build _build -- -j

* If the build was successful, install the code ::
* After successful build, you should test the code by running ::

pushd _build
ctest -j
popd

* If the tests were successful, install the package via ::

cmake --install _build


Advanced build configuration
============================

Controlling the toolchain file selection
----------------------------------------

You can override the toolchain file, and select a different provided case,
passing the ``-DTOOLCHAIN`` option with the relevant name, e.g.::

-DTOOLCHAIN=gnu

or ::

-DTOOLCHAIN=intel

or by setting the toolchain name in the ``SKPROGS_TOOLCHAIN`` environment
variable. If you want to load an external toolchain file instead of one from the
source tree, you can specify the file path with the ``-DTOOLCHAIN_FILE`` option
::

-DTOOLCHAIN_FILE=/some/path/myintel.cmake

or with the ``SKPROGS_TOOLCHAIN_FILE`` environment variable.

Similarly, you can also use an alternative build config file instead of
`config.cmake` in the source tree by specifying it with the
``-DBUILD_CONFIG_FILE`` option or by defining the ``SKPROGS_BUILD_CONFIG_FILE``
environment variable.


Generating SK-files
===================

Expand Down Expand Up @@ -94,3 +133,7 @@ General Public License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version. See the files
`COPYING <COPYING>`_ and `COPYING.LESSER <COPYING.LESSER>`_ for the detailed
licensing conditions.


.. |build status| image:: https://img.shields.io/github/actions/workflow/status/dftbplus/skprogs/build.yml
:target: https://github.com/dftbplus/skprogs/actions/
Loading

0 comments on commit 054c961

Please sign in to comment.