pfunit: add mpi-test patch (#9387)

This commit is contained in:
Christoph Junghans 2018-12-05 06:15:16 -07:00 committed by GitHub
parent 583617ed67
commit d149ab63a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,35 @@
From Ferenbaugh, Charles <cferenba@lanl.gov>
This patch modifies pfunit to be usable by codes that have MPI_COMM_WORLD hardcoded
as their communicator, by skipping over any tests whose PE count does not match the
size of the current MPI_COMM_WORLD.
--- pFUnit-3.2.8/source/TestSuite.F90 2016-09-05 17:55:26.000000000 -0600
+++ pFUnit-3.2.8.mod1/source/TestSuite.F90 2017-01-04 12:41:24.818441000 -0700
@@ -117,6 +117,9 @@
end subroutine run
recursive subroutine addTest(this, aTest)
+#ifdef USE_MPI
+ use MpiTestCase_mod
+#endif
class (TestSuite), intent(inout) :: this
class (Test), intent(in) :: aTest
#ifdef DEFERRED_LENGTH_CHARACTER
@@ -129,6 +134,17 @@
integer :: suiteNameLength
integer :: testNameLength
#endif
+#ifdef USE_MPI
+ integer :: numpe, error
+ include 'mpif.h'
+
+ select type (t => aTest)
+ class is (MpiTestCase)
+ call MPI_Comm_size(MPI_COMM_WORLD, numpe, error)
+ if (t%getNumProcessesRequested() /= numpe) return
+ end select
+#endif
+
call extend(this%tests)
allocate(this%tests(this%getNumTests())%pTest, source=aTest)
#ifdef DEFERRED_LENGTH_CHARACTER

View File

@ -22,12 +22,16 @@ class Pfunit(CMakePackage):
variant('shared', default=True,
description='Build shared library in addition to static')
variant('mpi', default=False, description='Enable MPI')
variant('use_comm_world', default=False, description='Enable MPI_COMM_WORLD for testing')
variant('openmp', default=False, description='Enable OpenMP')
variant('docs', default=False, description='Build docs')
depends_on('python@2.7:', type=('build', 'run')) # python3 too!
depends_on('mpi', when='+mpi')
conflicts("use_comm_world", when="~mpi")
patch("mpi-test.patch", when="+use_comm_world")
def patch(self):
# The package tries to put .mod files in directory ./mod;
# spack needs to put them in a standard location: