Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ project(FMS
LANGUAGES C Fortran)

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.")
Expand Down Expand Up @@ -63,6 +64,11 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")

# 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")
# 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_DEBUG "-O0 -g -W -fbounds-check")

Expand All @@ -74,7 +80,7 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
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 -align all")
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")

Expand All @@ -85,7 +91,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 -traceback -nowarn -check noarg_temp_created -assume nobuffered_io -convert big_endian -grecord-gcc-switches -align all")
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")

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

# Copied from MOM5/bin/mkmf.template.nci
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
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")

elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")

# Copied from MOM5/bin/mkmf.template.nci
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
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")

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