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 all 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
30 changes: 30 additions & 0 deletions src/run_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,34 @@ 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 = Parameter(T=T;kwargs...)
return model_setup(T,P)
end

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

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

@unpack Tprog = P

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

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

S = ModelSetup{T,Tprog}(P,G,C,F,Prog,Diag,0)

return S

end
Loading