Skip to content

Commit 005967d

Browse files
authored
Merge pull request #1415 from CliMA/glw/ecco-init
Initialize OceananigansSimulation from the ECCO state estimate
2 parents acdc4e7 + cd8dcf3 commit 005967d

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

experiments/ClimaEarth/components/ocean/oceananigans.jl

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,19 @@ a surface area fraction field.
3535
This type is used to indicate that this simulation is an ocean simulation for
3636
dispatch in coupling.
3737
38-
Specific details about the complexity of the model
39-
can be found in the Oceananigans.jl documentation.
38+
Specific details about the default model configuration
39+
can be found in the documentation for `ClimaOcean.ocean_simulation`.
4040
"""
4141
function OceananigansSimulation(area_fraction, start_date, stop_date; output_dir, comms_ctx = ClimaComms.context())
4242
arch = comms_ctx.device isa ClimaComms.CUDADevice ? OC.GPU() : OC.CPU()
4343

44-
use_ecco = start_date + Dates.Month(1) < stop_date
45-
if use_ecco
46-
# Retrieve ECCO data (monthly)
47-
# (It requires username and password)
48-
dates = range(start_date, step = Dates.Month(1), stop = stop_date)
49-
ecco_temperature = CO.Metadata(:temperature; dates, dataset = CO.ECCO.ECCO4Monthly())
50-
ecco_salinity = CO.Metadata(:salinity; dates, dataset = CO.ECCO.ECCO4Monthly())
51-
download_dataset(ecco_temperature)
52-
download_dataset(ecco_salinity)
53-
end
44+
# Retrieve ECCO data (monthly)
45+
# (It requires username and password)
46+
dates = range(start_date, step = Dates.Month(1), stop = stop_date)
47+
ecco_temperature = CO.Metadata(:temperature; dates, dataset = CO.ECCO.ECCO4Monthly())
48+
ecco_salinity = CO.Metadata(:salinity; dates, dataset = CO.ECCO.ECCO4Monthly())
49+
download_dataset(ecco_temperature)
50+
download_dataset(ecco_salinity)
5451

5552
# Set up ocean grid (1 degree)
5653
resolution_points = (360, 160, 32)
@@ -76,7 +73,9 @@ function OceananigansSimulation(area_fraction, start_date, stop_date; output_dir
7673

7774
grid = OC.ImmersedBoundaryGrid(underlying_grid, OC.GridFittedBottom(bottom_height); active_cells_map = true)
7875

79-
if use_ecco
76+
use_restoring = start_date + Dates.Month(1) < stop_date
77+
78+
if use_restoring
8079
# When we use ecco data, the forcing takes care of everything, including
8180
# the initial conditions
8281
restoring_rate = 1 / (3 * 86400)
@@ -92,16 +91,12 @@ function OceananigansSimulation(area_fraction, start_date, stop_date; output_dir
9291
# Create ocean simulation
9392
ocean = CO.ocean_simulation(grid; forcing)
9493

95-
if !use_ecco
96-
T_init(λ, φ, z) = 30 * (1 - tanh((abs(φ) - 30) / 5)) / 2 + rand()
97-
S_init(λ, φ, z) = 30 - 5e-3 * z + rand()
98-
OC.set!(ocean.model, T = T_init, S = S_init)
99-
end
94+
# Set initial condition to ECCO state estimate at start_date
95+
OC.set!(ocean.model, T = ecco_temperature[1], S = ecco_salinity[1])
10096

10197
long_cc = OC.λnodes(grid, OC.Center(), OC.Center(), OC.Center())
10298
lat_cc = OC.φnodes(grid, OC.Center(), OC.Center(), OC.Center())
10399

104-
105100
# TODO: Go from 0 to Nx+1, Ny+1 (for halos) (for LatLongGrid)
106101

107102
# Construct a remapper from the exchange grid to `Center, Center` fields

0 commit comments

Comments
 (0)