Skip to content

Update compiler flags for consistency with MOM5 - #27

Draft
dougiesquire wants to merge 5 commits into
mom5from
mom5-flag-consolidate
Draft

dougiesquire wants to merge 5 commits into
mom5from
mom5-flag-consolidate

Conversation

@dougiesquire

@dougiesquire dougiesquire commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

This PR updates the compiler flags in the CMakeLists for consistency with what is used in MOM5 - see discussion here.

This is a temporary measure until we have a organisational recommendations for compiler flags. This change should not change any answers (will test)

To do:

  • Expose build_type variant in spack package (default RelWithDebInfo) - PR here

@dougiesquire dougiesquire self-assigned this Aug 21, 2026
@dougiesquire

Copy link
Copy Markdown
Collaborator Author

A couple of things slightly different than what was discussed:

  • r8_flags is being used so I've kept it and removed duplicate flags from CMAKE_Fortran_FLAGS. r4_flags is not used so has been removed.
  • I removed -check noarg_temp_created from CMAKE_Fortran_FLAGS. This was doing nothing due to the -check none in the RELEASE and RELWITHDEBINFO set. It is still included in the DEBUG set.

@dougiesquire

Copy link
Copy Markdown
Collaborator Author

This is ready for review together with ACCESS-NRI/MOM5#91 @harshula, @manodeep

No answer changes with oneapi in ACCESS-OM2 or ACCESS-ESM1.6 (tested here and here)

@manodeep manodeep left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good - I made some minor comments

Comment thread CMakeLists.txt Outdated

# 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")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Intel/IntelLLVM branches have an -i4 embedded into the "always-on" flags but GNU does not - is that intentional?

Copy link
Copy Markdown
Collaborator

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-conversion flag?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Intel/IntelLLVM branches have an -i4 embedded into the "always-on" flags but GNU does not - is that intentional?

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.

Copy link
Copy Markdown
Collaborator Author

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-conversion flag?

Yeah, probably a good idea. Added in 4a8501b

Copy link
Copy Markdown
Collaborator

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

Comment thread CMakeLists.txt Outdated
Comment on lines +109 to +111
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")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I added CMAKE_C_FLAGS_RELWITHDEBINFO (below) and tried to align things for readability/consistency (though I see I missed a space 😅)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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 CMAKE_C_FLAGS_RELWITHDEBINFO set. But happy to do this if you prefer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Comment thread CMakeLists.txt

@manodeep manodeep left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - thanks!

@dougiesquire

Copy link
Copy Markdown
Collaborator Author

Thanks @manodeep. Are you also planning on looking at the MOM5 counterpart PR?

@manodeep

Copy link
Copy Markdown
Collaborator

@dougiesquire LGTM (I had already approved)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants