[WIP] Oceananigans integration tests#2775
Open
glwagner wants to merge 3 commits intoEnzymeAD:mainfrom
Open
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/test/integration/Oceananigans/runtests.jl b/test/integration/Oceananigans/runtests.jl
index dab12a36..41a64e6e 100644
--- a/test/integration/Oceananigans/runtests.jl
+++ b/test/integration/Oceananigans/runtests.jl
@@ -3,14 +3,14 @@ using GPUArraysCore: @allowscalar
using Oceananigans
using Test
-function kinetic_energy(model, ν, K, dt=1)
+function kinetic_energy(model, ν, K, dt = 1)
vitd = VerticallyImplicitTimeDiscretization()
new_closure = ScalarDiffusivity(vitd; ν)
tracer_names = keys(model.tracers)
new_closure = Oceananigans.TurbulenceClosures.with_tracers(tracer_names, new_closure)
model.closure = new_closure
- for n = 1:10
+ for n in 1:10
time_step!(model, dt)
end
@@ -20,17 +20,19 @@ function kinetic_energy(model, ν, K, dt=1)
end
@testset "Column model with ScalarDiffusivity" begin
- ν = 1e-3
- grid = RectilinearGrid(size=128, z=(-64, 64), topology=(Flat, Flat, Bounded))
+ ν = 1.0e-3
+ grid = RectilinearGrid(size = 128, z = (-64, 64), topology = (Flat, Flat, Bounded))
vitd = VerticallyImplicitTimeDiscretization()
closure = ScalarDiffusivity(vitd; ν)
- m = HydrostaticFreeSurfaceModel(; grid, closure, coriolis=FPlane(f=1e-4),
- tracers=:b, buoyancy=BuoyancyTracer())
+ m = HydrostaticFreeSurfaceModel(;
+ grid, closure, coriolis = FPlane(f = 1.0e-4),
+ tracers = :b, buoyancy = BuoyancyTracer()
+ )
- N² = 1e-6
+ N² = 1.0e-6
bᵢ(z) = N² * z
uᵢ(z) = exp(-z^2 / 10)
- set!(m, b=bᵢ, u=uᵢ)
+ set!(m, b = bᵢ, u = uᵢ)
u, v, w = m.velocities
ke = (u^2 + v^2) / 2
@@ -39,11 +41,13 @@ end
dm = Enzyme.make_zero(m)
dK = Enzyme.make_zero(K)
- dKdν = autodiff(set_strong_zero(Enzyme.ReverseWithPrimal),
- kinetic_energy, Active,
- Duplicated(m, dm),
- Active(ν),
- Duplicated(K, dK))
+ dKdν = autodiff(
+ set_strong_zero(Enzyme.ReverseWithPrimal),
+ kinetic_energy, Active,
+ Duplicated(m, dm),
+ Active(ν),
+ Duplicated(K, dK)
+ )
@test dKdν[1][1] != 0
end |
giordano
reviewed
Nov 12, 2025
Collaborator
Author
|
Looks like I need to be a little less ambitious probably |
wsmoses
reviewed
Nov 22, 2025
|
|
||
| compute!(K) | ||
|
|
||
| return @allowscalar first(K) |
Member
9b8a278 to
727981b
Compare
|
This might be relevant for you @dkytezab |
Member
|
1.10 just needs to be marked runtime activity. 1.11 hits a weird issue in an error handler, @vchuravy was looking at a while back but I don't think had cycles to look into for completion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR starts adding some integration tests. I noticed that the first thing I tried failed, so we'll have to work our way up.
Working on this with @giordano and @jtbuch