Skip to content

address pio issues#4925

Open
jedwards4b wants to merge 5 commits intoESMCI:masterfrom
jedwards4b:pio_settings_update
Open

address pio issues#4925
jedwards4b wants to merge 5 commits intoESMCI:masterfrom
jedwards4b:pio_settings_update

Conversation

@jedwards4b
Copy link
Contributor

Description

Updates build process for netcdf/4.9.3 in a backward compatible manner.
Adds logic to make sure that typename netcdf4p is not combined with format 64bit_data.

Checklist

  • My code follows the style guidelines of this project (black formatting)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that exercise my feature/fix and existing tests continue to pass
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding additions and changes to the documentation

@jedwards4b jedwards4b requested a review from jgfouca January 30, 2026 19:55
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.32%. Comparing base (800e2d7) to head (20ffc33).
⚠️ Report is 24 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4925      +/-   ##
==========================================
- Coverage   31.38%   31.32%   -0.07%     
==========================================
  Files         264      264              
  Lines       38869    38967      +98     
  Branches     8260     8280      +20     
==========================================
+ Hits        12199    12206       +7     
- Misses      25430    25521      +91     
  Partials     1240     1240              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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 updates the CIME build process to support netcdf/4.9.3 in a backward-compatible manner and adds validation to prevent incompatible PIO configuration combinations (specifically, preventing the use of netcdf4p typename with 64bit_data format).

Changes:

  • Updated CMake cache string detection in buildlib.pio for netcdf 4.9.3 compatibility
  • Added validation in env_run.py to check PIO_TYPENAME and PIO_NETCDF_FORMAT compatibility when setting values
  • Added validation in preview_namelists.py to verify compatibility before creating namelists

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
CIME/build_scripts/buildlib.pio Updates expect_string and netcdf4_string to match netcdf 4.9.3 CMake output format, adds backward compatibility check for old expect_string format
CIME/XML/env_run.py Adds import for zip_longest, implements validation logic in set_value() to prevent incompatible PIO_TYPENAME and PIO_NETCDF_FORMAT combinations
CIME/case/preview_namelists.py Adds validation check during namelist creation to catch incompatible PIO configurations
Comments suppressed due to low confidence (1)

CIME/build_scripts/buildlib.pio:212

  • The netcdf4_string was changed from "NetCDF_C_HAS_PARALLEL:BOOL=TRUE" to "HAVE_NETCDF_PAR:INTERNAL=1" for netcdf 4.9.3 compatibility. However, unlike expect_string which has backward compatibility logic (line 207-208), there's no fallback check for the old netcdf4_string pattern. This could cause netcdf4_parallel_found to remain False when using older versions of netcdf, preventing netcdf4p and netcdf4c from being added to valid_values. Consider adding a similar elif check for "NetCDF_C_HAS_PARALLEL:BOOL=TRUE" to maintain backward compatibility.
        netcdf4_string = "HAVE_NETCDF_PAR:INTERNAL=1"

    # make sure case pio_typename valid_values is set correctly
    expect_string_found = False
    pnetcdf_found = False
    netcdf4_parallel_found = False

    cache_file = open(os.path.join(pio_dir, "CMakeCache.txt"), "r")
    for line in cache_file:
        if re.search(expect_string, line):
            expect_string_found = True
        elif re.search("NetCDF_C_LIBRARY-ADVANCED", line):
            expect_string_found = True
        if re.search(pnetcdf_string, line):
            pnetcdf_found = True
        if re.search(netcdf4_string, line):
            netcdf4_parallel_found = True

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 87 to 89
pio_typenames = [
self.get_value("PIO_TYPENAME_{}".format(comp.upper()))
]
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

If get_value() returns None (which can happen if the entry is not found), this will create a list containing None [None]. Later when the validation tries to check "64bit_data" in pio_netcdf_format (line 105), it will raise a TypeError because the in operator cannot be used with None. Consider adding a check to handle the case where get_value returns None, or provide a default value.

Copilot uses AI. Check for mistakes.
Comment on lines 72 to 109
if "PIO_TYPENAME" in vid or "PIO_NETCDF_FORMAT" in vid:
nvid, comp, iscompvar = self.check_if_comp_var(vid, None)
pio_netcdf_formats = []
pio_typenames = []

if nvid == "PIO_TYPENAME":
if comp:
pio_netcdf_formats = [
self.get_value("PIO_NETCDF_FORMAT_{}".format(comp.upper()))
]
else:
pio_netcdf_formats = self.get_values("PIO_NETCDF_FORMAT")
pio_typenames = [value]
elif nvid == "PIO_NETCDF_FORMAT":
if comp:
pio_typenames = [
self.get_value("PIO_TYPENAME_{}".format(comp.upper()))
]
else:
pio_typenames = self.get_values("PIO_TYPENAME")
pio_netcdf_formats = [value]

last_format = pio_netcdf_formats[-1]
last_typename = pio_typenames[-1]
for pio_typename, pio_netcdf_format in zip_longest(
pio_typenames, pio_netcdf_formats
):
if pio_typename is None:
pio_typename = last_typename
if pio_netcdf_format is None:
pio_netcdf_format = last_format

expect(
not ("4" in pio_typename and "64bit_data" in pio_netcdf_format),
"pio_typename {} is not compatible with pio_netcdf_format {}".format(
pio_typename, pio_netcdf_format
),
)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The new validation logic for incompatible PIO_TYPENAME and PIO_NETCDF_FORMAT combinations lacks test coverage. Given that this repo has comprehensive automated testing (as seen in the CIME/tests directory), consider adding unit tests to verify that:

  1. The validation correctly prevents setting netcdf4p/netcdf4c with 64bit_data format
  2. The validation works for both component-specific and general PIO settings
  3. Edge cases like None values or empty lists are handled properly
  4. The validation allows valid combinations to pass through

Copilot uses AI. Check for mistakes.
else:
pio_typenames = self.get_values("PIO_TYPENAME")
pio_netcdf_formats = [value]

Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

This code will raise an IndexError if either pio_netcdf_formats or pio_typenames is an empty list, since it tries to access [-1] index. This could happen if get_values() returns an empty list when the variable is not found or has no values. Consider adding a check to ensure the lists are not empty before accessing the last element, or handle the case where no values are found.

Suggested change
# If either list is empty, we cannot perform a meaningful compatibility
# check. In that case, skip the check and proceed with setting the value.
if not pio_netcdf_formats or not pio_typenames:
return EnvBase.set_value(self, vid, value, subgroup, ignore_type)

Copilot uses AI. Check for mistakes.
jedwards4b and others added 4 commits February 2, 2026 08:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pio_typename=netcdf4p is not compatible with pio_netcdf_format=64bit_data pio updates and improved logic

1 participant