Skip to content

Conversation

@joewallwork
Copy link
Contributor

@joewallwork joewallwork commented Oct 14, 2025

XIOS: Handle CGField

Fixes #911
Merges into #952

Task List

  • Defined the tests that specify a complete and functioning change (It may help to create a design specification & test specification)
  • Implemented the source code change that satisfies the tests
  • Documented the feature by providing worked example
  • Updated the README or other documentation
  • Completed the pre-Request checklist below

Change Description

Currently the XIOS implementation accounts for HField, VertexField, and DGField. #952 extends to cover DGSField. This PR extends further to cover CGField.

This involved checking the global and local dimensions and start index are set up correctly, as well as the XIOS domain, grid, and field.

Several error messages were also made clearer as part of this change.


Test Description

The XIOS read and write tests are updated to account for the CG field type.

A minor looping issue is also fixed in the value checking - it was missing the final value for VertexField. As such, the value checking code in XiosRead_test was reworked to loop over fields first and then dimensions. To make this easier to check, I changed the coordinate field to align with the coordinates of the grid (assuming unit spacing in each direction).

Note that the file reading code accounts for halos out-of-the-box! 👼


Documentation Impact

CGField is mentioned in the XIOS docs page.


Pre-Request Checklist

  • The requirements of this pull request are fully captured in an issue or design specification and are linked and summarised in the description of this PR
  • No new warnings are generated
  • The documentation has been updated (or an issue has been created to track the corresponding change)
  • Methods and Tests are commented such that they can be understood without having to obtain additional context
  • This PR/Issue is labelled as a bug/feature/enhancement/breaking change
  • This change conforms to the conventions described in the README

@joewallwork joewallwork self-assigned this Oct 14, 2025
@joewallwork joewallwork added enhancement New feature or request ICCS Tasks or reviews for the ICCS team labels Oct 14, 2025
@joewallwork joewallwork linked an issue Oct 14, 2025 that may be closed by this pull request
@joewallwork joewallwork changed the base branch from issue917_xios-write-diag-time to issue911_xios-dgs October 14, 2025 19:04
@joewallwork joewallwork changed the title XIOS: Handle CGField and DGSField XIOS: Handle CGField Oct 14, 2025
@joewallwork
Copy link
Contributor Author

[Rebased on top of issue911_xios-dgs]

@joewallwork joewallwork marked this pull request as ready for review October 21, 2025 17:11
Copy link
Collaborator

@timspainNERSC timspainNERSC left a comment

Choose a reason for hiding this comment

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

One small, non-essential suggestion: rather than using cice as the name of the CG variable, might I suggest uice, as ice velocity is written by the real model as a CG field, whereas ice concentration never will be.

@joewallwork
Copy link
Contributor Author

One small, non-essential suggestion: rather than using cice as the name of the CG variable, might I suggest uice, as ice velocity is written by the real model as a CG field, whereas ice concentration never will be.

Thanks @timspainNERSC. I made this change in 8f40681. Given that that variable was being used for diagnostics, I switched to output hsnow as a diagnostic. Let me know if you'd prefer to use something different.

Copy link
Contributor

@TomMelt TomMelt left a comment

Choose a reason for hiding this comment

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

Thanks @jwallwork23 looks good to me. I don't think you need to change anything but I do want to make sure I understand the plan for CG Vectors before we merge this (and my changes #969). I will mark as request changes for now, but after we discuss next meeting I can probs just approve this.

Comment on lines +698 to +703
} else if (dimType == ModelArray::Dimension::XCG) {
localLength = CGDEGREE * metadata.getLocalExtentX() + 1;
start = CGDEGREE * metadata.getLocalCornerX();
} else if (dimType == ModelArray::Dimension::YCG) {
localLength = CGDEGREE * metadata.getLocalExtentY() + 1;
start = CGDEGREE * metadata.getLocalCornerY();
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW this is also how I am currently determining the CG dims.... but I would like to hear Tim's comments on PR #969 first. I am worried we might end up in a situation where CG dims is set in several different places. I don't think you need to change this, just raising it as an FYI.

Comment on lines 716 to 730
throw std::runtime_error("Xios: inconsistent global dimensions for "
+ dimName + ": " + std::to_string(dim.getSize()) + " vs. "
+ std::to_string(
ModelArray::definedDimensions.at(dimType).globalLength));
}
if (localLength != ModelArray::size(dimType)) {
throw std::runtime_error(
"Xios: inconsistent local dimensions for " + dimName);
if (localLength != ModelArray::definedDimensions.at(dimType).localLength) {
throw std::runtime_error("Xios: inconsistent local dimensions for "
+ dimName + ": " + std::to_string(localLength) + " vs. "
+ std::to_string(
ModelArray::definedDimensions.at(dimType).localLength));
}
if (start != ModelArray::definedDimensions.at(dimType).start) {
throw std::runtime_error("Xios: inconsistent start index for " + dimName);
throw std::runtime_error("Xios: inconsistent start index for " + dimName
+ ": " + std::to_string(start) + " vs. "
+ std::to_string(ModelArray::definedDimensions.at(dimType).start));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this alleviates my prev. concern about different sizes for CG dims in the code. However, I might need to understand how this works a bit better. Where will this be called in NextSim? Is it only called once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My subsequent PR #968 will make it a bit clearer, but it's only called once yeah. In that follow-up PR I have it happening when the Model gets configured, which in turn calls ModelMetadata.setTime.

@joewallwork joewallwork mentioned this pull request Nov 10, 2025
11 tasks
Base automatically changed from issue911_xios-dgs to develop November 10, 2025 10:17
@joewallwork joewallwork requested a review from TomMelt November 10, 2025 10:21
Copy link
Contributor

@TomMelt TomMelt left a comment

Choose a reason for hiding this comment

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

Thanks @jwallwork23. It's all good for now

@joewallwork joewallwork merged commit 5266a43 into develop Nov 10, 2025
9 checks passed
@joewallwork joewallwork deleted the issue911_xios-cg-dgs branch November 10, 2025 10:38
joewallwork added a commit that referenced this pull request Nov 10, 2025
# Automation and pruning for the XIOS handler class

Towards #850
Merges into #951

### Task List
- [x] Defined the tests that specify a complete and functioning change
(*It may help to create a [design specification & test
specification](../../../wiki/Specification-Template)*)
- [x] Implemented the source code change that satisfies the tests
- [x] Documented the feature by providing worked example
- [x] Updated the README or other documentation
- [x] Completed the pre-Request checklist below

---
# Change Description

This PR contains refactoring work to (a) automate the XIOS I/O
implementation to streamline the user experience and (b) remove member
functions that it turns out aren't needed.

#### Automation

* Separate `affixModelMetadata` into `parseInputFiles`, `setupDomains`,
`setupAxes`, and `setupGrids`. Call `parseInputFiles` in the `Xios`
constructor and the rest in the `ParaGridIO` constructor.
* Automate setting `nCoords` for `VERTEX` in `setupDomains`.
* Automate setting `nComponents` for `DG` in `setupDomains`.
* Automate setting `nComponents` for `DGSTRESS` in `setupDomains`.
* Automate `enableXios` by inlining it at the start of
`Model.configureTime`.

#### Pruning

* Inline `enableXios` in `Model.configureTime` as mentioned above.
* Remove `getClientMPISize` and `getClientMPIRank`.
* Remove `setAxisValues` and `getAxisValues`.
* No need to call `ModelMetadata.setTime` because it already gets called
in `Model.configureTime`.
* Inline `isInitialized` at the end of the `Xios` constructor, throwing
an error if not.
* Drop `getCalendarType` since it's hard-coded to `"Gregorian"`.
* Drop `getCalendarTimestep` because this is given by
`ModelMetadata.stepLength`.

---
# Test Description

The XIOS handler tests are reworked to account for the automation. This
involved some reordering of how things are done.

---
# Documentation Impact

The XIOS docs page has been updated.


---
# Other information

I changed the default `DGCOMP` value in
`discontinuousgalerkin/ModelArrayDetails.cpp` to be consistent with the
default DG degree that gets set in the root `CMakeLists.txt`.

---
### Pre-Request Checklist

- [x] The requirements of this pull request are fully captured in an
issue or design specification and are linked and summarised in the
description of this PR
- [x] No new warnings are generated
- [x] The documentation has been updated (or an issue has been created
to track the corresponding change)
- [x] Methods and Tests are commented such that they can be understood
without having to obtain additional context
- [x] This PR/Issue is labelled as a bug/feature/enhancement/breaking
change
- [x] This change conforms to the conventions described in the README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ICCS Tasks or reviews for the ICCS team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XIOS: Handle CGField and DGSField

4 participants