diff --git a/test/fc_mpi/src/CMakeLists.txt b/test/fc_mpi/src/CMakeLists.txt index 1d44328..30ea8b5 100644 --- a/test/fc_mpi/src/CMakeLists.txt +++ b/test/fc_mpi/src/CMakeLists.txt @@ -1,6 +1,5 @@ if(MPI_FOUND) add_executable(example example.F90) - target_link_libraries(example ${MPI_LIBRARIES}) else() message(FATAL_ERROR "MPI not found") endif() diff --git a/test/fc_mpi/src/example.F90 b/test/fc_mpi/src/example.F90 index ca5b642..2eee4f2 100644 --- a/test/fc_mpi/src/example.F90 +++ b/test/fc_mpi/src/example.F90 @@ -1,44 +1,24 @@ program example - 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 + implicit none #include "mpif.h" - integer :: ierr, rank, num_ranks - logical :: test_ok + integer :: ierr, rank, num_ranks + logical :: test_ok - call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) - call MPI_COMM_SIZE(MPI_COMM_WORLD, num_ranks, ierr) + call MPI_Init(ierr) - test_ok = (num_ranks == 2 .and. (rank == 0 .or. rank == 1)) + call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) + call MPI_COMM_SIZE(MPI_COMM_WORLD, num_ranks, ierr) - if (test_ok) then - if (rank == 0) print *, 'PASSED' - else - stop "FAILED" - endif + test_ok = (num_ranks == 2 .and. (rank == 0 .or. rank == 1)) - end subroutine + if (test_ok) then + if (rank == 0) print *, 'PASSED' + else + stop "FAILED" + endif + + call MPI_Finalize(ierr) end program