Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetCDFOutputWriter should have mode = "c" as default? #2339

Closed
navidcy opened this issue Mar 13, 2022 · 7 comments
Closed

NetCDFOutputWriter should have mode = "c" as default? #2339

navidcy opened this issue Mar 13, 2022 · 7 comments
Labels
documentation 📜 The sacred scrolls question 💭 No such thing as a stupid question user interface/experience 💻

Comments

@navidcy
Copy link
Collaborator

navidcy commented Mar 13, 2022

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

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

isnothing(mode) && (mode = "c")

?

Why not have mode = "c" the default?

@navidcy navidcy added question 💭 No such thing as a stupid question documentation 📜 The sacred scrolls user interface/experience 💻 labels Mar 13, 2022
@glwagner
Copy link
Member

glwagner commented Mar 13, 2022

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

if isfile(filepath) && isnothing(mode)
@warn "$filepath already exists but no NetCDFOutputWriter mode was explicitly specified. " *
"Will default to mode = \"a\" to append to existing file. You might experience errors " *
"when writing output if the existing file belonged to a different simulation!"
mode = "a"
end

@glwagner
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Resolved, right @tomchor ?

@tomchor
Copy link
Collaborator

tomchor commented Apr 15, 2022

Kinda. The current behavior is this

if isnothing(overwrite_existing)
if isfile(filepath)
overwrite_existing = false
else
overwrite_existing = true
end
else

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.

@glwagner
Copy link
Member

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

@glwagner
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📜 The sacred scrolls question 💭 No such thing as a stupid question user interface/experience 💻
Projects
None yet
Development

No branches or pull requests

3 participants