Skip to content

Evaluating a field at certain indices in a GPU simulation #4052

Discussion options

You must be logged in to vote

First you can try

max_dSdz = maximum(∂z(model.tracers.S), dims=3)

or

max_dSdz = maximum(Field(∂z(model.tracers.S)), dims=3)

then max_dSdz should be a 2D field.

If you want to form an object that can be repeatedly compute!'d then I think you want to use Reduction with maximum! (see the docstring for Reduction):

max_dSdz_reduction = Reduction(maximum!, ∂z(model.tracers.S), dims=3)
max_dSdz = Field(max_dSdz_reduction)
compute!(max_dSdz)

To go further with custom kernels I suggest checking out the implementation of MixedLayerDepthOperand and MixedLayerDepthField here:

https://github.com/CliMA/ClimaOcean.jl/blob/main/src/Diagnostics/mixed_layer_depth.jl

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SamDeAbreu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants