From 8f94da2bca11f986a13fad3c9a4c48b2480af87d Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 5 Oct 2020 09:34:34 -0600 Subject: [PATCH 1/3] changed to remove pFUnit test framework --- .github/workflows/main.yml | 28 +--------------------------- CMakeLists.txt | 20 ++++++++------------ tests/CMakeLists.txt | 12 +++++++----- tests/test_sp_mod.pf | 22 ---------------------- tests/tst_sp.F | 30 ++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 66 deletions(-) delete mode 100644 tests/test_sp_mod.pf create mode 100644 tests/tst_sp.F diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b322dbb0..7f2b3592 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,32 +6,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: checkout-pfunit - uses: actions/checkout@v2 - with: - repository: Goddard-Fortran-Ecosystem/pFUnit - path: pfunit - - - name: cache pfunit - id: cache-pfunit - uses: actions/cache@v2 - with: - path: ~/pfunit - key: pfunit-${{ runner.os }}-${{ hashFiles('pfunit/VERSION') }} - - - name: build_pfunit - env: - FC: gfortran-9 - if: steps.cache-pfunit.outputs.cache-hit != 'true' - run: | - pwd - cd pfunit - mkdir build - cd build - cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit - make -j2 - make install - - name: checkout-sp uses: actions/checkout@v2 with: @@ -45,7 +19,7 @@ jobs: cd sp mkdir build cd build - cmake .. -DENABLE_TESTS=ON -DOPENMP=ON -DCMAKE_PREFIX_PATH=~/pfunit + cmake .. -DOPENMP=ON make -j2 - name: test_sp diff --git a/CMakeLists.txt b/CMakeLists.txt index 79a868a9..cb777d11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,13 @@ # Mark Potts, Kyle Gerheiser cmake_minimum_required(VERSION 3.15) +# Get the version from the VERSION file. file(STRINGS "VERSION" pVersion) - project(sp VERSION ${pVersion} LANGUAGES Fortran) option(OPENMP "use OpenMP threading" OFF) -option(ENABLE_TESTS "Enable tests" OFF) +# Check build type. if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") message(STATUS "Setting build type to 'Release' as none was specified.") set(CMAKE_BUILD_TYPE @@ -19,19 +19,15 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") "MinSizeRel" "RelWithDebInfo") endif() -if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU)$") - message( - WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}") -endif() - +# This is where the library code is. add_subdirectory(src) -if (${ENABLE_TESTS}) - find_package(PFUNIT REQUIRED) - enable_testing() - add_subdirectory(tests) +# Build and run tests. +include(CTest) +if (BUILD_TESTING) + add_subdirectory(tests) endif() - + # Determine whether or not to generate documentation. OPTION(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) IF(ENABLE_DOCS) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bf8700ff..277ac82f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,8 @@ -set(test_srcs test_sp.pf) +# This is the CMake build file for the test directory of NCEPLIBS-sp. + +# Mark Potts, Kyle Gerheiser, Ed Hartnett + +add_executable (tst_sp tst_sp.F) +add_test(tst_sp tst_sp) +target_link_libraries (tst_sp sp_d) -add_pfunit_ctest (sp_mod_test - TEST_SOURCES test_sp_mod.pf - LINK_LIBRARIES sp::sp_4 -) diff --git a/tests/test_sp_mod.pf b/tests/test_sp_mod.pf deleted file mode 100644 index b5e39702..00000000 --- a/tests/test_sp_mod.pf +++ /dev/null @@ -1,22 +0,0 @@ -module test_sp_mod - use funit - implicit none - -contains - - @test - subroutine test_splat() - integer :: j, jmax - real slat(384), wlat(384) - - jmax = 384 ! t382 grid - - call splat(0, jmax,slat,wlat) - - do j = 2, jmax-1 - @assertGreaterThan(slat(j), slat(j+1), "this should be less than that") - end do - - end subroutine test_splat - -end module test_sp_mod diff --git a/tests/tst_sp.F b/tests/tst_sp.F new file mode 100644 index 00000000..f6bfc791 --- /dev/null +++ b/tests/tst_sp.F @@ -0,0 +1,30 @@ +C This is a test program for NCEPLIBS-sp. +C +C Ed Hartnett, Kyle Gerheiser + +C Test of splat(). + subroutine test_splat() + integer :: j, jmax + real*8 slat(384), wlat(384) + + jmax = 384 ! t382 grid + + call splat(0, jmax,slat,wlat) + + do j = 2, jmax-1 + if (slat(j) < slat(j+1)) stop 2 + end do + + end subroutine test_splat + +C Run all the tests. + program tst_sp + implicit none + + print *, '' + print *,'*** Testing NCEPLIBS-sp.' + + call test_splat() + + print *,'*** SUCCESS!' + end program From 8eaf807e1cfc3ca9b7015f739d879524a4eb24f8 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 5 Oct 2020 09:37:50 -0600 Subject: [PATCH 2/3] fixed comment --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 277ac82f..b5948547 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ # This is the CMake build file for the test directory of NCEPLIBS-sp. -# Mark Potts, Kyle Gerheiser, Ed Hartnett +# Kyle Gerheiser, Ed Hartnett add_executable (tst_sp tst_sp.F) add_test(tst_sp tst_sp) From f52defefaba1adf033a521e4b32a6904e80d7370 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Mon, 5 Oct 2020 09:43:04 -0600 Subject: [PATCH 3/3] adding no openmp build --- .github/workflows/main.yml | 2 +- .github/workflows/no_openmp.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/no_openmp.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f2b3592..e48e9ea8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Build and Test +name: with OPENMP on: [push, pull_request] jobs: diff --git a/.github/workflows/no_openmp.yml b/.github/workflows/no_openmp.yml new file mode 100644 index 00000000..33ddf231 --- /dev/null +++ b/.github/workflows/no_openmp.yml @@ -0,0 +1,29 @@ +name: without OPENMP +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: checkout-sp + uses: actions/checkout@v2 + with: + path: sp + + - name: build_sp + env: + FC: gfortran-9 + CC: gcc-9 + run: | + cd sp + mkdir build + cd build + cmake .. + make -j2 + + - name: test_sp + run: | + cd $GITHUB_WORKSPACE/sp/build + make test +