Skip to content

Conversation

AdelekeBankole
Copy link
Contributor

@AdelekeBankole AdelekeBankole commented May 13, 2025

XIOS configuration available through the help-config system

Fixes #830
Merges into #859

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 implements and hooks up a HelpConfig system for the XIOS handler class. Building with XIOS support and running ./build/nextsim --help-config, I see the following at the bottom:

Xios

xios.enable
Boolean                
Boolean option to toggle whether XIOS is enabled in the build. This should not need to be modifed by the user. Build nextSIM-DG with XIOS support with the CMake argument -DENABLE_XIOS=ON, passing the path to your XIOS installation with -Dxios_DIR=/path/to/xios.


XiosInput

XiosInput.period
string           (default = 0)
The period between restart file outputs expected in a file to be read, formatted as an ISO8601 duration (P prefix) or number of seconds. A value of zero assumes no intermediate restart files.

XiosInput.filename
string
The file name to be used for input.

XiosInput.field_names
string
Comma-separated list of field names to be read from the input file.


XiosOutput

XiosOutput.period
string           (default = 0)
The period between restart file outputs, formatted as an ISO8601 duration (P prefix) or number of seconds. A value of zero ensures no intermediate restart files are written.

XiosOutput.filename
string
The file name to be used for output.

XiosOutput.field_names
string
Comma-separated list of field names to be written to the output file.

Test Description

The input/output frequency now default to the timestep. This is tested by dropping their specifications in the XiosRead and XiosWrite tests.


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

@AdelekeBankole AdelekeBankole self-assigned this May 13, 2025
@AdelekeBankole AdelekeBankole added the ICCS Tasks or reviews for the ICCS team label May 13, 2025
@jwallwork23 jwallwork23 force-pushed the xios-help-config-system branch from 1b8e3ef to c867e4e Compare July 14, 2025 12:49
@jwallwork23 jwallwork23 changed the base branch from develop to issue850_xios-domain-from-modelmetadata July 14, 2025 12:50
@jwallwork23 jwallwork23 moved this from Todo to Review required in neXtSIM_DG overview Jul 14, 2025
@jwallwork23 jwallwork23 added the documentation Improvements or additions to documentation label Jul 14, 2025
@jwallwork23 jwallwork23 marked this pull request as ready for review July 14, 2025 12:55
Comment on lines +41 to +54
static const std::map<int, std::string> keyMap
= { { Xios::ENABLED_KEY, "xios.enable" }, { Xios::STARTTIME_KEY, "model.start" },
{ Xios::STOPTIME_KEY, "model.stop" }, { Xios::TIME_STEP_KEY, "model.time_step" },
{ Xios::OUTPUT_RESTARTPERIOD_KEY, xOutputPfx + ".period" },
{ Xios::OUTPUT_RESTARTFILE_KEY, xOutputPfx + ".filename" },
{ Xios::OUTPUT_FIELD_NAMES_KEY, xOutputPfx + ".field_names" },
{ Xios::INPUT_RESTARTPERIOD_KEY, xInputPfx + ".period" },
{ Xios::INPUT_RESTARTFILE_KEY, xInputPfx + ".filename" },
{ Xios::INPUT_FIELD_NAMES_KEY, xInputPfx + ".field_names" } };
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that I renamed the keys for consistency with their names in Model.

"an ISO8601 duration (P prefix) or number of seconds. A value of zero assumes no "
"intermediate restart files." },
{ keyMap.at(INPUT_RESTARTFILE_KEY), ConfigType::STRING, {}, "", "",
// TODO: Support format "restart%Y-%m-%dT%H:%M:%SZ.nc"
Copy link
Contributor

Choose a reason for hiding this comment

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

Filename patterns are not currently supported in our XIOS implementation. This would likely make use of setFileSplitFreq and getFileSplitFreq.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't plan to do this in this PR.

>> std::boolalpha >> isEnabled;

// Extract the start time from the model configuration
// TODO: Deduce from Model.iterator rather than duplicating here?
Copy link
Contributor

Choose a reason for hiding this comment

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

Question for the reviewer: what's the best way to transfer start time, stop time, and timestep info to the XIOS handler? The current implementation duplicates the logic in Model.iterator. I considered associating the Model with the XIOS handler but then we'd have to set up Models for the sake of the unit tests. Perhaps some of the parsed info could be static?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is something I have faced with development of the MPI backend. IMO I think we should get the info from Model either by making it a friend or by creating getters. But yes, it does make testing more laborious 😞

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest a new class (or perhaps rather a struct) that holds two TimePoints and one Duration. The Iterator class could then hold a private one, but have a getter function to create copy of the information it holds. The duration/stop time logic would then be a part of this class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @timspainNERSC. I opened #925 to follow this up.

@jwallwork23 jwallwork23 force-pushed the issue850_xios-domain-from-modelmetadata branch from f388d14 to 00acebc Compare July 29, 2025 08:17
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 all looks good to me

Xios::HelpMap& Xios::getHelpText(HelpMap& map, bool getAll)
{
map["Xios"] = {
{ keyMap.at(ENABLED_KEY), ConfigType::BOOLEAN, {}, "", "",
Copy link
Contributor

Choose a reason for hiding this comment

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

is the idea of this key so that we can build with XIOS=ON but then disable it as a runtime option?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I'd just been including it because it was in the map. But yes, I suppose that could be one use case.

Base automatically changed from issue850_xios-domain-from-modelmetadata to develop July 30, 2025 09:48
@jwallwork23 jwallwork23 force-pushed the xios-help-config-system branch from ccdca3a to 456d2a7 Compare August 20, 2025 07:58
@jwallwork23
Copy link
Contributor

[Rebased on top of develop]

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, unless you want to include a possible new start/stop time handling class.

@jwallwork23 jwallwork23 merged commit 5575ba3 into develop Sep 15, 2025
24 checks passed
@jwallwork23 jwallwork23 deleted the xios-help-config-system branch September 15, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation ICCS Tasks or reviews for the ICCS team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XIOS configuration should be available through the help-config system.

4 participants