@@ -23,6 +23,9 @@ Base.@kwdef struct StochasticStirring{NF} <: SpeedyWeather.AbstractForcing
23
23
" Stirring latitude [˚N]"
24
24
latitude:: NF = 45
25
25
26
+ " En/disable stirring mask"
27
+ mask:: Bool = true
28
+
26
29
" Stirring width [˚]"
27
30
width:: NF = 24
28
31
@@ -81,12 +84,13 @@ function SpeedyWeather.initialize!( forcing::StochasticStirring,
81
84
forcing. a[] = A* sqrt (1 - exp (- 2 dt/ τ))
82
85
forcing. b[] = exp (- dt/ τ)
83
86
84
- # precompute the Gaussian latitudinal mask
85
- (;latd) = model. geometry # in ˚N on every latitude ring
86
-
87
- for j in eachindex (forcing. lat_mask)
88
- # Gaussian centred at forcing.latitude of width forcing.width
89
- forcing. lat_mask[j] = exp (- (forcing. latitude- latd[j])^ 2 / forcing. width^ 2 * 2 )
87
+ if forcing. mask
88
+ # precompute the Gaussian latitudinal mask
89
+ (;latd) = model. geometry # in ˚N on every latitude ring
90
+ for j in eachindex (forcing. lat_mask)
91
+ # Gaussian centred at forcing.latitude of width forcing.width
92
+ forcing. lat_mask[j] = exp (- (forcing. latitude- latd[j])^ 2 / forcing. width^ 2 * 2 )
93
+ end
90
94
end
91
95
92
96
return nothing
@@ -134,16 +138,22 @@ function SpeedyWeather.forcing!(
134
138
end
135
139
end
136
140
137
- # to grid-point space
138
- S_grid = diagn. dynamics_variables. a_grid # reuse general work array
139
- SpeedyTransforms. gridded! (S_grid, S, spectral_transform)
140
-
141
- # mask everything but mid-latitudes
142
- RingGrids. _scale_lat! (S_grid, forcing. lat_mask)
143
-
144
- # back to spectral space, write directly into vorticity tendency
141
+ # add stochastic stirring term S to vorticity tendency
142
+ # with masked or without (=skip additional transform)
145
143
(; vor_tend) = diagn. tendencies
146
- SpeedyTransforms. spectral! (vor_tend, S_grid, spectral_transform)
147
-
144
+ if forcing. mask
145
+ # to grid-point space
146
+ S_grid = diagn. dynamics_variables. a_grid # reuse general work array
147
+ SpeedyTransforms. gridded! (S_grid, S, spectral_transform)
148
+
149
+ # mask everything but mid-latitudes
150
+ RingGrids. _scale_lat! (S_grid, forcing. lat_mask)
151
+
152
+ # back to spectral space, write directly into vorticity tendency
153
+ SpeedyTransforms. spectral! (vor_tend, S_grid, spectral_transform)
154
+ else
155
+ vor_tend .= S # copy forcing S over into vor_tend
156
+ end
157
+
148
158
return nothing
149
159
end
0 commit comments