-
Notifications
You must be signed in to change notification settings - Fork 19
Align update of nextSIM-DG and XIOS calendars #757
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
Conversation
38e2e5c
to
0ca57ad
Compare
test-ubuntu-mpi-noxios: | ||
|
||
runs-on: ubuntu-22.04 | ||
container: | ||
image: ghcr.io/nextsimhub/nextsimdg-dev-env:latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: build and compile with MPI but not XIOS | ||
run: | | ||
. /opt/spack-environment/activate.sh | ||
mkdir -p build && cd build | ||
cmake -DENABLE_MPI=ON -DENABLE_XIOS=OFF -DCMAKE_CXX_COMPILER="$(which mpic++)" .. | ||
make -j 4 | ||
- name: run MPI tests | ||
run: | | ||
. /opt/spack-environment/activate.sh | ||
apt update | ||
apt install -y wget | ||
cd build | ||
(cd core/test && wget "ftp://ftp.nersc.no/nextsim/netCDF/partition_metadata_1.nc") | ||
for component in core physics dynamics | ||
do | ||
cd $component/test | ||
for file in $(find test* -maxdepth 0 -type f) | ||
do | ||
echo $file | ||
nprocs=$(echo $file | sed -r "s/.*MPI([0-9]+)/\1/") | ||
mpirun --allow-run-as-root --oversubscribe -n $nprocs ./$file | ||
done | ||
cd - | ||
done | ||
test-ubuntu-mpi-xios: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this change is the same as the one in #758.
timeVar.getVar(timeVec.data()); | ||
// Get the index of the largest TimePoint less than the target. | ||
targetTIndex = std::find_if(begin(timeVec), end(timeVec), [time](double t) { | ||
targetTIndex = std::find_if(std::begin(timeVec), std::end(timeVec), [time](double t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to avoid compile errors about begin
and end
being overloaded and it not being clear which version to use.
//! Enable XIOS in the 'config' | ||
void enableXios() | ||
{ | ||
Configurator::clearStreams(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is important when you set up XIOS after you've already configured other parts of nextSIM-DG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XIOS handler living in ModelMetadata
feels out of place. Perhaps define it as a singleton in Xios.hpp
/.cpp
?
core/src/include/ModelMetadata.hpp
Outdated
const std::string bboxName = "bounding_boxes"; | ||
#endif | ||
#ifdef USE_XIOS | ||
Xios* xiosHandler = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ModelMetadata
the best place for the XIOS handler? It doesn't (instinctively) feel like metadata data to me. Perhaps implementing the infrastructure necessary to return an Xios
singleton.
Also, wherever it ends up, might a smarter pointer be better than a raw pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I currently have it set up in #751 is that multiple classes (ParaGridIO
and ModelMetadata
) have pointers to it. A singleton would make sense in general, yes. It might make test files containing multiple tests that use XIOS a little trickier to set up, but that's not really the important thing. I'll look into how to implement it. Also good point on using smart pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened PR #763 to address this issue, which would merge into this PR if approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timspainNERSC what kind of smart pointer were you considering? I guess we could do something like unique_ptr
but this slightly different to the singleton functionality we need. We really want a single instance rather than a unique pointer. But perhaps both is extra protection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a shared_ptr
is more likely to be the type of smart pointer that we need for a singleton.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking further, the singleton function should return a reference, rather than any kind of smart or dumb pointer. If an object needs to store a pointer to the object, then a plain pointer should be fine, as the ownership of the object is clear: it belongs to the singleton function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AdelekeBankole , place the unique_ptr
into xios.hpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This discussion will be resolved upon merging #763 with recent changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #763 is merged in this looks good to go 🚀
Oops, wrong PR. |
[Rebased on top of |
28b2453
to
e4b4870
Compare
Supersedes #808. As discussed in the meeting this morning, this PR hooks the `Xios` class into the `Finalizer`. Since no `Model`s are created in the standalone XIOS unit tests, they need to call `Finalizer::finalize` explicitly. It seems the same is also true of the `ConfigOutput` and `ParaGrid` tests. So actually the changeset isn't that different than @TomMelt's one in #808.
Note that this PR merges into the branch for #757, not `develop`. This PR implements the `Xios` handler object as a singleton, as requested. This means that nextSIM-DG classes don't need to own pointers to the current working `Xios` instance. There can be only one `Xios` instance. The first time the static `Xios::getInstance` method is called, it creates the singleton and returns a pointer to it. On subsequent calls, this method simply returns a pointer to the singleton. Unfortunately, I had to rework the XIOS read/write test. The singleton design pattern isn't suitable for the way it's currently written, so I re-separated out the reading and writing parts and re-combined the 2D and 3D cases.
The same is true here as in #758 because of the (duplicate) workflow change.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good, now
Perfect, thanks @timspainNERSC. Please could you temporarily disable the requirement for the |
Will merge once the periodic Docker build passes. |
Align update of nextSIM-DG and XIOS calendars
Fixes #756
Fixes #740
Refinement of #751
Task List
Change Description
This PR adds functionality for incrementing XIOS' calendar and hooks it up in the
ModelMetadata::incrementTime
method.More specifically:
Xios::incrementCalendar
.Xios::updateCalendar
andXios::setCalendarStep
(for consistency withXios::getCalendarStep
.Test Description
The new method is used in the XIOS read/write test. Unfortunately, I found a bug in XIOS (see comments below). However, this is fixed with a minor hack in the
install-xios.sh
script. We should be able to avoid this hack when we update to XIOS3 (see #761).Pre-Request Checklist