-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
5,159 additions
and
998 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ | |
*.a | ||
*.mod | ||
make.arch | ||
|
||
doc/doxygen/_build | ||
_build | ||
_install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
os: linux | ||
dist: focal | ||
|
||
language: python | ||
python: 3.7 | ||
|
||
env: | ||
- BUILD_SHARED_LIBS=False | ||
- BUILD_SHARED_LIBS=True | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- cmake | ||
- gfortran | ||
- libblas-dev | ||
- liblapack-dev | ||
- libopenmpi-dev | ||
|
||
install: | ||
- pip install fypp | ||
|
||
script: | ||
- > | ||
FC=gfortran cmake -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} | ||
-DCMAKE_INSTALL_PREFIX=${PWD}/_install | ||
-B _build . | ||
&& cmake --build _build -- -j | ||
&& cmake --install _build | ||
- > | ||
CMAKE_PREFIX_PATH="${PWD}/_install:${CMAKE_PREFIX_PATH}" | ||
./test/integration/cmake/runtest.sh _build_cmake | ||
- > | ||
PKG_CONFIG_PATH="${PWD}/_install/lib/pkgconfig:${PKG_CONFIG_PATH}" | ||
FC=mpifort | ||
./test/integration/pkgconfig/runtest.sh _build_pkgconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
include(MpiFxUtils) | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake) | ||
|
||
project(MpiFx VERSION 0.1 LANGUAGES Fortran) | ||
|
||
setup_build_type() | ||
|
||
# | ||
# Prerequisites | ||
# | ||
find_package(MPI REQUIRED) | ||
find_program(FYPP fypp) | ||
if(NOT FYPP) | ||
message(FATAL_ERROR "Preprocessor fypp could not be found") | ||
endif() | ||
|
||
# | ||
# Build instructions | ||
# | ||
include(GNUInstallDirs) | ||
|
||
add_subdirectory(lib) | ||
if(NOT BUILD_EXPORTED_TARGETS_ONLY) | ||
add_subdirectory(test) | ||
endif() | ||
|
||
# | ||
# Installation | ||
# | ||
add_library(MpiFx INTERFACE) | ||
target_link_libraries(MpiFx INTERFACE mpifx) | ||
install(TARGETS MpiFx EXPORT mpifx-targets) | ||
|
||
install(EXPORT mpifx-targets | ||
FILE mpifx-targets.cmake | ||
NAMESPACE MpiFx:: | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mpifx") | ||
|
||
configure_package_config_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/utils/export/mpifx-config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/mpifx-config.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mpifx) | ||
|
||
write_basic_package_version_file( | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/mpifx-config-version.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion) | ||
|
||
install( | ||
FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/mpifx-config.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/mpifx-config-version.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mpifx) | ||
|
||
get_pkgconfig_params(PKGCONFIG_REQUIRES PKGCONFIG_LIBS PKGCONFIG_LIBS_PRIVATE PKGCONFIG_C_FLAGS) | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/utils/export/mpifx.pc.in | ||
${CMAKE_CURRENT_BINARY_DIR}/mpifx.pc @ONLY) | ||
install( | ||
FILES "${CMAKE_CURRENT_BINARY_DIR}/mpifx.pc" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,94 @@ | ||
MPIFX - Modern Fortran Interface for MPI | ||
======================================== | ||
**************************************** | ||
MpiFx - Modern Fortran Interface for MPI | ||
**************************************** | ||
|
||
The MPIFX project is devoted to create **modern Fortran interfaces** for | ||
the MPI library. | ||
The open source library `MpiFx <https://github.com/dftbplus/mpifx>`_ provides | ||
modern Fortran (Fortran 2003) wrappers around routines of the MPI library to | ||
make their use as simple as possible. Currently several data distribution | ||
routines are covered. | ||
|
||
It contains only a few routines for so far, but if those happen the ones | ||
you need, feel free to use them (MPIFX is licensed under the **simplified BSD | ||
license**). | ||
The documentation is included inside the repository, but is also available at | ||
`dftbplus.github.io <https://dftbplus.github.io/>`_. | ||
|
||
If your routine is not wrapped yet, you could wrap it yourself and contribute it | ||
to the project to enable to cover the target library sooner. | ||
|
||
Installation | ||
============ | ||
|
||
Prerequisites | ||
------------- | ||
|
||
* CMake (version >= 3.16) | ||
|
||
* Fortran 2003 compatible Fortran compiler | ||
|
||
* MPI-library and wrappers for your compiler | ||
|
||
* `Fypp preprocessor <https://github.com/aradi/fypp>`_ | ||
|
||
|
||
Building and installing the library | ||
----------------------------------- | ||
|
||
The library can be built and installed with the usual CMake-workflow:: | ||
|
||
FC=gfortran cmake -B _build -DCMAKE_INSTALL_PREFIX=$HOME/opt/mpifx | ||
cmake --build _build | ||
cmake --install _build | ||
|
||
You can influence the configuration via CMake-variables, which are listed in | ||
`config.cmake <config.cmake>`_. You can either modify the values directly there | ||
or pass them as command line options at the configuration phase, e.g.:: | ||
|
||
FC=ifort cmake -B _build -DBUILD_LIBRARY_ONLY=True | ||
|
||
Testing | ||
------- | ||
|
||
A few tests / usage examples can be found in the `test/` subdirectory. The | ||
compiled test programs will be in the `test/` subfolder of your build directory. | ||
|
||
|
||
Using the library | ||
================= | ||
|
||
CMake build | ||
----------- | ||
|
||
* Make sure to add the root folder of the installed library to the | ||
``CMAKE_PREFIX_PATH`` environment variable. | ||
|
||
* Use ``find_package()`` in `CMakeLists.txt` to locate the library and link | ||
``MpiFx::MpiFx`` to every target which relies directly on the library :: | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
project(TestMpiFx LANGUAGES Fortran) | ||
find_package(MpiFx REQUIRED) | ||
add_executable(test_mpifx test_mpifx.f90) | ||
target_link_libraries(test_mpifx MpiFx::MpiFx) | ||
|
||
|
||
Pkg-config build | ||
---------------- | ||
|
||
* Make sure to add the `lib/pkgconfig` folder of the installed library to the | ||
``PKG_CONFIG_PATH`` environment variable. | ||
|
||
* Query the include and library options needed for the build with the usual | ||
``pkg-config`` commands:: | ||
|
||
mpifort $(pkg-config --cflags mpifx) test_mpifx.f90 $(pkg-config --libs mpifx) | ||
|
||
Note, that neither ``-cflags`` or ``--libs`` return any options related to | ||
your MPI-framework nor is the MPI-framework specified as dependency in the | ||
pkg-config file. Use the MPI-wrapper of your compiler to compile and link your | ||
executable or pass the additional include and library options by hand. | ||
|
||
|
||
License | ||
======= | ||
|
||
MpiFx is licensed under the `2-Clause BSD License <LICENSE>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Register custom commands for processing source files with fypp (.fpp -> .f90) | ||
# | ||
# Args: | ||
# oldfiles [in]: List of files to preprocess (must have .fpp suffix) | ||
# newfiles [out]: List of preprocessed files (will have .f90 suffix). | ||
# | ||
function(fypp_preprocess oldfiles newfiles) | ||
|
||
set(_newfiles) | ||
foreach(oldfile IN LISTS oldfiles) | ||
string(REGEX REPLACE "\\.fpp" ".f90" newfile ${oldfile}) | ||
add_custom_command( | ||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${newfile} | ||
COMMAND ${FYPP} ${FYPP_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${oldfile} ${CMAKE_CURRENT_BINARY_DIR}/${newfile} | ||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${oldfile}) | ||
list(APPEND _newfiles ${CMAKE_CURRENT_BINARY_DIR}/${newfile}) | ||
endforeach() | ||
set(${newfiles} ${_newfiles} PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
|
||
# Returns the parameters needed to create a pkg-config export file | ||
# | ||
# Args: | ||
# pkgconfig_requires [out]: Value for the Requires field. | ||
# pkgconfig_libs [out]: Value for the Libs field. | ||
# pkgconfig_libs_private [out]: Value for the Libs.private field. | ||
# pkgconfig_c_flags [out]: Value for the cflags field. | ||
# pkgconfig_prefix [out]: Value for the installation prefix. | ||
# | ||
function(get_pkgconfig_params pkgconfig_requires pkgconfig_libs pkgconfig_libs_private | ||
pkgconfig_c_flags) | ||
|
||
set(_pkgconfig_requires) | ||
|
||
set(_pkgconfig_libs "-L${CMAKE_INSTALL_FULL_LIBDIR} -lmpifx") | ||
|
||
set(_pkgconfig_libs_private "${CMAKE_EXE_LINKER_FLAGS}") | ||
|
||
set(_pkgconfig_c_flags "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/${INSTALL_MODULEDIR}") | ||
|
||
set(${pkgconfig_requires} "${_pkgconfig_requires}" PARENT_SCOPE) | ||
set(${pkgconfig_libs} "${_pkgconfig_libs}" PARENT_SCOPE) | ||
set(${pkgconfig_libs_private} "${_pkgconfig_libs_private}" PARENT_SCOPE) | ||
set(${pkgconfig_c_flags} "${_pkgconfig_c_flags}" PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
|
||
# Sets up the build type. | ||
function (setup_build_type) | ||
set(default_build_type "RelWithDebInfo") | ||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Setting build type to ${default_build_type} as none was specified") | ||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Build type" FORCE) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Build options | ||
# | ||
|
||
# CMAKE_BUILD_TYPE is commented out in order to allow for multi-configuration builds. It will | ||
# automatically default to RelWithDebInfo if used in a single configuration build. Uncomment or | ||
# override it only if you want a non-default single configuration build. | ||
# | ||
#set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (Release|RelWithDebInfo|Debug|MinSizeRel)") | ||
|
||
# If set to True, only those public targets (typically the library) will be built, which are usually | ||
# exported via CMake export files. Otherwise all targets all built (default case). Set this option | ||
# to True, if you invoke this project as part of an other CMake project via the add_subdirectory() | ||
# command without the EXCLUDE_FROM_ALL option (e.g. if you want this project to install its targets | ||
# as part of the top projects installation process). | ||
# | ||
option(BUILD_EXPORTED_TARGETS_ONLY | ||
"Whether only exported targets (the library, but no tests) should be built" FALSE) | ||
|
||
option(BUILD_SHARED_LIBS "Whether the library should be a shared one" FALSE) | ||
|
||
# | ||
# Installation options | ||
# | ||
|
||
option(INSTALL_INCLUDE_FILES "Whether include / module files should be installed" TRUE) | ||
|
||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/_install" CACHE STRING | ||
"Directory to install the compiled code into") | ||
|
||
set(INSTALL_INCLUDEDIR "mpifx" CACHE PATH | ||
"Installation directory for header and include files (within standard include folder)") | ||
|
||
set(INSTALL_MODULEDIR "${INSTALL_INCLUDEDIR}/modfiles" CACHE PATH | ||
"Installation directory for Fortran module files (within standard include folder)") |
Oops, something went wrong.