Skip to content
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

CMake Fix split command flags to be correctly populated #2108

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 8 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,23 +321,20 @@ if ( ${USE_MPI} )
# Which may or may not get polluted by the environment
# It still technically finds MPI but the output is nonintuitive
# saying things like hdf5 or pthread
find_package( MPI REQUIRED COMPONENTS Fortran C )
add_compile_definitions(
USE_MPI=1
DM_PARALLEL
)

# Supply any language-specific flags for interrogation
if ( DEFINED WRF_MPI_Fortran_FLAGS AND NOT "${WRF_MPI_Fortran_FLAGS}" STREQUAL "" )
add_compile_options(
$<$<COMPILE_LANGUAGE:Fortran>:${WRF_MPI_Fortran_FLAGS}>
)
set( MPI_Fortran_COMPILER_FLAGS ${WRF_MPI_Fortran_FLAGS} )
endif()

if ( DEFINED WRF_MPI_C_FLAGS AND NOT "${WRF_MPI_C_FLAGS}" STREQUAL "" )
add_compile_options(
$<$<COMPILE_LANGUAGE:C>:${WRF_MPI_C_FLAGS}>
)
set( MPI_C_COMPILER_FLAGS ${WRF_MPI_C_FLAGS} )
endif()
find_package( MPI REQUIRED COMPONENTS Fortran C )
add_compile_definitions(
USE_MPI=1
DM_PARALLEL
)

# Check if MPI in all its glory has forced IPO down our throats due to hard-coding the wrapper flags
# https://www.open-mpi.org/faq/?category=mpi-apps#why-no-rpath LOL!
Expand Down
22 changes: 21 additions & 1 deletion arch/configure_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def splitIntoFieldAndFlags( self, field ) :
fieldValue = self.kvPairs_[ field ]

self.kvPairs_[field] = fieldValue.partition(" ")[0]
self.kvPairs_[field + "_FLAGS"] = fieldValue.partition(" ")[1]
self.kvPairs_[field + "_FLAGS"] = fieldValue.partition(" ")[2]

######################################################################################################################
##
Expand Down Expand Up @@ -222,6 +222,26 @@ def sanitize( self ) :
# And for final measure strip
self.kvPairs_[ key ] = self.kvPairs_[ key ].strip()

# Finally, further sanitize MPI compilers, we don't need to specify underlying
# compiler since CMake already does that
filters = [
self.kvPairs_[ "SFC" ],
self.kvPairs_[ "SCC" ],
"-compiler"
]
keysToSanitize = [ "DM_FC_FLAGS", "DM_CC_FLAGS" ]

for keyToSan in keysToSanitize :
if self.kvPairs_[ keyToSan ] :
allFlags = self.kvPairs_[ keyToSan ].split( " " )
newFlags = []
for flag in allFlags :
if not any( [ f in flag for f in filters ] ) :
newFlags.append( flag )

# We always need this field updated
self.kvPairs_[ keyToSan ] = " ".join( newFlags )

def serialCompilersAvailable( self ) :
return which( self.kvPairs_["SFC"] ) is not None and which( self.kvPairs_["SCC"] ) is not None

Expand Down