From 14d5116ee97600609079722ce794276bdf564f3e Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Fri, 21 Aug 2026 15:30:53 +1000 Subject: [PATCH 1/5] Update compiler flags for consistency with MOM5 --- CMakeLists.txt | 66 ++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 261a38dbc4..dffaaaae88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,9 @@ include(GNUInstallDirs) include(CheckFortranCompilerFlag) if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$") - message(STATUS "Setting build type to 'Release' as none was specified.") + message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") set(CMAKE_BUILD_TYPE - "Release" + "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() @@ -59,41 +59,32 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - # Precision-based Fortran compiler flags - set(r8_flags "-fdefault-real-8 -fdefault-double-8") # Fortran flags for 64BIT precision - # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-real-8 -ffree-line-length-none -fno-range-check -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fno-range-check -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") # Note, -fallow-argument-mismatch is handled further down check_fortran_compiler_flag("-fallow-invalid-boz" _boz_flag) if(_boz_flag) set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-invalid-boz" ) endif() set(CMAKE_Fortran_FLAGS_RELEASE "-O2") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g -frecord-gcc-switches -fbacktrace") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -W -fbounds-check") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") - # Precision-based Fortran compiler flags - set(r4_flags "-real-size 32") # Fortran flags for 32BIT precision - set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision - set(r8_flags "${r8_flags} -no-prec-div -no-prec-sqrt") - # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -traceback -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -grecord-gcc-switches -fp-model precise -fp-model source -align all") - set(CMAKE_Fortran_FLAGS_RELEASE "-g3 -O2 -xCORE-AVX2 -debug all -check none") - set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") + set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") - # Precision-based Fortran compiler flags - set(r4_flags "-real-size 32") # Fortran flags for 32BIT precision - set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision - # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -traceback -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -grecord-gcc-switches -fp-model precise -fp-model source -align all") - set(CMAKE_Fortran_FLAGS_RELEASE "-g3 -O2 -xCORE-AVX2 -debug all -check none") - set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") + set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") + set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") else() message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") @@ -106,30 +97,34 @@ endif() if(CMAKE_C_COMPILER_ID MATCHES "GNU") # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel") # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -fp-model source") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") - set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -fp-model source") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") + set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") - set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") + set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") else() message(WARNING "C compiler with ID ${CMAKE_C_COMPILER_ID} will be used with CMake default options") @@ -139,9 +134,8 @@ endif() # Build options option(OPENMP "Build FMS with OpenMP support" OFF) -# Commented out while CMAKE_Fortran_FLAGS contains -r8 +# Only 64BIT (r8) builds are supported: CMAKE_Fortran_FLAGS above unconditionally contains -r8 / -fdefault-real-8 # option(32BIT "Build 32-bit (r4) FMS library" OFF) -# Refer to CMAKE_Fortran_FLAGS above, it contains -r8 option(64BIT "Build 64-bit (r8) FMS library" ON) option(FPIC "Build with position independent code" OFF) option(SHARED_LIBS "Build shared/dynamic libraries" OFF) @@ -353,8 +347,6 @@ foreach(kind ${kinds}) target_compile_definitions(${libTgt}_f PRIVATE "${fms_defs}") target_compile_definitions(${libTgt}_f PRIVATE "${${kind}_defs}") - set_target_properties(${libTgt}_f PROPERTIES COMPILE_FLAGS "${${kind}_flags}") - set_target_properties(${libTgt}_f PROPERTIES Fortran_MODULE_DIRECTORY ${moduleDir}) From 057d085f944fc0c1e90feee63bcf444b907b5d70 Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Fri, 21 Aug 2026 16:54:53 +1000 Subject: [PATCH 2/5] Add back r8_flags --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dffaaaae88..9b0c351b51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,8 +59,11 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + # Precision-based Fortran compiler flags + set(r8_flags "-fdefault-real-8 -fdefault-double-8") # Fortran flags for 64BIT precision + # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -fdefault-real-8 -fdefault-double-8 -ffree-line-length-none -fno-range-check -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") # Note, -fallow-argument-mismatch is handled further down check_fortran_compiler_flag("-fallow-invalid-boz" _boz_flag) if(_boz_flag) @@ -72,6 +75,9 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + # Precision-based Fortran compiler flags + set(r8_flags "-real-size 64 -no-prec-div -no-prec-sqrt") # Fortran flags for 64BIT precision + # Copied from MOM5/bin/mkmf.template.nci set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") @@ -80,6 +86,9 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + # Precision-based Fortran compiler flags + set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision + # Copied from MOM5/bin/mkmf.template.nci set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") @@ -134,7 +143,7 @@ endif() # Build options option(OPENMP "Build FMS with OpenMP support" OFF) -# Only 64BIT (r8) builds are supported: CMAKE_Fortran_FLAGS above unconditionally contains -r8 / -fdefault-real-8 +# Only 64BIT (r8) builds are supported: only r8_flags (used below) is defined for the Fortran precision flags # option(32BIT "Build 32-bit (r4) FMS library" OFF) option(64BIT "Build 64-bit (r8) FMS library" ON) option(FPIC "Build with position independent code" OFF) @@ -347,6 +356,8 @@ foreach(kind ${kinds}) target_compile_definitions(${libTgt}_f PRIVATE "${fms_defs}") target_compile_definitions(${libTgt}_f PRIVATE "${${kind}_defs}") + set_target_properties(${libTgt}_f PROPERTIES COMPILE_FLAGS "${${kind}_flags}") + set_target_properties(${libTgt}_f PROPERTIES Fortran_MODULE_DIRECTORY ${moduleDir}) From 9e55c1c7ab79cd80aff3785bb76c8359b33ffdef Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Fri, 21 Aug 2026 20:44:29 +1000 Subject: [PATCH 3/5] Remove duplicate -r8; replace -i4 with -integer-size 32 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b0c351b51..c7d9235202 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") set(r8_flags "-real-size 64 -no-prec-div -no-prec-sqrt") # Fortran flags for 64BIT precision # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") @@ -90,7 +90,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -i4 -r8 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") From c907a3436957152e1768290a1185827432cfc669 Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Fri, 21 Aug 2026 20:59:00 +1000 Subject: [PATCH 4/5] Remove duplicate and redundant -check noarg_temp_created --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7d9235202..201f720120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") set(r8_flags "-real-size 64 -no-prec-div -no-prec-sqrt") # Fortran flags for 64BIT precision # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") @@ -90,7 +90,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-alias -safe-cray-ptr -fpe0 -ftz -assume byterecl -integer-size 32 -nowarn -assume nobuffered_io -convert big_endian -fp-model precise -fp-model source -align all") set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xCORE-AVX2 -debug all -check none") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELEASE} -g3 -grecord-gcc-switches -traceback") set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv -traceback") From 4a8501baedf81791505fd765f822987eb070ac28 Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Tue, 25 Aug 2026 11:02:51 +1000 Subject: [PATCH 5/5] Address review comments --- CMakeLists.txt | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 201f720120..da64228898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(r8_flags "-fdefault-real-8 -fdefault-double-8") # Fortran flags for 64BIT precision # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check -fconvert=big-endian -Waliasing -Wampersand -Warray-bounds -Wcharacter-truncation -Wconversion -Wline-truncation -Wintrinsics-std -Wsurprising -Wno-tabs -Wunderflow -Wunused-parameter -Wintrinsic-shadow -Wno-align-commons") # Note, -fallow-argument-mismatch is handled further down check_fortran_compiler_flag("-fallow-invalid-boz" _boz_flag) if(_boz_flag) @@ -106,33 +106,33 @@ endif() if(CMAKE_C_COMPILER_ID MATCHES "GNU") # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel") # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -fp-model source") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") - set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -fp-model source") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") + set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") # Copied from MOM5/bin/mkmf.template.nci - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") - set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback") + set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") # Copied from MOM5/bin/mkmf.template.nci.gfortran - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g") - set(CMAKE_C_FLAGS_RELEASE "-O2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g") + set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g") else() @@ -149,6 +149,10 @@ option(64BIT "Build 64-bit (r8) FMS library" ON) option(FPIC "Build with position independent code" OFF) option(SHARED_LIBS "Build shared/dynamic libraries" OFF) +if(NOT 64BIT) + message(FATAL_ERROR "64BIT must be ON: only 64-bit (r8) builds are currently supported.") +endif() + # Options for compiler definitions option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON) option(PORTABLE_KINDS "Enable compiler definition -DPORTABLE_KINDS" OFF)