Skip to content

Commit 68b7f9c

Browse files
authored
Merge pull request #144 from milankl/rk2
Rk2
2 parents 0df1366 + 7c1dc07 commit 68b7f9c

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

.appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
environment:
22
matrix:
3-
- julia_version: 1.4
3+
- julia_version: 1.2
4+
- julia_version: 1.5
45
- julia_version: nightly
56

67
platform:

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 1.4
7+
- 1.2
8+
- 1.5
89
- nightly
910
notifications:
1011
email: false

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ShallowWaters"
22
uuid = "56019723-2d87-4a65-81ff-59d5d8913e3c"
33
authors = ["Milan Kloewer"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -14,7 +14,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1414
Interpolations = "^0.12"
1515
NetCDF = "^0.10"
1616
Parameters = "^0.12"
17-
julia = "1"
17+
julia = "^1.2"
1818

1919
[extras]
2020
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/Constants.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ end
2525
"""Generator function for the mutable struct Constants."""
2626
function Constants{T,Tprog}(P::Parameter,G::Grid) where {T<:AbstractFloat,Tprog<:AbstractFloat}
2727

28-
# Runge-Kutta 3rd/4th order coefficients including time step Δt
29-
# (which includes the grid spacing Δ too)
30-
if P.RKo == 3 # version 2
28+
# Runge-Kutta 2nd/3rd/4th order coefficients including time step Δt and grid spacing Δ
29+
# a are the coefficents to sum the rhs on the fly, such that sum=1
30+
# b are the coefficents for the update that used for a new evaluation of the RHS
31+
if P.RKo == 2 # Heun's method
32+
RKaΔt = Tprog.([1/2,1/2]*G.dtint/G.Δ)
33+
RKbΔt = Tprog.([1]*G.dtint/G.Δ)
34+
elseif P.RKo == 3 # version 2 / Heun's 3rd order
3135
RKaΔt = Tprog.([1/4,0.,3/4]*G.dtint/G.Δ)
3236
RKbΔt = Tprog.([1/3,2/3]*G.dtint/G.Δ)
3337
elseif P.RKo == 4

src/DefaultParameters.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
# OUTPUT OPTIONS
9797
output::Bool=false # netcdf output?
98-
output_vars::Array{String,1}=["u","v","η","sst","q","ζ"] # which variables to output? "du","dv","dη" also allowed
98+
output_vars::Array{String,1}=["u","v","η","sst"] # which variables to output? "du","dv","dη" also allowed
9999
output_dt::Real=6 # output time step [hours]
100100
outpath::String=pwd() # path to output folder
101101

@@ -118,7 +118,7 @@
118118
@assert topo_width > 0.0 "topo_width has to be >0, $topo_width given."
119119
@assert t_relax > 0.0 "t_relax has to be >0, $t_relax given."
120120
@assert η_refw > 0.0 "η_refw has to be >0, $η_refw given."
121-
@assert RKo in [3,4] "RKo has to be 3 or 4, $RKo given."
121+
@assert RKo in [2,3,4] "RKo has to be 2,3 or 4, $RKo given."
122122
@assert Ndays > 0.0 "Ndays has to be >0, $Ndays given."
123123
@assert nstep_diff > 0 "nstep_diff has to be >0, $nstep_diff given."
124124
@assert nstep_advcor >= 0 "nstep_advcor has to be >=0, $nstep_advcor given."
@@ -191,8 +191,8 @@ Creates a Parameter struct with following options and default values
191191
wk::Real=10e3 # width [m] in y of Gaussian used for surface forcing
192192
193193
# TIME STEPPING OPTIONS
194-
RKo::Int=4 # Order of the RK time stepping scheme (3 or 4)
195-
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3)
194+
RKo::Int=4 # Order of the RK time stepping scheme (2,3 or 4)
195+
cfl::Real=1.0 # CFL number (1.0 recommended for RK4, 0.6 for RK3, 0.1 for RK2)
196196
Ndays::Real=10.0 # number of days to integrate for
197197
nstep_diff::Int=1 # diffusive part every nstep_diff time steps.
198198
nstep_advcor::Int=0 # advection and coriolis update every nstep_advcor time steps.
@@ -239,7 +239,7 @@ Creates a Parameter struct with following options and default values
239239
240240
# OUTPUT OPTIONS
241241
output::Bool=false # netcdf output?
242-
output_vars::Array{String,1}=["u","v","η","sst","q","ζ"] # which variables to output? "du","dv","dη" also allowed
242+
output_vars::Array{String,1}=["u","v","η","sst"] # which variables to output? q,ζ,du,dv,dη also allowed.
243243
output_dt::Real=6 # output time step [hours]
244244
outpath::String=pwd() # path to output folder
245245

src/Output.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ function nc_create( x::Array{T,1},
6565
tvar = NcVar("t",tdim,t=Int32)
6666

6767
nc = NetCDF.create(joinpath(path,name*".nc"),[var,tvar],mode=NC_NETCDF4)
68-
NetCDF.putatt(nc,name,Dict("units"=>unit,"long_name"=>long_name))
68+
# add missing_value although irrelevant for ncview compatibility
69+
NetCDF.putatt(nc,name,Dict("units"=>unit,"long_name"=>long_name,"missing_value"=>-999999f0))
6970
return nc
7071
end
7172

@@ -107,10 +108,12 @@ function output_nc!(i::Int,
107108
NetCDF.putvar(ncs.sst,"sst",sst,start=[1,1,iout],count=[-1,-1,1])
108109
end
109110
if ncs.q != nothing
110-
@views q = Float32.(Diag.Vorticity)
111+
@views q = Float32.(Diag.Vorticity.q[haloη+1:end-haloη,haloη+1:end-haloη])
111112
NetCDF.putvar(ncs.q,"q",q,start=[1,1,iout],count=[-1,-1,1])
112113
end
113114
if ncs.ζ != nothing
115+
@unpack dvdx,dudy = Diag.Vorticity
116+
@unpack f_q = S.grid
114117
@views ζ = Float32.((dvdx[2:end-1,2:end-1]-dudy[2+ep:end-1,2:end-1])./abs.(f_q))
115118
NetCDF.putvar(ncs.ζ,"relvort",ζ,start=[1,1,iout],count=[-1,-1,1])
116119
end

0 commit comments

Comments
 (0)