Skip to content

Commit

Permalink
Merge pull request #138 from milankl/julia14
Browse files Browse the repository at this point in the history
Julia14
  • Loading branch information
Milan K authored Apr 28, 2020
2 parents be8457c + fc6e59b commit 45bda15
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 79 deletions.
3 changes: 1 addition & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
environment:
matrix:
- julia_version: 1
- julia_version: 1.3
- julia_version: 1.4
- julia_version: nightly

platform:
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ os:
- linux
- osx
julia:
- 1.0
- 1.3
- 1.4
- nightly
notifications:
email: false
Expand Down
57 changes: 26 additions & 31 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BinDeps]]
deps = ["Libdl", "Pkg", "SHA", "URIParser", "Unicode"]
git-tree-sha1 = "66158ad56b4bf6cc8413b37d0b7bc52402682764"
git-tree-sha1 = "46cf2c1668ad07aba5a9d331bdeea994a1f13856"
uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
version = "1.0.0"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.2.0"
version = "1.0.1"

[[Conda]]
deps = ["JSON", "VersionParsing"]
Expand All @@ -37,9 +31,10 @@ version = "0.2.0"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
[[DiskArrays]]
git-tree-sha1 = "d89f6d225ea9e107ab1903e8b7881f1b1bd06148"
uuid = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
version = "0.2.3"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
Expand All @@ -57,9 +52,9 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[Interpolations]]
deps = ["AxisAlgorithms", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
git-tree-sha1 = "c7579b2617b513d8e6eb9f4b91837eefe7080af8"
git-tree-sha1 = "3af735234d9b1ff9ff1af89875735cd9549c0c5f"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.12.8"
version = "0.12.9"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
Expand All @@ -68,6 +63,7 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
Expand All @@ -88,15 +84,15 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[NetCDF]]
deps = ["BinDeps", "CondaBinDeps", "Formatting", "Libdl"]
git-tree-sha1 = "fce0c7962fb14b8cf2f33ea77885f3b7c7e1485e"
deps = ["BinDeps", "CondaBinDeps", "DiskArrays", "Formatting", "Libdl"]
git-tree-sha1 = "0c6a63d16e9261bf2fa4eecbab575ae7e7fef11c"
uuid = "30363a11-5582-574a-97bb-aa9a979735b9"
version = "0.8.0"
version = "0.10.2"

[[OffsetArrays]]
git-tree-sha1 = "707e34562700b81e8aa13548eb6b23b18112e49b"
git-tree-sha1 = "930db8ef90483570107f2396b1ffc6680f08e8b7"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.0.2"
version = "1.0.4"

[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
Expand All @@ -112,12 +108,12 @@ version = "0.12.0"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "d112c19ccca00924d5d3a38b11ae2b4b268dda39"
git-tree-sha1 = "f8f5d2d4b4b07342e5811d2b6428e45524e241df"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.11"
version = "1.0.2"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
Expand All @@ -133,10 +129,9 @@ deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Ratios]]
deps = ["Compat"]
git-tree-sha1 = "cdbbe0f350581296f3a2e3e7a91b214121934407"
git-tree-sha1 = "37d210f612d70f3f7d57d488cb3b6eff56ad4e41"
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
version = "0.3.1"
version = "0.4.0"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Expand All @@ -157,9 +152,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "5a3bcb6233adabde68ebc97be66e95dcb787424c"
git-tree-sha1 = "4118cba3529e99af61aea9a83f7bfd3cff5ffb28"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.12.1"
version = "0.12.2"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand All @@ -170,10 +165,10 @@ deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[URIParser]]
deps = ["Test", "Unicode"]
git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69"
deps = ["Unicode"]
git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d"
uuid = "30578b45-9adc-5946-b283-645ec420af67"
version = "0.4.0"
version = "0.4.1"

[[UUIDs]]
deps = ["Random", "SHA"]
Expand All @@ -189,6 +184,6 @@ version = "1.2.0"

[[WoodburyMatrices]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "bbb9f7fd6fbdd9582e77c0b698312c543de5eb71"
git-tree-sha1 = "28ffe06d28b1ba8fdb2f36ec7bb079fac81bac0d"
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
version = "0.5.0"
version = "0.5.2"
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ShallowWaters"
uuid = "56019723-2d87-4a65-81ff-59d5d8913e3c"
authors = ["Milan Kloewer"]
version = "0.2.0"
version = "0.3.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -11,10 +11,10 @@ Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[compat]
NetCDF = "^0.8"
Interpolations = "^0.12"
NetCDF = "^0.10"
Parameters = "^0.12"
julia = "1"
Interpolations = "^0.12"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ ShallowWaters is fully-explicit with an energy and enstrophy conserving advectio

Please feel free to raise an [issue](https://github.com/milankl/ShallowWaters.jl/issues) if you discover bugs or have an idea how to improve ShallowWaters.

Requires: Julia 1.2

### How to use

`RunModel` initialises the model, preallocates memory and starts the time integration. You find the options and default parameters in `src/DefaultParameters.jl` (or by typing `?Parameter`).
`RunModel` initialises the model, preallocates memory and starts the time integration. You find the options and default parameters in `src/DefaultParameters.jl` (or by typing `?Parameter`).
```julia
help?> Parameter
search: Parameter

Creates a Parameter struct with following options and default values

T::DataType=Float32 # number format

Tprog::DataType=T # number format for prognostic variables
Tcomm::DataType=Tprog # number format for ghost-point copies

# DOMAIN RESOLUTION AND RATIO
nx::Int=100 # number of grid cells in x-direction
Lx::Real=2000e3 # length of the domain in x-direction [m]
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultParameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Creates a Parameter struct with following options and default values
# SURFACE FORCING
surface_forcing::Bool=false # yes?
ωFη::Real=1.0 # (annual) frequency [1/year]
ωFη::Real=1.0 # frequency [1/year] for surfance forcing
A::Real=3e-5 # Amplitude [m/s]
ϕk::Real=ϕ # Central latitude of Kelvin wave pumping
wk::Real=10e3 # width [m] in y of Gaussian used for surface forcing
Expand Down
16 changes: 4 additions & 12 deletions src/InitialConditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ function initial_conditions(::Type{T},S::ModelSetup) where {T<:AbstractFloat}
end

u = ncu.vars["u"][:,:,init_starti]
NetCDF.close(ncu)
# NetCDF.close(ncu)

ncv = NetCDF.open(joinpath(inirunpath,"v.nc"))
v = ncv.vars["v"][:,:,init_starti]
NetCDF.close(ncv)
# NetCDF.close(ncv)

ncη = NetCDF.open(joinpath(inirunpath,"eta.nc"))
η = ncη.vars["eta"][:,:,init_starti]
NetCDF.close(ncη)
# NetCDF.close(ncη)

# remove singleton time dimension
u = reshape(u,size(u)[1:2])
Expand Down Expand Up @@ -147,7 +147,7 @@ function initial_conditions(::Type{T},S::ModelSetup) where {T<:AbstractFloat}
if initial_cond == "ncfile" && sst_initial == "restart"
ncsst = NetCDF.open(joinpath(inirunpath,"sst.nc"))
sst = ncsst.vars["sst"][:,:,init_starti]
NetCDF.close(ncsst)
# NetCDF.close(ncsst)

sst = reshape(sst,size(sst)[1:2])
end
Expand All @@ -164,11 +164,3 @@ function initial_conditions(::Type{T},S::ModelSetup) where {T<:AbstractFloat}

return PrognosticVars{T}(u,v,η,sst)
end

# if injection_region == "south"
# sst_inj_region = sst_south
# elseif injection_region == "west"
# sst_inj_region = sst_west
# elseif injection_region == "rect"
# sst_inj_region = sst_rect
# end
41 changes: 16 additions & 25 deletions src/Output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,54 +88,45 @@ function output_nc!(i::Int,
@unpack f_q,ep,dtint = S.grid

# CUT OFF HALOS
# @views u = Prog.u[halo+1:end-halo,halo+1:end-halo]
# @views v = Prog.v[halo+1:end-halo,halo+1:end-halo]
# @views η = Prog.η[haloη+1:end-haloη,haloη+1:end-haloη]
# @views sst = Prog.sst[halosstx+1:end-halosstx,halossty+1:end-halossty]
# @views ζ = (dvdx[2:end-1,2:end-1]-dudy[2+ep:end-1,2:end-1])./abs.(f_q)
# @views du = Diag.Tendencies.du[halo+1:end-halo,halo+1:end-halo]
# @views dv = Diag.Tendencies.dv[halo+1:end-halo,halo+1:end-halo]
# @views dη = Diag.Tendencies.dη[haloη+1:end-haloη,haloη+1:end-haloη]

# As output is before copyto!(u,u0), take u0,v0,η0
@views u = Float32.(Diag.RungeKutta.u0[halo+1:end-halo,halo+1:end-halo])
@views v = Float32.(Diag.RungeKutta.v0[halo+1:end-halo,halo+1:end-halo])
@views η = Float32.(Diag.RungeKutta.η0[haloη+1:end-haloη,haloη+1:end-haloη])

@views sst = Float32.(Prog.sst[halosstx+1:end-halosstx,halossty+1:end-halossty])
@views ζ = Float32.((dvdx[2:end-1,2:end-1]-dudy[2+ep:end-1,2:end-1])./abs.(f_q))

# Tendencies calculate from the last time step, du = u_n+1-u_n etc
@views du = u-Float32.(Prog.u[halo+1:end-halo,halo+1:end-halo])
@views dv = v-Float32.(Prog.v[halo+1:end-halo,halo+1:end-halo])
@views= η-Float32.(Prog.η[haloη+1:end-haloη,haloη+1:end-haloη])

# WRITING THE VARIABLES
if ncs.u != nothing
@views u = Float32.(Diag.RungeKutta.u0[halo+1:end-halo,halo+1:end-halo])
NetCDF.putvar(ncs.u,"u",u,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.v != nothing
@views v = Float32.(Diag.RungeKutta.v0[halo+1:end-halo,halo+1:end-halo])
NetCDF.putvar(ncs.v,"v",v,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.η != nothing
@views η = Float32.(Diag.RungeKutta.η0[haloη+1:end-haloη,haloη+1:end-haloη])
NetCDF.putvar(ncs.η,"eta",η,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.sst != nothing
@views sst = Float32.(Prog.sst[halosstx+1:end-halosstx,halossty+1:end-halossty])
NetCDF.putvar(ncs.sst,"sst",sst,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.q != nothing
NetCDF.putvar(ncs.q,"q",q,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.ζ != nothing
@views ζ = Float32.((dvdx[2:end-1,2:end-1]-dudy[2+ep:end-1,2:end-1])./abs.(f_q))
NetCDF.putvar(ncs.ζ,"relvort",ζ,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.du != nothing
@views u = Float32.(Diag.RungeKutta.u0[halo+1:end-halo,halo+1:end-halo])
@views du = u-Float32.(Prog.u[halo+1:end-halo,halo+1:end-halo])
NetCDF.putvar(ncs.du,"du",du,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.dv != nothing
@views v = Float32.(Diag.RungeKutta.v0[halo+1:end-halo,halo+1:end-halo])
@views dv = v-Float32.(Prog.v[halo+1:end-halo,halo+1:end-halo])
NetCDF.putvar(ncs.dv,"dv",dv,start=[1,1,iout],count=[-1,-1,1])
end
if ncs.!= nothing
@views η = Float32.(Diag.RungeKutta.η0[haloη+1:end-haloη,haloη+1:end-haloη])
@views= η-Float32.(Prog.η[haloη+1:end-haloη,haloη+1:end-haloη])
NetCDF.putvar(ncs.dη,"deta",dη,start=[1,1,iout],count=[-1,-1,1])
end

Expand All @@ -156,11 +147,11 @@ function output_close!(ncs::NcFiles,feedback::Feedback,S::ModelSetup)
@unpack output = S.parameters

if output
for nc in (ncs.u,ncs.v,ncs.η,ncs.sst,ncs.q,ncs.ζ,ncs.du,ncs.dv,ncs.dη)
if nc != nothing
NetCDF.close(nc)
end
end
# for nc in (ncs.u,ncs.v,ncs.η,ncs.sst,ncs.q,ncs.ζ,ncs.du,ncs.dv,ncs.dη)
# if nc != nothing
# NetCDF.close(nc)
# end
# end
println("All data stored.")
write(feedback.progress_txt,"All data stored.")
close(feedback.progress_txt)
Expand Down

0 comments on commit 45bda15

Please sign in to comment.