diff --git a/src/ShallowWaters.jl b/src/ShallowWaters.jl index fda5303..de2b84b 100644 --- a/src/ShallowWaters.jl +++ b/src/ShallowWaters.jl @@ -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 diff --git a/src/run_model.jl b/src/run_model.jl index 396edf7..a3bac94 100644 --- a/src/run_model.jl +++ b/src/run_model.jl @@ -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 \ No newline at end of file