-
Notifications
You must be signed in to change notification settings - Fork 791
CMake check system for underscore requirements between C and Fortran #2091
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
base: develop
Are you sure you want to change the base?
Conversation
b263d5f to
2f2b7df
Compare
|
@amstokely @mgduda This is ready to be reviewed again. The plan is to get this and its dependent PRs into the upcoming release. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a CMake-based system to programmatically determine whether underscores are needed when linking C and Fortran code, replacing the previous manual stanza-based configuration approach. This eliminates platform-specific configuration errors and makes the build system more portable.
Key Changes:
- Adds compile/link tests to automatically detect C-Fortran symbol naming conventions
- Removes hardcoded underscore definitions from architecture configuration files
- Applies the detected underscore requirements as compile definitions across the project
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| confcheck/check_underscore.f90 | Test program that calls a C function from Fortran to verify symbol compatibility |
| confcheck/check_underscore.c | C implementation that conditionally adds underscores based on preprocessor definitions |
| confcheck/CMakeLists.txt | Configuration checks that test both NOUNDERSCORE and UNDERSCORE symbol conventions |
| cmake/confcheck.cmake | Minor improvements to check result handling and error messaging |
| arch/configure_reader.py | Sanitization logic to strip underscore definitions from legacy stanzas |
| CMakeLists.txt | Applies the detected underscore convention as a compile definition |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
confcheck/CMakeLists.txt
Outdated
| endif() | ||
|
|
||
|
|
||
| # Check if underscores are needing for implicit c-Fortran intrefacing functions that |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
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'.
| # Check if underscores are needing for implicit c-Fortran intrefacing functions that | |
| # Check if underscores are needed for implicit c-Fortran interfacing functions that |
confcheck/CMakeLists.txt
Outdated
| # 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 |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
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'.
| # 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 |
| @@ -0,0 +1,8 @@ | |||
| #include <stdio.h> | |||
| #ifdef UNDERSCORE | |||
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
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).
| #ifdef UNDERSCORE | |
| #if defined(UNDERSCORE) |
TYPE: enhancement
KEYWORDS: cmake, configuration
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem:
The current solution for implicitly matching symbols between C and Fortran relies on user-modification of a stanza for their system. While stanzas can be configured to a specific architecture and options selection, this approach is limited and overly specific to user configuration when it could be programmatically determined. Likewise, if a new stanza is introduced it will likely only be tested by one user on their particular system. Thus, if this stanza could be used elsewhere but needs underscores on C symbols for Fortran usage it will not be evident why the stanza does not work for this new user.
Solution:
Programmatically determine if underscores are needed in C compilation in the CMake build. Sanitize out any definition of underscore in the stanza so that CMake configuration checks take precedence.