Skip to content

Commit 7792990

Browse files
some corrections
1 parent b74450f commit 7792990

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

src/DataWrangling/JRA55/JRA55_field_time_series.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ function set!(fts::JRA55NetCDFFTSMultipleYears, backend=fts.backend)
189189
LX, LY, LZ = location(fts)
190190
i₁, i₂, j₁, j₂, TX = compute_bounding_indices(nothing, nothing, fts.grid, LX, LY, λc, φc)
191191

192+
192193
if issorted(nn)
193194
data = ds[name][i₁:i₂, j₁:j₂, nn]
194195
else
@@ -457,7 +458,7 @@ function JRA55FieldTimeSeries(metadata::JRA55Metadata, architecture=CPU(), FT=Fl
457458
ds = Dataset(filepath)
458459
data = ds[shortname][i₁:i₂, j₁:j₂, time_indices_in_memory]
459460
close(ds)
460-
461+
461462
copyto!(interior(fts, :, :, 1, :), data)
462463
fill_halo_regions!(fts)
463464

src/InitialConditions/InitialConditions.jl

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using JLD2
1818
# Implementation of 3-dimensional regridding
1919
# TODO: move all the following to Oceananigans!
2020

21-
using Oceananigans.Fields: interpolate!
21+
using Oceananigans.Fields: regrid!, interpolate!
2222
using Oceananigans.Grids: cpu_face_constructor_x,
2323
cpu_face_constructor_y,
2424
cpu_face_constructor_z,
@@ -31,6 +31,44 @@ construct_grid(::Type{<:RectilinearGrid}, arch, size, extent, topology) =
3131
construct_grid(::Type{<:LatitudeLongitudeGrid}, arch, size, extent, topology) =
3232
LatitudeLongitudeGrid(arch; size, longitude = extent[1], latitude = extent[2], z = extent[3], topology)
3333

34+
# Regrid a field in three dimensions
35+
function three_dimensional_regrid!(a, b)
36+
target_grid = a.grid isa ImmersedBoundaryGrid ? a.grid.underlying_grid : a.grid
37+
source_grid = b.grid isa ImmersedBoundaryGrid ? b.grid.underlying_grid : b.grid
38+
39+
topo = topology(target_grid)
40+
arch = architecture(target_grid)
41+
arch = child_architecture(arch)
42+
43+
target_y = yt = cpu_face_constructor_y(target_grid)
44+
target_z = zt = cpu_face_constructor_z(target_grid)
45+
46+
target_size = Nt = size(target_grid)
47+
48+
source_x = xs = cpu_face_constructor_x(source_grid)
49+
source_y = ys = cpu_face_constructor_y(source_grid)
50+
51+
source_size = Ns = size(source_grid)
52+
53+
# Start by regridding in z
54+
@debug "Regridding in z"
55+
zgrid = construct_grid(typeof(target_grid), arch, (Ns[1], Ns[2], Nt[3]), (xs, ys, zt), topo)
56+
field_z = Field(location(b), zgrid)
57+
regrid!(field_z, zgrid, source_grid, b)
58+
59+
# regrid in y
60+
@debug "Regridding in y"
61+
ygrid = construct_grid(typeof(target_grid), arch, (Ns[1], Nt[2], Nt[3]), (xs, yt, zt), topo)
62+
field_y = Field(location(b), ygrid);
63+
regrid!(field_y, ygrid, zgrid, field_z);
64+
65+
# Finally regrid in x
66+
@debug "Regridding in x"
67+
regrid!(a, target_grid, ygrid, field_y)
68+
69+
return a
70+
end
71+
3472
include("diffuse_tracers.jl")
3573

3674
end # module

src/OceanSeaIceModels/InterfaceComputations/atmosphere_sea_ice_fluxes.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ function compute_atmosphere_sea_ice_fluxes!(coupled_model)
1414
v = ZeroField(),
1515
h = sea_ice.model.ice_thickness,
1616
= sea_ice.model.ice_concentration,
17-
hc = sea_ice.model.ice_consolidation_thickness,
1817
Tₒ = ocean.model.tracers.T,
1918
Sₒ = ocean.model.tracers.S)
2019

@@ -98,7 +97,6 @@ end
9897
uᵢ = zero(FT) # ℑxᶜᵃᵃ(i, j, 1, grid, interior_state.u)
9998
vᵢ = zero(FT) # ℑyᵃᶜᵃ(i, j, 1, grid, interior_state.v)
10099
hᵢ = interior_state.h[i, j, 1]
101-
hc = interior_state.hc[i, j, 1]
102100
ℵᵢ = interior_state.ℵ[i, j, 1]
103101
Tₛ = interface_temperature[i, j, 1]
104102
Tₛ = convert_to_kelvin(sea_ice_properties.temperature_units, Tₛ)
@@ -119,7 +117,7 @@ end
119117
h_bℓ = atmosphere_state.h_bℓ)
120118

121119
downwelling_radiation = (; Qs, Qℓ)
122-
local_interior_state = (u=uᵢ, v=vᵢ, T=Tᵢ, S=Sᵢ, h=hᵢ, hc=hc)
120+
local_interior_state = (u=uᵢ, v=vᵢ, T=Tᵢ, S=Sᵢ, h=hᵢ)
123121

124122
# Estimate initial interface state
125123
u★ = convert(FT, 1e-4)

src/OceanSeaIceModels/InterfaceComputations/component_interfaces.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function default_ai_temperature(sea_ice::SeaIceSimulation)
291291
end
292292

293293
function default_ao_specific_humidity(ocean)
294-
FT = Float64
294+
FT = eltype(ocean)
295295
phase = AtmosphericThermodynamics.Liquid()
296296
x_H₂O = convert(FT, 0.98)
297297
return ImpureSaturationSpecificHumidity(phase, x_H₂O)
@@ -345,7 +345,7 @@ function ComponentInterfaces(atmosphere, ocean, sea_ice=nothing;
345345
sea_ice_heat_capacity = heat_capacity(sea_ice),
346346
gravitational_acceleration = g_Earth)
347347

348-
FT = Float64
348+
FT = eltype(ocean)
349349

350350
ocean_reference_density = convert(FT, ocean_reference_density)
351351
ocean_heat_capacity = convert(FT, ocean_heat_capacity)

src/OceanSeaIceModels/OceanSeaIceModels.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const default_freshwater_density = 1000
4343
const SeaIceSimulation = Simulation{<:SeaIceModel}
4444
const OceananigansSimulation = Simulation{<:HydrostaticFreeSurfaceModel}
4545

46+
Base.eltype(ocean::OceananigansSimulation) = eltype(ocean.model.grid)
47+
4648
sea_ice_thickness(::Nothing) = ZeroField()
4749
sea_ice_thickness(sea_ice::SeaIceSimulation) = sea_ice.model.ice_thickness
4850

src/OceanSeaIceModels/ocean_sea_ice_model.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import Oceananigans.TimeSteppers: time_step!, update_state!, time
1919
import Oceananigans.Utils: prettytime
2020
import Oceananigans.Models: timestepper, NaNChecker, default_nan_checker, initialization_update_state!
2121

22+
import Base
23+
2224
mutable struct OceanSeaIceModel{I, A, O, F, C, Arch} <: AbstractModel{Nothing, Arch}
2325
architecture :: Arch
2426
clock :: C

0 commit comments

Comments
 (0)