diff --git a/CMakeLists.txt b/CMakeLists.txt index d5053dd..4c46bf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,15 +61,15 @@ set(GEOSChem_Fortran_FLAGS_Intel ) set(GEOSChem_Fortran_FLAGS_RELEASE_Intel -O2 - CACHE STRING "GEOSChem compiler flags for build type release with Intel compilers" + CACHE STRING "GEOSChem compiler flags for build type Release with Intel compilers" ) set(GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_Intel -O2 - CACHE STRING "GEOSChem compiler flags for build type relwithdebinfo with Intel compilers" + CACHE STRING "GEOSChem compiler flags for build type RelWithdDebInfo with Intel compilers" ) set(GEOSChem_Fortran_FLAGS_DEBUG_Intel - -g -O0 "SHELL:-check arg_temp_created" "SHELL:-debug all" -fpe0 -ftrapuv -check,bounds - CACHE STRING "GEOSChem compiler flags for build type debug with Intel compilers" + g -O0 "SHELL:-check arg_temp_created" "SHELL:-debug all" -fpe0 -ftrapuv -check,bounds + CACHE STRING "GEOSChem compiler flags for build type Debug with Intel compilers" ) set(GEOSChem_Fortran_FLAGS_GNU @@ -80,17 +80,17 @@ set(GEOSChem_Fortran_FLAGS_GNU ) set(GEOSChem_Fortran_FLAGS_RELEASE_GNU -O3 -funroll-loops - CACHE STRING "GEOSChem compiler flags for build type release with GNU compilers" + CACHE STRING "GEOSChem compiler flags for build type Release with GNU compilers" ) set(GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_GNU -O3 -funroll-loops - CACHE STRING "GEOSChem compiler flags for build type relwithdebinfo with GNU compilers" + CACHE STRING "GEOSChem compiler flags for build type RelWithDebInfo with GNU compilers" ) set(GEOSChem_Fortran_FLAGS_DEBUG_GNU - -g -gdwarf-2 -gstrict-dwarf -O0 -Wall -Wextra -Wconversion -Warray-temporaries + -g -O0 -Wall -Wextra -Wconversion -Warray-temporaries -fcheck=array-temps -ffpe-trap=invalid,zero,overflow -finit-real=snan -fcheck=bounds -fcheck=pointer - CACHE STRING "GEOSChem compiler flags for build type debug with GNU compilers" + CACHE STRING "GEOSChem compiler flags for build type Debug with GNU compilers" ) set(GEOSChem_SUPPORTED_COMPILER_IDS "Intel" "GNU") @@ -221,9 +221,9 @@ if(NOT GC_EXTERNAL_CONFIG) set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE) gc_pretty_print(VARIABLE RUNDIR) - # Configure for GCClassic - include(GC-ConfigureClassic) - configureGCClassic() + # Configure for GCClassic + include(GC-ConfigureClassic) + configureGCClassic() endif() diff --git a/CMakeScripts/GC-ConfigureClassic.cmake b/CMakeScripts/GC-ConfigureClassic.cmake index 078b9c4..97834f3 100755 --- a/CMakeScripts/GC-ConfigureClassic.cmake +++ b/CMakeScripts/GC-ConfigureClassic.cmake @@ -74,6 +74,39 @@ function(configureGCClassic) INTERFACE $<$:USE_REAL8> ) + #------------------------------------------------------------------------- + # Add code sanitization options (GNU Fortran only) + # We need to add these options to both compiler & linker. + #------------------------------------------------------------------------- + set(SANITIZE OFF CACHE BOOL + "Switch to turn on code sanitation (i.e. identify memory leaks and similar conditions)" + ) + gc_pretty_print(VARIABLE SANITIZE IS_BOOLEAN) + if(${SANITIZE}) + if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + target_compile_options(GEOSChemBuildProperties + INTERFACE "-fsanitize=address" + ) + target_link_libraries(GEOSChemBuildProperties + INTERFACE "-fsanitize=address" + ) + target_compile_options(GEOSChemBuildProperties + INTERFACE "-fsanitize=leak" + ) + target_link_libraries(GEOSChemBuildProperties + INTERFACE "-fsanitize=leak" + ) + target_compile_options(GEOSChemBuildProperties + INTERFACE "-fsanitize=undefined" + ) + target_link_libraries(GEOSChemBuildProperties + INTERFACE "-fsanitize=undefined" + ) + else() + message( FATAL_ERROR "The SANITIZE option is only defined for GNU Fortran.") + endif() + endif() + #------------------------------------------------------------------------- # Always set MODEL_CLASSIC when building GEOS-Chem Classic #------------------------------------------------------------------------- @@ -180,6 +213,7 @@ function(configureGCClassic) set(RRTMG ${RRTMG} PARENT_SCOPE) set(GTMM ${GTMM} PARENT_SCOPE) set(LUO_WETDEP ${LUO_WETDEP} PARENT_SCOPE) + set(SANITIZE ${SANITIZE} PARENT_SCOPE) #------------------------------------------------------------------------- # Export information about Git status diff --git a/src/GEOS-Chem b/src/GEOS-Chem index 53cac3b..29ae8da 160000 --- a/src/GEOS-Chem +++ b/src/GEOS-Chem @@ -1 +1 @@ -Subproject commit 53cac3b937064bdceed21acec721a157b6fb8b1e +Subproject commit 29ae8daf0f0e9d3748d0a2fb85f6dae5154579f9 diff --git a/src/HEMCO b/src/HEMCO index 505975a..5be2f32 160000 --- a/src/HEMCO +++ b/src/HEMCO @@ -1 +1 @@ -Subproject commit 505975a7ce9bf4080f777bf96879187ae9bfc1eb +Subproject commit 5be2f322de561ee46ecbd07ac30ef105544ed3f5