Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-silvestri committed Nov 16, 2023
1 parent fe2e521 commit 29a61d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/freely_decaying_mediterraneum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using Oceananigans.Coriolis: ActiveCellEnstrophyConserving
##### Regional Mediterranean grid
#####

function regrid_ecco_tracers_to_grid(grid)
function regrid_ecco_tracers(grid)
Tecco = ecco2_field(:temperature)
Secco = ecco2_field(:salinity)

Expand All @@ -25,6 +25,7 @@ function regrid_ecco_tracers_to_grid(grid)
T = CenterField(grid)
S = CenterField(grid)

# Regrid to our grid!
three_dimensional_regrid!(T, Tecco)
three_dimensional_regrid!(S, Secco)

Expand Down Expand Up @@ -52,7 +53,7 @@ h = regrid_bathymetry(grid, height_above_water=1)

grid = ImmersedBoundaryGrid(grid, GridFittedBottom(h))

T, S = regrid_ecco_tracers_to_grid(grid)
T, S = regrid_ecco_tracers(grid)

mask_immersed_field!(T)
mask_immersed_field!(S)
Expand Down
7 changes: 6 additions & 1 deletion src/DataWrangling/ECCO2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,17 @@ function ecco2_field(variable_name;
return field
end

@kernel function _set_ecco2_mask!(mask, Tᵢ, minimum_value)
i, j, k = @index(Global, NTuple)
@inbounds mask[i, j, k] = ifelse(Tᵢ[i, j, k] < minimum_value, 0, 1)
end

function ecco2_center_mask(architecture = CPU(); minimum_value = Float32(-1e5))
Tᵢ = ecco2_field(:temperature; architecture)
mask = CenterField(Tᵢ.grid)

# Set the mask with ones where T is defined
set!(mask, (!).(Tᵢ .< minimum_value))
launch!(architecture, Tᵢ.grid, _set_ecco2_mask!, mask, Tᵢ, minimum_value)

return mask
end
Expand Down

0 comments on commit 29a61d4

Please sign in to comment.