@@ -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,20 @@ 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
145
- (; vor_tend) = diagn. tendencies
146
- SpeedyTransforms. spectral! (vor_tend, S_grid, spectral_transform)
147
-
141
+ if forcing. mask
142
+ # to grid-point space
143
+ S_grid = diagn. dynamics_variables. a_grid # reuse general work array
144
+ SpeedyTransforms. gridded! (S_grid, S, spectral_transform)
145
+
146
+ # mask everything but mid-latitudes
147
+ RingGrids. _scale_lat! (S_grid, forcing. lat_mask)
148
+
149
+ # back to spectral space, write directly into vorticity tendency
150
+ (; vor_tend) = diagn. tendencies
151
+ SpeedyTransforms. spectral! (vor_tend, S_grid, spectral_transform)
152
+ else
153
+ vor_tend .= S # copy forcing S over into vor_tend
154
+ end
155
+
148
156
return nothing
149
157
end
0 commit comments