From 613dbe1a2c100dff65a41f853bee8b7071c0aa13 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Thu, 30 Aug 2018 11:38:00 +0900 Subject: [PATCH] Added option for mpi.h --- CMakeLists.txt | 8 ++++++++ Source/Fortran/CMakeLists.txt | 1 + Source/Fortran/ChebyshevSolversModule.f90 | 2 +- Source/Fortran/DataTypesModule.f90 | 2 +- Source/Fortran/DensityMatrixSolversModule.f90 | 2 +- .../Fortran/DistributedSparseMatrixAlgebraModule.f90 | 2 +- Source/Fortran/DistributedSparseMatrixModule.f90 | 2 +- Source/Fortran/EigenBoundsModule.f90 | 2 +- Source/Fortran/ErrorModule.f90 | 6 +++--- Source/Fortran/ExponentialSolversModule.f90 | 2 +- Source/Fortran/GeometryOptimizationModule.f90 | 2 +- Source/Fortran/HermiteSolversModule.f90 | 2 +- Source/Fortran/InverseSolversModule.f90 | 2 +- Source/Fortran/MatrixGatherModule.f90 | 2 +- Source/Fortran/MinimizerSolversModule.f90 | 2 +- Source/Fortran/NTMPIModule.f90 | 12 ++++++++++++ Source/Fortran/PolynomialSolversModule.f90 | 2 +- Source/Fortran/ProcessGridModule.f90 | 2 +- Source/Fortran/RootSolversModule.f90 | 2 +- Source/Fortran/SignSolversModule.f90 | 2 +- Source/Fortran/SparseMatrixModule.f90 | 2 +- Source/Fortran/SquareRootSolversModule.f90 | 4 +--- Source/Fortran/TimerModule.f90 | 2 +- Source/Fortran/TrigonometrySolversModule.f90 | 2 +- Source/Fortran/TripletListModule.f90 | 2 +- Source/Fortran/TripletModule.f90 | 2 +- 26 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 Source/Fortran/NTMPIModule.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index ed005fd8..8eda1b4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,14 @@ else() endif() ################################################################################ +# Other optional parameters. +option(USE_MPIH OFF) +if(USE_MPIH) + add_definitions(-DUSE_MPIH) +endif() + +################################################################################ +# Handle the Debug/Release choices. set(CMAKE_Fortran_FLAGS_DEBUG ${F_TOOLCHAINFLAGS_DEBUG}) set(CMAKE_CXX_FLAGS_DEBUG ${CXX_TOOLCHAINFLAGS_DEBUG}) set(CMAKE_Fortran_FLAGS_RELEASE ${F_TOOLCHAINFLAGS_RELEASE}) diff --git a/Source/Fortran/CMakeLists.txt b/Source/Fortran/CMakeLists.txt index 93bf10b9..4bd34253 100644 --- a/Source/Fortran/CMakeLists.txt +++ b/Source/Fortran/CMakeLists.txt @@ -23,6 +23,7 @@ set(Fsrc MatrixMarketModule.f90 MatrixMemoryPoolModule.f90 MinimizerSolversModule.f90 + NTMPIModule.f90 ParameterConverterModule.f90 PermutationModule.f90 PolynomialSolversModule.f90 diff --git a/Source/Fortran/ChebyshevSolversModule.f90 b/Source/Fortran/ChebyshevSolversModule.f90 index 0defd8dd..03821b45 100644 --- a/Source/Fortran/ChebyshevSolversModule.f90 +++ b/Source/Fortran/ChebyshevSolversModule.f90 @@ -16,7 +16,7 @@ MODULE ChebyshevSolversModule & EnterSubLog, ExitSubLog USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/DataTypesModule.f90 b/Source/Fortran/DataTypesModule.f90 index bcf9b2ff..7d9bf7be 100644 --- a/Source/Fortran/DataTypesModule.f90 +++ b/Source/Fortran/DataTypesModule.f90 @@ -4,7 +4,7 @@ MODULE DataTypesModule USE ErrorModule, ONLY : CheckMPIError, Error_t USE ISO_C_BINDING USE ISO_FORTRAN_ENV - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/DensityMatrixSolversModule.f90 b/Source/Fortran/DensityMatrixSolversModule.f90 index 1ed78221..aea5b96d 100644 --- a/Source/Fortran/DensityMatrixSolversModule.f90 +++ b/Source/Fortran/DensityMatrixSolversModule.f90 @@ -19,7 +19,7 @@ MODULE DensityMatrixSolversModule & WriteHeader, WriteListElement, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 b/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 index 755bb090..c5f1a5f8 100644 --- a/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 +++ b/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 @@ -26,7 +26,7 @@ MODULE DistributedSparseMatrixAlgebraModule USE TimerModule, ONLY : StartTimer, StopTimer USE TripletListModule, ONLY : TripletList_t, DestructTripletList USE ISO_C_BINDING - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/DistributedSparseMatrixModule.f90 b/Source/Fortran/DistributedSparseMatrixModule.f90 index 159f71b0..a98fbeee 100644 --- a/Source/Fortran/DistributedSparseMatrixModule.f90 +++ b/Source/Fortran/DistributedSparseMatrixModule.f90 @@ -30,7 +30,7 @@ MODULE DistributedSparseMatrixModule & SymmetrizeTripletList, GetTripletAt, RedistributeTripletLists, & & ShiftTripletList USE iso_c_binding - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/EigenBoundsModule.f90 b/Source/Fortran/EigenBoundsModule.f90 index a64071b5..3d4656d9 100644 --- a/Source/Fortran/EigenBoundsModule.f90 +++ b/Source/Fortran/EigenBoundsModule.f90 @@ -17,7 +17,7 @@ MODULE EigenBoundsModule USE TripletListModule, ONLY : TripletList_t, AppendToTripletList, & & ConstructTripletList, DestructTripletList USE TripletModule, ONLY : Triplet_t - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/ErrorModule.f90 b/Source/Fortran/ErrorModule.f90 index 1260a759..bc8685ec 100644 --- a/Source/Fortran/ErrorModule.f90 +++ b/Source/Fortran/ErrorModule.f90 @@ -1,7 +1,7 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A (under development) module to do handle error passing. MODULE ErrorModule - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -173,8 +173,8 @@ RECURSIVE SUBROUTINE PrintError(this) WRITE(*,*) this%alloc_error ELSE IF (this%mpi_error_set) THEN WRITE(*,*) "Of type: mpi error." - CALL MPI_Error_String(this%mpi_error,error_string,error_string_len, & - & error_string_error) + CALL MPI_Error_String(this%mpi_error, error_string, & + & error_string_len, error_string_error) WRITE(*,*) error_string ELSE WRITE(*,*) "Of type: generic error." diff --git a/Source/Fortran/ExponentialSolversModule.f90 b/Source/Fortran/ExponentialSolversModule.f90 index 8afc4d3f..67b2bcf7 100644 --- a/Source/Fortran/ExponentialSolversModule.f90 +++ b/Source/Fortran/ExponentialSolversModule.f90 @@ -28,7 +28,7 @@ MODULE ExponentialSolversModule USE RootSolversModule, ONLY : ComputeRoot USE SquareRootSolversModule, ONLY : SquareRoot USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/GeometryOptimizationModule.f90 b/Source/Fortran/GeometryOptimizationModule.f90 index 5cba5a7a..6fc56b96 100644 --- a/Source/Fortran/GeometryOptimizationModule.f90 +++ b/Source/Fortran/GeometryOptimizationModule.f90 @@ -19,7 +19,7 @@ MODULE GeometryOptimizationModule USE ProcessGridModule USE SquareRootSolversModule, ONLY : InverseSquareRoot, SquareRoot USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/HermiteSolversModule.f90 b/Source/Fortran/HermiteSolversModule.f90 index 807ce055..be30534a 100644 --- a/Source/Fortran/HermiteSolversModule.f90 +++ b/Source/Fortran/HermiteSolversModule.f90 @@ -17,7 +17,7 @@ MODULE HermiteSolversModule & WriteListElement, WriteHeader USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/InverseSolversModule.f90 b/Source/Fortran/InverseSolversModule.f90 index bba7f862..b6413d1d 100644 --- a/Source/Fortran/InverseSolversModule.f90 +++ b/Source/Fortran/InverseSolversModule.f90 @@ -18,7 +18,7 @@ MODULE InverseSolversModule & WriteElement, WriteListElement, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE mpi + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/MatrixGatherModule.f90 b/Source/Fortran/MatrixGatherModule.f90 index a3bab1c9..5eebf533 100644 --- a/Source/Fortran/MatrixGatherModule.f90 +++ b/Source/Fortran/MatrixGatherModule.f90 @@ -5,7 +5,7 @@ MODULE MatrixGatherModule USE SparseMatrixAlgebraModule, ONLY : IncrementSparseMatrix USE SparseMatrixModule, ONLY : SparseMatrix_t, ConstructEmptySparseMatrix, & & DestructSparseMatrix - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/MinimizerSolversModule.f90 b/Source/Fortran/MinimizerSolversModule.f90 index 995dde0a..cc14d1ca 100644 --- a/Source/Fortran/MinimizerSolversModule.f90 +++ b/Source/Fortran/MinimizerSolversModule.f90 @@ -18,7 +18,7 @@ MODULE MinimizerSolversModule & WriteListElement, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/NTMPIModule.f90 b/Source/Fortran/NTMPIModule.f90 new file mode 100644 index 00000000..19481617 --- /dev/null +++ b/Source/Fortran/NTMPIModule.f90 @@ -0,0 +1,12 @@ +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!> This module wraps the MPI include statement because on certain platforms +!! just writing "USE MPI" does not work. +MODULE NTMPIModule +#if USE_MPIF08 + USE MPI_F08 +#elif USE_MPIH + include "mpif.h" +#else + USE MPI +#endif +END MODULE diff --git a/Source/Fortran/PolynomialSolversModule.f90 b/Source/Fortran/PolynomialSolversModule.f90 index 19e4da23..e47e2cb8 100644 --- a/Source/Fortran/PolynomialSolversModule.f90 +++ b/Source/Fortran/PolynomialSolversModule.f90 @@ -15,7 +15,7 @@ MODULE PolynomialSolversModule & WriteHeader, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/ProcessGridModule.f90 b/Source/Fortran/ProcessGridModule.f90 index 4aad9780..26f82239 100644 --- a/Source/Fortran/ProcessGridModule.f90 +++ b/Source/Fortran/ProcessGridModule.f90 @@ -4,7 +4,7 @@ MODULE ProcessGridModule USE DataTypesModule, ONLY : MPITypeInfoInit USE LoggingModule, ONLY : ActivateLogger, EnterSubLog, ExitSubLog, & & WriteHeader, WriteListElement - USE MPI + USE NTMPIModule USE ISO_C_BINDING, ONLY : c_int, c_bool #ifdef _OPENMP USE omp_lib, ONLY : omp_get_num_threads diff --git a/Source/Fortran/RootSolversModule.f90 b/Source/Fortran/RootSolversModule.f90 index 44ab2656..3e0ef9fd 100644 --- a/Source/Fortran/RootSolversModule.f90 +++ b/Source/Fortran/RootSolversModule.f90 @@ -24,7 +24,7 @@ MODULE RootSolversModule & SetCoefficient USE SquareRootSolversModule, ONLY : SquareRoot, InverseSquareRoot USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/SignSolversModule.f90 b/Source/Fortran/SignSolversModule.f90 index dbec4a96..21ecd6fc 100644 --- a/Source/Fortran/SignSolversModule.f90 +++ b/Source/Fortran/SignSolversModule.f90 @@ -18,7 +18,7 @@ MODULE SignSolversModule & WriteListElement, WriteHeader, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/SparseMatrixModule.f90 b/Source/Fortran/SparseMatrixModule.f90 index 7d8ebf1e..7dc378d3 100644 --- a/Source/Fortran/SparseMatrixModule.f90 +++ b/Source/Fortran/SparseMatrixModule.f90 @@ -8,7 +8,7 @@ MODULE SparseMatrixModule & ConstructTripletList, DestructTripletList, SetTripletAt, & & AppendToTripletList, SymmetrizeTripletList USE TripletModule, ONLY : Triplet_t - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/SquareRootSolversModule.f90 b/Source/Fortran/SquareRootSolversModule.f90 index a0e6761a..75cecdd2 100644 --- a/Source/Fortran/SquareRootSolversModule.f90 +++ b/Source/Fortran/SquareRootSolversModule.f90 @@ -19,7 +19,7 @@ MODULE SquareRootSolversModule & WriteHeader, WriteListElement, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -40,7 +40,6 @@ SUBROUTINE SquareRoot(InputMat, OutputMat, solver_parameters_in, order_in) INTEGER, INTENT(IN), OPTIONAL :: order_in !! Local Variables TYPE(IterativeSolverParameters_t) :: solver_parameters - INTEGER :: order IF (PRESENT(solver_parameters_in)) THEN solver_parameters = solver_parameters_in @@ -71,7 +70,6 @@ SUBROUTINE InverseSquareRoot(InputMat, OutputMat, solver_parameters_in, & INTEGER, INTENT(IN), OPTIONAL :: order_in !! Local Variables TYPE(IterativeSolverParameters_t) :: solver_parameters - INTEGER :: order IF (PRESENT(solver_parameters_in)) THEN solver_parameters = solver_parameters_in diff --git a/Source/Fortran/TimerModule.f90 b/Source/Fortran/TimerModule.f90 index 920efba8..d0f67794 100644 --- a/Source/Fortran/TimerModule.f90 +++ b/Source/Fortran/TimerModule.f90 @@ -4,7 +4,7 @@ MODULE TimerModule USE LoggingModule, ONLY : EnterSubLog, ExitSubLog, WriteElement, & & WriteHeader USE ProcessGridModule - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE LOGICAL :: is_initialized = .FALSE. diff --git a/Source/Fortran/TrigonometrySolversModule.f90 b/Source/Fortran/TrigonometrySolversModule.f90 index 7331232a..d03143de 100644 --- a/Source/Fortran/TrigonometrySolversModule.f90 +++ b/Source/Fortran/TrigonometrySolversModule.f90 @@ -16,7 +16,7 @@ MODULE TrigonometrySolversModule WriteHeader, WriteListElement, WriteCitation USE ProcessGridModule USE TimerModule, ONLY : StartTimer, StopTimer - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/TripletListModule.f90 b/Source/Fortran/TripletListModule.f90 index f11f9f34..58e71637 100644 --- a/Source/Fortran/TripletListModule.f90 +++ b/Source/Fortran/TripletListModule.f90 @@ -5,7 +5,7 @@ MODULE TripletListModule USE MatrixMarketModule, ONLY : MM_SYMMETRIC, MM_SKEW_SYMMETRIC USE TripletModule, ONLY : Triplet_t, CompareTriplets USE ISO_C_BINDING, ONLY : c_int - USE MPI + USE NTMPIModule IMPLICIT NONE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A data type for a list of triplets. diff --git a/Source/Fortran/TripletModule.f90 b/Source/Fortran/TripletModule.f90 index 2cfca26a..67410235 100644 --- a/Source/Fortran/TripletModule.f90 +++ b/Source/Fortran/TripletModule.f90 @@ -3,7 +3,7 @@ MODULE TripletModule USE DataTypesModule, ONLY: NTREAL, MPINTREAL USE ISO_C_BINDING, ONLY : c_int - USE MPI + USE NTMPIModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!