Skip to content

Commit aba99f7

Browse files
tomchorglwagner
andauthored
(0.96.0) Move NetCDFWriter to an extension (#4239)
* start with files that don't require re-indentation * re-format /examples * re-format src * re-format /test * re-format some validation scripts * more validation scripts * more validation scripts * rest of validation scripts * fix last validation files * re-format docs and examples * reformat src * reformat test * reformat validation * move netcdf_output_writer.jl to extension * rename files * move struct definition to OutputWriters * using much more stuff * KernelFunctinoOperation is needed * rename test_netcdf and test_jld2 files * include correct names * add NCDatasets to targets * Update OceananigansNCDatasetsExt.jl * fix bug in JLD2_writer.jl * fix examples * add NCDatasets to validation scripts * remove blank line * Use warning instead of error * Add output_averaging_schedule * Import more * using show_array_type * fix docs/src/model_setup * Fix lagrangian particle example --------- Co-authored-by: Gregory L. Wagner <[email protected]> Co-authored-by: Gregory Wagner <[email protected]>
1 parent 1db526e commit aba99f7

File tree

13 files changed

+1462
-1409
lines changed

13 files changed

+1462
-1409
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
2222
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2323
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2424
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
25-
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
2625
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2726
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
2827
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
@@ -42,12 +41,14 @@ Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
4241
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
4342
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
4443
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
44+
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
4545
Reactant = "3c362404-f566-11ee-1572-e11a4b42c853"
4646

4747
[extensions]
4848
OceananigansEnzymeExt = "Enzyme"
4949
OceananigansMakieExt = ["MakieCore", "Makie"]
5050
OceananigansMetalExt = "Metal"
51+
OceananigansNCDatasetsExt = "NCDatasets"
5152
OceananigansReactantExt = ["Reactant", "KernelAbstractions", "ConstructionBase"]
5253

5354
[compat]
@@ -101,4 +102,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
101102
TimesDates = "bdfc003b-8df8-5c39-adcd-3a9087f5df4a"
102103

103104
[targets]
104-
test = ["DataDeps", "SafeTestsets", "Test", "Enzyme", "Reactant", "Metal", "CUDA_Runtime_jll", "MPIPreferences", "TimesDates"]
105+
test = ["DataDeps", "SafeTestsets", "Test", "Enzyme", "Reactant", "Metal", "CUDA_Runtime_jll", "MPIPreferences", "TimesDates", "NCDatasets"]

docs/src/model_setup/lagrangian_particles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ When writing to JLD2 you can pass `model.particles` as part of the named tuple o
110110

111111
```@setup particles
112112
using Oceananigans
113+
using NCDatasets
113114
grid = RectilinearGrid(size=(10, 10, 10), extent=(1, 1, 1))
114115
Nparticles = 3
115116
x₀ = zeros(Nparticles)

docs/src/model_setup/output_writers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Saving the u velocity field and temperature fields as full 3D fields, surface 2D
5252

5353
```@example netcdf1
5454
using Oceananigans
55+
using NCDatasets
5556
5657
grid = RectilinearGrid(size=(16, 16, 16), extent=(1, 1, 1))
5758
@@ -84,6 +85,7 @@ provided that their `dimensions` are provided:
8485

8586
```@example
8687
using Oceananigans
88+
using NCDatasets
8789
8890
Nx, Ny, Nz = 16, 16, 16
8991
@@ -128,6 +130,7 @@ to a different grid than `model.grid`. To use this functionality, include the ke
128130
```@example
129131
using Oceananigans
130132
using Oceananigans.Fields: interpolate!
133+
using NCDatasets
131134
132135
grid = RectilinearGrid(size=(1, 1, 8), extent=(1, 1, 1));
133136
model = NonhydrostaticModel(; grid)

examples/shallow_water_Bickley_jet.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ using LinearAlgebra: norm
129129
perturbation_norm(args...) = norm(v)
130130

131131
# Build the `output_writer` for the two-dimensional fields to be output.
132-
# Output every `t = 1.0`.
132+
# Output every `t = 1.0`. Note that we need `NCDatasets` to be able to use
133+
# the `NetCDFWriter`.
134+
135+
using NCDatasets
133136

134137
fields_filename = joinpath(@__DIR__, "shallow_water_Bickley_jet_fields.nc")
135138
simulation.output_writers[:fields] = NetCDFWriter(model, (; ω, ω′),

examples/tilted_bottom_boundary_layer.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ simulation.callbacks[:progress] = Callback(progress_message, IterationInterval(2
187187

188188
# ## Add outputs to the simulation
189189
#
190-
# We add outputs to our model using the `NetCDFWriter`,
190+
# We add outputs to our model using the `NetCDFWriter`, which needs `NCDatasets` to be loaded:
191191

192192
u, v, w = model.velocities
193193
b = model.tracers.b
@@ -199,6 +199,8 @@ V = v + V∞
199199

200200
outputs = (; u, V, w, B, ωy)
201201

202+
using NCDatasets
203+
202204
simulation.output_writers[:fields] = NetCDFWriter(model, outputs;
203205
filename = joinpath(@__DIR__, "tilted_bottom_boundary_layer.nc"),
204206
schedule = TimeInterval(20minutes),

0 commit comments

Comments
 (0)