Skip to content

Submodules for diagnostics and output writers #498

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

Closed
wants to merge 4 commits into from

Conversation

ali-ramadhan
Copy link
Member

This PR refactors diagnostics.jl and output_writers.jl into their own submodules.

We might want to discuss #497 as we refactor things into submodules as it increases the number of cross-module import statements.

Helps with #456 and #495

@ali-ramadhan ali-ramadhan added the cleanup 🧹 Paying off technical debt label Oct 23, 2019
@glwagner
Copy link
Member

Can we please merge abstract operations before this. There will be merge conflicts.

Copy link
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it.

Only comment is that maybe we should remove export statements from Oceananigans associated with diagnostics and output writers.

Then a user can write using Oceananigans.Diagnostics if they need diagnostic stuff, and using Oceananigans.OutputWriters if they need to use output writers. Or they can write

using Oceananigans.OutputWriters: NetCDFOutputWriter

I personally like this semantics because 1) I think it's better to give users finer control over what's imported into the namespace and 2) it makes scripts clearer: script-readers know when diagnostics and output writers are used. Etc.

This also requires being a bit more selective about what is exported from the submodules.


export
write_output, read_output,
has_reference, has_array_refs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we export has_reference and has_array_refs? Doesn't seem like part of API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. I removed them.

module Diagnostics

export
run_diagnostic,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we export run_diagnostic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. Removed it.


using Oceananigans: AbstractDiagnostic

include("kernels.jl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may want to name this file diagnostics_kernels.jl. We should also probably rename the similarly named file in the nascent TimeSteppers submodule introduced in PR #505 timestepping_kernels.jl.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of more verbose file names. Done!

using Oceananigans,
Oceananigans.Operators

using Oceananigans: AbstractDiagnostic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should AbstractDiagnostic be introduced within this submodule, rather than in Oceananigans?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I do it in this case because it's used by a shared utility defined in utils.jl. Might make sense to move the shared util into the Diagnostics or OutputWriters module, whichever is defined first so it can be imported by the other.

Checkpointer, restore_from_checkpoint

using Oceananigans
using Oceananigans: AbstractOutputWriter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should AbstractOutputWriter be introduced in this submodule, rather than in Oceananigans? I think concept encapsulation is good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment.

@ali-ramadhan
Copy link
Member Author

The merge conflicts in this PR got a little messy so I started over in PR #512 and also moved the grids and Poisson solvers into their own submodules.

I will close this PR now.

@glwagner Your comments should have been addressed in PR #512, although there may be more to comment on now.

@ali-ramadhan ali-ramadhan deleted the ar/two-submodules branch October 30, 2019 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup 🧹 Paying off technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants