Skip to content

Commit 75c7b08

Browse files
authored
Merge pull request #156 from milankl/scale
with NetCDF compression
2 parents 22ff45c + 759c200 commit 75c7b08

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/default_parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
output_vars::Array{String,1}=["u","v","η","sst"] # which variables to output? "du","dv","dη" also allowed
107107
output_dt::Real=24 # output time step [hours]
108108
outpath::String=pwd() # path to output folder
109+
compression_level::Int=3 # compression level
109110

110111
# INITIAL CONDITIONS
111112
initial_cond::String="rest" # "rest" or "ncfile" for restart from file

src/output.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ function NcFiles(feedback::Feedback,S::ModelSetup)
1919

2020
if S.parameters.output
2121

22-
@unpack output_vars = S.parameters
22+
@unpack output_vars,compression_level = S.parameters
23+
P = S.parameters
2324
@unpack x_u,x_v,x_T,x_q = S.grid
2425
@unpack y_u,y_v,y_T,y_q = S.grid
2526

2627
@unpack run_id,runpath = feedback
2728

28-
ncu = if "u" in output_vars nc_create(x_u,y_u,"u",runpath,"m/s","zonal velocity") else nothing end
29-
ncv = if "v" in output_vars nc_create(x_v,y_v,"v",runpath,"m/s","meridional velocity") else nothing end
30-
ncη = if "η" in output_vars nc_create(x_T,y_T,"eta",runpath,"m","sea surface height") else nothing end
31-
ncsst = if "sst" in output_vars nc_create(x_T,y_T,"sst",runpath,"1","sea surface temperature") else nothing end
32-
ncq = if "q" in output_vars nc_create(x_q,y_q,"q",runpath,"1/(ms)","potential vorticity") else nothing end
33-
ncζ = if "ζ" in output_vars nc_create(x_q,y_q,"relvort",runpath,"1","relative vorticity") else nothing end
34-
ncdu = if "du" in output_vars nc_create(x_u,y_u,"du",runpath,"m^2/s^2","zonal velocity tendency") else nothing end
35-
ncdv = if "dv" in output_vars nc_create(x_v,y_v,"dv",runpath,"m^2/s^2","meridional velocity tendency") else nothing end
36-
ncdη = if "" in output_vars nc_create(x_T,y_T,"deta",runpath,"m^2/s","sea surface height tendency") else nothing end
29+
ncu = if "u" in output_vars nc_create(x_u,y_u,"u",runpath,"m/s","zonal velocity",P) else nothing end
30+
ncv = if "v" in output_vars nc_create(x_v,y_v,"v",runpath,"m/s","meridional velocity",P) else nothing end
31+
ncη = if "η" in output_vars nc_create(x_T,y_T,"eta",runpath,"m","sea surface height",P) else nothing end
32+
ncsst = if "sst" in output_vars nc_create(x_T,y_T,"sst",runpath,"1","sea surface temperature",P) else nothing end
33+
ncq = if "q" in output_vars nc_create(x_q,y_q,"q",runpath,"1/(ms)","potential vorticity",P) else nothing end
34+
ncζ = if "ζ" in output_vars nc_create(x_q,y_q,"relvort",runpath,"1","relative vorticity",P) else nothing end
35+
ncdu = if "du" in output_vars nc_create(x_u,y_u,"du",runpath,"m^2/s^2","zonal velocity tendency",P) else nothing end
36+
ncdv = if "dv" in output_vars nc_create(x_v,y_v,"dv",runpath,"m^2/s^2","meridional velocity tendency",P) else nothing end
37+
ncdη = if "" in output_vars nc_create(x_T,y_T,"deta",runpath,"m^2/s","sea surface height tendency",P) else nothing end
3738

3839
for nc in (ncu,ncv,ncη,ncsst,ncq,ncζ,ncdu,ncdv,ncdη)
3940
if nc != nothing
@@ -55,13 +56,16 @@ function nc_create( x::Array{T,1},
5556
name::String,
5657
path::String,
5758
unit::String,
58-
long_name::String) where {T<:Real}
59+
long_name::String,
60+
P::Parameter) where {T<:Real}
61+
62+
@unpack compression_level = P
5963

6064
xdim = NcDim("x",length(x),values=x)
6165
ydim = NcDim("y",length(y),values=y)
6266
tdim = NcDim("t",0,unlimited=true)
6367

64-
var = NcVar(name,[xdim,ydim,tdim],t=Float32)
68+
var = NcVar(name,[xdim,ydim,tdim],t=Float32,compress=compression_level)
6569
tvar = NcVar("t",tdim,t=Int32)
6670

6771
nc = NetCDF.create(joinpath(path,name*".nc"),[var,tvar],mode=NC_NETCDF4)

0 commit comments

Comments
 (0)