From d11b35b777220d2a0cd9c4bb880ebcdad7c45a8a Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 9 Mar 2022 15:29:56 -0500 Subject: [PATCH 1/4] Fixes to enable PGI compiler support - Treatment of 128 bit reals was not properly guarded for compilers that lack 128 bit support. - PGI compiler flags were fixed. PGI will soon be supported, but will likely require a very recent version of the compiler. --- CMakeLists.txt | 2 +- ChangeLog.md | 9 ++++++ cmake/PGI.cmake | 2 +- src/funit/fhamcrest/BaseDescription.F90 | 6 +++- src/funit/fhamcrest/IsEqual.F90 | 42 +++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d55defa..a27d0881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ cmake_minimum_required(VERSION 3.12) project (PFUNIT - VERSION 4.2.2 + VERSION 4.2.3 LANGUAGES Fortran C) # Determine if pFUnit is built as a subproject (using diff --git a/ChangeLog.md b/ChangeLog.md index a318c7fb..f37daccf 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.2.2] - 2022-03-09 + + + +### Fixed + + - Incorrect treatment of 128 bit real support for compilers that do not support REAL128. + - Incorrect compilel flags for PGI + ### Changed - When any tests fail, the driver now invokes Fortran `STOP` instead of diff --git a/cmake/PGI.cmake b/cmake/PGI.cmake index cd510a80..8b100551 100644 --- a/cmake/PGI.cmake +++ b/cmake/PGI.cmake @@ -2,7 +2,7 @@ # (or is this now NVIDIA?) set(traceback "-traceback") -set(check_all "-Mbounds -Mchkfpstk -Mchkstk") +set(check_all "-Mbounds -Mchkstk") set(CMAKE_Fortran_FLAGS_DEBUG "-O0") set(CMAKE_Fortran_FLAGS_RELEASE "-O3") diff --git a/src/funit/fhamcrest/BaseDescription.F90 b/src/funit/fhamcrest/BaseDescription.F90 index f3483947..01abc0d4 100644 --- a/src/funit/fhamcrest/BaseDescription.F90 +++ b/src/funit/fhamcrest/BaseDescription.F90 @@ -115,7 +115,7 @@ recursive subroutine append_value_scalar(this, value) call this%append(description_of(value)) call this%append('_real64>') #endif -#if (defined(_ISO_REAL128) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) +#if (defined(_ISO_REAL128) && (_ISO_REAL128 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) type is (real(kind=REAL128)) call this%append('<') call this%append(description_of(value)) @@ -305,6 +305,7 @@ function description_of_real64(value) result(string) end function description_of_real64 +#if (defined(_ISO_REAL128) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) function description_of_real128(value) result(string) use pf_Matchable character(:), allocatable :: string @@ -314,6 +315,7 @@ function description_of_real128(value) result(string) write(buffer,'(g0)') value string = trim(buffer) end function description_of_real128 +#endif function description_of_complex32(value) result(string) use pf_Matchable @@ -332,6 +334,7 @@ function description_of_complex64(value) result(string) end function description_of_complex64 +#if (defined(_ISO_REAL128) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) function description_of_complex128(value) result(string) use pf_Matchable character(:), allocatable :: string @@ -339,6 +342,7 @@ function description_of_complex128(value) result(string) string = "(" // description_of(real(value)) // "," // description_of(aimag(value)) // ")" end function description_of_complex128 +#endif end module pf_BaseDescription diff --git a/src/funit/fhamcrest/IsEqual.F90 b/src/funit/fhamcrest/IsEqual.F90 index 59a3bec5..574b7f0b 100644 --- a/src/funit/fhamcrest/IsEqual.F90 +++ b/src/funit/fhamcrest/IsEqual.F90 @@ -220,6 +220,8 @@ logical function matches_intrinsic(this, actual_value) class(IsEqual), intent(in) :: this class(*), target, intent(in) :: actual_value + integer, parameter :: DP = kind(1.d0) + select type (e => this%expected_value) type is (logical) select type(a => actual_value) @@ -242,6 +244,21 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select + type is (real) + select type(a => actual_value) + type is (real) + matches_intrinsic = (e == a) + class default + matches_intrinsic = .false. + end select + type is (real(kind=DP)) + select type(a => actual_value) + type is (real(kind=DP)) + matches_intrinsic = (e == a) + class default + matches_intrinsic = .false. + end select +#if (defined(_ISO_REAL32) && (_ISO_REAL32 != _REAL_DEFAULT_KIND) && (_ISO_REAL32 != _DOUBLE_DEFAULT_KIND)) type is (real(kind=REAL32)) select type(a => actual_value) type is (real(kind=REAL32)) @@ -249,6 +266,8 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif +#if (defined(_ISO_REAL64) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL64 != _DOUBLE_DEFAULT_KIND)) type is (real(kind=REAL64)) select type(a => actual_value) type is (real(kind=REAL64)) @@ -256,6 +275,8 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif +#if (defined(_ISO_REAL128) && (_ISO_REAL128 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) type is (real(kind=REAL128)) select type(a => actual_value) type is (real(kind=REAL128)) @@ -263,6 +284,22 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif + type is (complex) + select type(a => actual_value) + type is (complex) + matches_intrinsic = (e == a) + class default + matches_intrinsic = .false. + end select + type is (complex(kind=DP)) + select type(a => actual_value) + type is (complex(kind=DP)) + matches_intrinsic = (e == a) + class default + matches_intrinsic = .false. + end select +#if (defined(_ISO_REAL32) && (_ISO_REAL32 != _REAL_DEFAULT_KIND) && (_ISO_REAL32 != _DOUBLE_DEFAULT_KIND)) type is (complex(kind=REAL32)) select type(a => actual_value) type is (complex(kind=REAL32)) @@ -270,6 +307,8 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif +#if (defined(_ISO_REAL64) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL64 != _DOUBLE_DEFAULT_KIND)) type is (complex(kind=REAL64)) select type(a => actual_value) type is (complex(kind=REAL64)) @@ -277,6 +316,8 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif +#if (defined(_ISO_REAL128) && (_ISO_REAL128 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) type is (complex(kind=REAL128)) select type(a => actual_value) type is (complex(kind=REAL128)) @@ -284,6 +325,7 @@ logical function matches_intrinsic(this, actual_value) class default matches_intrinsic = .false. end select +#endif type is (character(*)) select type(a => actual_value) type is (character(*)) From 82e658cd7bcf23c270588e535ec3af9e9ddb216f Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 9 Mar 2022 15:41:13 -0500 Subject: [PATCH 2/4] Missed a file. --- cmake/NVHPC.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 cmake/NVHPC.cmake diff --git a/cmake/NVHPC.cmake b/cmake/NVHPC.cmake new file mode 100644 index 00000000..8b100551 --- /dev/null +++ b/cmake/NVHPC.cmake @@ -0,0 +1,10 @@ +# Compiler specific flags for PGI Fortran compiler +# (or is this now NVIDIA?) + +set(traceback "-traceback") +set(check_all "-Mbounds -Mchkstk") + +set(CMAKE_Fortran_FLAGS_DEBUG "-O0") +set(CMAKE_Fortran_FLAGS_RELEASE "-O3") +set(CMAKE_Fortran_FLAGS "-g ${traceback} ${check_all} -Mallocatable=03") + From 15316578d0fb829b8b21939c0c076ec8d58c6240 Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 9 Mar 2022 16:14:06 -0500 Subject: [PATCH 3/4] Update src/funit/fhamcrest/BaseDescription.F90 Co-authored-by: Matthew Thompson --- src/funit/fhamcrest/BaseDescription.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funit/fhamcrest/BaseDescription.F90 b/src/funit/fhamcrest/BaseDescription.F90 index 01abc0d4..7cab4643 100644 --- a/src/funit/fhamcrest/BaseDescription.F90 +++ b/src/funit/fhamcrest/BaseDescription.F90 @@ -305,7 +305,7 @@ function description_of_real64(value) result(string) end function description_of_real64 -#if (defined(_ISO_REAL128) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) +#if (defined(_ISO_REAL128) && (_ISO_REAL128 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) function description_of_real128(value) result(string) use pf_Matchable character(:), allocatable :: string From e2bdc712506af9d6687c6ac98c37604c526f4b3c Mon Sep 17 00:00:00 2001 From: Tom Clune Date: Wed, 9 Mar 2022 16:14:23 -0500 Subject: [PATCH 4/4] Update src/funit/fhamcrest/BaseDescription.F90 Co-authored-by: Matthew Thompson --- src/funit/fhamcrest/BaseDescription.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/funit/fhamcrest/BaseDescription.F90 b/src/funit/fhamcrest/BaseDescription.F90 index 7cab4643..0eda5a42 100644 --- a/src/funit/fhamcrest/BaseDescription.F90 +++ b/src/funit/fhamcrest/BaseDescription.F90 @@ -334,7 +334,7 @@ function description_of_complex64(value) result(string) end function description_of_complex64 -#if (defined(_ISO_REAL128) && (_ISO_REAL64 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) +#if (defined(_ISO_REAL128) && (_ISO_REAL128 != _REAL_DEFAULT_KIND) && (_ISO_REAL128 != _DOUBLE_DEFAULT_KIND)) function description_of_complex128(value) result(string) use pf_Matchable character(:), allocatable :: string