From 41ef2c3f3f79505521e26bec18b90cc433fd1f36 Mon Sep 17 00:00:00 2001 From: Alessandro Pecchia Date: Thu, 9 Sep 2021 10:30:44 +0200 Subject: [PATCH 1/5] Remove only options from use mpi --- lib/mpifx_comm.fpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpifx_comm.fpp b/lib/mpifx_comm.fpp index 9c4b039..79fbcf2 100644 --- a/lib/mpifx_comm.fpp +++ b/lib/mpifx_comm.fpp @@ -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 From e1d6e26cafac7199c003000210e74374c4486de1 Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Tue, 12 Oct 2021 09:30:36 +0200 Subject: [PATCH 2/5] Add support for meson build system --- CMakeLists.txt | 9 ++++++- VERSION | 1 + cmake/install-mod.py | 32 ++++++++++++++++++++++ lib/meson.build | 63 ++++++++++++++++++++++++++++++++++++++++++++ meson.build | 32 ++++++++++++++++++++++ test/meson.build | 22 ++++++++++++++++ 6 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 VERSION create mode 100644 cmake/install-mod.py create mode 100644 lib/meson.build create mode 100644 meson.build create mode 100644 test/meson.build diff --git a/CMakeLists.txt b/CMakeLists.txt index 8de8fc7..13c4c3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..9084fa2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.1.0 diff --git a/cmake/install-mod.py b/cmake/install-mod.py new file mode 100644 index 0000000..34f7278 --- /dev/null +++ b/cmake/install-mod.py @@ -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) + diff --git a/lib/meson.build b/lib/meson.build new file mode 100644 index 0000000..db50325 --- /dev/null +++ b/lib/meson.build @@ -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 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..19d724c --- /dev/null +++ b/meson.build @@ -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') diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..eb813e3 --- /dev/null +++ b/test/meson.build @@ -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 From b0b206757500eb538afe888c9abac4f784f36459 Mon Sep 17 00:00:00 2001 From: Alessandro Pecchia Date: Tue, 30 Nov 2021 10:15:24 +0100 Subject: [PATCH 3/5] Add -fallow-argument-mismatch for GNU 11 --- lib/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8fd9245..fd3c892 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -27,6 +27,12 @@ fypp_preprocess("${sources-fpp}" sources-f90) if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "NAG") set_source_files_properties(SOURCE ${sources-f90} PROPERTY COMPILE_FLAGS -mismatch) endif() +# GNU 11 compiler won't compile these files without the '-fallow-argument-mismatch' option +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}) From 50de0a6d223999a9863136187aad2af7131cd63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Tue, 30 Nov 2021 20:52:38 +0100 Subject: [PATCH 4/5] Add some more info about mismatch flags --- lib/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fd3c892..b5250a0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -23,11 +23,17 @@ 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() -# GNU 11 compiler won't compile these files without the '-fallow-argument-mismatch' option + +# 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) From d35cdca02628c9ca993b8592a78ce4bf91bbccd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Thu, 9 Dec 2021 17:27:36 +0100 Subject: [PATCH 5/5] Bump version to 1.2, update change log --- CHANGELOG.rst | 13 ++++++++++++- VERSION | 2 +- doc/doxygen/Doxyfile | 2 +- doc/sphinx/conf.py | 4 ++-- utils/srcmanip/set_version | 5 +---- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9c00206..cac490b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 === @@ -30,5 +41,5 @@ Changed * The Fypp-preprocessor is not shipped with MpiFx but is an external requirement. - + * Name convention for processes (master -> lead). diff --git a/VERSION b/VERSION index 9084fa2..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index 045fac5..0439a1e 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -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 diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py index 35addeb..4ec24c2 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -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. diff --git a/utils/srcmanip/set_version b/utils/srcmanip/set_version index b2888d2..00be0d0 100755 --- a/utils/srcmanip/set_version +++ b/utils/srcmanip/set_version @@ -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'), @@ -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}') ]