simplify MPI test

This commit is contained in:
Radovan Bast
2015-09-18 12:04:33 +02:00
parent 7548f26a08
commit 05fadb04ee
2 changed files with 38 additions and 27 deletions

View File

@ -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