@@ -169,6 +169,60 @@ operations of mask-aware and mask-unaware:
169169 This was a design implementation detail, users should not generally depend on the results where ` mask == 0 ` , in case this is changed in the future.
170170 - internal array operations (` fill!(parent(field), 0) ` ) mask-unaware.
171171
172+ ## Temporary work-arounds
173+
174+ We can perform mask-aware reductions with the following work-around
175+
176+ ``` julia
177+ using ClimaComms
178+ ClimaComms. @import_required_backends
179+ import ClimaCore: Spaces, Fields, DataLayouts, Geometry, Operators
180+ using ClimaCore. CommonSpaces
181+ using Test
182+
183+ FT = Float64
184+ ᶜspace = ExtrudedCubedSphereSpace (FT;
185+ z_elem = 10 ,
186+ z_min = 0 ,
187+ z_max = 1 ,
188+ radius = 10 ,
189+ h_elem = 10 ,
190+ n_quad_points = 4 ,
191+ staggering = CellCenter (),
192+ enable_mask = true ,
193+ )
194+ ᶠspace = Spaces. face_space (ᶜspace)
195+ ᶠcoords = Fields. coordinate_field (ᶠspace)
196+
197+ # Set the mask
198+ Spaces. set_mask! (ᶜspace) do coords
199+ coords. lat > 0.5
200+ end
201+
202+ # get the mask
203+ mask = Spaces. get_mask (ᶜspace)
204+
205+ # make a field of ones
206+ ᶜf = ones (ᶜspace) # ignores mask
207+
208+ # bitmask spanning datalayout
209+ bm = DataLayouts. full_bitmask (mask, Fields. field_values (ᶜf));
210+
211+ # mask-unaware integral (includes jacobian weighting)
212+ @show sum (ᶜf)
213+
214+ # mask-unaware sum (excludes jacobian weighting)
215+ @show sum (Fields. field_values (ᶜf))
216+
217+ # mask-aware sum (excludes jacobian)
218+ @show sum (parent (ᶜf)[bm])
219+
220+ # level mask
221+ ᶜf_lev = Fields. level (ᶜf, 1 );
222+ bm_lev = DataLayouts. full_bitmask (mask, Fields. field_values (ᶜf_lev));
223+ @show sum (parent (ᶜf_lev)[bm_lev])
224+ ```
225+
172226## Developer docs
173227
174228In order to support masks, we define their types in ` DataLayouts ` , since
0 commit comments