-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Description
I’m trying to output the free surface η using NetCDFWriter, but I encountered an error. Below is an example:
using Oceananigans
using NCDatasets
grid = RectilinearGrid(size = (20, 40, 100),
extent=(4e5, 8e5, 2e3),
topology = (Periodic, Bounded, Bounded))
model = HydrostaticFreeSurfaceModel(; grid,
buoyancy = BuoyancyTracer(),
tracers = :b)
b0=rand(Float64, 100)
using LinearAlgebra
b0=repeat(reshape(b0,(1,1,100)),20,40,1);
set!(model, b=b0)
simulation = Simulation(model, Δt=120, stop_time=24*60*60)
fields = Dict("η" => model.free_surface.η);
simulation.output_writers[:field_writerETA] =
NetCDFWriter(model, fields, filename="eta.nc",
schedule=TimeInterval(60*60), array_type = Array{Float64})
run!(simulation)
This results in the error:
ArgumentError: view indices (1:20, 1:40, 1:101) do not intersect field indices (Colon(), Colon(), 101:101)
I also tried specifying: indices=(:,:,grid.Nz+1)
,but then got:
ArgumentError: view indices (1:1, 1:1, 101:100) do not intersect field indices (Colon(), Colon(), 101:101)
I attempted with_halos=true, but that led to:
[ Info: Initializing simulation...
DimensionMismatch: new dimensions (26, 46, 107, 1) must be consistent with array size 1196
How can I correctly output the η variable with NetCDFWriter?
Metadata
Metadata
Assignees
Labels
No labels