From 7d192205aac68b53df12dae60379580482a56e6b Mon Sep 17 00:00:00 2001 From: Miro ILIAS Date: Sun, 2 Aug 2015 13:37:50 +0200 Subject: [PATCH] new test for lapack added, all fc tests fixed for PGI Fortran --- .travis.yml | 2 +- test/fc/src/CMakeLists.txt | 4 ++++ test/fc_blas/src/CMakeLists.txt | 6 ++++++ test/fc_lapack/cmake/autocmake.cfg | 20 ++++++++++++++++++++ test/fc_lapack/src/CMakeLists.txt | 10 ++++++++++ test/fc_lapack/src/example.F90 | 24 ++++++++++++++++++++++++ test/test.py | 12 +++++++++++- 7 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 test/fc_lapack/cmake/autocmake.cfg create mode 100644 test/fc_lapack/src/CMakeLists.txt create mode 100644 test/fc_lapack/src/example.F90 diff --git a/.travis.yml b/.travis.yml index 500bfbb..5ea775a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: cpp install: - - sudo apt-get install g++ cmake gfortran libblas-dev + - sudo apt-get install g++ cmake gfortran libblas-dev liblapack-dev - sudo pip install pytest pep8 script: - pep8 --ignore=E501 update.py diff --git a/test/fc/src/CMakeLists.txt b/test/fc/src/CMakeLists.txt index e5d6b3d..9bd048a 100644 --- a/test/fc/src/CMakeLists.txt +++ b/test/fc/src/CMakeLists.txt @@ -1 +1,5 @@ +if(CMAKE_Fortran_COMPILER_ID MATCHES PGI) +# remove -rdynamic flag offensive to PGI Fortran + SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS) +endif() add_executable(example example.f90 module.f90) diff --git a/test/fc_blas/src/CMakeLists.txt b/test/fc_blas/src/CMakeLists.txt index c311c0a..0fd37dc 100644 --- a/test/fc_blas/src/CMakeLists.txt +++ b/test/fc_blas/src/CMakeLists.txt @@ -1,4 +1,10 @@ if(BLAS_FOUND) + + if(CMAKE_Fortran_COMPILER_ID MATCHES PGI) + # remove -rdynamic flag offensive to PGI Fortran + SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS) + endif() + add_executable(example example.f90) target_link_libraries(example ${MATH_LIBS}) else() diff --git a/test/fc_lapack/cmake/autocmake.cfg b/test/fc_lapack/cmake/autocmake.cfg new file mode 100644 index 0000000..7314248 --- /dev/null +++ b/test/fc_lapack/cmake/autocmake.cfg @@ -0,0 +1,20 @@ +[project] +name: example + +[fc] +source: ../../../modules/fc.cmake + +[static] +source: ../../../modules/static_linking.cmake + +[int64] +source: ../../../modules/int64.cmake + +[math_libs] +source: ../../../modules/math_libs.cmake + +[default_build_paths] +source: ../../../modules/default_build_paths.cmake + +[src] +source: ../../../modules/src.cmake diff --git a/test/fc_lapack/src/CMakeLists.txt b/test/fc_lapack/src/CMakeLists.txt new file mode 100644 index 0000000..4404f76 --- /dev/null +++ b/test/fc_lapack/src/CMakeLists.txt @@ -0,0 +1,10 @@ +if(LAPACK_FOUND) + if(CMAKE_Fortran_COMPILER_ID MATCHES PGI) + # remove -rdynamic flag offensive for PGI Fortran + set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS) + endif() + add_executable(example example.F90) + target_link_libraries(example ${MATH_LIBS}) +else() + message(FATAL_ERROR "LAPACK/BLAS libraries not found for the test fc_lapack!") +endif() diff --git a/test/fc_lapack/src/example.F90 b/test/fc_lapack/src/example.F90 new file mode 100644 index 0000000..07a5df6 --- /dev/null +++ b/test/fc_lapack/src/example.F90 @@ -0,0 +1,24 @@ +program example + implicit none + integer, parameter :: n = 3 + integer :: info + real(8) :: a(n, n) + real(8) :: b(n) + integer :: ipiv(n) + logical :: roots_ok=.false. + + data a /2,1,3,2,6,8,6,8,18/ + data b /1,3,5/ + + call dgesv( n, 1, a, n, ipiv, b, n , info ) + if (info.gt.0) stop "error in dgesv routine !" + +! roots are -0.5, 0.25, 0.25 + roots_ok=dabs(b(1)+0.5).le.1d-12.and.dabs(b(2)-0.25).le.1d-12.and.dabs(b(3)-0.25).le.1d-12 + + if (roots_ok) then + print *, 'dgesv test ok' + else + stop 'dgesv test failed!' + endif +end program diff --git a/test/test.py b/test/test.py index 471d437..ebb6556 100644 --- a/test/test.py +++ b/test/test.py @@ -137,7 +137,17 @@ def test_fc(): def test_fc_blas(): if sys.platform != 'win32': - stdout, stderr = configure_build_and_exe('fc_blas', 'python setup.py --fc=gfortran --blas=auto') + stdout, stderr = configure_build_and_exe('fc_blas', 'python setup.py --fc=gfortran') assert 'dgemm test ok' in stdout else: pass + +# ------------------------------------------------------------------------------ + + +def test_fc_lapack(): + if sys.platform != 'win32': + stdout, stderr = configure_build_and_exe('fc_lapack', 'python setup.py --fc=gfortran') + assert 'dgesv test ok' in stdout + else: + pass