@@ -10,9 +10,88 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Yₜ_lim, Y, p, t)
10
10
apply_hyperdiffusion_tendency! (Yₜ, Y, p, t)
11
11
end
12
12
13
+ prognostic_nt (:: Val{names} , tends... ) where {names} =
14
+ NamedTuple {names} (tends)
15
+
16
+ function ᶜremaining_tendency (ᶜY, ᶠY, p, t)
17
+ names = propertynames (ᶜY)
18
+ tends = (
19
+ ᶜremaining_tendency_ρ (ᶜY, ᶠY, p, t)... ,
20
+ ᶜremaining_tendency_uₕ (ᶜY, ᶠY, p, t)... ,
21
+ ᶜremaining_tendency_ρe_tot (ᶜY, ᶠY, p, t)... ,
22
+ ᶜremaining_tendency_ρq_tot (ᶜY, ᶠY, p, t)... ,
23
+ ᶜremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)... ,
24
+ )
25
+ return lazy .(prognostic_nt .(Val (names), tends... ))
26
+ end
27
+ function ᶠremaining_tendency (ᶜY, ᶠY, p, t)
28
+ names = propertynames (ᶠY)
29
+ tends = (
30
+ ᶠremaining_tendency_u₃ (ᶜY, ᶠY, p, t)... ,
31
+ ᶠremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)... ,
32
+ )
33
+ return lazy .(prognostic_nt .(Val (names), tends... ))
34
+ end
35
+
36
+ function ᶜremaining_tendency_ρ (ᶜY, ᶠY, p, t)
37
+ :ρ in propertynames (ᶜY) || return ()
38
+ ∑tendencies = zero (eltype (ᶜY. ρ))
39
+ return (;ρ= ∑tendencies)
40
+ end
41
+ function ᶜremaining_tendency_uₕ (ᶜY, ᶠY, p, t)
42
+ :uₕ in propertynames (ᶜY) || return ()
43
+ ∑tendencies = zero (eltype (ᶜY. uₕ))
44
+ return (;uₕ= ∑tendencies)
45
+ end
46
+ function ᶜremaining_tendency_ρe_tot (ᶜY, ᶠY, p, t)
47
+ :ρe_tot in propertynames (ᶜY) || return ()
48
+ ∑tendencies = zero (eltype (ᶜY. ρe_tot))
49
+ return (;ρe_tot= ∑tendencies)
50
+ end
51
+ function ᶜremaining_tendency_ρq_tot (ᶜY, ᶠY, p, t)
52
+ :ρq_tot in propertynames (ᶜY) || return ()
53
+ ∑tendencies = zero (eltype (ᶜY. ρq_tot))
54
+ return (;ρq_tot= ∑tendencies)
55
+ end
56
+ function ᶜremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)
57
+ :sgsʲs in propertynames (ᶜY) || return ()
58
+ ∑tendencies = zero (eltype (ᶜY. sgsʲs))
59
+ return (;sgsʲs= ∑tendencies)
60
+ end
61
+ function ᶠremaining_tendency_u₃ (ᶜY, ᶠY, p, t)
62
+ :u₃ in propertynames (ᶠY) || return ()
63
+ ∑tendencies = zero (eltype (ᶠY. u₃))
64
+ return (;u₃= ∑tendencies)
65
+ end
66
+ function ᶠremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)
67
+ :sgsʲs in propertynames (ᶠY) || return ()
68
+ ∑tendencies = zero (eltype (ᶠY. sgsʲs))
69
+ return (;sgsʲs= ∑tendencies)
70
+ end
71
+
72
+
13
73
NVTX. @annotate function remaining_tendency! (Yₜ, Yₜ_lim, Y, p, t)
14
74
Yₜ_lim .= zero (eltype (Yₜ_lim))
15
- Yₜ .= zero (eltype (Yₜ))
75
+ device = ClimaComms. device (axes (Y. c))
76
+ (localmem_lg, localmem_state) = if device isa ClimaComms. CUDADevice
77
+ Val (false ), Val (true )
78
+ else
79
+ Val (false ), Val (false )
80
+ end
81
+ p_kernel = (;)
82
+ Operators. columnwise! (
83
+ device,
84
+ ᶜremaining_tendency,
85
+ ᶠremaining_tendency,
86
+ Yₜ. c,
87
+ Yₜ. f,
88
+ Y. c,
89
+ Y. f,
90
+ p_kernel,
91
+ t,
92
+ localmem_lg,
93
+ localmem_state
94
+ )
16
95
horizontal_tracer_advection_tendency! (Yₜ_lim, Y, p, t)
17
96
fill_with_nans! (p)
18
97
horizontal_advection_tendency! (Yₜ, Y, p, t)
0 commit comments