Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,12 @@ else()
list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK FSEEK_OK )
endif()

if ( ${NOUNDERSCORE_SYMBOL} )
list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK NOUNDERSCORE )
elseif( ${UNDERSCORE_SYMBOL} )
list( APPEND PROJECT_COMPILE_DEFINITIONS_CONFCHECK UNDERSCORE )
endif()

# I don't believe these are used anymore...
# $<$<BOOL:${MPI2_SUPPORT}>:MPI2_SUPPORT=$<BOOL:${MPI2_SUPPORT}>>
# $<$<BOOL:${MPI2_THREAD_SUPPORT}>:MPI2_THREAD_SUPPORT=$<BOOL:${MPI2_THREAD_SUPPORT}>>
Expand Down
7 changes: 6 additions & 1 deletion arch/configure_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,18 @@ def sanitize( self ) :
# # Now deref
self.dereference( "FCBASEOPTS" )

definesToRemove = [ "-DUNDERSCORE", "-DNOUNDERSCORE" ]

# Remove rogue compile commands that should *NOT* even be here
for keyToSan in self.kvPairs_.keys() :
# It's easier to do this first
for cppDef in definesToRemove :
self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( cppDef, "" )

self.kvPairs_[ keyToSan ] = configureRepl.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
self.kvPairs_[ keyToSan ] = compileObject.sub( r"\1\2", self.kvPairs_[ keyToSan ] ).strip()
self.kvPairs_[ keyToSan ] = defineRepl.sub( r"\1", self.kvPairs_[ keyToSan ] ).strip()


# Now fix certain ones that are mixing programs with flags all mashed into one option
self.splitIntoFieldAndFlags( "SFC" )
self.splitIntoFieldAndFlags( "SCC" )
Expand Down
6 changes: 3 additions & 3 deletions cmake/confcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function( wrf_conf_check )

message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR}" )

if ( DEFINED WRF_CFG_RUN )
if ( DEFINED WRF_CFG_RUN AND "${WRF_CFG_RUN}" )
try_run(
${WRF_CFG_RESULT_VAR}
WRF_CFG_COMPILE_RESULT_VAR
Expand Down Expand Up @@ -61,9 +61,9 @@ function( wrf_conf_check )
endif()

if ( DEFINED WRF_CFG_MESSAGE )
message( ${WRF_CFG_MSG_TYPE} "${WRF_CFG_MESSAGE}" )
message( ${WRF_CFG_MSG_TYPE} " ${WRF_CFG_MESSAGE}" )
else()
message( ${WRF_CFG_MSG_TYPE} "${WRF_CFG_RESULT_VAR} marked as required, check failed" )
message( ${WRF_CFG_MSG_TYPE} " ${WRF_CFG_RESULT_VAR} check failed" )
endif()
else()
message( STATUS "Performing Check ${WRF_CFG_RESULT_VAR} - Success" )
Expand Down
25 changes: 25 additions & 0 deletions confcheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ if ( NOT "${FSEEKO64}" )
set(FSEEKO ${FSEEKO} PARENT_SCOPE)
endif()


# Check if underscores are needing for implicit c-Fortran intrefacing functions that
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'needing' to 'needed' and 'intrefacing' to 'interfacing'.

Suggested change
# Check if underscores are needing for implicit c-Fortran intrefacing functions that
# Check if underscores are needed for implicit c-Fortran interfacing functions that

Copilot uses AI. Check for mistakes.
# don't use ISO C binding to map symbols
wrf_conf_check(
# try_run() with more than one source was introduced in CMake 3.25+
# so we won't use it here until we see reasonable need to incease the
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'incease' to 'increase'.

Suggested change
# so we won't use it here until we see reasonable need to incease the
# so we won't use it here until we see reasonable need to increase the

Copilot uses AI. Check for mistakes.
# version requirements
RESULT_VAR NOUNDERSCORE_SYMBOL
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.c ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.f90
OPTIONS
COMPILE_DEFINITIONS -DNOUNDERSCORE
MESSAGE "Implicit symbol usage between C and Fortran are not identical, checking with underscores"
)
if ( NOT ${NOUNDERSCORE_SYMBOL} )
# If the above fails we NEED the following to work
wrf_conf_check(
RESULT_VAR UNDERSCORE_SYMBOL
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.c ${CMAKE_CURRENT_SOURCE_DIR}/check_underscore.f90
OPTIONS
COMPILE_DEFINITIONS -DUNDERSCORE
MESSAGE "Implicit symbol usage between C with underscores and Fortran did not link!"
REQUIRED
)
endif()

# Unsure if this is even necessary. Defines littered throughout configure.defaults
# if ( ${USE_MPI} )
# wrf_conf_check(
Expand Down
8 changes: 8 additions & 0 deletions confcheck/check_underscore.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
#ifdef UNDERSCORE
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The check uses #ifdef UNDERSCORE but the CMake configuration defines -DUNDERSCORE which sets it to a value. Consider using #if defined(UNDERSCORE) or checking if the define should be set without a value (e.g., just -DUNDERSCORE without =1).

Suggested change
#ifdef UNDERSCORE
#if defined(UNDERSCORE)

Copilot uses AI. Check for mistakes.
# define foo foo_
#endif
void foo( void )
{
printf( "Hello World!\n" );
}
5 changes: 5 additions & 0 deletions confcheck/check_underscore.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

program test
write( *, * ) "Calling foo() from Fortran"
call foo()
end program test