From 17e157f1fd0afcc6dcf7d9762fe385f00133fe44 Mon Sep 17 00:00:00 2001 From: Justin Bich Date: Sat, 25 Nov 2023 17:09:50 +0100 Subject: [PATCH] Update all module imports --- lib/CMakeLists.txt | 1 - lib/meson.build | 1 - lib/mpifx_abort.fpp | 4 +++- lib/mpifx_allgather.fpp | 4 +++- lib/mpifx_allgatherv.fpp | 4 +++- lib/mpifx_allreduce.fpp | 6 ++++-- lib/mpifx_barrier.fpp | 12 +++++++----- lib/mpifx_bcast.fpp | 6 ++++-- lib/mpifx_comm.fpp | 2 +- lib/mpifx_common.fpp | 13 ------------- lib/mpifx_finalize.fpp | 8 +++++--- lib/mpifx_gather.fpp | 22 ++++++++++++---------- lib/mpifx_gatherv.fpp | 4 +++- lib/mpifx_get_processor_name.fpp | 1 - lib/mpifx_helper.fpp | 2 +- lib/mpifx_init.fpp | 6 ++++-- lib/mpifx_recv.fpp | 12 +++++++----- lib/mpifx_reduce.fpp | 24 +++++++++++++----------- lib/mpifx_scatter.fpp | 24 +++++++++++++----------- lib/mpifx_scatterv.fpp | 10 ++++++---- lib/mpifx_send.fpp | 6 ++++-- test/test_scatterv.f90 | 2 +- 22 files changed, 94 insertions(+), 80 deletions(-) delete mode 100644 lib/mpifx_common.fpp diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0cdf659..f5d23d5 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -7,7 +7,6 @@ set(sources-fpp mpifx_barrier.fpp mpifx_bcast.fpp mpifx_comm.fpp - mpifx_common.fpp mpifx_constants.fpp mpifx_finalize.fpp mpifx_gather.fpp diff --git a/lib/meson.build b/lib/meson.build index c590372..962bea4 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -9,7 +9,6 @@ sources_fpp = files( 'mpifx_barrier.fpp', 'mpifx_bcast.fpp', 'mpifx_comm.fpp', - 'mpifx_common.fpp', 'mpifx_constants.fpp', 'mpifx_finalize.fpp', 'mpifx_gather.fpp', diff --git a/lib/mpifx_abort.fpp b/lib/mpifx_abort.fpp index 0d7203f..26a2522 100644 --- a/lib/mpifx_abort.fpp +++ b/lib/mpifx_abort.fpp @@ -1,6 +1,8 @@ !> Contains wrapper for \c MPI_ABORT. module mpifx_abort_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : handle_errorflag implicit none private diff --git a/lib/mpifx_allgather.fpp b/lib/mpifx_allgather.fpp index 893d2fa..94ffe02 100644 --- a/lib/mpifx_allgather.fpp +++ b/lib/mpifx_allgather.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_ALLGATHER module mpifx_allgather_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, handle_errorflag, sp implicit none private diff --git a/lib/mpifx_allgatherv.fpp b/lib/mpifx_allgatherv.fpp index 55898bb..df6afd6 100644 --- a/lib/mpifx_allgatherv.fpp +++ b/lib/mpifx_allgatherv.fpp @@ -106,7 +106,9 @@ !> Contains wrapper for \c MPI_allgatherv module mpifx_allgatherv_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, handle_errorflag, sp implicit none private diff --git a/lib/mpifx_allreduce.fpp b/lib/mpifx_allreduce.fpp index c3e30c8..783a6ad 100644 --- a/lib/mpifx_allreduce.fpp +++ b/lib/mpifx_allreduce.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_ALLREDUCE. module mpifx_allreduce_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, handle_errorflag, sp implicit none private @@ -86,7 +88,7 @@ module mpifx_allreduce_module !! write(*, "(I2.2,'-',I3.3,'|',1X,A,3F8.2)") 4, mycomm%rank, & !! & "Obtained result (prod):", resvalr(:) !! call mpifx_finalize() - !! + !! !! end program test_allreduceip !! interface mpifx_allreduceip diff --git a/lib/mpifx_barrier.fpp b/lib/mpifx_barrier.fpp index cf8efde..c98908c 100644 --- a/lib/mpifx_barrier.fpp +++ b/lib/mpifx_barrier.fpp @@ -1,8 +1,10 @@ #:include 'mpifx.fypp' -!> Contains wrapper for \c MPI_BARRIER. +!> Contains wrapper for \c MPI_BARRIER. module mpifx_barrier_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : handle_errorflag implicit none private @@ -35,12 +37,12 @@ contains subroutine mpifx_barrier(mycomm, error) type(mpifx_comm), intent(in) :: mycomm integer, intent(out), optional :: error - + integer :: error0 - + call mpi_barrier(mycomm%id, error0) call handle_errorflag(error0, "MPI_BARRIER in mpifx_barrier", error) - + end subroutine mpifx_barrier diff --git a/lib/mpifx_bcast.fpp b/lib/mpifx_bcast.fpp index 264c1fb..cdb339a 100644 --- a/lib/mpifx_bcast.fpp +++ b/lib/mpifx_bcast.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_BCAST. module mpifx_bcast_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, getoptarg, handle_errorflag, sp implicit none private @@ -80,7 +82,7 @@ contains #:enddef mpifx_bcast_template - + #:for TYPE in TYPES #:for RANK in RANKS diff --git a/lib/mpifx_comm.fpp b/lib/mpifx_comm.fpp index 1d7b01a..ac30042 100644 --- a/lib/mpifx_comm.fpp +++ b/lib/mpifx_comm.fpp @@ -1,7 +1,7 @@ !> Contains the extended MPI communicator. module mpifx_comm_module use mpi - use mpifx_helper_module + use mpifx_helper_module, only : getoptarg, handle_errorflag implicit none private diff --git a/lib/mpifx_common.fpp b/lib/mpifx_common.fpp deleted file mode 100644 index d00d1fc..0000000 --- a/lib/mpifx_common.fpp +++ /dev/null @@ -1,13 +0,0 @@ -!> Exports constants, helper functions, MPI descriptor and legacy MPI routines. -!! \cond HIDDEN -module mpifx_common_module - use mpi - use mpifx_helper_module - use mpifx_comm_module - implicit none - - public - -end module mpifx_common_module - -!> \endcond diff --git a/lib/mpifx_finalize.fpp b/lib/mpifx_finalize.fpp index b9b98cc..21976bf 100644 --- a/lib/mpifx_finalize.fpp +++ b/lib/mpifx_finalize.fpp @@ -1,6 +1,8 @@ -!> Contains wrapper for \c MPI_FINALIZE. +!> Contains wrapper for \c MPI_FINALIZE. module mpifx_finalize_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : handle_errorflag implicit none private @@ -39,5 +41,5 @@ contains call handle_errorflag(error0, "Error: mpi_finalize() in mpifx_finalize()", error) end subroutine mpifx_finalize - + end module mpifx_finalize_module diff --git a/lib/mpifx_gather.fpp b/lib/mpifx_gather.fpp index b79bc2a..5370bf0 100644 --- a/lib/mpifx_gather.fpp +++ b/lib/mpifx_gather.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_GATHER module mpifx_gather_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, getoptarg, handle_errorflag, sp implicit none private @@ -30,17 +32,17 @@ module mpifx_gather_module !! program test_gather !! use libmpifx_module !! implicit none - !! + !! !! type(mpifx_comm) :: mycomm !! integer :: send0 !! integer, allocatable :: send1(:) !! integer, allocatable :: recv1(:), recv2(:,:) !! character(100) :: formstr !! character(*), parameter :: label = "(I2.2,'-',I3.3,'|',1X" - !! + !! !! call mpifx_init() !! call mycomm%init() - !! + !! !! ! I0 -> I1 !! send0 = mycomm%rank * 2 ! Arbitrary number to send !! if (mycomm%lead) then @@ -55,7 +57,7 @@ module mpifx_gather_module !! write(*, *) mycomm%rank, "Recv1 buffer:", recv1(:) !! end if !! deallocate(recv1) - !! + !! !! ! I1 -> I1 !! allocate(send1(2)) !! send1(:) = [ mycomm%rank, mycomm%rank + 1 ] ! Arbitrary numbers @@ -70,7 +72,7 @@ module mpifx_gather_module !! if (mycomm%lead) then !! write(*, *) mycomm%rank, "Recv1 buffer:", recv1 !! end if - !! + !! !! ! I1 -> I2 !! send1(:) = [ mycomm%rank, mycomm%rank + 1 ] !! if (mycomm%lead) then @@ -82,9 +84,9 @@ module mpifx_gather_module !! if (mycomm%lead) then !! write(*, *) mycomm%rank, "Recv2 buffer:", recv2 !! end if - !! + !! !! call mpifx_finalize() - !! + !! !! end program test_gather !! interface mpifx_gather @@ -100,7 +102,7 @@ module mpifx_gather_module #:endfor #:endfor end interface mpifx_gather - + contains #:def mpifx_gather_dr0_template(SUFFIX, TYPE, MPITYPE, RANK, HASLENGTH) @@ -135,7 +137,7 @@ contains call mpi_gather(send, ${COUNT}$, ${MPITYPE}$, recv, ${COUNT}$, ${MPITYPE}$, root0,& & mycomm%id, error0) call handle_errorflag(error0, "MPI_GATHER in mpifx_gather_${SUFFIX}$", error) - + end subroutine mpifx_gather_${SUFFIX}$ #:enddef mpifx_gather_dr0_template diff --git a/lib/mpifx_gatherv.fpp b/lib/mpifx_gatherv.fpp index c1cb677..6fb1170 100644 --- a/lib/mpifx_gatherv.fpp +++ b/lib/mpifx_gatherv.fpp @@ -131,7 +131,9 @@ !> Contains wrapper for \c MPI_gatherv module mpifx_gatherv_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, handle_errorflag, sp implicit none private diff --git a/lib/mpifx_get_processor_name.fpp b/lib/mpifx_get_processor_name.fpp index 7e274b6..4b0fb8f 100644 --- a/lib/mpifx_get_processor_name.fpp +++ b/lib/mpifx_get_processor_name.fpp @@ -1,6 +1,5 @@ !> Contains the extended MPI communicator. module mpifx_get_processor_name_module - use mpifx_helper_module use mpi implicit none private diff --git a/lib/mpifx_helper.fpp b/lib/mpifx_helper.fpp index 70fa09b..44100b0 100644 --- a/lib/mpifx_helper.fpp +++ b/lib/mpifx_helper.fpp @@ -6,7 +6,7 @@ module mpifx_helper_module use mpi use, intrinsic :: iso_fortran_env, only : stderr => error_unit - use mpifx_constants_module + use mpifx_constants_module, only : MPIFX_ASSERT_FAILED, MPIFX_UNHANDLED_ERROR implicit none private diff --git a/lib/mpifx_init.fpp b/lib/mpifx_init.fpp index 387b758..98422a5 100644 --- a/lib/mpifx_init.fpp +++ b/lib/mpifx_init.fpp @@ -1,7 +1,9 @@ !> Contains wrapper for \c MPI_INIT. module mpifx_init_module - use mpifx_common_module - use mpifx_constants_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_constants_module, only : MPIFX_UNHANDLED_ERROR + use mpifx_helper_module, only : handle_errorflag implicit none private diff --git a/lib/mpifx_recv.fpp b/lib/mpifx_recv.fpp index d5ec093..6f5f681 100644 --- a/lib/mpifx_recv.fpp +++ b/lib/mpifx_recv.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_RECV module mpifx_recv_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, sp implicit none private @@ -15,7 +17,7 @@ module mpifx_recv_module !! !! \details All functions have the same argument list only differing in the !! type and rank of the second argument. The second argument can be of - !! type integer (i), real (s), double precision (d), complex (c), + !! type integer (i), real (s), double precision (d), complex (c), !! double complex (z), logical (b) and character (h). Its rank can vary from !! zero (scalar) up to the maximum rank. !! @@ -60,7 +62,7 @@ contains #:def mpifx_recv_template(SUFFIX, TYPE, MPITYPE, RANK, HASLENGTH) #:assert RANK >= 0 - + !> Receives a message from a given process. !! \param mycomm MPI descriptor. !! \param msg Msg to be received. @@ -105,6 +107,6 @@ contains $:mpifx_recv_template(SUFFIX, FTYPE, MPITYPE, RANK, HASLENGTH) #:endfor -#:endfor - +#:endfor + end module mpifx_recv_module diff --git a/lib/mpifx_reduce.fpp b/lib/mpifx_reduce.fpp index b14fdb3..4f538ad 100644 --- a/lib/mpifx_reduce.fpp +++ b/lib/mpifx_reduce.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_REDUCE. module mpifx_reduce_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, getoptarg, handle_errorflag, sp implicit none private @@ -13,8 +15,8 @@ module mpifx_reduce_module !> Reduces a scalar/array on a given node. !! !! \details All functions have the same argument list only differing in the - !! type and rank of the second and third arguments. The second and third - !! arguments can be of type integer (i), real (s), double precision (d), + !! type and rank of the second and third arguments. The second and third + !! arguments can be of type integer (i), real (s), double precision (d), !! complex (c), double complex (z) or logical (l). Their rank can vary from !! zero (scalars) up to the maximum rank. Both arguments must be of same !! type and rank. @@ -42,7 +44,7 @@ module mpifx_reduce_module !! write(*, "(I2.2,'-',I3.3,'|',1X,A,3F8.2)") 4, mycomm%rank, & !! & "Obtained result (prod):", resvalr(:) !! call mpifx_finalize() - !! + !! !! end program test_reduce !! interface mpifx_reduce @@ -86,9 +88,9 @@ module mpifx_reduce_module !! write(*, "(I2.2,'-',I3.3,'|',1X,A,3F8.2)") 4, mycomm%rank, & !! & "Obtained result (prod):", resvalr(:) !! call mpifx_finalize() - !! + !! !! end program test_reduceip - !! + !! interface mpifx_reduceip #:for TYPE in TYPES #:for RANK in RANKS @@ -129,16 +131,16 @@ contains call mpi_reduce(orig, reduced, ${COUNT}$, ${MPITYPE}$, reduceop, root0, mycomm%id, error0) call handle_errorflag(error0, "MPI_REDUCE in mpifx_reduce_${SUFFIX}$", error) - + end subroutine mpifx_reduce_${SUFFIX}$ #:enddef mpifx_reduce_template - + #:def mpifx_reduceip_template(SUFFIX, TYPE, MPITYPE, RANK) #:assert RANK >= 0 - + !> Reduces results on one process (type ${SUFFIX}$). !! !! \param mycomm MPI communicator. @@ -170,12 +172,12 @@ contains & error0) end if call handle_errorflag(error0, "MPI_REDUCE in mpifx_reduce_${SUFFIX}$", error) - + end subroutine mpifx_reduceip_${SUFFIX}$ #:enddef mpifx_reduceip_template - + #:for TYPE in TYPES #:for RANK in RANKS diff --git a/lib/mpifx_scatter.fpp b/lib/mpifx_scatter.fpp index de288b9..ee9505e 100644 --- a/lib/mpifx_scatter.fpp +++ b/lib/mpifx_scatter.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_SCATTER module mpifx_scatter_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, getoptarg, handle_errorflag, sp implicit none private @@ -30,16 +32,16 @@ module mpifx_scatter_module !! program test_scatter !! use libmpifx_module !! implicit none - !! + !! !! type(mpifx_comm) :: mycomm !! integer, allocatable :: send1(:), send2(:,:) !! integer :: recv0 !! integer, allocatable :: recv1(:) !! integer :: ii - !! + !! !! call mpifx_init() !! call mycomm%init() - !! + !! !! ! I1 -> I0 !! if (mycomm%lead) then !! allocate(send1(mycomm%size)) @@ -51,7 +53,7 @@ module mpifx_scatter_module !! recv0 = 0 !! call mpifx_scatter(mycomm, send1, recv0) !! write(*, *) mycomm%rank, "Recv0 buffer:", recv0 - !! + !! !! ! I1 -> I1 !! if (mycomm%lead) then !! deallocate(send1) @@ -63,7 +65,7 @@ module mpifx_scatter_module !! recv1(:) = 0 !! call mpifx_scatter(mycomm, send1, recv1) !! write(*, *) mycomm%rank, "Recv1 buffer:", recv1 - !! + !! !! ! I2 -> I1 !! if (mycomm%lead) then !! allocate(send2(2, mycomm%size)) @@ -75,9 +77,9 @@ module mpifx_scatter_module !! recv1(:) = 0 !! call mpifx_scatter(mycomm, send2, recv1) !! write(*, *) mycomm%rank, "Recv1 buffer:", recv1 - !! + !! !! call mpifx_finalize() - !! + !! !! end program test_scatter !! interface mpifx_scatter @@ -119,12 +121,12 @@ contains @:ASSERT(.not. mycomm%lead .or. size(send) == size(recv) * mycomm%size) @:ASSERT(.not. mycomm%lead& & .or. size(send, dim=${RANK}$) == size(recv, dim=${RANK}$) * mycomm%size) - + call getoptarg(mycomm%leadrank, root0, root) call mpi_scatter(send, ${COUNT}$, ${MPITYPE}$, recv, ${COUNT}$, ${MPITYPE}$, root0,& & mycomm%id, error0) call handle_errorflag(error0, "MPI_SCATTER in mpifx_scatter_${SUFFIX}$", error) - + end subroutine mpifx_scatter_${SUFFIX}$ #:enddef mpifx_scatter_dr0_template @@ -133,7 +135,7 @@ contains #:def mpifx_scatter_dr1_template(SUFFIX, TYPE, MPITYPE, RANK, HASLENGTH) #:assert RANK > 0 - + !> Scatters results on one process (type ${SUFFIX}$). !! !! \param mycomm MPI communicator. diff --git a/lib/mpifx_scatterv.fpp b/lib/mpifx_scatterv.fpp index aaa4944..44586c6 100644 --- a/lib/mpifx_scatterv.fpp +++ b/lib/mpifx_scatterv.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_SCATTER module mpifx_scatterv_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : dp, getoptarg, handle_errorflag, sp implicit none private @@ -113,7 +115,7 @@ contains @:ASSERT(.not. mycomm%lead .or. size(send) == size(recv) * mycomm%size) @:ASSERT(.not. mycomm%lead& & .or. size(send, dim=${RANK}$) == size(recv, dim=${RANK}$) * mycomm%size) - + call getoptarg(mycomm%leadrank, root0, root) if (mycomm%rank == root0) then if (present(displs)) then @@ -132,7 +134,7 @@ contains & mycomm%id, error0) call handle_errorflag(error0, "MPI_SCATTER in mpifx_scatterv_${SUFFIX}$", error) - + end subroutine mpifx_scatterv_${SUFFIX}$ #:enddef mpifx_scatterv_dr0_template @@ -141,7 +143,7 @@ contains #:def mpifx_scatterv_dr1_template(SUFFIX, TYPE, MPITYPE, RANK, HASLENGTH) #:assert RANK > 0 - + !> Scatter results from one process (type ${SUFFIX}$). !! !! \param mycomm MPI communicator. diff --git a/lib/mpifx_send.fpp b/lib/mpifx_send.fpp index fc775dd..4459795 100644 --- a/lib/mpifx_send.fpp +++ b/lib/mpifx_send.fpp @@ -4,7 +4,9 @@ !> Contains wrapper for \c MPI_SEND module mpifx_send_module - use mpifx_common_module + use mpi + use mpifx_comm_module, only : mpifx_comm + use mpifx_helper_module, only : default_tag, dp, sp implicit none private @@ -15,7 +17,7 @@ module mpifx_send_module !! !! \details All functions have the same argument list only differing in the !! type and rank of the second argument. The second argument can be of - !! type integer (i), real (s), double precision (d), complex (c), + !! type integer (i), real (s), double precision (d), complex (c), !! double complex (z), logical (b) and character (h). Its rank can vary from !! zero (scalar) up to the maximum rank. !! diff --git a/test/test_scatterv.f90 b/test/test_scatterv.f90 index 6de8d51..00777b2 100644 --- a/test/test_scatterv.f90 +++ b/test/test_scatterv.f90 @@ -81,5 +81,5 @@ program test_scatterv write(*, label // formstr) 8, mycomm%rank, "Recv1 buffer:", recv1 call mpifx_finalize() - + end program test_scatterv