Oceananigans.jl icon indicating copy to clipboard operation
Oceananigans.jl copied to clipboard

`NetCDFOutputWriter` should have `mode = "c"` as default?

Open navidcy opened this issue 3 years ago • 6 comments

I was reading the NetCDFOutputWriter docstring and I got confused. Why mode = nothing is set as default in NetCDFOutputWriter

https://github.com/CliMA/Oceananigans.jl/blob/6ceeb012f1432bf936edd977fa1390dc694a0adc/src/OutputWriters/netcdf_output_writer.jl#L289

and then straight after is converted to mode = "c"

https://github.com/CliMA/Oceananigans.jl/blob/6ceeb012f1432bf936edd977fa1390dc694a0adc/src/OutputWriters/netcdf_output_writer.jl#L301 ?

Why not have mode = "c" the default?

navidcy avatar Mar 13 '22 03:03 navidcy

The default depends on whether the file already exists or not? Just above that...

https://github.com/CliMA/Oceananigans.jl/blob/6ceeb012f1432bf936edd977fa1390dc694a0adc/src/OutputWriters/netcdf_output_writer.jl#L293-L298

glwagner avatar Mar 13 '22 11:03 glwagner

It's all a little weird though I agree...

Partly I think we're in a much better position to figure out whether we want to destroy an existing file or append to a new one when we call run!. At the time the output writers are created, we don't know if someone is pickup=true or if iteration != 0, etc. I think there's an issue about this...

glwagner avatar Mar 13 '22 11:03 glwagner

Something about "initializing" an output writer only after we call run!. Basically we can just move the whole constructor to some function initialize_output_writer! that only get's called when a simulation is "initialized".

glwagner avatar Mar 13 '22 11:03 glwagner

Resolved, right @tomchor ?

glwagner avatar Apr 15 '22 17:04 glwagner

Kinda. The current behavior is this https://github.com/CliMA/Oceananigans.jl/blob/470fd110a99b1967510979fbc313093dac060636/src/OutputWriters/netcdf_output_writer.jl#L302-L308

So the default is similar to what it was when this issue was posted, although I think it's formulated a little clearer now.

I'm okay with this and also okay with closing this issue, but I'm not sure everyone else feels this way. You mentioned at some point that we could move this part to after run!() is called and I don't think we discussed that.

tomchor avatar Apr 15 '22 17:04 tomchor

Oh I see... you're right, we should leave this open.

glwagner avatar Apr 15 '22 18:04 glwagner

I'm closing this issue because I'm judging that it's not of current, timely relevance to Oceananigans development. If you would like to make it a higher priority or if you think the issue was closed in error please feel free to re-open.

glwagner avatar Mar 22 '23 17:03 glwagner