diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 59a5aa0..9c00206 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,15 @@ Change Log Notable project changes in various releases. +1.1 +=== + +Added +----- + +* Method 'free' implemented to release the MPI-communicator + + 1.0 === diff --git a/CMakeLists.txt b/CMakeLists.txt index a9581ff..8de8fc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ include(MpiFxUtils) include(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake) -project(MpiFx VERSION 1.0 LANGUAGES Fortran) +project(MpiFx VERSION 1.1 LANGUAGES Fortran) setup_build_type() diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index cf3eac9..045fac5 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.0" +PROJECT_NUMBER = "1.1" # 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 e73f6ff..35addeb 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -45,10 +45,10 @@ # built documents. # # The short X.Y version. -version = '1.0' +version = '1.1' # The full version, including alpha/beta/rc tags. -release = '1.0' +release = '1.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/lib/mpifx.fypp b/lib/mpifx.fypp index 68e76bb..8aa702c 100644 --- a/lib/mpifx.fypp +++ b/lib/mpifx.fypp @@ -39,7 +39,7 @@ #:set MAX_RANK = getvar('MAX_RANK', 6) -#! Returns colons within paranthesis according to the RANK or empty string +#! Returns colons within parenthesis according to the RANK or empty string #! if RANK is zero. #:def RANKSUFFIX(RANK) ${'' if RANK == 0 else '(' + ':' + ',:' * (RANK - 1) +')'}$ diff --git a/lib/mpifx_comm.fpp b/lib/mpifx_comm.fpp index fa99e76..9c4b039 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 + use mpi, only : MPI_COMM_WORLD, mpi_comm_size, mpi_comm_rank, mpi_comm_split, mpi_comm_free use mpifx_helper_module implicit none private @@ -21,6 +21,9 @@ module mpifx_comm_module !> Creates a new communicator by splitting the old one. procedure :: split => mpifx_comm_split + !> Frees the communicator. The communicator should not be used after this. + procedure :: free => mpifx_comm_free + end type mpifx_comm contains @@ -52,7 +55,7 @@ contains end if self%leadrank = 0 self%lead = (self%rank == self%leadrank) - + end subroutine mpifx_comm_init @@ -73,10 +76,10 @@ contains !! program test_split !! use libmpifx_module !! implicit none - !! + !! !! type(mpifx_comm) :: allproc, groupproc !! integer :: groupsize, mygroup - !! + !! !! call mpifx_init() !! call allproc%init() !! groupsize = allproc%size / 2 @@ -85,9 +88,9 @@ contains !! write(*, "(3(A,1X,I0,1X))") "ID:", allproc%rank, "SUBGROUP", & !! & mygroup, "SUBGROUP ID", groupproc%rank !! call mpifx_finalize() - !! + !! !! end program test_split - !! + !! !! \see MPI documentation (\c MPI_COMM_SPLIT) !! subroutine mpifx_comm_split(self, splitkey, rankkey, newcomm, error) @@ -97,7 +100,7 @@ contains integer, intent(out), optional :: error integer :: error0, newcommid - + call mpi_comm_split(self%id, splitkey, rankkey, newcommid, error0) call handle_errorflag(error0, "mpi_comm_split() in mpifx_comm_split()", error) if (error0 /= 0) then @@ -106,6 +109,22 @@ contains call newcomm%init(newcommid, error) end subroutine mpifx_comm_split - - + + + !> Frees the MPI communicator. + !> + !> After this call, the passed communicator should not be used any more. + !> + !> \param self Communicator instance. + !> + subroutine mpifx_comm_free(self) + class(mpifx_comm), intent(inout) :: self + + integer :: error + + call mpi_comm_free(self%id, error) + + end subroutine mpifx_comm_free + + end module mpifx_comm_module