You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be useful to add a field to the cache where we can put temporary fields on the boundary space. For example, a land mask over the surface. This could prevent allocating new fields (masks) at each timestep.
We already have two fields defined on the boundary space: :temp1 and :temp2 in coupler_fields. We should use these more throughout the code where we're using fields for calculations but don't necessarily need to keep the field itself. Atmos also stores some temp fields in its cache, which we can use in functions accessing the AtmosSimulation.
Note: Fields.ones and Fields.zeros allocate a new field. parent and level both return views and do not allocate. axes also doesn't allocate, but creating a new field on the space returned by it would
places to use temp fields
import_combined_surface_fields
swap_space (double check that it allocates as it is now) - maybe we can change this to take in a space instead of calling axes(field). Then we won't have to create a field on a space just to access the space, e.g. in Regridder.land_fraction
It might be useful to add a field to the cache where we can put temporary fields on the boundary space. For example, a land mask over the surface. This could prevent allocating new fields (masks) at each timestep.
We already have two fields defined on the boundary space:
:temp1
and:temp2
incoupler_fields
. We should use these more throughout the code where we're using fields for calculations but don't necessarily need to keep the field itself. Atmos also stores some temp fields in its cache, which we can use in functions accessing the AtmosSimulation.Note:
Fields.ones
andFields.zeros
allocate a new field.parent
andlevel
both return views and do not allocate.axes
also doesn't allocate, but creating a new field on the space returned by it wouldplaces to use temp fields
import_combined_surface_fields
swap_space
(double check that it allocates as it is now) - maybe we can change this to take in a space instead of callingaxes(field)
. Then we won't have to create a field on a space just to access the space, e.g. inRegridder.land_fraction
calculate_surface_air_density
for atmosget_field(bucket_sim::BucketSimulation, ::Val{:energy})
check_conservation!(cc::WaterConservationCheck, coupler_sim::Interfacer.CoupledSimulation)
Some useful findings
@btime p.precomputed.ᶜts > 450.522 ns (4 allocations: 4.66 KiB)
@btime @. ᶜgradᵥ_.(ᶠinterp_(u.c.ρ)) > 16.212 μs (12 allocations: 120.62 KiB)
notes:
@btime FieldExchanger.import_combined_surface_fields!(cs.fields, cs.model_sims, cs.boundary_space, cs.turbulent_fluxes) 122.500 μs (207 allocations: 119.08 KiB)
if all predefined:@btime FieldExchanger.import_combined_surface_fields!(fields, model_sims, boundary_space, turbulent_fluxes) 121.709 μs (200 allocations: 102.61 KiB)
@btime Regridder.combine_surfaces!(combined_field, model_sims, Val(:surface_temperature)) 8.333 μs (28 allocations: 11.23 KiB)
@btime eltype(field1) 11.094 ns (0 allocations: 0 bytes)
@btime Interfacer.get_field(sim, Val(:area_fraction)) 54.272 ns (1 allocation: 32 bytes)
@btime nans_to_zero.(Interfacer.get_field(sim, field_name)) 1.467 μs (5 allocations: 12.39 KiB)
(1 from get_field()).@btime Regridder.dummmy_remap!(csf.T_S, combined_field) 290.280 ns (1 allocation: 32 bytes)
vs@btime Regridder.dummmy_remap!(T_S, combined_field) 233.447 ns (0 allocations: 0 bytes
@btime parent(cs.fields.T_S) 338.352 ns (3 allocations: 3.73 KiB)
@btime Utilities.swap_space!(cs.fields.temp1, cs.fields.temp2) 759.009 ns (7 allocations: 7.50 KiB)
if fields preallocated:@btime Utilities.swap_space!(field1, field2) 56.968 ns (1 allocation: 32 bytes)
The text was updated successfully, but these errors were encountered: