Skip to content

Fix NCDatasets extension for Julia 1.12#126

Closed
ewquon wants to merge 1 commit into
CliMA:mainfrom
ewquon:fix-ncdatasets-ext-eval-init
Closed

Fix NCDatasets extension for Julia 1.12#126
ewquon wants to merge 1 commit into
CliMA:mainfrom
ewquon:fix-ncdatasets-ext-eval-init

Conversation

@ewquon
Copy link
Copy Markdown

@ewquon ewquon commented Apr 1, 2026

Summary

  • Move default_output_attributes(::SeaIceModel) method definition from __init__() with @eval to top-level extension scope
  • Julia 1.12 rejects eval into a closed module during __init__, causing precompilation to fail with: "Evaluation into the closed module ClimaSeaIceNCDatasetsExt breaks incremental compilation because the side effects will not be permanent."
  • The method is now defined at extension load time, which is both correct and compatible with Julia 1.12's stricter compilation model

Test plan

  • Verified Pkg.precompile() succeeds on Julia 1.12 with this patch

🤖 Generated with Claude Code

Move the method definition for `default_output_attributes(::SeaIceModel)`
from `__init__()` with `@eval` to top-level extension scope. Julia 1.12
rejects `eval` into a closed module during `__init__`, causing
precompilation to fail with:

    "Evaluation into the closed module ClimaSeaIceNCDatasetsExt breaks
     incremental compilation because the side effects will not be permanent."

The method is now defined at extension load time, which is both correct
and compatible with Julia 1.12's stricter compilation model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines +31 to +36
OCNE = Base.get_extension(Oceananigans, :OceananigansNCDatasetsExt)
if !isnothing(OCNE)
function OCNE.default_output_attributes(model::SeaIceModel)
velocity_attrs = default_horizontal_velocity_attributes(model.grid)
tracer_attrs = default_sea_ice_attributes()
return merge(velocity_attrs, tracer_attrs)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will not work because the extension is not loaded at compile time. We need CliMA/Oceananigans.jl#5469 and then extend the function in output_writers

@simone-silvestri
Copy link
Copy Markdown
Collaborator

@ewquon if it is not a problem I will close this PR in favor of #127

@ewquon ewquon deleted the fix-ncdatasets-ext-eval-init branch April 2, 2026 15:30
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.

2 participants