Skip to content

Commit 923eb74

Browse files
Add cloud diag per stage option
1 parent 1f63b3b commit 923eb74

File tree

10 files changed

+82
-5
lines changed

10 files changed

+82
-5
lines changed

.buildkite/gpu_pipeline/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ steps:
110110
- mkdir -p gpu_aquaplanet_dyamond_ss_1process
111111
- >
112112
srun --cpu-bind=threads --cpus-per-task=4
113+
nsys profile --trace=nvtx,mpi,cuda,osrt --output=gpu_aquaplanet_dyamond_ss_1process/output_active/report
113114
julia --threads=3 --color=yes --project=examples examples/hybrid/driver.jl
114115
--config_file ${GPU_CONFIG_PATH}gpu_aquaplanet_dyamond_ss_1process.yml
115116
artifact_paths: "gpu_aquaplanet_dyamond_ss_1process/output_active/*"

.buildkite/pipeline.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,16 @@ steps:
699699
slurm_gpus: 1
700700
slurm_mem: 16G
701701

702+
- label: "GPU: GPU moist Held-Suarez cloud diagnostics per stage"
703+
command:
704+
- >
705+
julia --color=yes --project=examples examples/hybrid/driver.jl
706+
--config_file $GPU_CONFIG_PATH/central_cloud_diag_gpu_hs_rhoe_equil_55km_nz63_0M.yml
707+
artifact_paths: "central_cloud_diag_gpu_hs_rhoe_equil_55km_nz63_0M/output_active/*"
708+
agents:
709+
slurm_gpus: 1
710+
slurm_mem: 16G
711+
702712
- label: ":umbrella: GPU: gpu_aquaplanet_dyamond"
703713
command:
704714
- mkdir -p gpu_aquaplanet_dyamond

config/default_configs/default_config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,7 @@ restart_file:
280280
prescribed_aerosols:
281281
help: "Which aerosols to add. List of keys from the data file (e.g., CB1, CB2)."
282282
value: []
283+
# TODO: remove once https://github.com/CliMA/ClimaAtmos.jl/issues/2873 is closed
284+
call_cloud_diagnostics_per_stage:
285+
help: "A temporary Bool for calling cloud diagnostics every stage"
286+
value: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dt_save_state_to_disk: "Inf"
2+
dt_save_to_sol: "Inf"
3+
output_default_diagnostics: false
4+
dt: "150secs"
5+
t_end: "2days"
6+
h_elem: 16
7+
z_elem: 63
8+
dz_bottom: 30.0
9+
dz_top: 3000.0
10+
z_max: 55000.0
11+
vert_diff: "true"
12+
moist: "equil"
13+
precip_model: "0M"
14+
rayleigh_sponge: true
15+
forcing: "held_suarez"
16+
call_cloud_diagnostics_per_stage: true
17+
job_id: "central_cloud_diag_gpu_hs_rhoe_equil_55km_nz63_0M"
18+
toml: [toml/longrun_hs_rhoe_equil_55km_nz63_0M.toml]

src/cache/cloud_fraction.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ NVTX.@annotate function set_cloud_fraction!(
3333
(; ᶜts, ᶜmixing_length, ᶜcloud_fraction) = p.precomputed
3434
thermo_params = CAP.thermodynamics_params(params)
3535
if isnothing(turbconv_model)
36+
if p.atmos.call_cloud_diagnostics_per_stage isa
37+
CallCloudDiagnosticsPerStage
38+
(; ᶜgradᵥ_θ_virt, ᶜgradᵥ_q_tot, ᶜgradᵥ_θ_liq_ice) = p.precomputed
39+
thermo_params = CAP.thermodynamics_params(p.params)
40+
@. ᶜgradᵥ_θ_virt =
41+
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts)))
42+
@. ᶜgradᵥ_q_tot =
43+
ᶜgradᵥ(ᶠinterp(TD.total_specific_humidity(thermo_params, ᶜts)))
44+
@. ᶜgradᵥ_θ_liq_ice =
45+
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts)))
46+
end
3647
compute_gm_mixing_length!(ᶜmixing_length, Y, p)
3748
end
3849
@. ᶜcloud_fraction = ifelse(TD.has_condensate(thermo_params, ᶜts), 1, 0)
@@ -50,6 +61,17 @@ NVTX.@annotate function set_cloud_fraction!(
5061
(; ᶜts, ᶜp, ᶜmixing_length, ᶜcloud_fraction) = p.precomputed
5162
(; turbconv_model) = p.atmos
5263
if isnothing(turbconv_model)
64+
if p.atmos.call_cloud_diagnostics_per_stage isa
65+
CallCloudDiagnosticsPerStage
66+
(; ᶜgradᵥ_θ_virt, ᶜgradᵥ_q_tot, ᶜgradᵥ_θ_liq_ice) = p.precomputed
67+
thermo_params = CAP.thermodynamics_params(p.params)
68+
@. ᶜgradᵥ_θ_virt =
69+
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts)))
70+
@. ᶜgradᵥ_q_tot =
71+
ᶜgradᵥ(ᶠinterp(TD.total_specific_humidity(thermo_params, ᶜts)))
72+
@. ᶜgradᵥ_θ_liq_ice =
73+
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts)))
74+
end
5375
compute_gm_mixing_length!(ᶜmixing_length, Y, p)
5476
end
5577

src/cache/precomputed_quantities.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,9 @@ function instead of recomputing the value yourself. Otherwise, it will be
443443
difficult to ensure that the duplicated computations are consistent.
444444
"""
445445
NVTX.@annotate function set_precomputed_quantities!(Y, p, t)
446-
(; moisture_model, turbconv_model, vert_diff, precip_model) = p.atmos
446+
(; moisture_model, turbconv_model, vert_diff, precip_model, cloud_model) =
447+
p.atmos
448+
(; call_cloud_diagnostics_per_stage) = p.atmos
447449
thermo_params = CAP.thermodynamics_params(p.params)
448450
n = n_mass_flux_subdomains(turbconv_model)
449451
thermo_args = (thermo_params, moisture_model)
@@ -618,7 +620,9 @@ NVTX.@annotate function set_precomputed_quantities!(Y, p, t)
618620
end
619621

620622
# TODO
621-
#set_cloud_fraction!(Y, p, moisture_model)
623+
if call_cloud_diagnostics_per_stage isa CallCloudDiagnosticsPerStage
624+
set_cloud_fraction!(Y, p, moisture_model, cloud_model)
625+
end
622626

623627
return nothing
624628
end

src/callbacks/get_callbacks.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,11 @@ function get_callbacks(config, sim_info, atmos, params, Y, p, t_start)
272272
)
273273
end
274274

275-
dt_cf = FT(time_to_seconds(parsed_args["dt_cloud_fraction"]))
276-
callbacks =
277-
(callbacks..., call_every_dt(cloud_fraction_model_callback!, dt_cf))
275+
if !parsed_args["call_cloud_diagnostics_per_stage"]
276+
dt_cf = FT(time_to_seconds(parsed_args["dt_cloud_fraction"]))
277+
callbacks =
278+
(callbacks..., call_every_dt(cloud_fraction_model_callback!, dt_cf))
279+
end
278280

279281
if atmos.radiation_mode isa RRTMGPI.AbstractRRTMGPMode
280282
# TODO: better if-else criteria?

src/solver/model_getters.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,17 @@ function get_forcing_type(parsed_args)
289289
end
290290
end
291291

292+
struct CallCloudDiagnosticsPerStage end
293+
function get_call_cloud_diagnostics_per_stage(parsed_args)
294+
ccdps = parsed_args["call_cloud_diagnostics_per_stage"]
295+
@assert ccdps in (nothing, true, false)
296+
return if ccdps in (nothing, false)
297+
nothing
298+
elseif ccdps == true
299+
CallCloudDiagnosticsPerStage()
300+
end
301+
end
302+
292303
function get_subsidence_model(parsed_args, radiation_mode, FT)
293304
subsidence = parsed_args["subsidence"]
294305
subsidence == nothing && return nothing

src/solver/type_getters.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function get_atmos(config::AtmosConfig, params)
2121
cloud_model = get_cloud_model(parsed_args)
2222
radiation_mode = get_radiation_mode(parsed_args, FT)
2323
forcing_type = get_forcing_type(parsed_args)
24+
call_cloud_diagnostics_per_stage =
25+
get_call_cloud_diagnostics_per_stage(parsed_args)
2426

2527
diffuse_momentum = !(forcing_type isa HeldSuarezForcing)
2628

@@ -70,6 +72,7 @@ function get_atmos(config::AtmosConfig, params)
7072
precip_model,
7173
cloud_model,
7274
forcing_type,
75+
call_cloud_diagnostics_per_stage,
7376
turbconv_model = get_turbconv_model(FT, parsed_args, turbconv_params),
7477
non_orographic_gravity_wave = get_non_orographic_gravity_wave_model(
7578
parsed_args,

src/solver/types.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ Base.@kwdef struct AtmosModel{
327327
MM,
328328
PM,
329329
CM,
330+
CCDPS,
330331
F,
331332
S,
332333
RM,
@@ -359,6 +360,7 @@ Base.@kwdef struct AtmosModel{
359360
moisture_model::MM = nothing
360361
precip_model::PM = nothing
361362
cloud_model::CM = nothing
363+
call_cloud_diagnostics_per_stage::CCDPS = nothing
362364
forcing_type::F = nothing
363365
subsidence::S = nothing
364366
radiation_mode::RM = nothing

0 commit comments

Comments
 (0)