Skip to content

Commit

Permalink
Merge branch 'stage-1.2' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Dec 9, 2021
2 parents 8c959ff + d35cdca commit 8200a5e
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 11 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ Change Log
Notable project changes in various releases.


1.2
===

Added
-----

* Support for building with meson

* Support to build with GNU Fortran >= 11


1.1
===

Expand All @@ -30,5 +41,5 @@ Changed

* The Fypp-preprocessor is not shipped with MpiFx but is an external
requirement.

* Name convention for processes (master -> lead).
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ include(MpiFxUtils)

include(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)

project(MpiFx VERSION 1.1 LANGUAGES Fortran)
project(MpiFx LANGUAGES Fortran)

# Get version number from file
file (STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PROJECT_VERSION)
string(REPLACE "." ";" VERSION_LIST ${PROJECT_VERSION})
list(GET VERSION_LIST 0 PROJECT_VERSION_MAJOR)
list(GET VERSION_LIST 1 PROJECT_VERSION_MINOR)
list(GET VERSION_LIST 2 PROJECT_VERSION_PATCH)

setup_build_type()

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2.0
32 changes: 32 additions & 0 deletions cmake/install-mod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python
# SPDX-Identifier: BSD-2-Clause

from os import environ, listdir, makedirs
from os.path import join, isdir, exists
from sys import argv
from shutil import copy

if "MESON_INSTALL_DESTDIR_PREFIX" in environ:
install_dir = environ["MESON_INSTALL_DESTDIR_PREFIX"]
else:
install_dir = environ["MESON_INSTALL_PREFIX"]

include_dir = argv[1] if len(argv) > 1 else "include"
build_dir = argv[2] if len(argv) > 2 else environ["MESON_BUILD_ROOT"]
module_dir = join(install_dir, include_dir)

modules = []
for d in listdir(build_dir):
bd = join(build_dir, d)
if isdir(bd):
for f in listdir(bd):
if f.endswith(".mod"):
modules.append(join(bd, f))

if not exists(module_dir):
makedirs(module_dir)

for mod in modules:
print("Installing", mod, "to", module_dir)
copy(mod, module_dir)

2 changes: 1 addition & 1 deletion doc/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PROJECT_NAME = "MpiFx"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = "1.1"
PROJECT_NUMBER = "1.2.0"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
# built documents.
#
# The short X.Y version.
version = '1.1'
version = '1.2'

# The full version, including alpha/beta/rc tags.
release = '1.1'
release = '1.2.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
14 changes: 13 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ set(sources-fpp

fypp_preprocess("${sources-fpp}" sources-f90)

# NAG compiler won't compile these files without the '-mismatch' option
# Some MPI frameworks (e.g. MPICH) do not provide all possible argument
# combinations explicitely in their mpi module. Consequently, compilers
# checking for different signatures for calls of the same subroutine
# may refuse to compile the libray.

# Allow argument mismatch for the NAG compiler
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "NAG")
set_source_files_properties(SOURCE ${sources-f90} PROPERTY COMPILE_FLAGS -mismatch)
endif()

# Allow argument mismatch for recent GNU compilers
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_GREATER_EQUAL "11")
set_source_files_properties(SOURCE ${sources-f90} PROPERTY COMPILE_FLAGS -fallow-argument-mismatch)
endif()
endif()

add_library(mpifx ${sources-f90})

target_link_libraries(mpifx PRIVATE MPI::MPI_Fortran)
Expand Down
63 changes: 63 additions & 0 deletions lib/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# SPDX-Identifier: BSD-2-Clause

sources_fpp = files(
'module.fpp',
'mpifx_abort.fpp',
'mpifx_allgather.fpp',
'mpifx_allgatherv.fpp',
'mpifx_allreduce.fpp',
'mpifx_barrier.fpp',
'mpifx_bcast.fpp',
'mpifx_comm.fpp',
'mpifx_common.fpp',
'mpifx_constants.fpp',
'mpifx_finalize.fpp',
'mpifx_gather.fpp',
'mpifx_gatherv.fpp',
'mpifx_get_processor_name.fpp',
'mpifx_helper.fpp',
'mpifx_init.fpp',
'mpifx_recv.fpp',
'mpifx_reduce.fpp',
'mpifx_scatter.fpp',
'mpifx_scatterv.fpp',
'mpifx_send.fpp',
)
sources_f90 = []
foreach src : sources_fpp
sources_f90 += configure_file(
command: ['fypp', '@INPUT@', '@OUTPUT@'],
input: src,
output: '@BASENAME@.f90',
)
endforeach

mpifx_lib = library(
meson.project_name(),
sources: sources_f90,
dependencies: mpi_dep,
install: install,
)

mpifx_inc = mpifx_lib.private_dir_include()
mpifx_dep = declare_dependency(
link_with: mpifx_lib,
include_directories: mpifx_inc,
dependencies: mpi_dep,
)

if install
module_id = meson.project_name()
meson.add_install_script(
'../cmake/install-mod.py',
get_option('includedir') / module_id,
meson.current_build_dir(),
)

pkg = import('pkgconfig')
pkg.generate(
mpifx_lib,
description: 'Modern Fortran Interface for MPI',
subdirs: ['', module_id],
)
endif
2 changes: 1 addition & 1 deletion lib/mpifx_comm.fpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!> Contains the extended MPI communicator.
module mpifx_comm_module
use mpi, only : MPI_COMM_WORLD, mpi_comm_size, mpi_comm_rank, mpi_comm_split, mpi_comm_free
use mpi
use mpifx_helper_module
implicit none
private
Expand Down
32 changes: 32 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-Identifier: BSD-2-Clause

project(
'mpifx',
'Fortran',
version: files('VERSION'),
license: 'BSD-2-Clause',
meson_version: '>=0.57.2',
default_options: [
'buildtype=debugoptimized',
'default_library=both',
],
)
install = not (meson.is_subproject() and get_option('default_library') == 'static')

# Prerequisites
mpi_dep = dependency('mpi', language: 'fortran')
fypp = find_program('fypp')

# Build instructions
subdir('lib')

mpifx_lic = files('LICENSE')

if install
install_data(
mpifx_lic,
install_dir: get_option('datadir')/'licenses'/meson.project_name()
)
endif

subdir('test')
22 changes: 22 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-Identifier: BSD-2-Clause

tests = [
'allgather',
'allgatherv',
'allreduce',
'bcast',
'comm_split',
'gather',
'gatherv',
'reduce',
'scatter',
'scatterv',
]

foreach t : tests
executable(
'test_@0@'.format(t),
sources: files('test_@0@.f90'.format(t)),
dependencies: mpifx_dep,
)
endforeach
5 changes: 1 addition & 4 deletions utils/srcmanip/set_version
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ _VERSION_PATTERN = r'\d+\.\d+(?:\.\d+)?(?:-\w+)?'

_FILES_AND_PATTERNS = [
#
('CMakeLists.txt',
r'project\(\s*MpiFx\s+VERSION\s+{}(\s+|\))'.format(_VERSION_PATTERN),
r'project(MpiFx VERSION {version}\1'),
#
('doc/doxygen/Doxyfile',
r'^PROJECT_NUMBER\s*=\s*([\'"]){}\1\s*$'.format(_VERSION_PATTERN),
'PROJECT_NUMBER = "{version}"\n'),
Expand All @@ -30,6 +26,7 @@ _FILES_AND_PATTERNS = [
('doc/sphinx/conf.py',
r'release\s*=\s*([\'"]){}\1'.format(_VERSION_PATTERN),
"release = '{version}'"),
('VERSION', _VERSION_PATTERN, '{version}')
]


Expand Down

0 comments on commit 8200a5e

Please sign in to comment.