Skip to content

Commit a02649d

Browse files
authored
(0.98.1) Make convert_for_netcdf() accesible to users (#4772)
1 parent d0bbd43 commit a02649d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Oceananigans"
22
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
33
authors = ["Climate Modeling Alliance and contributors"]
4-
version = "0.98.0"
4+
version = "0.98.1"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

ext/OceananigansNCDatasetsExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using Oceananigans.OutputWriters:
4141
show_array_type
4242

4343
import Oceananigans: write_output!
44-
import Oceananigans.OutputWriters: NetCDFWriter, write_grid_reconstruction_data!, materialize_from_netcdf, reconstruct_grid
44+
import Oceananigans.OutputWriters: NetCDFWriter, write_grid_reconstruction_data!, convert_for_netcdf, materialize_from_netcdf, reconstruct_grid
4545

4646
const c = Center()
4747
const f = Face()
@@ -669,8 +669,8 @@ function grid_attributes(ibg::ImmersedBoundaryGrid)
669669
return attrs, dims
670670
end
671671

672-
# Using OrderedDict to preserve order of keys. Important for positional arguments.
673-
convert_for_netcdf(dict::AbstractDict) = OrderedDict{Symbol, Any}(key => convert_for_netcdf(value) for (key, value) in dict)
672+
# Using OrderedDict to preserve order of keys (important when saving positional arguments), and string(key) because that's what NetCDF supports as global_attributes.
673+
convert_for_netcdf(dict::AbstractDict) = OrderedDict(string(key) => convert_for_netcdf(value) for (key, value) in dict)
674674
convert_for_netcdf(x::Number) = x
675675
convert_for_netcdf(x::Bool) = string(x)
676676
convert_for_netcdf(x::NTuple{N, Number}) where N = collect(x)
@@ -699,7 +699,7 @@ function write_grid_reconstruction_data!(ds, grid; array_type=Array{eltype(grid)
699699
:bottom_height keys(args) && delete!(args, :bottom_height)
700700

701701
args, kwargs = map(convert_for_netcdf, (args, kwargs))
702-
args[:grid_type] = typeof(grid).name.wrapper |> string # Save type of grid for reconstruction
702+
args["grid_type"] = typeof(grid).name.wrapper |> string # Save type of grid for reconstruction
703703

704704
defGroup(ds, "grid_reconstruction_args"; attrib = args)
705705
defGroup(ds, "grid_reconstruction_kwargs"; attrib = kwargs)

src/OutputWriters/netcdf_writer.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ function NetCDFWriter(model, outputs; kw...)
3131
end
3232

3333
function write_grid_reconstruction_data! end
34+
function convert_for_netcdf end
3435
function materialize_from_netcdf end
3536
function reconstruct_grid end

0 commit comments

Comments
 (0)