Skip to content

Commit 7954db9

Browse files
authored
Merge pull request #3763 from CliMA/zs/hotfix
use lazy broadcasting instead of temp scalar in implicit solver
2 parents 00c2d32 + a89283a commit 7954db9

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

reproducibility_tests/ref_counter.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
231
1+
232
22

33
# **README**
44
#
@@ -20,6 +20,11 @@
2020

2121

2222
#=
23+
24+
232
25+
- Use lazy broadcasting instead of temp scalar in implicit solver for kappa_m vars,
26+
which fixes a bug that the temp scalar is updated before it is reused.
27+
2328
231
2429
- Add mass flux derivatives with respect to grid-mean u_3
2530

src/prognostic_equations/implicit/implicit_solver.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,9 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
621621
ᶠgⁱʲ = Fields.local_geometry_field(Y.f).gⁱʲ
622622
ᶠlg = Fields.local_geometry_field(Y.f)
623623

624-
ᶜkappa_m = p.ᶜtemp_scalar
625-
@. ᶜkappa_m =
626-
TD.gas_constant_air(thermo_params, ᶜts) / TD.cv_m(thermo_params, ᶜts)
624+
ᶜkappa_m = @. lazy(
625+
TD.gas_constant_air(thermo_params, ᶜts) / TD.cv_m(thermo_params, ᶜts),
626+
)
627627

628628
if use_derivative(topography_flag)
629629
@. ∂ᶜK_∂ᶜuₕ = DiagonalMatrixRow(
@@ -899,10 +899,10 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
899899
) # Need to wrap ᶠupwind_matrix in this for well-defined boundaries.
900900

901901
ᶠu³ʲ_data = ᶠu³ʲs.:(1).components.data.:1
902-
ᶜkappa_mʲ = p.ᶜtemp_scalar
903-
@. ᶜkappa_mʲ =
902+
ᶜkappa_mʲ = @. lazy(
904903
TD.gas_constant_air(thermo_params, ᶜtsʲs.:(1)) /
905-
TD.cv_m(thermo_params, ᶜtsʲs.:(1))
904+
TD.cv_m(thermo_params, ᶜtsʲs.:(1)),
905+
)
906906

907907
∂ᶜq_totʲ_err_∂ᶜq_totʲ =
908908
matrix[@name(c.sgsʲs.:(1).q_tot), @name(c.sgsʲs.:(1).q_tot)]
@@ -1132,11 +1132,6 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ, t)
11321132
ᶠupwind_matrix =
11331133
is_third_order ? ᶠupwind3_matrix : ᶠupwind1_matrix
11341134

1135-
ᶜkappa_mʲ = p.ᶜtemp_scalar
1136-
@. ᶜkappa_mʲ =
1137-
TD.gas_constant_air(thermo_params, ᶜtsʲs.:(1)) /
1138-
TD.cv_m(thermo_params, ᶜtsʲs.:(1))
1139-
11401135
# Jacobian contributions of updraft massflux to grid-mean
11411136

11421137
∂ᶜupdraft_mass_flux_∂ᶜscalar = ᶠbidiagonal_matrix_ct3

0 commit comments

Comments
 (0)