Skip to content

Commit

Permalink
Adding a new function that runs the setup of structure S (#177)
Browse files Browse the repository at this point in the history
* Adding a new function that runs the setup of structure S

* Modifying function name

* Also making it so model_setup is exported in ShallowWaters.jl

* Removing ShallowWaters. everywhere it was used
  • Loading branch information
swilliamson7 authored May 14, 2024
1 parent 7d4296a commit 87156f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit 87156f6

Please sign in to comment.