Skip to content

Commit e00d275

Browse files
Merge pull request #3775 from CliMA/rc/nogw
Support for intermittent calls to update non-orographic gravity wave tendencies (Replacement for #3761)
2 parents 80826e5 + 2ac7c40 commit e00d275

File tree

15 files changed

+157
-35
lines changed

15 files changed

+157
-35
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ main
77
### Add support for reanalysis-driven single column model with time-varying forcing
88
PR [#3758](https://github.com/CliMA/ClimaAtmos.jl/pull/3758) adds support for driving single-column model (SCM) simulations with time-varying ERA5 reanalysis data. This extends the existing GCM-driven SCM interface to allow site-specific simulations that resolve the diurnal cycle and are suited for calibration against observations. Users can now run reanalysis-driven cases globally using only a date and lat/lon, thanks to integrated data handling via ClimaArtifacts.jl. See the updated “Single Column Model” docs page for details on setup, variable requirements, and how to prepare ERA5 input files.
99

10+
### Non-orographic gravity wave tendency as a callback
11+
12+
PR[#3761](https://github.com/CliMA/ClimaAtmos.jl/pull/3761) introduces support for intermittent calls to update the computation of non-orographic gravity wave tendencies. This PR closes issue[#3434](https://github.com/CliMA/ClimaAtmos.jl/issues/3434).
13+
1014
### Remove `dt_save_to_sol`
1115

1216
The option to save the solution to the integrator object (`dt_save_to_sol`) was

config/default_configs/default_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ orographic_gravity_wave:
220220
non_orographic_gravity_wave:
221221
help: "Apply parameterization for convective gravity wave forcing on horizontal mean flow [`false` (default), `true`]"
222222
value: false
223+
dt_nogw:
224+
help: "Time between calling non-orographic gravity wave update"
225+
value: "1800secs"
223226
nh_poly:
224227
help: "Horizontal polynomial degree. Note: The number of quadrature points in 1D within each horizontal element is then Nq = <--nh_poly> + 1"
225228
value: 3

config/model_configs/single_column_nonorographic_gravity_wave.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ hyperdiff: false
66
dt: "400secs"
77
disable_surface_flux_tendency: true
88
non_orographic_gravity_wave: true
9+
dt_nogw: "400secs"
10+
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
t_end: "1500secs"
2-
dt: "400secs"
1+
t_end: "48hours"
2+
dt: "450secs"
33
disable_surface_flux_tendency: true
44
non_orographic_gravity_wave: true
5+
dt_nogw: "450secs"
6+
diagnostics:
7+
- short_name: [ta, thetaa, ua, va, wa, zg, utendnogw, vtendnogw]
8+
period: 1hours

docs/src/diagnostics.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,6 @@ were computed differently for `EquilMoistModel` and `NonEquilMoistModel`.
209209
In `ClimaAtmos`, we define some helper functions to produce error messages, so
210210
the above code can be written as
211211
```julia
212-
compute_relative_humidity!(out, state, cache, time) =
213-
compute_relative_humidity!(out, state, cache, time, cache.atmos.moisture_model)
214-
compute_relative_humidity!(_, _, _, _, model::T) where {T} =
215-
error_diagnostic_variable("relative_humidity", model)
216-
217212
function compute_relative_humidity!(
218213
out,
219214
state,
@@ -228,6 +223,11 @@ function compute_relative_humidity!(
228223
out .= TD.relative_humidity.(thermo_params, cache.ᶜts)
229224
end
230225
end
226+
227+
compute_relative_humidity!(out, state, cache, time) =
228+
compute_relative_humidity!(out, state, cache, time, cache.atmos.moisture_model)
229+
compute_relative_humidity!(_, _, _, _, model) =
230+
error_diagnostic_variable("relative_humidity", model)
231231
```
232232

233233
### The `ClimaAtmos` `DiagnosticVariable`s

docs/src/gravity_wave.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ Similar to the base flux calculation but for the 3D fields, we computed ``N`` an
165165
^f N[k]^2 = \frac{g}{^f T[k]} * ( ^f \overline{\frac{dT}{dz}}[k] + \frac{g}{cp}),
166166
```
167167
```math
168-
^f V_{\tau}[k] = \max(\epsilon_0, - V[k] \cdot \frac{\tau}{|\tau|}).
168+
^f V_{\tau}[k] = \max(\epsilon_0, - V[k] \cdot \frac{\tau}{|\tau|}),
169169
```
170+
where ``\epsilon_0`` denotes a measure of floating-point precision.
170171

171172
Let ``L_1 = L_0 * \max(0.5, \min(2.0, 1.0-samp*V_\tau*d^2V_{\tau}/N^2))`` where ``samp=1.0`` is the correction for coarse sampling of ``d^2V/dz^2``, and
172173
```math

reproducibility_tests/ref_counter.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
234
1+
235
22

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

2121

2222
#=
23+
235
24+
- Related to #3775, the computation and update of non-orographic gravity wave (NOGW)
25+
are now separated into callback and tendencies update, affecting the NOGW-related
26+
tests.
2327
2428
234
2529
- Move the virtual mass term in pressure closure to prognostic edmf momentum equation

src/callbacks/callbacks.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@ NVTX.@annotate function rrtmgp_model_callback!(integrator)
399399
return nothing
400400
end
401401

402+
NVTX.@annotate function nogw_model_callback!(integrator)
403+
Y = integrator.u
404+
p = integrator.p
405+
406+
non_orographic_gravity_wave_compute_tendency!(Y, p)
407+
return nothing
408+
end
409+
402410
#Uniform insolation, magnitudes from Wing et al. (2018)
403411
#Note that the TOA downward shortwave fluxes won't be the same as the values in the paper if add_isothermal_boundary_layer is true
404412
function set_insolation_variables!(Y, p, t, ::RCEMIPIIInsolation)

src/callbacks/get_callbacks.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,5 +365,21 @@ function get_callbacks(config, sim_info, atmos, params, Y, p)
365365
(callbacks..., call_every_dt(rrtmgp_model_callback!, dt_rad))
366366
end
367367

368+
if atmos.non_orographic_gravity_wave isa NonOrographicGravityWave
369+
dt_nogw =
370+
dt isa ITime ? ITime(time_to_seconds(parsed_args["dt_nogw"])) :
371+
FT(time_to_seconds(parsed_args["dt_nogw"]))
372+
dt_nogw, _, _, _ = promote(dt_nogw, t_start, dt, sim_info.t_end)
373+
# We use Millisecond to support fractional seconds, eg. 0.1
374+
dt_nogw_ms = Dates.Millisecond(1_000 * float(dt_nogw))
375+
if parsed_args["dt_save_state_to_disk"] != "Inf" &&
376+
!CA.isdivisible(dt_save_state_to_disk_dates, dt_nogw_ms)
377+
@warn "Non-orographic gravity wave period ($(dt_nogw_ms)) is not an even divisor of the checkpoint frequency ($dt_save_state_to_disk_dates)"
378+
@warn "This simulation will not be reproducible when restarted"
379+
end
380+
381+
callbacks = (callbacks..., call_every_dt(nogw_model_callback!, dt_nogw))
382+
end
383+
368384
return callbacks
369385
end

src/diagnostics/Diagnostics.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ import ..EDOnlyEDMFX
4141
import ..PrognosticEDMFX
4242
import ..DiagnosticEDMFX
4343

44+
# gravitywave_models
45+
import ..NonOrographicGravityWave
46+
import ..OrographicGravityWave
47+
4448
# surface_model
4549
import ..PrognosticSurfaceTemperature
4650

0 commit comments

Comments
 (0)