simple MPI test for testing the autocmake

- code reviewer's comments included
This commit is contained in:
Miro ILIAS 2015-08-07 08:01:26 +02:00
parent baa9fe5555
commit f8905fed65
5 changed files with 57 additions and 4 deletions

View File

@ -1,6 +1,6 @@
language: cpp
install:
- sudo apt-get install g++ cmake gfortran libblas-dev liblapack-dev
- sudo apt-get install g++ cmake gfortran libblas-dev liblapack-dev openmpi-bin libopenmpi-dev
- sudo pip install pytest pep8
script:
- pep8 --ignore=E501 update.py

View File

@ -0,0 +1,17 @@
[project]
name: example
[fc]
source: ../../../modules/fc.cmake
[mpi]
source: ../../../modules/mpi.cmake
[int64]
source: ../../../modules/int64.cmake
[default_build_paths]
source: ../../../modules/default_build_paths.cmake
[src]
source: ../../../modules/src.cmake

View File

@ -0,0 +1,6 @@
if (MPI_FOUND)
add_executable(example example.f90)
else()
message(FATAL "MPI not found!")
endif()

View File

@ -0,0 +1,16 @@
program example
use mpi
implicit none
integer :: ierr, rank, size
logical :: test_ok
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
call MPI_FINALIZE(ierr)
test_ok=(size==2.and.(rank==0.or.rank==1))
if (test_ok) then
if (rank == 0) print *,'Test OK!'
else
stop "test fc_mpi failed!"
endif
end program

View File

@ -72,7 +72,7 @@ def exe(command):
# ------------------------------------------------------------------------------
def configure_build_and_exe(name, setup_command):
def configure_build_and_exe(name, setup_command, launcher=None):
stamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S')
@ -97,10 +97,16 @@ def configure_build_and_exe(name, setup_command):
if sys.platform == 'win32':
stdout, stderr = exe('mingw32-make')
stdout, stderr = exe('bin\\\example.exe')
if (launcher):
stdout, stderr = exe(launcher + ' bin\\\example.exe')
else:
stdout, stderr = exe('bin\\\example.exe')
else:
stdout, stderr = exe('make')
stdout, stderr = exe('./bin/example')
if (launcher):
stdout, stderr = exe(launcher + ' ./bin/example')
else:
stdout, stderr = exe('./bin/example')
return stdout, stderr
@ -142,6 +148,14 @@ def test_fc_int64():
stdout, stderr = configure_build_and_exe('fc_int64', 'python setup.py --fc=gfortran --int64')
assert 'test_int64 ok' in stdout
def test_fc_mpi():
if sys.platform != 'win32':
stdout, stderr = configure_build_and_exe('fc_mpi', 'python setup.py --mpi --fc=mpif90', 'mpirun -np 2')
assert 'Test OK!' in stdout
else:
pass
# ------------------------------------------------------------------------------