Skip to content

Commit 557ddc9

Browse files
Merge branch 'main' into ss/omip-prototype
2 parents f9613d8 + cc60ff3 commit 557ddc9

File tree

10 files changed

+84
-74
lines changed

10 files changed

+84
-74
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
arch: aarch64
4040
version: '1.10'
4141
steps:
42-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v5
4343
- uses: julia-actions/setup-julia@latest
4444
with:
4545
version: ${{ matrix.version }}
@@ -76,7 +76,7 @@ jobs:
7676
arch: aarch64
7777
version: '1.10'
7878
steps:
79-
- uses: actions/checkout@v4
79+
- uses: actions/checkout@v5
8080
- uses: julia-actions/setup-julia@latest
8181
with:
8282
version: ${{ matrix.version }}
@@ -112,7 +112,7 @@ jobs:
112112
arch: aarch64
113113
version: '1.10'
114114
steps:
115-
- uses: actions/checkout@v4
115+
- uses: actions/checkout@v5
116116
- uses: julia-actions/setup-julia@latest
117117
with:
118118
version: ${{ matrix.version }}

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "ClimaOcean"
22
uuid = "0376089a-ecfe-4b0e-a64f-9c555d74d754"
33
license = "MIT"
44
authors = ["Climate Modeling Alliance and contributors"]
5-
version = "0.8.2"
5+
version = "0.8.4"
66

77
[deps]
88
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -51,11 +51,11 @@ DataDeps = "0.7"
5151
DocStringExtensions = "0.9"
5252
Downloads = "1.6"
5353
ImageMorphology = "0.4"
54-
JLD2 = "0.4, 0.5"
54+
JLD2 = "0.4, 0.5, 0.6"
5555
KernelAbstractions = "0.9"
5656
MPI = "0.20"
5757
NCDatasets = "0.12, 0.13, 0.14"
58-
Oceananigans = "0.97.6"
58+
Oceananigans = "0.97.6, 0.98"
5959
OffsetArrays = "1.14"
6060
PrecompileTools = "1"
6161
PythonCall = "0.9"
@@ -65,7 +65,7 @@ SeawaterPolynomials = "0.3.5"
6565
StaticArrays = "1"
6666
Statistics = "1.9"
6767
SurfaceFluxes = "0.11, 0.12"
68-
Thermodynamics = "0.12, 0.13"
68+
Thermodynamics = "0.14"
6969
ZipFile = "0.10"
7070
julia = "1.10"
7171

docs/make.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using
22
ClimaOcean,
3+
CUDA,
34
Documenter,
45
DocumenterCitations,
56
Literate
@@ -43,6 +44,8 @@ for file in to_be_literated
4344
withenv("JULIA_DEBUG" => "Literate") do
4445
Literate.markdown(filepath, OUTPUT_DIR; flavor = Literate.DocumenterFlavor(), execute = true)
4546
end
47+
GC.gc()
48+
CUDA.reclaim()
4649
end
4750

4851
#####

examples/one_degree_simulation.jl

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ using CUDA
2424
arch = GPU()
2525
Nx = 360
2626
Ny = 180
27-
Nz = 40
27+
Nz = 50
28+
29+
depth = 5000meters
30+
z = ExponentialCoordinate(Nz, -depth, 0; scale = depth/4)
2831

29-
depth = 4000meters
30-
z = ExponentialCoordinate(Nz, -depth, 0; scale = 0.85*depth)
31-
z = Oceananigans.Grids.MutableVerticalDiscretization(z)
3232
underlying_grid = TripolarGrid(arch; size = (Nx, Ny, Nz), halo = (5, 5, 4), z)
3333

3434
# Next, we build bathymetry on this grid, using interpolation passes to smooth the bathymetry.
@@ -49,29 +49,29 @@ grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height);
4949
#
5050
# We include a Gent-McWilliams isopycnal diffusivity as a parameterization for the mesoscale
5151
# eddy fluxes. For vertical mixing at the upper-ocean boundary layer we include the CATKE
52-
# parameterization. We also include some explicit horizontal diffusivity.
52+
# parameterization.
5353

54-
eddy_closure = Oceananigans.TurbulenceClosures.IsopycnalSkewSymmetricDiffusivity(κ_skew=2e3, κ_symmetric=2e3)
55-
horizontal_viscosity = HorizontalScalarDiffusivity=4000)
54+
eddy_closure = Oceananigans.TurbulenceClosures.IsopycnalSkewSymmetricDiffusivity(κ_skew=10, κ_symmetric=10)
5655
vertical_mixing = ClimaOcean.OceanSimulations.default_ocean_closure()
57-
56+
5857
# ### Ocean simulation
5958
# Now we bring everything together to construct the ocean simulation.
60-
# We use a split-explicit timestepping with 70 substeps for the barotropic
61-
# mode.
59+
# We use a split-explicit timestepping with 70 substeps for the barotropic mode.
6260

6361
free_surface = SplitExplicitFreeSurface(grid; substeps=70)
6462
momentum_advection = WENOVectorInvariant(order=5)
6563
tracer_advection = WENO(order=5)
6664

6765
ocean = ocean_simulation(grid; momentum_advection, tracer_advection, free_surface,
68-
closure=(eddy_closure, horizontal_viscosity, vertical_mixing))
66+
timestepper = :SplitRungeKutta3,
67+
closure=(eddy_closure, vertical_mixing))
6968

7069
@info "We've built an ocean simulation with model:"
7170
@show ocean.model
7271

7372
# ### Sea Ice simulation
74-
# We also need to build a sea ice simulation. We use the default configuration:
73+
#
74+
# We also build a sea ice simulation. We use the default configuration:
7575
# EVP rheology and a zero-layer thermodynamic model that advances thickness
7676
# and concentration.
7777

@@ -84,8 +84,8 @@ sea_ice = sea_ice_simulation(grid, ocean; advection=tracer_advection)
8484
date = DateTime(1993, 1, 1)
8585
dataset = ECCO4Monthly()
8686
ecco_temperature = Metadatum(:temperature; date, dataset)
87-
ecco_salinity = Metadatum(:salinity; date, dataset)
88-
ecco_sea_ice_thickness = Metadatum(:sea_ice_thickness; date, dataset)
87+
ecco_salinity = Metadatum(:salinity; date, dataset)
88+
ecco_sea_ice_thickness = Metadatum(:sea_ice_thickness; date, dataset)
8989
ecco_sea_ice_concentration = Metadatum(:sea_ice_concentration; date, dataset)
9090

9191
set!(ocean.model, T=ecco_temperature, S=ecco_salinity)
@@ -103,12 +103,10 @@ atmosphere = JRA55PrescribedAtmosphere(arch; backend=JRA55NetCDFBackend(80),
103103
# Now we are ready to build the coupled ocean--sea ice model and bring everything
104104
# together into a `simulation`.
105105

106-
# We use a relatively short time step initially and only run for a few days to
107-
# avoid numerical instabilities from the initial "shock" of the adjustment of the
108-
# flow fields.
106+
# With Runge-Kutta 3rd order time-stepping we can safely use a timestep of 20 minutes.
109107

110108
coupled_model = OceanSeaIceModel(ocean, sea_ice; atmosphere, radiation)
111-
simulation = Simulation(coupled_model; Δt=8minutes, stop_time=20days)
109+
simulation = Simulation(coupled_model; Δt=20minutes, stop_time=365days)
112110

113111
# ### A progress messenger
114112
#
@@ -141,7 +139,7 @@ function progress(sim)
141139
end
142140

143141
# And add it as a callback to the simulation.
144-
add_callback!(simulation, progress, IterationInterval(1000))
142+
add_callback!(simulation, progress, TimeInterval(5days))
145143

146144
# ### Output
147145
#
@@ -157,27 +155,19 @@ sea_ice_outputs = merge((h = sea_ice.model.ice_thickness,
157155
sea_ice.model.velocities)
158156

159157
ocean.output_writers[:surface] = JLD2Writer(ocean.model, ocean_outputs;
160-
schedule = TimeInterval(5days),
158+
schedule = TimeInterval(1days),
161159
filename = "ocean_one_degree_surface_fields",
162160
indices = (:, :, grid.Nz),
163161
overwrite_existing = true)
164162

165163
sea_ice.output_writers[:surface] = JLD2Writer(ocean.model, sea_ice_outputs;
166-
schedule = TimeInterval(5days),
164+
schedule = TimeInterval(1days),
167165
filename = "sea_ice_one_degree_surface_fields",
168166
overwrite_existing = true)
169167

170168
# ### Ready to run
171169

172170
# We are ready to press the big red button and run the simulation.
173-
174-
# After we run for a short time (here we set up the simulation with `stop_time = 20days`),
175-
# we increase the timestep and run for longer.
176-
177-
run!(simulation)
178-
179-
simulation.Δt = 30minutes
180-
simulation.stop_time = 365days
181171
run!(simulation)
182172

183173
# ### A movie

ext/ClimaOceanPythonCallExt.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Oceananigans
77
using Oceananigans.DistributedComputations: @root
88

99
using Dates: DateTime
10-
using ClimaOcean.DataWrangling.Copernicus: CopernicusMetadata
10+
using ClimaOcean.DataWrangling.Copernicus: CopernicusMetadata, CopernicusMetadatum
1111

1212
import ClimaOcean.DataWrangling: download_dataset
1313

@@ -25,7 +25,17 @@ function install_copernicusmarine()
2525
return cli
2626
end
2727

28-
function download_dataset(meta::CopernicusMetadata, grid=nothing; skip_existing = true, additional_kw...)
28+
# Download each date individually, instead of downloading the entire dataset at once.
29+
# This is useful for a possible extension of the temporal horizon of the dataset.
30+
function download_dataset(metadata::CopernicusMetadata; kwargs...)
31+
paths = Array{String}(undef, length(metadata))
32+
for (m, metadatum) in enumerate(metadata)
33+
paths[m] = download_dataset(metadatum; kwargs...)
34+
end
35+
return paths
36+
end
37+
38+
function download_dataset(meta::CopernicusMetadatum; skip_existing = true, additional_kw...)
2939
output_directory = meta.dir
3040
output_filename = ClimaOcean.DataWrangling.metadata_filename(meta)
3141
output_path = joinpath(output_directory, output_filename)

src/DataWrangling/Copernicus/Copernicus.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using NCDatasets
66
using Printf
77

88
using Oceananigans.Fields: Center
9-
using ClimaOcean.DataWrangling: Metadata, Metadatum, metadata_path
9+
using ClimaOcean.DataWrangling: Metadata, Metadatum
1010
using Dates: DateTime, Day, Month
1111

1212
import Oceananigans.Fields:
@@ -45,6 +45,8 @@ dataset_name(::GLORYSStatic) = "GLORYSStatic"
4545
dataset_name(::GLORYSDaily) = "GLORYSDaily"
4646
dataset_name(::GLORYSMonthly) = "GLORYSMonthly"
4747

48+
Base.size(::CopernicusDataset, variable) = (4320, 2040, 50)
49+
4850
all_dates(::GLORYSStatic, var) = [nothing]
4951
all_dates(::GLORYSDaily, var) = range(DateTime("1993-01-01"), stop=DateTime("2021-06-30"), step=Day(1))
5052
all_dates(::GLORYSMonthly, var) = range(DateTime("1993-01-01"), stop=DateTime("2024-12-01"), step=Month(1))
@@ -57,10 +59,11 @@ copernicusmarine_dataset_id(::GLORYSMonthly) = "cmems_mod_glo_phy_my_0.083deg_P1
5759
struct CMEMSHourlyAnalysis <: CopernicusDataset end
5860
copernicusmarine_dataset_id(::CMEMSHourlyAnalysis) = "cmems_mod_glo_phy_anfc_0.083deg_PT1H-m"
5961

60-
CopernicusMetadata{D} = Metadata{<:CopernicusDataset, D}
61-
CopernicusMetadatum = Metadatum{<:CopernicusDataset}
62+
const CopernicusMetadata{D} = Metadata{<:CopernicusDataset, D}
63+
const CopernicusMetadatum = Metadatum{<:CopernicusDataset}
6264

6365
Base.size(::CopernicusMetadatum) = (4320, 2040, 50, 1)
66+
6467
reversed_vertical_axis(::CopernicusDataset) = true
6568

6669
available_variables(::CopernicusDataset) = copernicus_dataset_variable_names
@@ -93,6 +96,8 @@ function bbox_strs(c)
9396
return first, second
9497
end
9598

99+
colon2dash(s::String) = replace(s, ":" => "-")
100+
96101
function metadata_prefix(metadata::CopernicusMetadata)
97102
var = copernicus_dataset_variable_names[metadata.name]
98103
dataset = dataset_name(metadata.dataset)
@@ -109,7 +114,7 @@ function metadata_prefix(metadata::CopernicusMetadata)
109114
return string(var, "_",
110115
dataset, "_",
111116
start_date, "_",
112-
end_date, suffix)
117+
end_date, suffix) |> colon2dash
113118
end
114119

115120
function metadata_filename(metadata::CopernicusMetadata)

src/DataWrangling/JRA55/JRA55_metadata.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ JRA55_dataset_variable_names = Dict(
118118
:northward_velocity => "vas", # Northward near-surface wind
119119
)
120120

121-
JRA55_multiple_year_url = "https://esgf-data2.llnl.gov/thredds/fileServer/user_pub_work/input4MIPs/CMIP6/OMIP/MRI/MRI-JRA55-do-1-5-0/"
121+
JRA55_multiple_year_url = "http://esgf-node.ornl.gov/thredds/fileServer/user_pub_work/input4MIPs/CMIP6/OMIP/MRI/MRI-JRA55-do-1-5-0/"
122122

123123
JRA55_multiple_year_prefix = Dict(
124124
:river_freshwater_flux => "land/day",

src/OceanSeaIceModels/InterfaceComputations/similarity_theory_turbulent_fluxes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using KernelAbstractions.Extras.LoopInfo: @unroll
1414
using Statistics: norm
1515

1616
import Thermodynamics as AtmosphericThermodynamics
17-
import Thermodynamics.Parameters: molmass_ratio
17+
import Thermodynamics.Parameters: Rv_over_Rd
1818

1919
#####
2020
##### Bulk turbulent fluxes based on similarity theory
@@ -264,7 +264,7 @@ L_★ = u_★² / ϰ b_★ .
264264
@inline function buoyancy_scale(θ★, q★, ℂ, 𝒬, g)
265265
𝒯ₐ = AtmosphericThermodynamics.virtual_temperature(ℂ, 𝒬)
266266
qₐ = AtmosphericThermodynamics.vapor_specific_humidity(ℂ, 𝒬)
267-
ε = AtmosphericThermodynamics.Parameters.molmass_ratio(ℂ)
267+
ε = AtmosphericThermodynamics.Parameters.Rv_over_Rd(ℂ)
268268
δ = ε - 1 # typically equal to 0.608
269269

270270
b★ = g / 𝒯ₐ * (θ★ * (1 + δ * qₐ) + δ * 𝒯ₐ * q★)

0 commit comments

Comments
 (0)