Repository navigation
Update compiler flags for consistency with MOM5 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mom5
Are you sure you want to change the base?
Changes from 4 commits
14d5116
057d085
9e55c1c
c907a34
4a8501b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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() | ||
|
|
@@ -63,37 +63,37 @@ 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 -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 -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") | ||
| 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 -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 -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") | ||
|
|
||
| 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 -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") | ||
|
|
||
| else() | ||
| message(WARNING "Fortran compiler with ID ${CMAKE_Fortran_COMPILER_ID} will be used with CMake default options") | ||
|
|
@@ -106,30 +106,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") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't see any difference between these two changed lines? Are these whitespace-only changes?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I added
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spacing is sorted in 4a8501b. If I don't adjust the whitespace for the existing sets they will be inconsistent with the new
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fine with whichever works for you. Was just making sure that I wasn't missing anything :D |
||
| 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 +143,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: only r8_flags (used below) is defined for the Fortran precision flags | ||
|
manodeep marked this conversation as resolved.
|
||
| # 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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
Intel/IntelLLVMbranches have an-i4embedded into the "always-on" flags but GNU does not - is that intentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we need a
big-endian-conversionflag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as far as I know, there is no equivalent flag. 4-byte integers are gfortran's default. One can set
-fdefault-integer-8, but there's no equivalent flag to "unset" it back to the default like there is for ifx/ifort.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably a good idea. Added in 4a8501b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - totally forgot to update here. I trawled through the gfortran docs and yes, there is no equivalent compiler flag for
-i4