Skip to content

Commit c56cd23

Browse files
committed
Add MOM5 REPRO flags to preserve answers with MOM5 internal FMS
1 parent 5419a11 commit c56cd23

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ project(FMS
3030
LANGUAGES C Fortran)
3131

3232
include(GNUInstallDirs)
33+
include(CheckFortranCompilerFlag)
3334

3435
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
3536
message(STATUS "Setting build type to 'Release' as none was specified.")
@@ -63,6 +64,11 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
6364

6465
# Copied from MOM5/bin/mkmf.template.nci.gfortran
6566
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")
67+
# Note, -fallow-argument-mismatch is handled further down
68+
check_fortran_compiler_flag("-fallow-invalid-boz" _boz_flag)
69+
if(_boz_flag)
70+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-invalid-boz" )
71+
endif()
6672
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
6773
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -W -fbounds-check")
6874

@@ -74,7 +80,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
7480
set(r8_flags "${r8_flags} -no-prec-div -no-prec-sqrt")
7581

7682
# Copied from MOM5/bin/mkmf.template.nci
77-
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 -align all")
83+
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")
7884
set(CMAKE_Fortran_FLAGS_RELEASE "-g3 -O2 -xCORE-AVX2 -debug all -check none")
7985
set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv")
8086

@@ -85,7 +91,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
8591
set(r8_flags "-real-size 64") # Fortran flags for 64BIT precision
8692

8793
# Copied from MOM5/bin/mkmf.template.nci
88-
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 -align all")
94+
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")
8995
set(CMAKE_Fortran_FLAGS_RELEASE "-g3 -O2 -xCORE-AVX2 -debug all -check none")
9096
set(CMAKE_Fortran_FLAGS_DEBUG "-g3 -O0 -debug all -check -check noarg_temp_created -check nopointer -warn -warn noerrors -ftrapuv")
9197

@@ -107,14 +113,14 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU")
107113
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
108114

109115
# Copied from MOM5/bin/mkmf.template.nci
110-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
116+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -fp-model source")
111117
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback")
112118
set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2")
113119

114120
elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
115121

116122
# Copied from MOM5/bin/mkmf.template.nci
117-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
123+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise")
118124
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -ftrapuv -traceback")
119125
set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal -xCORE-AVX2")
120126

@@ -362,7 +368,6 @@ foreach(kind ${kinds})
362368
# Check if gnu 10 or higher
363369
# this should only be needed with mpich, but wasn't able to find a good way to find the MPI flavor consistently
364370
if ( CMAKE_Fortran_COMPILER_VERSION MATCHES "1[0-9]\.[0-9]*\.[0-9]*" AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
365-
include(CheckFortranCompilerFlag)
366371
check_fortran_compiler_flag("-fallow-argument-mismatch" _arg_mismatch_flag)
367372
if(_arg_mismatch_flag)
368373
message(STATUS "Adding -fallow-argument-mismatch flag to compile with GCC >=10 and MPICH")

0 commit comments

Comments
 (0)