From 1d6e1d0b614193cc86aa710fe04d38277dd17d31 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 2 Dec 2024 13:06:17 -0700 Subject: [PATCH 1/3] Clear all cmake default imported release flags to avoid flag pollution Depending on architecture and compiler, CMake may prepend flags into global flags. While this may work for general CMake projects, the use of arch/configure.defaults allows for specific control of flag options where additional unintended optimization flags may negatively impact compilation, performance, or even model validity. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd0264b72..49c09c1035 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ if ( DEFINED CMAKE_TOOLCHAIN_FILE ) # include( ${WRF_CONFIG} ) endif() +# Import default flags now, get rid of any imported release flag +# we will handle that ourselves with WRF_FCOPTIM/WRF_FCNOOPT +set( CMAKE_Fortran_FLAGS_RELEASE "" CACHE STRING "" FORCE ) +set( CMAKE_C_FLAGS_RELEASE "" CACHE STRING "" FORCE ) + # list( APPEND CMAKE_MODULE_PATH ) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${PROJECT_SOURCE_DIR}/cmake/modules ) From 13eecaa6eb2a5e219cd7001efa7b932be247bd80 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 2 Dec 2024 13:11:06 -0700 Subject: [PATCH 2/3] Use capitalized naming of predefined build types --- cmake/template/arch_config.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/template/arch_config.cmake b/cmake/template/arch_config.cmake index 0a655a4e32..7780034c30 100644 --- a/cmake/template/arch_config.cmake +++ b/cmake/template/arch_config.cmake @@ -15,10 +15,10 @@ set( CMAKE_Fortran_FLAGS_INIT "{SFC_FLAGS} {FCBASEOPTS} {BYTESWAPIO}" ) set( CMAKE_C_FLAGS_INIT "{SCC_FLAGS} {CFLAGS_LOCAL}" ) # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.html -set( CMAKE_Fortran_FLAGS_Debug_INIT "{FCDEBUG}" ) -set( CMAKE_Fortran_FLAGS_Release_INIT "" ) -set( CMAKE_C_FLAGS_Debug_INIT "" ) -set( CMAKE_C_FLAGS_Release_INIT "" ) +set( CMAKE_Fortran_FLAGS_DEBUG_INIT "{FCDEBUG}" ) +set( CMAKE_Fortran_FLAGS_RELEASE_INIT "" ) +set( CMAKE_C_FLAGS_DEBUG_INIT "" ) +set( CMAKE_C_FLAGS_RELEASE_INIT "" ) # Project specifics now set( WRF_MPI_Fortran_FLAGS "{DM_FC_FLAGS}" ) From ab2c46f907db8c82d079813b51476d383f64a03f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Mon, 2 Dec 2024 13:11:50 -0700 Subject: [PATCH 3/3] Set the directory of the property to be properly scoped --- frame/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/CMakeLists.txt b/frame/CMakeLists.txt index 4543c4694e..dde702bcf6 100644 --- a/frame/CMakeLists.txt +++ b/frame/CMakeLists.txt @@ -155,6 +155,8 @@ target_sources( # Disable optimizations on these files always set_source_files_properties( ${nl_dyn_source} + module_comm_nesting_dm.F + DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTIES COMPILE_OPTIONS_OPTIMIZATION $<$:${WRF_FCNOOPT}>