Skip to content
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

Enable PIO to Add Attributes to Existing NetCDF Files #1234

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

amstokely
Copy link
Contributor

@amstokely amstokely commented Sep 17, 2024

Add Ability to Write New Attributes to Existing NetCDF Files in PIO

Overview:

Currently, PIO in MPAS lacks the ability to add new attributes to existing NetCDF files. This limitation arises because when PIO attempts to write a new attribute, the file remains in data mode, which does not allow for the addition of attributes. Instead, attributes can only be added when the file is in define mode.

Unfortunately, the public APIs of both PIO and NetCDF do not provide a way to inquire about a file’s current mode. Switching to define mode each time a new attribute is needed is expensive, as transitioning between data and define modes introduces significant I/O costs.

@mgduda
Copy link
Contributor

mgduda commented Oct 19, 2024

@amstokely Can you fix up the commit history? As of now it looks like there are 23 files changed.

- Adds support for adding new attributes to existing NetCDF files by
  minimizing expensive mode switches between data and define modes.
- Introduces `put_att_pio` interface with try-fail logic, handling scalar
  and 1D attributes of various data types (int, real, double, string).
- Enhances performance by avoiding unnecessary transitions and includes
  extensive logging for better traceability.
- Ensures backward compatibility for NetCDF files generated by earlier MPAS
  versions.
@amstokely
Copy link
Contributor Author

@amstokely Can you fix up the commit history? As of now it looks like there are 23 files changed.

@mgduda I just rebased off of the current MPAS-Dev develop branch. This should resolve the previously large diff.

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.

2 participants