From 945cf00212ade8ddebe1c622d0f1093e1c619314 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Fri, 13 Jan 2023 14:52:06 -0500 Subject: [PATCH] add gfortran flags for tracking down memory access issues --- cmake/Modules/SetFortranFlags.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/SetFortranFlags.cmake b/cmake/Modules/SetFortranFlags.cmake index 5ce3c4925..cb5ab68ad 100644 --- a/cmake/Modules/SetFortranFlags.cmake +++ b/cmake/Modules/SetFortranFlags.cmake @@ -109,14 +109,17 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" "-fbacktrace" # GNU (gfortran) "-ftrace=full" # GNU (g95) ) +# Sanitize +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-fsanitize=address" # Gnu + ) + # Check everything SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-check" # Intel "/check" # Intel Windows - "-fcheck=bounds" # GNU (New style) - "-fbounds-check" # GNU (Old style) - "-Mbounds" # Portland Group + "-fcheck=all" # GNU ) # Initializes matrices/arrays with NaN values @@ -142,6 +145,7 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" # Enables floating-point invalid, divide-by-zero, and overflow exceptions SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-fpe-all=0" # Intel + "-ffpe-trap=zero,overflow,underflow" # GNU ) # Improves floating-point precision and consistency