Skip to content

Conversation

jwallwork23
Copy link
Contributor

@jwallwork23 jwallwork23 commented Sep 18, 2025

XIOS implementation of readForcingTimeStatic

Fixes #916

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

This PR provides an XIOS implementation of the readForcingTimeStatic function. Doing so requires introducing a new XiosForcing category to account for forcings as well as restarts.

This PR works under the assumption that the forcings data are found in the same input file used for restarts. I plan to account for separate forcings and restart files when addressing #929.

Other changes to facilitate the implementation:

  • Switch getCurrentDate to return a TimePoint rather than string.
  • Separate out configGetFieldNames for the different categories (input, output, forcing).

Test Description

Tests for reading forcings have been added into the existing XiosRead_test.


Documentation Impact

The XIOS section of the documentation is updated to mention the new XiosForcing section.


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

@jwallwork23 jwallwork23 self-assigned this Sep 18, 2025
@jwallwork23 jwallwork23 added enhancement New feature or request ICCS Tasks or reviews for the ICCS team labels Sep 18, 2025
Comment on lines 95 to 101
// TODO: Avoid making configGetForcingFieldNames public?
auto forcingFieldNames = xiosHandler.configGetForcingFieldNames();
for (int ts = 1; ts <= 4; ts++) {

// Read forcings from file and check they take the expected values
TimePoint time = xiosHandler.getCurrentDate();
ModelState forcings = pio->readForcingTimeStatic(forcingFieldNames, time, filename);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rest of the configGetXFieldNames member functions are private. I couldn't see a way to keep this one private while maintaining the interface to readForcingTimeStatic that accepts the set of forcing field names as its first argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's currently unnecessary to run these tests in both the MPI and XIOS test workflows.

@jwallwork23 jwallwork23 force-pushed the issue916_xios-read-forcing-time-static branch from a506306 to 116506e Compare September 18, 2025 15:54
@jwallwork23 jwallwork23 marked this pull request as ready for review September 18, 2025 15:55
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

Comment on lines 145 to +147
// ASSUME all forcings are HFields: finite volume fields on the same
// grid as ice thickness
std::vector<size_t> indexArray = { targetTIndex };
std::vector<size_t> extentArray = { 1 };

// Loop over the dimensions of H
const std::vector<ModelArray::Dimension>& dimensions
= ModelArray::typeDimensions.at(ModelArray::Type::H);
for (auto riter = dimensions.rbegin(); riter != dimensions.rend(); ++riter) {
indexArray.push_back(0);
extentArray.push_back(ModelArray::definedDimensions.at(*riter).localLength);
}

for (const std::string& varName : forcings) {
netCDF::NcVar var = ncFile.getVar(varName);
state.data[varName] = ModelArray(ModelArray::Type::H);
ModelArray& data = state.data.at(varName);
data.resize();
HField field(ModelArray::Type::H);
field.resize();
state.merge(ModelState { { { fieldId, field } }, {} });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand this is just for the Forcing file and not restart currently. Just to make a note for future, that Restart files also need to support CGFields (AFAIK anyway).

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.

Approved, assuming the XIOS things work as they are supposed to :)

@jwallwork23 jwallwork23 merged commit 4a5a87a into develop Oct 2, 2025
@jwallwork23 jwallwork23 deleted the issue916_xios-read-forcing-time-static branch October 2, 2025 12:35
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 implementation of readForcingTimeStatic
3 participants