Skip to content

Conversation

@joewallwork
Copy link
Contributor

@joewallwork joewallwork commented Jan 8, 2026

XIOS: Separate out testing of restarts and diagnostics

Fixes #977
Fixes #1003
Refinement of #1002

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

Test Description

This PR separates the XIOS reading and writing tests out by type. In addition, we add a read test for the diagnostic outputs and check that they are time-averaged.


Change Description

Code changes are made to account for the case where only one XIOS domain is used when writing. This is required due to an unfortunate consequence of the way XIOS appends the domain name only if there are two or more domains.

In detail: if only one domain type is used then the output file will use x and y dimensions, rather than the versions appended with _<dimName>. We account for this by assuming that x and y imply x_dim and y_dim if encountered in an input file.


Documentation Impact

n/a


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
  • 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 Jan 8, 2026
@joewallwork joewallwork added enhancement New feature or request ICCS Tasks or reviews for the ICCS team labels Jan 8, 2026
@joewallwork joewallwork marked this pull request as ready for review January 9, 2026 09:31
Comment on lines +199 to +213
#ifdef USE_XIOS
// Account for the fact that XIOS writes dimensions differently if only one
// discretisation is written out. If the dimension is still null at this point then we
// assume that the only discretisation used is HDomain-based, i.e., HField, DGField, or
// DGSField.
if (dim.isNull()) {
if (dimensionSpec.name == "x_dim") {
dim = ncFile.getDim("x");
} else if (dimensionSpec.name == "y_dim") {
dim = ncFile.getDim("y");
} else {
continue;
}
}
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fixed by #1015, which ensures that XIOS never writes out files with x or y as dimensions.

joewallwork added a commit that referenced this pull request Jan 13, 2026
Comment on lines +965 to +971
{ "yx", ModelArray::Type::H },
{ "ydimxdim", ModelArray::Type::H },
{ "y_dimx_dim", ModelArray::Type::H },
{ "yxdg_comp", ModelArray::Type::DG },
{ "ydimxdimdg_comp", ModelArray::Type::DG },
{ "y_dimx_dimdg_comp", ModelArray::Type::DG },
{ "yxdgstress_comp", ModelArray::Type::DGSTRESS },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes will also be reverted in #1015.

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.

As usual with the XIOS tests, I haven't done more than a check that the they look reasonable and logical. Everything else looks good.

@joewallwork
Copy link
Contributor Author

As usual with the XIOS tests, I haven't done more than a check that the they look reasonable and logical. Everything else looks good.

Thanks @timspainNERSC. I'm going to wait for the current CI jobs on develop to finish before merging because the Docker one should 🤞 update the Docker image following #1024.

@joewallwork joewallwork merged commit 52ed982 into develop Jan 21, 2026
9 checks passed
@joewallwork joewallwork deleted the issue977_xios-diagnostic-averaging branch January 21, 2026 09:51
joewallwork added a commit that referenced this pull request Jan 21, 2026
Merges into #1010.

Currently in #1010 we have
the following issue with writing fields with XIOS:
* If there are multiple fields that are (between them) based on two or
more XIOS domains then the dimension names get appended with those
domain names. By naming the domains `dim`, `vertex`, and `cg`, this
gives rise to dimensions `x_dim`, `y_dim`, `x_vertex`, `y_vertex`,
`x_cg`, and `y_cg`.
* If the fields being written out are only based on one XIOS domain then
the appendment doesn't happen, meaning we just have `x` and `y`.
  
The workaround in that PR handles dimensions `x` or `y` in a file being
read by assuming they correspond to `x_dim` and `y_dim`. Ideally, we
would avoid having `x` or `y` alone in any files and instead make a
post-processing of the output file after it is written with XIOS.

That's achieved in this PR via a post-processing step. Upon finalising
the XIOS context, we:
1. Count how many different XIOS domains were used for writing out. If
there was exactly one then we proceed to tackle the issue.
2. Loop overall output files that might have been written by XIOS and
check they exist.
3. For any such files that exist, rename the dimensions and variables as
appropriate and write out.

To achieve this, I had to implement subtraction of a `Duration` from a
`TimePoint` because of how XIOS presents the time window suffices.
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: Case of only one field type Diagnostic files should default to averaging in XIOS

3 participants