Skip to content

Commit

Permalink
Merge pull request #248 from Goddard-Fortran-Ecosystem/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tclune authored Nov 8, 2020
2 parents 620edf0 + 649b5ac commit 4f11470
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 164 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.12)

project (PFUNIT
VERSION 4.1.12
VERSION 4.1.13
LANGUAGES Fortran C)

enable_testing()
Expand All @@ -52,6 +52,7 @@ option (SKIP_ESMF "Skip building ESMF support" YES)


set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PFUNIT_SOURCE_DIR}/cmake" "${PFUNIT_SOURCE_DIR}/include")
include(BuildType)
include(CheckCompilerCapabilities)

#-----------------------------------
Expand Down Expand Up @@ -89,6 +90,12 @@ if (NOT SKIP_OPENMP)
else (OpenMP_Fortran_FOUND)
message (STATUS "OpenMP not found - skipping openmp support.")
endif()
# Kludge to workaround cmake+NAG+openmp linkage problem
if (CMAKE_Fortran_COMPILER_ID MATCHES NAG)
set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY
INTERFACE_LINK_LIBRARIES "")
set_property(TARGET OpenMP::OpenMP_Fortran PROPERTY INTERFACE_LINK_OPTIONS "-openmp")
endif ()
endif()


Expand Down
33 changes: 32 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.1.13]

There is a ticket opened against Intel Fortran 19.2 which breaks some
fHamcrest functionality. A failing test has been added to the test
suite. 19.1.3 still has this bug. (I have not checked if earlier
compilers also had this problem, but quite possibly they do as
fHamcrest is still under development.)

## Changed

- Separated tests related to RobustRunner into separate test suite. This is to
facilitate CI, as the tests do intermittently fail under CI, though rarely
in any development environment used by the main developers.

- Corrected so that default flags are with aggressive debugging. This had been
the default in the past, but was apparently lost for NAG to workaround a compiler
bug in an intermediate release. Also corrected the way the flags are managed
for Debug vs Release.

## Fixed

- Added workaround for NAG+cmake+OpenMP. An issue has been filed with kitware
https://gitlab.kitware.com/cmake/cmake/-/issues/21280

- Missing PRESENT checks for arguments in TestMethod. Not sure how
these were not being caught - probably related to change mentioned
above about skipping debug flags with NAG Fortran.

- Missing RECURSIVE attribute on function in Every.F90. Not necessary
in F2008, but not all compilers have implemented this yet.

## [4.1.12] - 2020-08-21

### Fixed
Expand All @@ -18,7 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Tests for FHamcrest `equal_to` functionality.

### Chaneged
### Changed
- Changed `CMakeLists.txt` for FHamcrest tests to use the new `pfunit_add_ctest`
cmake macro.

Expand Down
11 changes: 11 additions & 0 deletions cmake/BuildType.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set a default build type if none was specified
set(default_build_type "Debug")

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()
7 changes: 5 additions & 2 deletions cmake/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ else ()
set(opt "-O0")
endif ()

set(CMAKE_Fortran_FLAGS "-g ${cpp} ${opt} ${traceback} -ffree-line-length-512")
set(common_flags "${cpp} ${opt} -ffree-line-length-512")
if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${MISMATCH}")
set (common_flags "${common_flags} ${MISMATCH}")
endif ()

set(CMAKE_Fortran_FLAGS_DEBUG "-g ${common_flags} ${traceback}")
set(CMAKE_Fortran_FLAGS_RELEASE "${common_flags}")

add_definitions(-D_GNU)
6 changes: 3 additions & 3 deletions cmake/Intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ set(traceback "-traceback")
set(cpp "-cpp")


set(CMAKE_Fortran_FLAGS_DEBUG "${no_optimize}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS "-g ${cpp} ${traceback} ${check_all} ${disable_warning_for_long_names} -save-temps")
set(common_flags "${cpp} ${disable_warning_for_long_names}")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g ${common_flags} ${traceback} ${no_optimize} ${check_all}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 ${common_flags}")

add_definitions(-D_INTEL)
add_definitions(-D__ifort_18)
11 changes: 6 additions & 5 deletions cmake/NAG.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Compiler specific flags for NAG Fortran compiler

set(traceback "-gline")
set(traceback "-g")
#set(check_all "-C=all")
#set(check_all "-C=pointer")
set(check_all "-C=pointer")

set(cpp "-fpp")
set(mismatch "-mismatch")

set(CMAKE_Fortran_FLAGS_DEBUG "-O0")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS "-g ${cpp} ${traceback} ${check_all} -w=x95")
set(common_flags "${cpp} -w=x95")

set(CMAKE_Fortran_FLAGS_DEBUG "${common_flags} -O0 ${check_all} ${traceback}")
set(CMAKE_Fortran_FLAGS_RELEASE ${common_flags})

add_definitions(-D_NAG)
4 changes: 2 additions & 2 deletions src/funit/core/TestMethod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ function TestMethod_(name, method, unused, setUp, tearDown) result(this)

call this%setName(name)
this%userMethod => method
this%userSetUp => setUp
this%userTearDown => tearDown
if (present(setUp)) this%userSetUp => setUp
if (present(tearDown)) this%userTearDown => tearDown

end function TestMethod_

Expand Down
2 changes: 1 addition & 1 deletion src/funit/fhamcrest/ArrayWrapper.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contains
! assignment in this context.
allocate(list, source=this%items)
#else
n = size(this%items)
n = size(this%items,{rank})
allocate(items(n))
do i = 1, n
items(i) = {get_ith}
Expand Down
4 changes: 2 additions & 2 deletions src/funit/fhamcrest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set (srcs
)

set (generated_sources)
function (expand in out)
function (expand in out rank)
set (generated_sources ${generated_sources} ${CMAKE_CURRENT_BINARY_DIR}/${out} PARENT_SCOPE)
add_custom_command (
OUTPUT ${out}
Expand All @@ -56,7 +56,7 @@ function (expand in out)
endfunction()

foreach(rank RANGE 1 ${MAX_ASSERT_RANK})
expand (${CMAKE_CURRENT_SOURCE_DIR}/ArrayWrapper.tmpl ArrayWrapper_${rank}d.F90)
expand (${CMAKE_CURRENT_SOURCE_DIR}/ArrayWrapper.tmpl ArrayWrapper_${rank}d.F90 ${rank})
endforeach()


Expand Down
4 changes: 2 additions & 2 deletions src/funit/fhamcrest/Every.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function every_item_(item_matcher) result(matcher)
matcher%item_matcher = item_matcher
end function every_item_

logical function matches(this, actual_value)
recursive logical function matches(this, actual_value)
class(Every), intent(in) :: this
class(*), intent(in) :: actual_value

Expand All @@ -51,7 +51,7 @@ logical function matches(this, actual_value)

end function matches

logical function matches_list(this, actual_values)
recursive logical function matches_list(this, actual_values)
class(Every), intent(in) :: this
class(*), intent(in) :: actual_values(:)

Expand Down
11 changes: 11 additions & 0 deletions tests/fhamcrest/Test_Every.pf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ contains

end subroutine test_every_fail_2d

! Ifort 19.1.2 reproducer fom AMR_Snowfake
@test
subroutine test_triply_periodic()
integer, parameter :: N = 2
real :: a(N,N,N)

a = 1
@assert_that(a(1,:,:), every_item(is(real(1))))

end subroutine test_triply_periodic

end module Test_Every
29 changes: 15 additions & 14 deletions tests/funit-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ set (test_srcs
Test_TestSuite.F90
)

if (NOT SKIP_ROBUST)
list (APPEND test_srcs
Test_UnixProcess.F90
Test_RobustRunner.F90
robustTestSuite.F90
)
endif ()

if (OPENMP_FORTRAN_FOUND)
list(APPEND test_srcs Test_BasicOpenMP.F90)
endif ()
Expand All @@ -90,9 +82,6 @@ target_link_libraries(funit_tests other_shared)

add_executable (funit_tests.x EXCLUDE_FROM_ALL serial_tests.F90)
target_link_libraries(funit_tests.x funit_tests funit)
if (NOT SKIP_ROBUST)
target_compile_definitions(funit_tests.x PRIVATE Robust)
endif ()

add_test(NAME old_tests
COMMAND funit_tests.x
Expand All @@ -101,11 +90,23 @@ add_test(NAME old_tests
add_dependencies(build-tests funit_tests.x)

if (NOT SKIP_ROBUST)
endif ()

if (NOT SKIP_ROBUST)
add_library(robust robustTestSuite.F90)
target_link_libraries(robust funit)
add_pfunit_ctest (robust_tests.x
TEST_SOURCES Test_UnixProcess.pf Test_RobustRunner.pf
LINK_LIBRARIES robust
)
add_dependencies(build-tests robust_tests.x)

set (REMOTE_EXE remote.x)
add_executable (${REMOTE_EXE} EXCLUDE_FROM_ALL serialRemoteProgram.F90)
target_link_libraries(${REMOTE_EXE} funit funit_tests)
add_dependencies(funit_tests.x ${REMOTE_EXE})
add_dependencies(tests ${REMOTE_EXE})
target_link_libraries(${REMOTE_EXE} funit robust)
add_dependencies(robust_tests.x ${REMOTE_EXE})
add_dependencies(build-tests ${REMOTE_EXE})

endif ()


Expand Down
77 changes: 0 additions & 77 deletions tests/funit-core/Test_RobustRunner.F90

This file was deleted.

21 changes: 2 additions & 19 deletions tests/funit-core/Test_RobustRunner.pf
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,9 @@ module Test_RobustRunner
use PF_Test
use PF_RobustRunner
implicit none
private

public :: suite

contains

function suite()
use PF_TestSuite, only: TestSuite
use PF_TestMethod, only: TestMethod
type (TestSuite) :: suite

suite = TestSuite('RobustRunner')
!#define ADD(method) call suite%addTest(TestMethod(REFLECT(method)))

call suite%addTest( &
& TestMethod('testRunVariety', &
& testRunVariety))

end function suite

subroutine testRunVariety()
use, intrinsic :: iso_fortran_env
Expand All @@ -60,11 +44,10 @@ contains

integer :: unit

open(newunit=unit,status='scratch')
open(newunit=unit, access='sequential',form='formatted',status='scratch')
runner = RobustRunner(ResultPrinter(unit), remoteRunCommand='./remote.x')
result = TestResult()
suite = remoteSuite()
call runner%runWithResult(suite, THE_SERIAL_CONTEXT, result)
result = runner%run(suite, THE_SERIAL_CONTEXT)

call assertEqual(5, result%runCount(),'runCount()')
call assertEqual(2, result%errorCount(), 'errorCount()')
Expand Down
Loading

0 comments on commit 4f11470

Please sign in to comment.