1
1
# When Julia 1.10+ is used interactively, stacktraces contain reduced type information to make them shorter.
2
- # On the other hand, the full type information is printed when julia is not run interactively.
2
+ # On the other hand, the full type information is printed when julia is not run interactively.
3
3
# Given that ClimaCore objects are heavily parametrized, non-abbreviated stacktraces are hard to read,
4
4
# so we force abbreviated stacktraces even in non-interactive runs.
5
5
# (See also Base.type_limited_string_from_context())
@@ -58,29 +58,7 @@ if !isempty(integrator.tstops)
58
58
end
59
59
CA. verify_callbacks (sol. t)
60
60
61
- if ClimaComms. iamroot (config. comms_ctx)
62
- @info " Plotting"
63
- make_plots (Val (Symbol (reference_job_id)), simulation. output_dir)
64
- @info " Plotting done"
65
-
66
- @info " Creating tarballs"
67
- Tar. create (
68
- f -> endswith (f, " .nc" ),
69
- simulation. output_dir,
70
- joinpath (simulation. output_dir, " nc_files.tar" ),
71
- )
72
- Tar. create (
73
- f -> endswith (f, r" hdf5|h5" ),
74
- simulation. output_dir,
75
- joinpath (simulation. output_dir, " hdf5_files.tar" ),
76
- )
77
-
78
- foreach (readdir (simulation. output_dir)) do f
79
- endswith (f, r" nc|hdf5|h5" ) && rm (joinpath (simulation. output_dir, f))
80
- end
81
- @info " Tarballs created"
82
- end
83
-
61
+ # Scaling check
84
62
if CA. is_distributed (config. comms_ctx)
85
63
nprocs = ClimaComms. nprocs (config. comms_ctx)
86
64
comms_ctx = config. comms_ctx
@@ -105,6 +83,7 @@ if CA.is_distributed(config.comms_ctx)
105
83
end
106
84
end
107
85
86
+ # Check if selected output has changed from the previous recorded output (bit-wise comparison)
108
87
include (joinpath (@__DIR__ , " .." , " .." , " regression_tests" , " mse_tables.jl" ))
109
88
if config. parsed_args[" regression_test" ]
110
89
# Test results against main branch
135
114
@info " Callback verification, n_expected_calls: $(CA. n_expected_calls (integrator)) "
136
115
@info " Callback verification, n_measured_calls: $(CA. n_measured_calls (integrator)) "
137
116
117
+ # Conservation checks
138
118
if config. parsed_args[" check_conservation" ]
119
+ @info " Checking conservation"
139
120
FT = Spaces. undertype (axes (sol. u[end ]. c. ρ))
140
121
141
122
# energy
@@ -154,8 +135,14 @@ if config.parsed_args["check_conservation"]
154
135
energy_surface_change = - p. net_energy_flux_sfc[][]
155
136
end
156
137
energy_radiation_input = - p. net_energy_flux_toa[][]
157
- @test (energy_atmos_change + energy_surface_change) / energy_total ≈
158
- energy_radiation_input / energy_total atol = 5 * sqrt (eps (FT))
138
+
139
+ energy_net =
140
+ abs (
141
+ energy_atmos_change + energy_surface_change -
142
+ energy_radiation_input,
143
+ ) / energy_total
144
+ @info " Net energy change: $energy_net "
145
+ @test (energy_net / energy_total) ≈ 0 atol = sqrt (eps (FT))
159
146
160
147
if p. atmos. moisture_model isa CA. DryModel
161
148
# density
@@ -169,12 +156,16 @@ if config.parsed_args["check_conservation"]
169
156
water_surface_change = CA. horizontal_integral_at_boundary (
170
157
sol. u[end ]. sfc. water .- sol. u[1 ]. sfc. water,
171
158
)
172
- @test (water_atmos_change + water_surface_change) / water_total ≈ 0 atol =
173
- 100 * sqrt (eps (FT))
159
+
160
+ water_net =
161
+ abs (water_atmos_change + water_surface_change) / water_total
162
+ @info " Net water change: $water_net "
163
+ @test water_net ≈ 0 atol = 100 * sqrt (eps (FT))
174
164
end
175
165
end
176
166
end
177
167
168
+ # Precipitation characteristic checks
178
169
if config. parsed_args[" check_precipitation" ]
179
170
# run some simple tests based on the output
180
171
FT = Spaces. undertype (axes (sol. u[end ]. c. ρ))
@@ -227,3 +218,27 @@ if config.parsed_args["check_precipitation"]
227
218
@test maximum (sol. prob. p. precomputed. ᶜcloud_fraction[colidx]) <= FT (1 )
228
219
end
229
220
end
221
+
222
+ # Visualize the solution
223
+ if ClimaComms. iamroot (config. comms_ctx)
224
+ @info " Plotting"
225
+ make_plots (Val (Symbol (reference_job_id)), simulation. output_dir)
226
+ @info " Plotting done"
227
+
228
+ @info " Creating tarballs"
229
+ Tar. create (
230
+ f -> endswith (f, " .nc" ),
231
+ simulation. output_dir,
232
+ joinpath (simulation. output_dir, " nc_files.tar" ),
233
+ )
234
+ Tar. create (
235
+ f -> endswith (f, r" hdf5|h5" ),
236
+ simulation. output_dir,
237
+ joinpath (simulation. output_dir, " hdf5_files.tar" ),
238
+ )
239
+
240
+ foreach (readdir (simulation. output_dir)) do f
241
+ endswith (f, r" nc|hdf5|h5" ) && rm (joinpath (simulation. output_dir, f))
242
+ end
243
+ @info " Tarballs created"
244
+ end
0 commit comments