Skip to content
Merged
Changes from 1 commit
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
31 changes: 26 additions & 5 deletions cmake/compiler_flags/Cray_Fortran.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,29 @@

# -emf activates .mods and uses lower case
# -rmoid produces a listing file
set( CMAKE_Fortran_FLAGS_RELEASE "-emf -rmoid -N 1023 -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" CACHE STRING "Release Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-emf -rmoid -N 1023 -O2 -hfp1 -g -DNDEBUG" CACHE STRING "Release-with-debug-info Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_PRODUCTION "-emf -rmoid -N 1023 -O2 -hfp1 -g" CACHE STRING "Production Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_BIT "-emf -rmoid -N 1023 -O2 -hfp1 -g -hflex_mp=conservative -hadd_paren -DNDEBUG" CACHE STRING "Bit-reproducible Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_DEBUG "-emf -rmoid -N 1023 -O0 -g" CACHE STRING "Debug Fortran flags" FORCE )

if( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0.1 )
# From CCE 18.0.1 onwards, HPE/Cray renamed mod files for Fortran submodules
# from <submodule_name>.mod to <parent_module_name>.<submodule_name>.smod
# CMake does not yet (as of v4.2.3) handle this correctly, thus we have to
# manually inject the correct behaviour here by
set( CMAKE_Fortran_SUBMODULE_SEP "." )
set( CMAKE_Fortran_SUBMODULE_EXT ".smod" )
endif()

if( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0.0 AND CMAKE_Fortran_COMPILER VERSION_LESS 20.0.0 )
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The version-range check uses CMAKE_Fortran_COMPILER VERSION_LESS 20.0.0, but CMAKE_Fortran_COMPILER is typically a path to the compiler executable, not a version string. This makes the condition unreliable (and can mis-detect CCE 18/19). Use CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 20.0.0 for the upper-bound comparison (or compare only against CMAKE_Fortran_COMPILER_VERSION on both sides).

Suggested change
if( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0.0 AND CMAKE_Fortran_COMPILER VERSION_LESS 20.0.0 )
if( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0.0 AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 20.0.0 )

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

# Unfortunately, CCE 18 and 19 incurred a bug in the lower-casing of
# submodule .smod files with the above change, leading to incomplete
# lower-casing of the output file name, e.g., `parent_mod.sUB_MOD.smod`.
# This is supposedly fixed in CCE20, but we have to switch off the use of
# the `-ef` option for versions in-between.
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

Comment mentions disabling the -ef option, but the logic is actually toggling between -emf and -em (i.e., dropping the trailing f). To avoid confusion for future maintainers, update the comment to reference the actual flag being changed (e.g., -emf / the f modifier) or confirm -ef is the intended option name.

Suggested change
# the `-ef` option for versions in-between.
# the `-emf` option (i.e., drop the trailing `f` and use `-em`) for versions in-between.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

set( _crayftn_mod_options "-em" )
else()
set( _crayftn_mod_options "-emf" )
endif()

set( CMAKE_Fortran_FLAGS_RELEASE "${_crayftn_mod_options} -rmoid -N 1023 -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" CACHE STRING "Release Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${_crayftn_mod_options} -rmoid -N 1023 -O2 -hfp1 -g -DNDEBUG" CACHE STRING "Release-with-debug-info Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_PRODUCTION "${_crayftn_mod_options} -rmoid -N 1023 -O2 -hfp1 -g" CACHE STRING "Production Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_BIT "${_crayftn_mod_options} -rmoid -N 1023 -O2 -hfp1 -g -hflex_mp=conservative -hadd_paren -DNDEBUG" CACHE STRING "Bit-reproducible Fortran flags" FORCE )
set( CMAKE_Fortran_FLAGS_DEBUG "${_crayftn_mod_options} -rmoid -N 1023 -O0 -g" CACHE STRING "Debug Fortran flags" FORCE )
Loading