Skip to content

Commit

Permalink
output debug diagnostics when there is nan
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Jun 19, 2024
1 parent d67e19e commit d3807ff
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/callbacks/get_callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,29 @@ function get_diagnostics(parsed_args, atmos_model, Y, p, t_start, dt)
@info "$writer_str: $diags_outputs"
end

return diagnostics, writers
function WhenRSUTIsNaN(integrator)
nlevels = Spaces.nlevels(axes(integrator.u.c))
return any(isnan, parent(Fields.level(
Fields.array2field(
integrator.p.radiation.radiation_model.face_sw_flux_up,
axes(integrator.u.f),
),
nlevels + ClimaCore.half,
)))
end

short_names_debug = ["ta", "hus", "wa"]

debug_diagnostics = [
CAD.ScheduledDiagnostic(
variable = CAD.get_diagnostic_variable(short_name),
compute_schedule_func = WhenRSUTIsNaN,
output_schedule_func = WhenRSUTIsNaN,
output_writer = netcdf_writer,
) for short_name in short_names_debug
]

return [diagnostics..., debug_diagnostics...], writers
end

function get_callbacks(config, sim_info, atmos, params, Y, p, t_start)
Expand Down

0 comments on commit d3807ff

Please sign in to comment.