From 5aa4807823615971a1be6983a628b72448bf8721 Mon Sep 17 00:00:00 2001 From: TimothyCera-NOAA <154259143+TimothyCera-NOAA@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:25:57 -0500 Subject: [PATCH] Set correct no bounds check for Intel and gfortran only for Debug build (#219) * 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. * Use foreach loop. * Changed use of the new format for -fcheck to gfortran >= 6. --------- Co-authored-by: Tim Cera --- src/CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86ce0c81..b979c148 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,9 +26,24 @@ 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. + 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 6) + 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() + endforeach() +endif() # Build _4, _d, and/or _8 depending on options provided to CMake foreach(kind ${kinds})