Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Merge #1871
Browse files Browse the repository at this point in the history
1871: Import prim-prog in AtmosModel r=jkozdon a=charleskawczynski

### Description

This PR `import`s `prognostic_to_primitive!, primitive_to_prognostic!` into the `Atmos` module, so that it's called with `AtmosModel`s. This was missed in #1830.



Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored Dec 17, 2020
2 parents 90bcf13 + d738654 commit 5034321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Atmos/Model/AtmosModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import ..BalanceLaws:
compute_gradient_argument!,
compute_gradient_flux!,
transform_post_gradient_laplacian!,
prognostic_to_primitive!,
primitive_to_prognostic!,
init_state_auxiliary!,
init_state_prognostic!,
update_auxiliary_state!,
Expand Down
11 changes: 10 additions & 1 deletion test/Atmos/prog_prim_conversion/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ using ClimateMachine.VariableTemplates
using ClimateMachine.Thermodynamics
using ClimateMachine.TemperatureProfiles
using ClimateMachine.Atmos: AtmosModel, DryModel, EquilMoist, NonEquilMoist
using ClimateMachine.Atmos: prognostic_to_primitive!, primitive_to_prognostic!
using ClimateMachine.BalanceLaws:
prognostic_to_primitive!, primitive_to_prognostic!
const BL = BalanceLaws

struct EarthParameterSet <: AbstractEarthParameterSet end
Expand Down Expand Up @@ -99,6 +100,7 @@ end
prog_0 = deepcopy(parent(prog))
prim_arr .= 0
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test all(parent(prog) .≈ prog_0)

Expand All @@ -107,6 +109,7 @@ end
prim_0 = deepcopy(parent(prim))
prog_arr .= 0
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test all(parent(prim) .≈ prim_0)
end
Expand All @@ -131,6 +134,7 @@ end
prog_0 = deepcopy(parent(prog))
prim_arr .= 0
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test all(parent(prog)[1:4] .≈ prog_0[1:4])
@test isapprox(parent(prog)[5], prog_0[5]; atol = atol_energy)
Expand All @@ -143,6 +147,7 @@ end
prim_0 = deepcopy(parent(prim))
prog_arr .= 0
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test all(parent(prim)[1:4] .≈ prim_0[1:4])
# @test all(parent(prim)[5] .≈ prim_0[5]) # fails
Expand Down Expand Up @@ -171,6 +176,7 @@ end
prog_0 = deepcopy(parent(prog))
prim_arr .= 0
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test all(parent(prog) .≈ prog_0)

Expand All @@ -179,6 +185,7 @@ end
prim_0 = deepcopy(parent(prim))
prog_arr .= 0
primitive_to_prognostic!(bl, bl.moisture, prog, prim, e_pot)
@test !all(parent(prim) .≈ parent(prog)) # ensure not calling fallback
prognostic_to_primitive!(bl, bl.moisture, prim, prog, e_int)
@test all(parent(prim) .≈ prim_0)
end
Expand Down Expand Up @@ -210,6 +217,7 @@ end
prog_0 = deepcopy(parent(prog))
prim_arr .= 0
BL.prognostic_to_primitive!(bl, prim_arr, prog_arr, aux_arr)
@test !all(prog_arr .≈ prim_arr) # ensure not calling fallback
BL.primitive_to_prognostic!(bl, prog_arr, prim_arr, aux_arr)
@test all(parent(prog) .≈ prog_0)

Expand All @@ -218,6 +226,7 @@ end
prim_0 = deepcopy(parent(prim))
prog_arr .= 0
BL.primitive_to_prognostic!(bl, prog_arr, prim_arr, aux_arr)
@test !all(prog_arr .≈ prim_arr) # ensure not calling fallback
BL.prognostic_to_primitive!(bl, prim_arr, prog_arr, aux_arr)
@test all(parent(prim) .≈ prim_0)
end
Expand Down

0 comments on commit 5034321

Please sign in to comment.