Skip to content

Fix several PIO warnings: guard empty-string attributes and match start/count dims to variable rank#8464

Open
ndkeen wants to merge 2 commits into
masterfrom
ndk/eam/resolve-pio-warnings
Open

Fix several PIO warnings: guard empty-string attributes and match start/count dims to variable rank#8464
ndkeen wants to merge 2 commits into
masterfrom
ndk/eam/resolve-pio-warnings

Conversation

@ndkeen

@ndkeen ndkeen commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fix a collection of PIO warnings emitted when writing NetCDF attributes with empty
strings and when start/count arrays do not match a variable's actual rank. Changes
span EAM, ELM, MPAS-framework, and the MCT/MOAB drivers.

  • Guard empty-string attribute writes (units, standard_name): wrap pio_put_att
    calls in if (len_trim(...) > 0) checks in driver-mct/seq_io_mod.F90,
    driver-moab/seq_io_mod.F90, cam_grid_support.F90, ncdio_pio.F90.in,
    restFileMod.F90, and mpas_stream_manager.F to prevent PIO from writing
    zero-length string attributes.

  • Match start/count rank to variable rank (tracer_data.F90, phys_prop.F90):
    query pio_inq_varndims before pio_get_var; pass strt(1:1)/cnt(1:1) for
    1-D variables to eliminate "count array size does not match variable rank" warnings.

  • Fix avgflag restart layout (cam_history.F90): add a dedicated avgflag_len
    string-length dimension and store avgflag as a 3-D variable to satisfy PIO's
    leading-dimension convention. Read path detects old 2-D layout for backward
    compatibility.

  • Fix date/time string dimension in ELM history (histFileMod.F90): introduce
    hist_date_str_len = 8 for date_written/time_written dimensions instead of
    reusing the 16-character field-name dimension; widen scale-type variables from
    character(len=8) to character(len=hist_dim_name_length).

[BFB]

@ndkeen

ndkeen commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

I started this effort with just a handful of cases, but then went through all of the tests in e3sm_integration to tackle the bulk of PIO warnings as it was clear some changes were impacting many cases.. I can break this up into components if it helps.

@ndkeen ndkeen added Coupler Related to code in driver-mct or driver-moab or component connections to the coupler. BFB PR leaves answers BFB EAM Fortran-based E3SM Atmosphere Model ELM land model labels Jun 8, 2026
@ndkeen ndkeen requested a review from rljacob June 8, 2026 03:02
@rljacob rljacob requested review from jonbob and peterdschwartz June 8, 2026 03:16
@jayeshkrishna

Copy link
Copy Markdown
Contributor

@ndkeen : Regarding the last change (autodetect ELM input file type), I think instead of reading a file to determine if its NetCDF4, a better approach is to convert NetCDF4 input files to ones that PnetCDF can work with ("64-bit data"). The choice of I/O type to read the file needs to be made in the config/xml stage.
(I can work on the conversion if its too much work for you, but I would recommend dropping that commit)

@ndkeen

ndkeen commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Yea I was also suspicious of that change. I reverted.

@rljacob

rljacob commented Jun 9, 2026

Copy link
Copy Markdown
Member

Maybe the model should error if it finds a NetCDF4 input file? That would encourage people to do the conversion!

@ndkeen

ndkeen commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

OK to merge or do we want changes?

@jayeshkrishna

Copy link
Copy Markdown
Contributor

@jonbob / @peterdschwartz : Please review the PR when you get a chance (please make sure that you are not losing any attributes. IMO, instead of removing the attributes a better approach would be to assign the correct value and write them out)

@peterdschwartz peterdschwartz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks ok for the elm files

@rljacob

rljacob commented Jul 10, 2026

Copy link
Copy Markdown
Member

@jonbob please review.

@jonbob jonbob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approved based on visual inspection and developer testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BFB PR leaves answers BFB Coupler Related to code in driver-mct or driver-moab or component connections to the coupler. EAM Fortran-based E3SM Atmosphere Model ELM land model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants