Skip to content

Commit dd5a4d8

Browse files
author
Milan K
authored
Merge pull request #114 from milankl/mixprec
Mixprec
2 parents c5c1e79 + 278b478 commit dd5a4d8

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/Preallocate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ struct DiagnosticVars{T,Tprog}
447447
Laplace::LaplaceVars{T}
448448
Smagorinsky::SmagorinskyVars{T}
449449
SemiLagrange::SemiLagrangeVars{T}
450-
PrognosticRHS::PrognosticVars{T} # low precision version
450+
PrognosticVarsRHS::PrognosticVars{T} # low precision version
451451
end
452452

453453
"""Preallocate the diagnostic variables and return them as matrices in structs."""

src/TestJuls.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
include("Juls.jl")
22
using .Juls
3-
RunJuls()
3+
using BFloat16s
4+
5+
Base.round(x::BFloat16, r::RoundingMode{:Up}) = BFloat16(ceil(Float32(x)))
6+
Base.round(x::BFloat16, r::RoundingMode{:Down}) = BFloat16(floor(Float32(x)))
7+
Base.round(x::BFloat16, r::RoundingMode{:Nearest}) = BFloat16(round(Float32(x)))
8+
9+
a = BFloat16(1.2)
10+
floor(a)
11+
12+
#RunJuls(BFloat16,Tprog=Float32)
13+
#RunJuls(BFloat16,Tprog=Float32,output=true,nx=200,Ndays=100,initial_cond="ncfile",sst_initial="rect",sst_rect_coords=[0.,0.5,0.,1.0],outpath="/local/home/kloewer/julsdata/mixedprec")

src/TimeIntegration.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ function time_integration( Prog::PrognosticVars{Tprog},
4747
end
4848

4949
# type conversion for mixed precision
50-
u1rhs = convert(Diag.PrognosticRHS.u,u1)
51-
v1rhs = convert(Diag.PrognosticRHS.v,v1)
52-
η1rhs = convert(Diag.PrognosticRHS.η,η1)
50+
u1rhs = convert(Diag.PrognosticVarsRHS.u,u1)
51+
v1rhs = convert(Diag.PrognosticVarsRHS.v,v1)
52+
η1rhs = convert(Diag.PrognosticVarsRHS.η,η1)
5353

5454
rhs!(u1rhs,v1rhs,η1rhs,Diag,S,t)
55-
55+
5656
if rki < RKo
5757
caxb!(u1,u,RKbΔt[rki],du) #u1 .= u .+ RKb[rki]*Δt*du
5858
caxb!(v1,v,RKbΔt[rki],dv) #v1 .= v .+ RKb[rki]*Δt*dv
@@ -68,9 +68,9 @@ function time_integration( Prog::PrognosticVars{Tprog},
6868
ghost_points!(u0,v0,η0,S)
6969

7070
# type conversion for mixed precision
71-
u0rhs = convert(Diag.PrognosticRHS.u,u0)
72-
v0rhs = convert(Diag.PrognosticRHS.v,v0)
73-
η0rhs = convert(Diag.PrognosticRHS.η,η0)
71+
u0rhs = convert(Diag.PrognosticVarsRHS.u,u0)
72+
v0rhs = convert(Diag.PrognosticVarsRHS.v,v0)
73+
η0rhs = convert(Diag.PrognosticVarsRHS.η,η0)
7474

7575
# ADVECTION and CORIOLIS TERMS
7676
# although included in the tendency of every RK substep,

src/TracerAdvection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function tracer!( i::Integer,
2222
@unpack ssti = Diag.SemiLagrange
2323

2424
# convert to type T for mixed precision
25-
sstrhs = convert(Diag.PrognosticRHS.sst,sst)
25+
sstrhs = convert(Diag.PrognosticVarsRHS.sst,sst)
2626

2727
departure!(u,v,Diag,S)
2828
adv_sst!(sstrhs,Diag,S)

0 commit comments

Comments
 (0)