Skip to content
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

add OceananigansSimulation template #1253

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

juliasloan25
Copy link
Member

@juliasloan25 juliasloan25 commented Apr 1, 2025

Purpose

Add a file oceananigans.jl to implement the OceananigansSimulation in.

To-do

  • Make a template file with function stubs
  • Clarify exchange fields, where fluxes will be calculated/updated
  • Fill in constructor
  • Fill in setters and getters
  • Fill in flux calculation function

Content

Summary by CodeRabbit

  • New Features
    • Introduced an ocean simulation component that integrates seamlessly with the climate modeling framework.
    • Provides dynamic simulation capabilities including time-stepping, updating simulation fields, and managing interactions with atmospheric data.
    • Enhances the system with mechanisms to compute surface fluxes between ocean and atmosphere.
    • Added functionality to import atmospheric fields and update turbulent fluxes within the simulation.
    • New methods for managing simulation state and retrieving model progress.
    • Expanded project dependencies to support new features and functionalities related to ocean modeling.

Copy link

coderabbitai bot commented Apr 1, 2025

Walkthrough

This change introduces a new file for ocean simulations within the ClimaCoupler framework. It defines the OceananigansSimulation struct along with its constructor and several methods required for simulation management. These methods include functions for advancing and reinitializing the simulation, retrieving and updating fields, importing atmospheric fields, computing turbulent and surface fluxes, and adding coupler fields. Some functionalities are marked as placeholders or require further implementation. Additionally, the project manifests have been updated to include new dependencies related to ocean modeling.

Changes

File(s) Change Summary
experiments/ClimaEarth/.../oceananigans.jl Adds OceananigansSimulation struct and its constructor. Implements methods for stepping (step!), reinitialization (reinit!), field retrieval (get_field), field updating, atmospheric field import, turbulent and surface flux computations, coupler field addition, and model progress state retrieval (some methods are placeholders/TODO).
experiments/ClimaEarth/Manifest-v1.11.toml Updates project hash and adds multiple new dependencies including BFloat16s, BitFlags, CUDA, and others for enhanced functionality.
experiments/ClimaEarth/Manifest.toml Updates project hash and adds new dependencies including BFloat16s, BitFlags, CUDA, and others to support new features.
experiments/ClimaEarth/Project.toml Adds new dependencies: ClimaOcean and Oceananigans with their respective UUIDs.

Possibly related issues

  • Add OceananigansSimulation to ClimaCoupler #1259: The changes in this PR implement the OceananigansSimulation struct and its associated methods, aligning closely with the objectives outlined in the retrieved issue to integrate this simulation into the ClimaCoupler framework.

Suggested reviewers

  • kmdeck

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

🧹 Nitpick comments (2)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

15-19: Consider documenting struct type parameters more explicitly.
Though the docstring lists the fields in OceananigansSimulation, it might also help to clarify how M, I, and A are intended to be used (e.g., constraints on M for the ocean model, etc.). This can make future refactors and debugging easier.


250-252: Implement or stub out get_model_prog_state in a clearer way.
It raises an error, which is acceptable if you’re not ready to support checkpointing. However, you might provide a minimal implementation returning nothing or an empty FieldVector to safely integrate with the checkpointing system in the near future.

🛑 Comments failed to post (4)
experiments/ClimaEarth/components/ocean/oceananigans.jl (4)

86-124: 🛠️ Refactor suggestion

Implement or remove unneeded update_field! stubs.
All these stub methods have “TODO fill this out” placeholders. Clarify which fields are genuinely needed by your ocean model. Unused ones can be removed to reduce confusion. If they are needed, ensure the method properly remaps field onto sim.model so that future flux computations rely on correct grid values.

Do you want help generating partial implementations for any of these stubs?


213-239: 🛠️ Refactor suggestion

Add logic for computing surface fluxes or remove placeholders.
Currently, the call Oceananigans.compute_surface_fluxes(p, sim.model, Y, t, atmos_sim.integrator) references undefined variables p, Y, t. Either define or pass them. If this is a placeholder, consider raising a NotImplementedError or removing it until ready. This helps avoid runtime confusion.


131-144: ⚠️ Potential issue

Undefined variable air_density
Inside FieldExchanger.update_sim!, the function calls Interfacer.update_field!(sim, Val(:air_density), air_density), but air_density is not defined in this scope. It seems you intended to use csf.air_density, mirroring the pattern used for precipitation and radiative fields.

Apply this diff to fix the variable reference:

-    Interfacer.update_field!(sim, Val(:air_density), air_density)
+    Interfacer.update_field!(sim, Val(:air_density), csf.air_density)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf, turbulent_fluxes, area_fraction)
    Interfacer.update_field!(sim, Val(:air_density), csf.air_density)
    Interfacer.update_field!(sim, Val(:area_fraction), area_fraction)

    # precipitation
    Interfacer.update_field!(sim, Val(:liquid_precipitation), csf.P_liq)
    Interfacer.update_field!(sim, Val(:snow_precipitation), csf.P_snow)

    # update fields for radiative transfer
    Interfacer.update_field!(sim, Val(:sw_d), csf.SW_d)
    Interfacer.update_field!(sim, Val(:lw_d), csf.LW_d)

    # TODO update other fields as needed
end

32-43: 🛠️ Refactor suggestion

Instantiate model and integrator before returning.
Right now, you return OceananigansSimulation(model, integrator, area_fraction) but neither model nor integrator is defined in the constructor. Consider instantiating them (e.g., Oceananigans.Model(...)) and your integrator. For example:

 function OceananigansSimulation(
     ::Type{FT},
     dt::TT,
     tspan::Tuple{TT, TT},
     start_date::Dates.DateTime,
     output_dir::String,
     area_fraction,
 ) where {FT, TT <: Union{Float64, ITime}}
     # TODO fill this out
-    return OceananigansSimulation(model, integrator, area_fraction)
+    model = Oceananigans.Model(...)  # For example, specify the domain, physics, etc.
+    integrator = some_integrator_creation(..., dt)
+    return OceananigansSimulation(model, integrator, area_fraction)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

function OceananigansSimulation(
    ::Type{FT},
    dt::TT,
    tspan::Tuple{TT, TT},
    start_date::Dates.DateTime,
    output_dir::String,
    area_fraction,
) where {FT, TT <: Union{Float64, ITime}}
    # TODO fill this out

    model = Oceananigans.Model(...)  # For example, specify the domain, physics, etc.
    integrator = some_integrator_creation(..., dt)
    return OceananigansSimulation(model, integrator, area_fraction)
end

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

62-67: Unimplemented field getters.

These get_field methods currently return nothing. If these fields are essential for coupled flux calculations (e.g., computing roughness length), leaving them unimplemented could block development.

Would you like help creating placeholder fields or implementing these lookups? I can open an issue or provide sample code.


250-251: Unimplemented checkpointer function.

error("get_model_prog_state not implemented") blocks usage of the restart system. This is expected to return a ClimaCore.FieldVector or similarly typed state for checkpointing.

You might implement a minimal version returning state fields from sim.model. Otherwise, checkpointing and restart features will remain unavailable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3fb0ad4 and 2a81f44.

📒 Files selected for processing (1)
  • experiments/ClimaEarth/components/ocean/oceananigans.jl (1 hunks)
🔇 Additional comments (2)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

52-53: Potential off-by-one in integration time.

Interfacer.step!(sim.integrator, t - sim.integrator.t, true) may skip or repeat steps if t is not exactly one step beyond sim.integrator.t. Verify the correctness of subtracting sim.integrator.t from t.

Would you like to run a check to confirm the time-stepping behavior aligns with your desired timeline? If so, I can generate a script to inspect and compare the integrator’s t values after each step.


213-239: Incomplete flux calculation referencing undefined variables.

Lines 223-224 call Oceananigans.compute_surface_fluxes(p, sim.model, Y, t, atmos_sim.integrator), but p, Y, and t are undeclared here. Until you implement the real flux logic (or supply these variables properly), calling this will fail.

If you need to gather evidence of how these variables are declared in other files, I can generate a script to search the repository for their definitions or usage to confirm the correct references.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
experiments/ClimaEarth/components/ocean/oceananigans.jl (4)

61-77: Several get_field methods return nothing.

These placeholders hinder proper data exchange. If you need these fields, implement the logic; if they’re unnecessary, remove them to avoid confusion.

Would you like me to help fill in or remove these placeholders?


90-92: Empty implementation for Val(:air_density) update.

This usage is unimplemented. If air density is integral to ocean model calculations, please add logic to remap and update its values.

Shall I propose a code snippet to properly integrate and remap the input field?


223-223: References to p, Y, and t are placeholders and undefined.

Use actual variables from the simulation state or remove this call until you're ready to compute surface fluxes.

Would you like me to open an issue or propose a scaffold for initializing these variables?


250-252: get_model_prog_state is unimplemented.

If you intend to leverage the restart system or checkpointing, implement a ClimaCore-like FieldVector retrieval. Otherwise, consider removing it until it’s needed.

Do you want help drafting an implementation that wraps your model state into a FieldVector?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a81f44 and 6134564.

📒 Files selected for processing (1)
  • experiments/ClimaEarth/components/ocean/oceananigans.jl (1 hunks)
🔇 Additional comments (2)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

32-43: Constructor still references undefined model and integrator.

This mirrors a previous comment and remains unresolved. Both variables must be defined or passed in before constructing the OceananigansSimulation.


131-132: Undefined variable air_density.

This is the same issue previously flagged and remains unresolved. Replace air_density with something like csf.air_density or pass it as a function argument:

- Interfacer.update_field!(sim, Val(:air_density), air_density)
+ Interfacer.update_field!(sim, Val(:air_density), csf.air_density)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
experiments/ClimaEarth/Project.toml (2)

12-12: Add version constraints for ClimaOcean
Currently, there's no [compat] entry for ClimaOcean. Consider specifying a version range in the [compat] section to ensure that updates to ClimaOcean don’t inadvertently break your code.


21-21: Pin or add version constraints for Oceananigans
Likewise, consider adding a [compat] entry for Oceananigans so that your environment remains stable and reproducible across potential major version changes.

experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

17-20: Clarify the naming of sim field
Renaming the sim field (e.g., to model or simulation) could reduce confusion, since sim typically refers to the whole simulation object while this field specifically appears to hold the Oceananigans simulation struct.


101-163: Implement or remove placeholder methods
Many Interfacer.get_field and Interfacer.update_field! methods currently return nothing or contain TODO comments. Please fill in the required logic (such as remapping to the ocean grid) or remove them if not needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6134564 and c27c6ed.

📒 Files selected for processing (4)
  • experiments/ClimaEarth/Manifest-v1.11.toml (42 hunks)
  • experiments/ClimaEarth/Manifest.toml (42 hunks)
  • experiments/ClimaEarth/Project.toml (2 hunks)
  • experiments/ClimaEarth/components/ocean/oceananigans.jl (1 hunks)
🔇 Additional comments (32)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

171-172: Undefined variable air_density
This usage still references air_density even though it isn’t passed into the function or defined locally, which replicates a past review comment. Consider using csf.air_density instead.

-    Interfacer.update_field!(sim, Val(:air_density), air_density)
+    Interfacer.update_field!(sim, Val(:air_density), csf.air_density)

88-90:

❓ Verification inconclusive

Verify the time-stepping logic
Passing t - sim.model.clock.time directly into Oceananigans.time_step! could cause unexpected behavior if t is less than sim.model.clock.time. Please verify that this aligns with the intended usage and potential negative or zero time steps are accounted for.


🏁 Script executed:

#!/bin/bash
# Attempt to locate all references to `time_step!` calls in the code
# to confirm that usage is consistent and no negative/zero step is introduced
rg "time_step!\(.*\)"

Length of output: 191


Action Item: Verify Handling of Negative/Zero Time Steps

The call to Oceananigans.time_step!(sim.model, t - sim.model.clock.time) has been confirmed as the sole invocation in the codebase. However, passing t - sim.model.clock.time directly may yield negative or zero values if t is less than or equal to sim.model.clock.time. Please double-check that such values are either explicitly handled (e.g., with assertions or conditional checks) or natively managed by the Oceananigans library. If this behavior is unintended, consider adding safeguards to ensure that the time step remains strictly positive.

experiments/ClimaEarth/Manifest.toml (13)

5-5: Project Hash Updated
The manifest’s project_hash has been updated to "49212e1dfe951689ca6571f5a37fc6f6430caa6f". This change is expected in a machine‐generated file when dependencies or the project state changes.


183-188: New Dependency: BFloat16s
A new dependency entry for BFloat16s has been added with the specified dependencies (LinearAlgebra, Printf, and Random), git-tree SHA, UUID, and version "0.5.1". Please verify that this version is compatible with the rest of the ecosystem and that its inclusion supports the intended numerical computations.


202-206: New Dependency: BitFlags
The entry for BitFlags is now present with its git-tree SHA, UUID, and version "0.1.9". Since BitFlags is a lightweight utility, ensure that its functionality and version meet the project’s needs without introducing conflicts.


262-267: CUDA Dependency Update
The [[deps.CUDA]] block now includes a comprehensive list of dependencies (including BFloat16s, Crayons, GPUArrays, etc.) and is updated to version "5.7.1", with weak dependencies on "ChainRulesCore", "EnzymeCore", and "SpecialFunctions". Please confirm that all these sub-dependencies correctly support GPU-accelerated operations and that no version conflicts arise across the toolchain.


274-278: CUDA_Driver_jll Version Update
This block updates the CUDA_Driver_jll dependency to version "0.12.1+1". Verify that this new version is consistent with the corresponding CUDA runtime and that it meets the hardware/driver requirements for your simulation workflow.


280-284: CUDA_Runtime_Discovery Update
The CUDA_Runtime_Discovery dependency is now set to version "0.3.5". Make sure that this adjustment correctly detects the required runtime components and integrates smoothly with the rest of the CUDA-related libraries.


286-290: CUDA_Runtime_jll Update
The entry for CUDA_Runtime_jll has been updated to version "0.16.1+0". This change should be verified to ensure that it properly matches the configurations set by the other CUDA packages and supports the runtime operations required by your simulation modules.


396-400: New/Updated ClimaOcean Dependency
The [[deps.ClimaOcean]] block has been added/updated with a robust list of dependencies (including Adapt, CFTime, CUDA, ClimaSeaIce, Oceananigans, etc.) and is set to version "0.5.10". This dependency is central to the ocean simulation capability. Please ensure that its composition meets the requirements of the forthcoming OceananigansSimulation template and that all sub-dependencies are compatible.


402-403: ClimaOcean Extension for Reactant
The manifest now specifies an extension: ClimaOceanReactantExt = "Reactant". Ensure that the Reactant package is appropriately integrated, as it may be utilized in downstream flux or coupling calculations within the simulation framework.


405-406: Weak Dependency on Reactant for ClimaOcean
A weak dependency on Reactant is declared with its UUID "3c362404-f566-11ee-1572-e11a4b42c853". Confirm that this weak dependency does not force a hard version constraint and that it harmonizes with any optional simulation features that might leverage Reactant.


414-418: ClimaSeaIce Dependency Update
The [[deps.ClimaSeaIce]] block now includes Oceananigans as one of its dependencies and is updated to version "0.2.5". This change is crucial if sea ice dynamics are to be coupled with the new ocean model. Verify that the integration between sea ice and ocean components is coherent.


476-480: CodecZlib Dependency Added
A new entry for CodecZlib has been introduced, depending on TranscodingStreams and Zlib_jll, with version "0.7.8". Please check that this compression library meets the project’s requirements for data format handling and that it integrates well with other I/O components.


567-571: CompoundPeriods Dependency Added
The manifest now includes a dependency for CompoundPeriods (version "0.5.4"), which depends on "Dates". This addition should support any complex time-period computations required by the simulation template. Verify that its functionality aligns with the project’s temporal modeling needs.

experiments/ClimaEarth/Manifest-v1.11.toml (17)

3-5: Project Hash Update

The project hash has been updated to
  project_hash = "cbaa13594b44cc87ad732d5b6f1cb0f59d88893f"
which reflects a new project state. Please ensure this change matches the intended release state for this update.


184-189: New Dependency: BFloat16s

The block for the dependency BFloat16s (version 0.5.1) has been added/updated with the expected dependency list. This is likely required for enhanced numerical precision in GPU routines.


204-208: New Dependency: BitFlags

The BitFlags dependency (version 0.1.9) is now included. Verify that its features (e.g. bitwise flag operations) will be used by some of the project’s components and that its version is correct.


265-271: Updated CUDA Dependency

The CUDA dependency now appears with a wide range of dependencies and has been updated to version 5.7.1. Note the inclusion of weak dependencies for ChainRulesCore, EnzymeCore, and SpecialFunctions. Please check that these versions work correctly with your GPU-based simulations and that there are no version conflicts in the broader dependency graph.


272-276: CUDA Extensions

In the CUDA extensions block, the following extensions have been added:
  ChainRulesCoreExt = "ChainRulesCore"
  EnzymeCoreExt = "EnzymeCore"
  SpecialFunctionsExt = "SpecialFunctions"
Confirm that these extension entries are required for your code (for example, to support automatic differentiation and optimized mathematical routines).


283-288: CUDA Runtime Discovery Dependency

The CUDA_Runtime_Discovery dependency (version 0.3.5) has been updated. This module helps detect available CUDA runtimes. It would be good to verify on your target systems that this discovery mechanism performs as expected.


289-294: CUDA Runtime JLL Dependency

The CUDA_Runtime_jll now uses version 0.16.1+0. Make sure that this version is fully in line with your CUDA driver and runtime requirements across your supported platforms.


340-345: ClimaComms Weak Dependencies

In the ClimaComms block, a weak dependency on both CUDA and MPI has been specified. Please verify that these optional dependencies are desired for the typical deployment environments and do not inadvertently force unneeded inclusions in situations where, for example, MPI support is not available.


352-357: ClimaCore Weak Dependencies Updated

The ClimaCore dependency now lists weak dependencies on CUDA and Krylov (version updates appear in the weakdeps). Confirm that this update in weak dependencies is consistent with the design of your core simulation routines and does not introduce extra constraints.


405-407: ClimaOcean Extensions

Within the ClimaOcean block, the extension:
  ClimaOceanReactantExt = "Reactant"
has been added. Confirm that this extension correctly enables any coupling or data transformation required when using the Reactant package.


408-410: ClimaOcean Weak Dependency

A weak dependency for Reactant is specified under ClimaOcean. This indicates that while Reactant is not strictly required, it enhances functionality if available. Please ensure that this optional dependency aligns with your intended simulation coupling and that fallback behavior is in place when Reactant is absent.


417-422: New Dependency: ClimaSeaIce

The ClimaSeaIce dependency (version 0.2.5) has been added. Since this package supports ocean–ice interactions, verify that its API and version are compatible with the new ocean simulation template and that any exchange fields involving sea ice are properly addressed in subsequent development.


626-631: Dependency Update: CubicSplines

The CubicSplines dependency has been updated to version 0.2.1. This update might affect any numerical routines using spline interpolation; make sure that these changes are intended and that all usages of the API are in line with the new version.


637-642: Dependency Update: DataDeps

The DataDeps dependency (version 0.7.13) has been updated. Please verify that the new version supports your project’s data acquisition and retrieval pipelines as expected.


643-648: Dependency Update: DataFrames

The DataFrames dependency now uses version 1.7.0. Given the widespread use of DataFrames in data manipulation, please ensure that this update does not break existing code (for example, by introducing incompatible API changes).


2968-2972: New Dependency: demumble_jll

The demumble_jll dependency has been updated to version 1.3.0+0. This package is likely related to symbol demangling in the compiled artifacts (especially relevant when dealing with CUDA or LLVM components). Please verify its necessity and compatibility within your toolchain.


2690-2694: New or Updated Dependency: TZJData

The TZJData dependency has been updated to version 1.5.0+2025b. Since TZJData is usually used for handling time zone–related data, confirm that its version satisfies your project's time/date handling requirements.

Comment on lines +260 to +264
# TODO fill this in -
# compute F_turb_ρτxz, F_turb_ρτyz, F_shf, F_lhf, F_turb_moisture using Oceananigans.jl functions
# something like this:

fluxes = Oceananigans.compute_surface_fluxes(p, sim.model, Y, t, atmos_sim.integrator)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Placeholder references undefined variables
The code snippet referencing Oceananigans.compute_surface_fluxes(p, sim.model, Y, t, atmos_sim.integrator) invokes p, Y, and t which are not defined in this scope. This fragment likely cannot compile and needs proper parameters or references.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
experiments/ClimaEarth/components/ocean/oceananigans.jl (2)

264-266: ⚠️ Potential issue

Undefined variables passed to compute_surface_fluxes.

p, Y, and t are unused and not declared. Either remove them or ensure they are derived from your environment.

- fluxes = Oceananigans.compute_surface_fluxes(p, sim.model, Y, t, atmos_sim.integrator)
+ # Possibly something like:
+ fluxes = Oceananigans.compute_surface_fluxes(sim.model, atmos_sim.integrator)

171-172: ⚠️ Potential issue

Undefined variable air_density.

This line references air_density directly, but it is never passed or defined. Use csf.air_density or rename the parameter in the function signature.

-function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf, turbulent_fluxes, area_fraction)
    Interfacer.update_field!(sim, Val(:air_density), air_density)
+function FieldExchanger.update_sim!(sim::OceananigansSimulation, csf, turbulent_fluxes, area_fraction)
+    Interfacer.update_field!(sim, Val(:air_density), csf.air_density)
🧹 Nitpick comments (5)
experiments/ClimaEarth/components/ocean/oceananigans.jl (5)

6-20: Documentation covers high-level intent but could link to usage details.

These docstrings do a decent job introducing the OceananigansSimulation struct and explaining fields. For clarity, consider adding short usage examples or references to relevant modules and functions, especially for new contributors or potential maintainers.


70-78: Initial conditions are set randomly.

You use rand() in Tᵢ and Sᵢ, yielding non-reproducible setups. If reproducibility is desired (e.g., for tests), consider seeding random number generation or removing the random factor.


92-92: Reinitialization is not implemented.

Interfacer.reinit! is currently a no-op. If the model state or integrator time must be reset, ensure this is filled in to allow consistent restarts.


101-108: Consider implementing more surface fields.

All fields except :area_fraction return nothing. Some ocean schemes may need actual values (temperature, humidity, albedos, roughness, etc.). Be sure to fill these out once you have clarity on how the coupler and ocean model must share these.


289-291: Checkpointer not implemented.

Checkpointer.get_model_prog_state raises an error, so restarts are currently unsupported. If you aim to integrate the restarts soon, consider implementing a partial state or an unstructured checkpoint.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c27c6ed and fecbe45.

📒 Files selected for processing (4)
  • experiments/ClimaEarth/Manifest-v1.11.toml (42 hunks)
  • experiments/ClimaEarth/Manifest.toml (42 hunks)
  • experiments/ClimaEarth/Project.toml (2 hunks)
  • experiments/ClimaEarth/components/ocean/oceananigans.jl (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • experiments/ClimaEarth/Project.toml
🔇 Additional comments (27)
experiments/ClimaEarth/components/ocean/oceananigans.jl (3)

1-5: Imports look good, but confirm dependencies.

The imports from Oceananigans, ClimaOcean, ClimaCoupler, and ClimaComms appear relevant. Just ensure all these modules are installed, properly versioned, and fully compatible.


194-200: No definitions for Val(:F_turb_ρτxz), etc.

This function updates flux fields F_turb_ρτxz, F_turb_ρτyz, etc., but corresponding Interfacer.update_field! overloads are missing. Properly define or handle them if your ocean model expects these flux fields.


83-91:

❓ Verification inconclusive

Interfacer.step! usage.

step!(sim, t) calls Oceananigans.time_step!(sim.model, t - sim.model.clock.time). Confirm that subtracting sim.model.clock.time from t is indeed the correct way to get the time step increment. Also verify if this handles negative or zero increments gracefully.


🏁 Script executed:

#!/bin/bash
# Searching for references to 'step!' usage to verify time stepping logic
rg -A 5 'step!\(.*OceananigansSimulation'

Length of output: 643


Confirm and Verify Time-Step Calculation and Edge Case Handling

In file experiments/ClimaEarth/components/ocean/oceananigans.jl (lines 83–91), the implementation:

Interfacer.step!(sim::OceananigansSimulation, t) = Oceananigans.time_step!(sim.model, t - sim.model.clock.time)

computes the elapsed time (dt) as the difference between the target time t and the current simulation time (sim.model.clock.time). Please ensure that:

  • Correctness of Calculation: Subtracting sim.model.clock.time from t indeed represents the intended time step increment for this simulation.
  • Handling of Non-positive Increments: The implementation (or the underlying Oceananigans.time_step! function) properly handles cases where t - sim.model.clock.time is zero or negative. If not, consider adding safeguards or explicit error handling.
experiments/ClimaEarth/Manifest.toml (9)

5-5: Project Hash Update:
The project_hash on line 5 has been updated to "49212e1dfe951689ca6571f5a37fc6f6430caa6f", which reflects the overall change in the dependency graph. Please confirm that the manifest was regenerated in a clean environment and that the hash is consistent with all the new and updated dependencies.


183-188: Addition of BFloat16s Dependency:
A new dependency for BFloat16s has been introduced with its own dependencies (i.e. LinearAlgebra, Printf, and Random) and version "0.5.1". This should support any operations in the simulation that require BFloat16 numerical types. Verify that its inclusion is intentional and that its version is compatible with the broader dependency ecosystem.


202-206: Addition of BitFlags Dependency:
The BitFlags package (version "0.1.9") has been added. Please confirm that this package is needed—perhaps for efficient management of flag values—and that it integrates well with the other simulation components.


262-273: New CUDA Package Block:
A comprehensive new block for the CUDA package has been introduced (version "5.7.1") with a long dependency list and weak dependencies on ChainRulesCore, EnzymeCore, and SpecialFunctions. This update is critical for GPU-accelerated parts of the simulation (e.g. in the upcoming OceananigansSimulation). Please verify that:

  • All listed dependencies match the project’s GPU requirements.
  • The weak dependencies resolve correctly in your environment.
  • There are no version conflicts with other GPU-related packages in your dependency tree.

274-279: CUDA_Driver_jll Addition:
The CUDA_Driver_jll package (version "0.12.1+1") has been added. This is necessary for interfacing with the system’s CUDA drivers. Make sure that the installed driver on your system is compatible with this version, and that it does not introduce conflicts with the main CUDA package functionality.


280-285: CUDA_Runtime_Discovery Inclusion:
The new dependency CUDA_Runtime_Discovery (version "0.3.5") is aimed at discovering CUDA runtime libraries at execution time. This addition should help in configuring the runtime environment correctly. Verify that it integrates seamlessly with the other CUDA components.


286-291: CUDA_Runtime_jll Update:
The CUDA_Runtime_jll package (version "0.16.1+0") has been added, ensuring that the CUDA runtime components are available to the project. It is important that the runtime, driver, and main CUDA package versions are synchronized. Please confirm that this version is fully compatible with the rest of your CUDA setup.


396-401: Inclusion of ClimaOcean Dependency:
The new dependency ClimaOcean (version "0.5.10") is critical for enabling ocean simulation capabilities. It brings in several packages—including Oceananigans—that will support the development of the OceananigansSimulation template. Please ensure that:

  • All the sub-dependencies (e.g., Oceananigans, CubicSplines, NCDatasets, etc.) are compatible with your overall ClimaCoupler ecosystem.
  • Any integration tests regarding ocean simulations are updated to use this dependency.

402-407: ClimaOcean Extensions and Weak Dependencies:
The extensions block for ClimaOcean now defines ClimaOceanReactantExt and marks Reactant as a weak dependency. This appears to be linked to the simulation’s need for coupling reactive components. Make sure that the Reactant package—with UUID "3c362404-f566-11ee-1572-e11a4b42c853"—meets your integration requirements and that any OceananigansSimulation code referring to these components is updated accordingly.

experiments/ClimaEarth/Manifest-v1.11.toml (15)

5-5: Project Hash Update Detected
The project_hash has been updated to "cbaa13594b44cc87ad732d5b6f1cb0f59d88893f". Please verify that this new hash accurately reflects the current state of all project dependencies.


185-189: New Dependency Addition: BFloat16s
The dependency for BFloat16s has been added with version "0.5.1", including its own dependencies: LinearAlgebra, Printf, and Random. Confirm that the git-tree-sha1 and the version are as expected for integration.


204-207: New Dependency Addition: BitFlags
A new dependency for BitFlags (version "0.1.9") has been introduced. Please check that its git-tree-sha1 and UUID match the release details and that it is compatible with the rest of the manifest.


265-269: CUDA Dependency Update – Main Block
The CUDA dependency now lists a comprehensive set of dependencies and has been updated to version "5.7.1". Verify that the inclusion of packages such as BFloat16s, CEnum, and others (along with weak dependencies on ChainRulesCore, EnzymeCore, and SpecialFunctions) is intentional and that they are mutually compatible.


272-276: CUDA Extensions Configuration
The extension settings for CUDA now include ChainRulesCoreExt, EnzymeCoreExt, and SpecialFunctionsExt. Please confirm that these extensions correctly map to their parent packages and support the intended GPU computing and simulation features.


278-282: CUDA_Driver_jll Dependency Addition
The CUDA_Driver_jll dependency has been added with version "0.12.1+1". Verify that the listed dependencies and git-tree-sha1 are current and meet the project’s driver requirements for CUDA interoperability.


284-288: CUDA_Runtime_Discovery Dependency Added
The dependency CUDA_Runtime_Discovery (version "0.3.5") is now included. Please ensure this module’s lightweight dependency on Libdl and its version align with the runtime discovery needs for CUDA.


289-293: CUDA_Runtime_jll Dependency Update
The CUDA_Runtime_jll dependency has been updated to version "0.16.1+0" with its corresponding dependencies. Verify that this update integrates correctly with the CUDA driver and overall GPU runtime environment.


399-403: ClimaOcean Dependency Introduced
A new dependency ClimaOcean has been added with version "0.5.10". This dependency is essential for ocean modeling and aligns with the new OceananigansSimulation template. Please ensure that its extensive dependency list (including items like CUDA, ClimaSeaIce, and Oceananigans) is correct and that there are no conflicts with other dependencies.


405-407: ClimaOcean Extensions Configuration
Within ClimaOcean, an extension named ClimaOceanReactantExt has been specified. Confirm that this extension correctly links ClimaOcean with the Reactant package and supports the intended simulation coupling.


408-410: ClimaOcean Weak Dependencies Setup
The weak dependency for ClimaOcean includes Reactant. Please check that marking Reactant as a weak dependency is appropriate for optional functionality and does not lead to unexpected runtime issues.


1905-1909: New Dependency Addition: Oceananigans (Main Block)
The dependency Oceananigans has been added with version "0.96.12". Its extensive dependency list is critical for ocean simulation functionality. Please verify that the git-tree-sha1, UUID, and version match the expected release and that it integrates smoothly with the overarching ClimaCoupler ecosystem.


1910-1916: Oceananigans Extensions Configuration
The extension configuration for Oceananigans now provides additional functionality through OceananigansEnzymeExt, OceananigansMakieExt, OceananigansMetalExt, OceananigansNCDatasetsExt, and OceananigansReactantExt. Confirm that these extensions are implemented as intended and offer the necessary hooks for performance, visualization, and optional coupling.


1917-1925: Oceananigans Weak Dependencies Setup
The weak dependencies for Oceananigans include packages such as ConstructionBase, Enzyme, Makie, MakieCore, Metal, NCDatasets, and Reactant. Please ensure that these are correctly set as optional integrations, providing flexibility without enforcing strict version requirements.


2968-2972: demumble_jll Dependency Update
The dependency demumble_jll has been added with version "1.3.0+0". Verify that its configuration, including the listed dependencies and git-tree-sha1, meets the project’s needs for demangling or debugging support as required by the simulation modules.

Comment on lines +17 to +20
struct OceananigansSimulation{M, I, A} <: Interfacer.OceanModelSimulation
sim::M
area_fraction::A
end
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confer type parameter usage.

The struct parameters {M, I, A} serve to define the ocean simulation model, integrator, and area fraction type. Verify if the I is still necessary since the constructor doesn't reference an integrator parameter.


🏁 Script executed:

#!/bin/bash
# Searching for references to the `I` type parameter in the codebase
rg --context 5 'OceananigansSimulation\{.*I.*\}'

Length of output: 1907


Unused Type Parameter in OceananigansSimulation

In experiments/ClimaEarth/components/ocean/oceananigans.jl (lines 17–20), the struct still declares the type parameter I, but it isn’t referenced in any field or constructor. Please evaluate whether this parameter serves a purpose elsewhere (for example, if intended for future integration or required by the parent type) and either remove it or update the struct to utilize it accordingly.

Comment on lines +33 to +81
function OceananigansSimulation(
::Type{FT}, # TODO decide which arguments we want here
dt::TT,
tspan::Tuple{TT, TT},
start_date::Dates.DateTime,
output_dir::String,
area_fraction,
comms_ctx = ClimaComms.context(),
) where {FT, TT <: Union{Float64, ITime}}
# TODO fill this out
arch = if comms_ctx.device isa ClimaComms.CUDADevice
Oceananigans.GPU()
else
Oceananigans.CPU()
end

# Set up ocean grid
Nx = 360
Ny = 170
Nz = 30
z_faces = Ocean.exponential_z_faces(; Nz, h = 30, depth = 6000)

# TODO how to specify FT?
grid = Oceananigans.LatitudeLongitudeGrid(
arch;
size = (Nx, Ny, Nz),
longitude = (0, 360),
latitude = (-85, 85),
z = z_faces,
halo = (7, 7, 7),
)

# Choose parameterizations
momentum_advection = Oceananigans.WENOVectorInvariant(order = 5)
tracer_advection = Oceananigans.WENO(order = 5)
free_surface = Oceananigans.SplitExplicitFreeSurface(grid; substeps = 30)

# Create ocean simulation
ocean = Ocean.ocean_simulation(grid; momentum_advection, tracer_advection, free_surface, warn = false)


# Set up initial conditions for temperature and salinity
Tᵢ(λ, φ, z) = 30 * (1 - tanh((abs(φ) - 30) / 5)) / 2 + rand()
Sᵢ(λ, φ, z) = 30 - 5e-3 * z + rand()
Oceananigans.set!(ocean.model, T = Tᵢ, S = Sᵢ)

# TODO do we want to store sim or model?
return OceananigansSimulation(ocean, area_fraction)
end
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

The constructor is incomplete.

  1. It mentions # TODO fill this out, but the function already instantiates an ocean simulation via Ocean.ocean_simulation(...).
  2. Unused parameters: start_date, output_dir, and tspan are not applied anywhere.
  3. If you plan to incorporate domain decomposition or more sophisticated initial conditions, ensure these placeholders eventually get used.
 function OceananigansSimulation(
     ::Type{FT}, 
     dt::TT,
     tspan::Tuple{TT, TT},
     start_date::Dates.DateTime,
     output_dir::String,
     area_fraction,
     comms_ctx = ClimaComms.context(),
 ) where {FT, TT <: Union{Float64, ITime}}
     # TODO fill this out

+    # e.g. possibly use 'start_date' or 'output_dir' to configure checkpointing:
+    # setup_output(output_dir, start_date)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function OceananigansSimulation(
::Type{FT}, # TODO decide which arguments we want here
dt::TT,
tspan::Tuple{TT, TT},
start_date::Dates.DateTime,
output_dir::String,
area_fraction,
comms_ctx = ClimaComms.context(),
) where {FT, TT <: Union{Float64, ITime}}
# TODO fill this out
arch = if comms_ctx.device isa ClimaComms.CUDADevice
Oceananigans.GPU()
else
Oceananigans.CPU()
end
# Set up ocean grid
Nx = 360
Ny = 170
Nz = 30
z_faces = Ocean.exponential_z_faces(; Nz, h = 30, depth = 6000)
# TODO how to specify FT?
grid = Oceananigans.LatitudeLongitudeGrid(
arch;
size = (Nx, Ny, Nz),
longitude = (0, 360),
latitude = (-85, 85),
z = z_faces,
halo = (7, 7, 7),
)
# Choose parameterizations
momentum_advection = Oceananigans.WENOVectorInvariant(order = 5)
tracer_advection = Oceananigans.WENO(order = 5)
free_surface = Oceananigans.SplitExplicitFreeSurface(grid; substeps = 30)
# Create ocean simulation
ocean = Ocean.ocean_simulation(grid; momentum_advection, tracer_advection, free_surface, warn = false)
# Set up initial conditions for temperature and salinity
Tᵢ(λ, φ, z) = 30 * (1 - tanh((abs(φ) - 30) / 5)) / 2 + rand()
Sᵢ(λ, φ, z) = 30 - 5e-3 * z + rand()
Oceananigans.set!(ocean.model, T = Tᵢ, S = Sᵢ)
# TODO do we want to store sim or model?
return OceananigansSimulation(ocean, area_fraction)
end
function OceananigansSimulation(
::Type{FT}, # TODO decide which arguments we want here
dt::TT,
tspan::Tuple{TT, TT},
start_date::Dates.DateTime,
output_dir::String,
area_fraction,
comms_ctx = ClimaComms.context(),
) where {FT, TT <: Union{Float64, ITime}}
# TODO fill this out
# e.g. possibly use 'start_date' or 'output_dir' to configure checkpointing:
# setup_output(output_dir, start_date)
arch = if comms_ctx.device isa ClimaComms.CUDADevice
Oceananigans.GPU()
else
Oceananigans.CPU()
end
# Set up ocean grid
Nx = 360
Ny = 170
Nz = 30
z_faces = Ocean.exponential_z_faces(; Nz, h = 30, depth = 6000)
# TODO how to specify FT?
grid = Oceananigans.LatitudeLongitudeGrid(
arch;
size = (Nx, Ny, Nz),
longitude = (0, 360),
latitude = (-85, 85),
z = z_faces,
halo = (7, 7, 7),
)
# Choose parameterizations
momentum_advection = Oceananigans.WENOVectorInvariant(order = 5)
tracer_advection = Oceananigans.WENO(order = 5)
free_surface = Oceananigans.SplitExplicitFreeSurface(grid; substeps = 30)
# Create ocean simulation
ocean = Ocean.ocean_simulation(grid; momentum_advection, tracer_advection, free_surface, warn = false)
# Set up initial conditions for temperature and salinity
Tᵢ(λ, φ, z) = 30 * (1 - tanh((abs(φ) - 30) / 5)) / 2 + rand()
Sᵢ(λ, φ, z) = 30 - 5e-3 * z + rand()
Oceananigans.set!(ocean.model, T = Tᵢ, S = Sᵢ)
# TODO do we want to store sim or model?
return OceananigansSimulation(ocean, area_fraction)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant