Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/sanitize' into dev/14.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: Melissa Sulprizio <[email protected]>
  • Loading branch information
msulprizio committed Nov 18, 2022
2 parents bc2679e + 27f3d0d commit 54a0055
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ This file documents all notable changes to the GEOS-Chem Classic wrapper reposit
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased 14.1.0]
## Changed
### Added
- Added SANITIZE CMake option

### Changed
- Updated GEOS-Chem submodule to 14.1.0
- Updated HEMCO submodule to 3.6.0

Expand Down
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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()

Expand Down
34 changes: 34 additions & 0 deletions CMakeScripts/GC-ConfigureClassic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,39 @@ function(configureGCClassic)
INTERFACE $<$<BOOL:${USE_REAL8}>: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
#-------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/HEMCO
Submodule HEMCO updated 1 files
+12 −2 CHANGELOG.md

0 comments on commit 54a0055

Please sign in to comment.