Skip to content

Commit e671d7a

Browse files
authored
Merge pull request #158 from milankl/scale
scale_sst_inv removed to avoid subnormal
2 parents b2f6f58 + 113b93e commit e671d7a

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

src/constants.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ struct Constants{T<:AbstractFloat,Tprog<:AbstractFloat}
5656
scale::T # multiplicative constant for low-precision arithmetics
5757
scale_inv::T # and its inverse
5858
scale_sst::T # scale for sst
59-
scale_sst_inv::T # and its inverse
6059
end
6160

6261
"""Generator function for the mutable struct Constants."""
@@ -118,12 +117,10 @@ function Constants{T,Tprog}(P::Parameter,G::Grid) where {T<:AbstractFloat,Tprog<
118117
scale = convert(T,P.scale)
119118
scale_inv = convert(T,1/P.scale)
120119
scale_sst = convert(T,P.scale_sst)
121-
scale_sst_inv = convert(T,1/P.scale_sst)
122120

123121
return Constants{T,Tprog}( RKaΔt,RKbΔt,Δt_Δs,Δt_Δ,Δt_Δ_half,
124122
SSPRK3c,one_minus_α,
125123
g,cD,rD,γ,cSmag,νB,τSST,jSST,
126124
ωFη,ωFx,ωFy,
127-
scale,scale_inv,
128-
scale_sst,scale_sst_inv)
125+
scale,scale_inv,scale_sst)
129126
end

src/ghost_points.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ function remove_halo( u::Array{T,2},
4040
S::ModelSetup) where {T<:AbstractFloat}
4141

4242
@unpack halo,haloη,halosstx,halossty = S.grid
43-
@unpack scale_inv,scale_sst_inv = S.constants
43+
@unpack scale_inv,scale_sst = S.constants
4444

4545
# undo scaling as well
46-
ucut = scale_inv*u[halo+1:end-halo,halo+1:end-halo]
47-
vcut = scale_inv*v[halo+1:end-halo,halo+1:end-halo]
48-
ηcut = η[haloη+1:end-haloη,haloη+1:end-haloη]
49-
sstcut = scale_sst_inv*sst[halosstx+1:end-halosstx,halossty+1:end-halossty]
46+
@views ucut = scale_inv*u[halo+1:end-halo,halo+1:end-halo]
47+
@views vcut = scale_inv*v[halo+1:end-halo,halo+1:end-halo]
48+
@views ηcut = η[haloη+1:end-haloη,haloη+1:end-haloη]
49+
@views sstcut = sst[halosstx+1:end-halosstx,halossty+1:end-halossty]/scale_sst
5050

5151
return ucut,vcut,ηcut,sstcut
5252
end

src/output.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function output_nc!(i::Int,
9090

9191
@unpack halo,haloη,halosstx,halossty = S.grid
9292
@unpack f_q,ep,dtint = S.grid
93-
@unpack scale,scale_inv,scale_sst_inv = S.constants
93+
@unpack scale,scale_inv,scale_sst = S.constants
9494

9595
# CUT OFF HALOS
9696
# As output is before copyto!(u,u0), take u0,v0,η0
@@ -109,7 +109,7 @@ function output_nc!(i::Int,
109109
NetCDF.putvar(ncs.η,"eta",η,start=[1,1,iout],count=[-1,-1,1])
110110
end
111111
if ncs.sst != nothing
112-
@views sst = Float32.(scale_sst_inv*Prog.sst[halosstx+1:end-halosstx,halossty+1:end-halossty])
112+
@views sst = Float32.(Prog.sst[halosstx+1:end-halosstx,halossty+1:end-halossty]/scale_sst)
113113
NetCDF.putvar(ncs.sst,"sst",sst,start=[1,1,iout],count=[-1,-1,1])
114114
end
115115
if ncs.q != nothing

0 commit comments

Comments
 (0)