Skip to content

Commit 87156f6

Browse files
authored
Adding a new function that runs the setup of structure S (#177)
* 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
1 parent 7d4296a commit 87156f6

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/ShallowWaters.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ShallowWaters
22

3-
export run_model, Parameter, ∂x, ∂y, Ix, Iy, ∇²
3+
export run_model, model_setup, Parameter, ∂x, ∂y, Ix, Iy, ∇²
44

55
using NetCDF, Parameters, Printf, Dates, Interpolations
66

src/run_model.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,34 @@ function run_model(::Type{T},P::Parameter) where {T<:AbstractFloat}
3939

4040
return Prog
4141

42+
end
43+
44+
function model_setup(::Type{T}=Float32; # number format
45+
kwargs... # all additional parameters
46+
) where {T<:AbstractFloat}
47+
48+
P = Parameter(T=T;kwargs...)
49+
return model_setup(T,P)
50+
end
51+
52+
function model_setup(P::Parameter)
53+
@unpack T = P
54+
return model_setup(T,P)
55+
end
56+
57+
function model_setup(::Type{T},P::Parameter) where {T<:AbstractFloat}
58+
59+
@unpack Tprog = P
60+
61+
G = Grid{T,Tprog}(P)
62+
C = Constants{T,Tprog}(P,G)
63+
F = Forcing{T}(P,G)
64+
65+
Prog = initial_conditions(Tprog,G,P,C)
66+
Diag = preallocate(T,Tprog,G)
67+
68+
S = ModelSetup{T,Tprog}(P,G,C,F,Prog,Diag,0)
69+
70+
return S
71+
4272
end

0 commit comments

Comments
 (0)