From d84ebe0c06c234d23880e4eb7efc85571baadce7 Mon Sep 17 00:00:00 2001 From: Tim Cera Date: Tue, 23 Jan 2024 19:53:22 -0500 Subject: [PATCH 1/3] Set correct no bounds check for Intel and gfortran and only for Debug build. Older versions of gfortran don't accept "-fcheck=no-bounds" but do accept "-fno-bounds-check" even though the later form is deprecated. --- src/CMakeLists.txt | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86ce0c81..66bedd66 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,9 +26,28 @@ if(BUILD_DEPRECATED) sptgpsd.f sptgptd.f sptgptsd.f sptgptvd.f sptrund.f sptrunl.f spvar.f) endif() -set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) -set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) -set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) +# Set compiler flags. +if(CMAKE_BUILD_TYPE MATCHES "Debug") + # Bounds checking is turned on for all files for the "Debug" build in the + # main CMakeLists.txt. + # Need to turn off bounds checking for fftpack.F, sptranf.f, and sptranfv.f + # in order to pass tests. + if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$") + set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -check=nobounds) + set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -check=nobounds) + set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -check=nobounds) + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) + set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) + set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) + else() + set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -fno-bounds-check) + set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -fno-bounds-check) + set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -fno-bounds-check) + endif() + endif() +endif() # Build _4, _d, and/or _8 depending on options provided to CMake foreach(kind ${kinds}) From f98cd41c39ccaab8632fd899f09a7528f0e94cbe Mon Sep 17 00:00:00 2001 From: Tim Cera Date: Wed, 24 Jan 2024 09:17:16 -0500 Subject: [PATCH 2/3] Use foreach loop. --- src/CMakeLists.txt | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 66bedd66..f115e5ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,21 +32,17 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug") # main CMakeLists.txt. # Need to turn off bounds checking for fftpack.F, sptranf.f, and sptranfv.f # in order to pass tests. - if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$") - set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -check=nobounds) - set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -check=nobounds) - set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -check=nobounds) - elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") - if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) - set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) - set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) - set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) - else() - set_source_files_properties(fftpack.F PROPERTIES COMPILE_FLAGS -fno-bounds-check) - set_source_files_properties(sptranf.f PROPERTIES COMPILE_FLAGS -fno-bounds-check) - set_source_files_properties(sptranfv.f PROPERTIES COMPILE_FLAGS -fno-bounds-check) + foreach(filename fftpack.F sptranf.f sptranfv.f) + if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$") + set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -check=nobounds) + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") + if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) + else() + set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -fno-bounds-check) + endif() endif() - endif() + endforeach() endif() # Build _4, _d, and/or _8 depending on options provided to CMake From 9004b0a58d1c950411a8015e7faccfaebdddaac4 Mon Sep 17 00:00:00 2001 From: Timothy Cera Date: Wed, 24 Jan 2024 16:18:50 -0500 Subject: [PATCH 3/3] Changed use of the new format for -fcheck to gfortran >= 6. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f115e5ee..b979c148 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,7 +36,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug") if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$") set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -check=nobounds) elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") - if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10) + if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 6) set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -fcheck=no-bounds) else() set_source_files_properties(${filename} PROPERTIES COMPILE_FLAGS -fno-bounds-check)