From 05fadb04ee890e242dd6c3ebc8199031fddec855 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Fri, 18 Sep 2015 12:04:33 +0200 Subject: [PATCH] simplify MPI test --- test/fc_mpi/src/example.F90 | 53 ++++++++++++++++++++++++------------- test/test.py | 12 +++------ 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/test/fc_mpi/src/example.F90 b/test/fc_mpi/src/example.F90 index 5c5d6f3..ca5b642 100644 --- a/test/fc_mpi/src/example.F90 +++ b/test/fc_mpi/src/example.F90 @@ -1,27 +1,44 @@ program example -#if defined USE_MPI_MODULE - use mpi - implicit none -#else - implicit none + call init() + call test_use() + call finalize() + +contains + + subroutine init() + use mpi, only: MPI_Init + implicit none + integer :: ierr + call MPI_Init(ierr) + end subroutine + + subroutine finalize() + use mpi, only: MPI_Finalize + implicit none + integer :: ierr + call MPI_Finalize(ierr) + end subroutine + + subroutine test_use() + + implicit none #include "mpif.h" -#endif - integer :: ierr, rank, num_ranks - logical :: test_ok + integer :: ierr, rank, num_ranks + logical :: test_ok - call MPI_INIT(ierr) - call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) - call MPI_COMM_SIZE(MPI_COMM_WORLD, num_ranks, ierr) - call MPI_FINALIZE(ierr) + call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) + call MPI_COMM_SIZE(MPI_COMM_WORLD, num_ranks, ierr) - test_ok = (num_ranks == 2 .and. (rank == 0 .or. rank == 1)) + test_ok = (num_ranks == 2 .and. (rank == 0 .or. rank == 1)) - if (test_ok) then - if (rank == 0) print *, 'PASSED' - else - stop "FAILED" - endif + if (test_ok) then + if (rank == 0) print *, 'PASSED' + else + stop "FAILED" + endif + + end subroutine end program diff --git a/test/test.py b/test/test.py index b1bd698..56c4019 100644 --- a/test/test.py +++ b/test/test.py @@ -115,16 +115,10 @@ def test_fc_int64(): def test_fc_mpi(): if sys.platform == 'win32': - configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=gfortran --extra-fc-flags="-D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check" --add-definitions="-D USE_MPI_MODULE"', 'mpiexec -n 2') + setup_line = 'python setup.py --mpi --fc=gfortran --extra-fc-flags="-D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check"' else: - configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=mpif90 --add-definitions="-D USE_MPI_MODULE"', 'mpirun -np 2') - - -def test_fc_mpi_include(): - if sys.platform == 'win32': - configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=gfortran --extra-fc-flags="-D_WIN64 -D INT_PTR_KIND()=8 -fno-range-check"', 'mpiexec -np 2') - else: - configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=mpif90', 'mpirun -np 2') + setup_line = 'python setup.py --mpi --fc=mpif90"' + configure_build_and_exe('fc_mpi', setup_line, 'mpiexec -np 2') @skip_on_osx