Skip to content

Re-enable ITime in ocean and sea-ice models#2006

Merged
hgpeterson merged 6 commits into
mainfrom
hp/clock
Jul 16, 2026
Merged

Re-enable ITime in ocean and sea-ice models#2006
hgpeterson merged 6 commits into
mainfrom
hp/clock

Conversation

@hgpeterson

@hgpeterson hgpeterson commented Jun 30, 2026

Copy link
Copy Markdown
Member

Closes #1992

Following the update to ClimaOcean v0.10 (#1971), stop_time would default to Inf in the ocean/sea-ice models, which forced us to use Floats instead of Dates. This PR in NumericalEarth.jl enables us to set stop_time as a kwarg.

This PR:

  • Updates how clock and stop_time are set in the ocean model
  • Updates how clock and stop_time are set in the sea-ice model
  • Re-enables use_itime: true in config files

This PR also fixes a completely unrelated bug in experiments/test/compare_cmip.jl that emerged from an update in NumericalEarth (see this PR; ocean surface salinity is now passed as a view instead of with interior, changing how we need to define _compare(v1, v2) for SubArrays).

@hgpeterson

Copy link
Copy Markdown
Member Author

The NumericalEarth PR is merged, but because NumericalEarth is not a direct dependency of ClimaCoupler (it comes in through ClimaOcean), we'll have to wait for a new release there for this PR to work.

@hgpeterson

hgpeterson commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

An issue that came up that I believe is unrelated to the clock changes: experiments/test/restart_cmip.jl started to fail here with a CUDA scalar indexing error. I believe it has something to do with how the sea-ice model is initialized with SubArrays of OffsetArrays of CuArrays from the ocean (e.g. IceWaterThermalEquilibrium.salinity). To fix the test, I had to add lines of the form

h1 = OffsetArrays.no_offset_view(on_architecture(CPU(), v1))

to experiments/test/compare_cmip.jl, which required adding OffsetArrays to our CMIP Project.toml.

@simone-silvestri Does it make sense to you why separate initializations of the sea-ice model might have different array offsets in their views?

@akshaysridhar Let me know if you're okay with adding OffsetArrays or if we should find a different solution.

@simone-silvestri

Copy link
Copy Markdown
Contributor

In NumericalEarth/NumericalEarth.jl#346 we have changed the ocean surface salinity to pass
view(S.data, :, :, Nz) instead of interior(S, :, :, Nz) because we need the halos of the surface salinity to compute fluxes inside the halo itself.

https://github.com/NumericalEarth/NumericalEarth.jl/blob/01ab2a6fc1d5e3d6e6b77c20897936495e5c914b/src/Oceans/Oceans.jl#L83-L91

Therefore, the output of that function switched from begin a subarray of a plain array to a subarray of an offsetarray of an array.

I think on_architecture(CPU(), subarray) is enough because it moves everything on the CPU so you avoid the scalar indexing

Comment thread experiments/test/compare_cmip.jl Outdated
Comment thread experiments/test/compare_cmip.jl Outdated
@hgpeterson
hgpeterson merged commit 843f98d into main Jul 16, 2026
13 of 14 checks passed
@hgpeterson
hgpeterson deleted the hp/clock branch July 16, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix clock in CMIP configurations

3 participants