Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 needed for implicit c-Fortran interfacing functions that
# 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 increase the
# 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
# 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