@@ -10,9 +10,118 @@ 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_ρq_liq (ᶜY, ᶠY, p, t)... ,
24
+ ᶜremaining_tendency_ρq_ice (ᶜY, ᶠY, p, t)... ,
25
+ ᶜremaining_tendency_ρq_rai (ᶜY, ᶠY, p, t)... ,
26
+ ᶜremaining_tendency_ρq_sno (ᶜY, ᶠY, p, t)... ,
27
+ ᶜremaining_tendency_sfc (ᶜY, ᶠY, p, t)... ,
28
+ ᶜremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)... ,
29
+ )
30
+ return lazy .(prognostic_nt .(Val (names), tends... ))
31
+ end
32
+ function ᶠremaining_tendency (ᶜY, ᶠY, p, t)
33
+ names = propertynames (ᶠY)
34
+ tends = (
35
+ ᶠremaining_tendency_u₃ (ᶜY, ᶠY, p, t)... ,
36
+ ᶠremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)... ,
37
+ )
38
+ return lazy .(prognostic_nt .(Val (names), tends... ))
39
+ end
40
+
41
+ function ᶜremaining_tendency_ρ (ᶜY, ᶠY, p, t)
42
+ :ρ in propertynames (ᶜY) || return ()
43
+ ∑tendencies = zero (eltype (ᶜY. ρ))
44
+ return (;ρ= ∑tendencies)
45
+ end
46
+ function ᶜremaining_tendency_uₕ (ᶜY, ᶠY, p, t)
47
+ :uₕ in propertynames (ᶜY) || return ()
48
+ ∑tendencies = zero (eltype (ᶜY. uₕ))
49
+ return (;uₕ= ∑tendencies)
50
+ end
51
+ function ᶜremaining_tendency_ρe_tot (ᶜY, ᶠY, p, t)
52
+ :ρe_tot in propertynames (ᶜY) || return ()
53
+ ∑tendencies = zero (eltype (ᶜY. ρe_tot))
54
+ return (;ρe_tot= ∑tendencies)
55
+ end
56
+ function ᶜremaining_tendency_ρq_tot (ᶜY, ᶠY, p, t)
57
+ :ρq_tot in propertynames (ᶜY) || return ()
58
+ ∑tendencies = zero (eltype (ᶜY. ρq_tot))
59
+ return (;ρq_tot= ∑tendencies)
60
+ end
61
+ function ᶜremaining_tendency_ρq_liq (ᶜY, ᶠY, p, t)
62
+ :ρq_liq in propertynames (ᶜY) || return ()
63
+ ∑tendencies = zero (eltype (ᶜY. ρq_liq))
64
+ return (;ρq_liq= ∑tendencies)
65
+ end
66
+ function ᶜremaining_tendency_ρq_ice (ᶜY, ᶠY, p, t)
67
+ :ρq_ice in propertynames (ᶜY) || return ()
68
+ ∑tendencies = zero (eltype (ᶜY. ρq_ice))
69
+ return (;ρq_ice= ∑tendencies)
70
+ end
71
+ function ᶜremaining_tendency_ρq_rai (ᶜY, ᶠY, p, t)
72
+ :ρq_rai in propertynames (ᶜY) || return ()
73
+ ∑tendencies = zero (eltype (ᶜY. ρq_rai))
74
+ return (;ρq_rai= ∑tendencies)
75
+ end
76
+ function ᶜremaining_tendency_ρq_sno (ᶜY, ᶠY, p, t)
77
+ :ρq_sno in propertynames (ᶜY) || return ()
78
+ ∑tendencies = zero (eltype (ᶜY. ρq_sno))
79
+ return (;ρq_sno= ∑tendencies)
80
+ end
81
+ function ᶜremaining_tendency_sfc (ᶜY, ᶠY, p, t)
82
+ :sfc in propertynames (ᶜY) || return ()
83
+ ∑tendencies = zero (eltype (ᶜY. sfc))
84
+ return (;sfc= ∑tendencies)
85
+ end
86
+ function ᶜremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)
87
+ :sgsʲs in propertynames (ᶜY) || return ()
88
+ ∑tendencies = zero (eltype (ᶜY. sgsʲs))
89
+ return (;sgsʲs= ∑tendencies)
90
+ end
91
+ function ᶠremaining_tendency_u₃ (ᶜY, ᶠY, p, t)
92
+ :u₃ in propertynames (ᶠY) || return ()
93
+ ∑tendencies = zero (eltype (ᶠY. u₃))
94
+ return (;u₃= ∑tendencies)
95
+ end
96
+ function ᶠremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)
97
+ :sgsʲs in propertynames (ᶠY) || return ()
98
+ ∑tendencies = zero (eltype (ᶠY. sgsʲs))
99
+ return (;sgsʲs= ∑tendencies)
100
+ end
101
+
102
+
13
103
NVTX. @annotate function remaining_tendency! (Yₜ, Yₜ_lim, Y, p, t)
14
104
Yₜ_lim .= zero (eltype (Yₜ_lim))
15
- Yₜ .= zero (eltype (Yₜ))
105
+ device = ClimaComms. device (axes (Y. c))
106
+ (localmem_lg, localmem_state) = if device isa ClimaComms. CUDADevice
107
+ Val (false ), Val (true )
108
+ else
109
+ Val (false ), Val (false )
110
+ end
111
+ p_kernel = (;)
112
+ Operators. columnwise! (
113
+ device,
114
+ ᶜremaining_tendency,
115
+ ᶠremaining_tendency,
116
+ Yₜ. c,
117
+ Yₜ. f,
118
+ Y. c,
119
+ Y. f,
120
+ p_kernel,
121
+ t,
122
+ localmem_lg,
123
+ localmem_state
124
+ )
16
125
horizontal_tracer_advection_tendency! (Yₜ_lim, Y, p, t)
17
126
fill_with_nans! (p)
18
127
horizontal_advection_tendency! (Yₜ, Y, p, t)
0 commit comments