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

Adding a new function that runs the setup of structure S #177

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ShallowWaters.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ShallowWaters

export run_model, Parameter, ∂x, ∂y, Ix, Iy, ∇²
export run_model, model_setup, Parameter, ∂x, ∂y, Ix, Iy, ∇²

using NetCDF, Parameters, Printf, Dates, Interpolations

Expand Down
31 changes: 31 additions & 0 deletions src/run_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,35 @@ function run_model(::Type{T},P::Parameter) where {T<:AbstractFloat}

return Prog

end

function model_setup(::Type{T}=Float32; # number format
kwargs... # all additional parameters
) where {T<:AbstractFloat}

P = ShallowWaters.Parameter(T=T;kwargs...)
milankl marked this conversation as resolved.
Show resolved Hide resolved
return model_setup(T,P)
end

function model_setup(P::ShallowWaters.Parameter)
@unpack T = P
return model_setup(T,P)
end

function model_setup(::Type{T},P::ShallowWaters.Parameter) where {T<:AbstractFloat}

@unpack Tprog = P

G = ShallowWaters.Grid{T,Tprog}(P)
C = ShallowWaters.Constants{T,Tprog}(P,G)
F = ShallowWaters.Forcing{T}(P,G)

Prog = ShallowWaters.initial_conditions(Tprog,G,P,C)
Diag = ShallowWaters.preallocate(T,Tprog,G)

# one structure with everything inside
S = ShallowWaters.ModelSetup{T,Tprog}(P,G,C,F,Prog,Diag,0)
milankl marked this conversation as resolved.
Show resolved Hide resolved

return S

end
Loading